run_sim
- czmtestkit.py_modules.run_sim(name, doe_data, fixed_data, abaqus_simFunc=None, abaqus_postProc=None, postProc=None)
Sequentially run Abaqus/CAE simulations and/or post processing functions for a design of experiments.
- Parameters
name (str): ID for colleciton of tests in the design of experiments.
doe_data (dict): dictionary with variables for tests in the design of experiments.
- ‘nPoints’
List of indicies corresponding to the tests to be run. (The defintion of this attribute was changed, see version history for details.)
- ‘Variable_Key_1’
List of values for the variable named Variable_Key_1.
- ‘Variable_Key_2’
List of values for the variable named Variable_Key_2.
fixed_data (dict): dictionary with constants for tests in the design of experiments.
- ‘Constant_Key_1’
Value of the variable named Constant_Key_1.
- ‘Constant_Key_2’
Value of the variable named Constant_Key_2.
abaqus_simFunc (str): Name of abaqus-python function from
czmtestkit.abaqus_modules
. SeeExample
for the differnce betweenabaqus_simFunc
andabaqus_postProc
parameters andczmtestkit.abaqus_modules
for available functions and instructions to create your own abaqus-python function that is compatible with theczmtestkit
.abaqus_postProc (str): Name of abaqus-python function from
czmtestkit.abaqus_modules
. SeeExample
for the differnce betweenabaqus_simFunc
andabaqus_postProc
parameters andczmtestkit.abaqus_modules
for available functions and instructions to create your own abaqus-python function that is compatible with theczmtestkit
.postProc (function object): Executable python post processing function.
Example
Assume that
abqPy_Func1
is a function in theczmtestkit
based on abaqus-python scripting language to run Abaqus/CAE simulation. Also assume thatabqPy_Func1
takes a dictionary as input parameter with param_1, param_2 and param_3 as keys within the dictionary.In_dict_Func1 = { 'param_1': value_param1, 'param_2': value_param2, 'param_3': value_param3, }
If param_1 requires a string input then value_param1 has to be a string and so forth. Further, if the design of experiments (doe) is such that the param_2 is to assume different values:
doe_param2 = [value0_param2, value1_param2, value2_param2, value3_param2]
and the aim is to run the simulations for the first and the third points (value0_param2, value2_param2) in this doe, then define the input dictionaries as follows:
dict_fix = { 'param_1': value_param1, 'param_3': value_param3, } dict_var = { 'param_2' : doe_param2, 'nPoints' : [0,2] }
Use the
run_sim()
function to sequentially run the tests:run_sim('ExampleDOE', dict_var, dict_fix, abaqus_simFunc="czmtestkit.abaqus_modules.abqPy_Func1")
This creates the main directory ExampleDOE in the current work directory and sub directories for each test. Further, with sub directories as working directories, each test in the nPoints is executed resulting in abaqus files.
$ <current working directory> └── ExampleDOE ├── point_00 │ ├── <abaqus file 1 test 1> │ ├── <abaqus file 2 test 1> │ ├── <abaqus file 3 test 1> │ ├── <abaqus file 4 test 1> │ ├── <abaqus file 5 test 1> │ └── point_00.json └── point_02 ├── <abaqus file 1 test 2> ├── <abaqus file 2 test 2> ├── <abaqus file 3 test 2> ├── <abaqus file 4 test 2> ├── <abaqus file 5 test 2> └── point_02.json
Here, the first test is exectued with the following dictionary saved to
point_00.json
and passed toczmtestkit.abaqus_modules.abqPy_Func1()
as input.{ 'param_1': value_param1, 'param_2': value0_param2, 'param_3': value_param3, }
and the input dictionary for the second test with the third point in the doe saved to
point_02.json
as{ 'param_1': value_param1, 'param_2': value2_param2, 'param_3': value_param3, }
Remaining tests in the doe can be executed by adding corresponding indices to the ‘nPoints’ list in the doe_data. Further, if a postprocessing function
abqPy_Func2
has to be executed with parameters param_1, param_2 and a new parameter param_4.run_sim()
can be used again.dict_fix2 = { 'param_1': value_param1, 'param_4': value_param4, } dict_var2 = { 'param_2' : doe_param2, 'nPoints' : [0,1,2,3] # assuming `abqPy_Func1` has already been executed for all the points. The directories should have already been created. } run_sim('ExampleDOE', dict_var2, dict_fix2, abaqus_postProc="czmtestkit.abaqus_modules.abqPy_Func2")
Similarly, python postprocessor (
py_func
) can be executed sequentially for the doe usingrun_sim(...,postProc=py_func)
. Executing apostProc
function results in the creation of aDatabase.json
in the test directory with input dictionaries from all the tests.$ <current working directory> └── ExampleDOE ├── point_00 ├── point_01 ├── point_02 ├── point_03 └── Database.json
{'param_1': value_param1, 'param_2': value0_param2, 'param_3': value_param3, 'param_4': value_param4 } {'param_1': value_param1, 'param_2': value1_param2, 'param_3': value_param3, 'param_4': value_param4 } {'param_1': value_param1, 'param_2': value2_param2, 'param_3': value_param3, 'param_4': value_param4 } {'param_1': value_param1, 'param_2': value3_param2, 'param_3': value_param3, 'param_4': value_param4 }
If the
py_func
results in an output dictionary{'output1': <value>, 'output2': <value>}
, the contents of the output dictionary are appended to the input dictionaries before writting to theDatabase.json
.{'param_1': value_param1, 'param_2': value0_param2, 'param_3': value_param3, 'param_4': value_param4, 'output1': value0_out1, 'output2': value0_out2} {'param_1': value_param1, 'param_2': value1_param2, 'param_3': value_param3, 'param_4': value_param4, 'output1': value1_out1, 'output2': value1_out2} {'param_1': value_param1, 'param_2': value2_param2, 'param_3': value_param3, 'param_4': value_param4, 'output1': value2_out1, 'output2': value2_out2} {'param_1': value_param1, 'param_2': value3_param2, 'param_3': value_param3, 'param_4': value_param4, 'output1': value3_out1, 'output2': value3_out2}
Note
All three functions can be executed at once.
FixDict = { 'param_1': value_param1, 'param_3': value_param3, 'param_4': value_param4, } VarDict = { 'param_2' : doe_param2, 'nPoints' : [0,1,2,3] } run_sim('ExampleDOE', VarDict, FixDict, abaqus_simFunc="czmtestkit.abaqus_modules.abqPy_Func1", abaqus_postProc="czmtestkit.abaqus_modules.abqPy_Func2", postProc=py_func)