Opera-3d Training Course
Power Conversion & Medical Physics & Transportation Power Systems
Electromechanical Science Applications
Devices
3-4: An introduction to the Command Interpreter
and Expression Analyser
Command Line Input from Macro Files
Offers the possibility to run a series of pre-defined OPERA
commands
Command files (*.comi) allow automated data input and post-
processing
They also offer a vehicle for parametric finite element model
definition
C
Command
d fil
file editor
dit assists
i t in
i preparing
i COMI fil
files
Also used to control transient simulations
Drive functions and mechanical coupling
2 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Command Line Input
As an alternative to the GUI, users may enter commands at the
keyboard
To switch from the menu system to keyboard input select
Windows -> View Console
move the mouse and click into the command entry line
The structure of a typical entry is
COMMAND PAR1=val1 PAR2=val2 ...
For example
THREED TYPE=COMP COMP=EMOD
3 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Command Line Input
4 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Main command Help
COMMAND !
Gives details of all the
parameters of a command
COMMAND !!
Requests prompting for
values for each parameter
of a command
Post-Processor
P t P E
Example
l
CIRCLE !
3-4: Command Interpreter and Expression Analyser 5
Cobham Technical Services
Command Line Input
COMMANDs and PARAMETERs are keywords. They can be abbreviated to
their minimum unambiguous form
Opera-3d > SELEC
Opera-3d
p > SELE
Opera-3d > SEL
Opera-3d > SE
DCOD Message 2:Command 'SE' ambiguous. (CMND)
Opera-3d > S
DCOD Message 2:Command 'S' ambiguous. (CMND)
Values can be numbers, character strings or booleans.
Booleans can take values YES or NO or can be specified as
+/-
/ PARAMETER
SELECT ACTION=SELECT -COIL +CUT
The parameter values can also be given by position
COMM val1 val2 PARA4=val4 val5
BODY 3 3 X0=5 6 7
6 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Command File Editor
In all Qt GUI based programs
(i.e. 2d PP, 3d Modeller, 3d Post-Processor)
Keyword highlighting,
highlighting showing the command and parameter names.
names
Access to the command and parameter names and documentation (via
Commands -> List commands)
Command and parameter names can be added to the command file by
double-clicking on the words in the list.
The tab key can be used to complete a partially typed word.
Running the command file currently being edited (via Commands ->
Run current file).
Copying the contents of the current log file (via File -> Open current
log file).
7 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Command File Editor
Find and replace
options
Tabbed windows
for multiple files
Search
directories for
COMI files
Execute part of
COMI using key
F10
8 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Expressions & Command Interpreter
Numeric values can be given in the form of expressions using
FORTRAN-77
FORTRAN 77 syntax and intrinsic functions
R1=SQRT(X1*2)
R1 is a numeric parameter and X1 is another parameter of the
same command. The expression is evaluated and the value is
stored
COMPONENT=BMOD/HMOD/MU0
COMPONENT BMOD/HMOD/MU0
COMPONENT is a functional parameter. BMOD, HMOD and MU0
are system variables. The expression is stored and evaluated at
each output point
9 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Expression Analyzer
Users have access to a set of system variables which are updated at
every evaluation point
THREED TYPE=COMP COMP=BX*NX+BY*NY+BZ*NZ
Displays
Di l the
th normall componentt off flux
fl density
d it on the
th surface
f off the
th
displayed geometry
A list of all available system variables is given in the manuals
10 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Supported mathematical functions
Expressions can include functions:
Trigonometric functions
SIN,
SIN COS,
COS TAN,
TAN COSH
COSH, COTAN
COTAN, SINH
SINH, ASIN
ASIN, ACOS
ACOS, ATAN,
ATAN ATAN2 ..
SIND, COSD, TAND, ASIND ...
Same as other trigonometric functions with argument in degrees
SIND(30) = SIN(PI/6) = 0.5
Arithmetic functions
EXP, LOG, LOG10, SQRT, MOD, ABS, INT, NINT, MIN, MAX, SIGN ..
Conditional behaviour functions
DELTA,
DELTA SWITCH
SWITCH, IF
IF, RANGE
Functions with 2 arguments use ; to separate the arguments
Angle of flux density in degrees when Bz = 0 given by ATAN2D(by;bx)
Listed in Opera-3d Reference Manual
11 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Logical arithmetic
The value of an expression can be determined by the current value of a
system variable or expression
Logical arithmetic supports this
! unary not
< less than
<= less than or equal to
&& and
.
Return 1 or 0 if expression is true or false respectively
Example
(BX>=BY&&BX>=BZ)*BX+(BY>=BX&&BY>=BZ)*BY+(BZ>=BX&&BZ>=BY)*BZ
Gives the most positive of BX, BY or BZ
Listed in Opera-3d Reference Manual
12 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Supported text functions
Values for command parameters sometimes need text
Text functions:
Create a text string
%INT, %REAL, %EXPR ..
Manipulate text strings
%COMPARE, %FIND, %SUBSTR
Use filenames and directories
%FILECOUNT,
%FILECOUNT %FILEPATH ..
Listed in Opera-3d Reference Manual
13 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
User defined variables
CONSTANTS
Retain the value they had when first defined
$CONSTANT #FLUX INTEGRAL
PARAMETERS
Retain the expression used to define them
$PARAMETER #BN BX*NX+BY*NY+BZ*NZ
MODELDIMENSION
Variables used in the Modeller to parameterize geometry
The VARIABLE command allows variables to be passed on to the
database from the Modeller
VARIABLE MODELDIMENSION #RADIUS SQRT(#X**2+#Y**2)
VARIABLE CONSTANT #VOL 4/3*PI*#RADIUS*3
14 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
User defined variables
The user can also create variables to hold text strings
$STRING creates a string for use in other commands
Note does not begin with #
Example
$STRING picfilename file_%INT(#I*#J).png
PICTURE SAVE=YES FILE=&picfilename& TYPE=PNG
Use quotes around filenames if they may include spaces
&picfilename& in example gives the text stored in string
15 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Control Statements: Conditional behaviour
$ IF val1 lop val2
commands
$ ELIF val3 lop val4
commands
$ ELSE
commands
$ END IF
where the Logical Operator (lop) is one of EQ, NE, LE, GE, GT, LT
$IF #A GT 0.0
$CONSTANT #B #B+#A
$ELSE
$CONSTANT #B #B-#A
$END IF
16 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Control Statements: Loops
$ DO #index start finish increment
commands
$ END DO
$ FOR #index val1 val2 val9
commands
$ END FOR
$ WHILE val1 lop val2
commands
$ END WHILE
where the Logical Operator (lop) is one of EQ, NE, LE, GE, GT, LT
$DO #Y 0 10 2
LINE 0 #Y 0 0 #Y 20 NP=100 | PLOT COMPONENT=BY
$PAUSE
END DO
17 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Other $ Commands (1)
$PAUSE
Waits for Enter key to continue to next commands
$PAUSE value waits for value seconds before continuing
$ ASK command
$ ASK #name numeric_variable
Requests user for the value of #name => constant
$ PROMPT
$ PROMPT name character_variable
$ COMI filename mode
Runs a series of pre-defined commands which are stored in a .comi file
in text format
$ OS command
Issues an OS (Operating System) command
18 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Other $ commands (2)
$OPEN, $CLOSE
Access other files for reading and writing
$READ, $WRITE, $FORMAT, $ASSIGN
Perform input from and output to files
$DIALOG, $DISPLAYLINE, $GROUPBOX
Allow user to make customized dialogs with $ASK and $PROMPT to get
user input
$DISPLAYLINE ffollowed
ll dbby a PNG fil
filename di
displays
l th
the picture
i t
$FILEPROMPT asks for a file name with a browser
More $ commands in the Opera-3d Reference Manual in Built-in
Commands section
19 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Use of Control Statements
LOAD OPTION=NEW FILE=[Link]
$DO #i 0 30 10
PICK OPTION=ADD PROPERTY=Name LABEL='armature'
TRANSFORM OPTION=APPLY
OPTION APPLY TYPE=ROTATE
TYPE ROTATE ROTU
ROTU=0 0 0 1 ANGLE
ANGLE=#i
#i
PICTURE SAVE=YES FILENAME=pos_%int(#i) TYPE=png
$END DO
Makes picture files pos_0.png, pos_10.png, pos_20.png and pos_30.png
3-4: Command Interpreter and Expression Analyser 20
Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
Parameterized model definition
$ASK #H Enter_Cylinder_Height
$DO #J 0 2
CYLINDER Name=CYL%int(#J) X0=0 Y0=0 Z0=0 X1=0 Y1=#H-#J Z1=0,
MAJORRADIUS #J 1 MINORRADIUS=#J+1
MAJORRADIUS=#J+1 MINORRADIUS #J 1 TOPRADIUS=#J+1
TOPRADIUS #J 1
PICK OPTION=ADD PROPERTY=Name LABEL=CYL%int(#J)
PICK OPTION=CHANGE TYPE=CELL
CELLDATA OPTION=MODIFY MATERIALLABEL=TUBE_%INT(#J)
$END DO
Result
esu t for
o #H = 4
3-4: Command Interpreter and Expression Analyser 21
Cobham Technical Services
User Input/Output Commands
$ OPEN stream filename authority +/-REDI
opens a file on a logical stream number (1-10). Authority determines
how the file can be used (READ, WRITE etc)
$ CLOSE stream
Closes a logical stream
$ READ stream #var1 #var2
Reads
R d variable
i bl values
l from
f a file
fil
$ WRITE stream data1 data2
Writes data into a stream
22 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011
Opera-3d Training Course
User Input/Output commands
$ FORMAT EXAMPLES
Defines the formats (up to 20
$FORMAT 17 FIXED 4 1
different allowed) for output
Fixed point format (for numerical data)
items of width 4 including 1 decimal place
$ ASSIGN $FORMAT 18 CHAR 12
Format of character data of width 12
Assigns format numbers to
the data items of subsequent
$FORMAT 19 STRING STRING=' WIDTH=3
$WRITE commands
String format containing spaces
$FORMAT 20 EXPO 0
Floating point format for numerical data
23 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
User Input/Output commands
$OPEN 10 [Link] AUTH=APPE REDI=NO
$FORMAT 17 FIXED 4 1 RESULT
$FORMAT 18 CHAR 12
$FORMAT 19 STRING STRING=' WIDTH=3
ANGLE FLUX
$FORMAT 20 EXPO 0 10.0 0.3062237833
$ASSIGN 18 20.0 0.6146161442
$WRITE 10 'ANGLE FLUX' 30.0 0.9159332384
$ASSIGN 17 19 20 40.0 1.2079086843
$DO #J 10 50 10 50.0 1.4926232081
SIMULATION CASE=%INT(#J/10)
POLAR 10 0 0,10 0 20,10 90 20,10 90 0
MAP COMPONENT=NX*BX+NY*BY+NZ*BZ
$WRITE 10 #J INTEGRAL
$END DO
$CLOSE 10
24 3-4: Command Interpreter and Expression Analyser Cobham Technical Services
Opera version 15, November 2011