Impetus Engine module
The impetus module is a built-in module which allows one to extract more data from the simulation, such as curve, table and path data.
Attention
This is a built-in module in IMPETUS Solver Engine. It should not be mixed up with the external IMPETUS Python API (with the same name). The latter one is designed to work standalone. It contains post-processing capabilities such as data extraction.
Module Contents
-
variable = impetus.
curve
(
curve_id , abscissa)
-
Returns the ordinate value of abscissa in the defined curve_id.
See the command *CURVE for more information.
-
variable = impetus.
table
(
table_id , row , col)
-
Returns the table value of row and col in table table_id.
See the command *TABLE for more information.
-
variable = impetus.
path
(
path_id , pos , relative)
-
Returns the coordinate of pos in path_id. The return variable is a 3-component long list
(x = variable[0], y = variable[1], z = variable[2]). Variable relative defines if the pos
value is relative (1) or absolute (0). If relative is set to 1, then pos will correspond
to the relative position between 0 and 1 in the path. If the pos value exceeds the upper limit of the path,
the return value will be extrapolated.
See the command *PATH for more information.
Example
Python script: script.py
# Import the impetus engine module
import impetus
# Curve example
def curve_example(curve_id, abscissa):
value = impetus.curve(int(curve_id), abscissa)
print("Value:", value, flush=True)
# The printed value should be "5"
# Table example
def table_example(table_id, row, col):
value = impetus.table(int(table_id), int(row), int(col))
print("Value:", value, flush=True)
# The printed value should be "4.7"
# Path example (using relative position)
def path_example(path_id, pos):
coordinate = impetus.path(int(path_id), pos, 1)
print("x:", coordinate[0], flush=True)
print("y:", coordinate[1], flush=True)
print("z:", coordinate[2], flush=True)
# The printed value should be:
# "x = 0.1622625066423805"
# "y = 0.1377374933576195"
# "z = -0.011312533211902509"
# Adding the python file to our input file
*SCRIPT_PYTHON
script.py
# Calling python function curve_example()
*FUNCTION
1000
script.curve_example(1, 5.0e-7)
# Calling python function table_example()
*FUNCTION
1001
script.table_example(100, 3, 1)
# Calling python function path_example()
*FUNCTION
1002
script.path_example(1234, 0.3)
*CURVE
1
0, 0
1.0e-6, 10.0
1.0, 10.0
*TABLE
100, 3
0.0, 0.0, 0.0
1.2, 3.4, 5.5
4.7, 2.2, 6.2
8.0, 1.1, 9.2
*PATH
1234
0.0, 0.0, 0.0
0.1, 0.2, 0.3
0.2, 0.1, -0.2
0.0, 1.0, -0.2
-0.1, 1.0, 0.3