Running Simulations from the Commandline

All inputs are specified in YAML configuration files.

Example makes are run on the command line within jupyter (using system magic via !)

Help

[1]:
# display help
! ctwrap --help
usage: ctwrap [-h] {list,run} ...

Wrapper for batch simulations (ctwrap).

positional arguments:
  {list,run}  ctwrap sub-commands
    list      list available simulation modules
    run       run simulation module

optional arguments:
  -h, --help  show this help message and exit
[2]:
# help of subcommand 'list'
! ctwrap list --help
usage: ctwrap list [-h]

List available simulation modules

optional arguments:
  -h, --help  show this help message and exit
[3]:
# list available modules
! ctwrap list
 - equilibrium
 - freeflame
 - ignition
 - minimal
 - solution
[4]:
# help of subcommand 'run'
! ctwrap run --help
usage: ctwrap run [-h] [--output OUTPUT] [-v] [--parallel]
                  [--strategy STRATEGY]
                  module_name yaml_config

Run simulation module

positional arguments:
  module_name          name of wrapped simulation module
  yaml_config          yaml configuration file

optional arguments:
  -h, --help           show this help message and exit
  --output OUTPUT      name of output file
  -v, --verbosity      verbosity level
  --parallel           run parallel calculations
  --strategy STRATEGY  batch job strategy

minimal Module

This example uses the YAML configuration file yaml/minimal.yaml, which specifies two batch strategies (sequence and matrix).

[5]:
%%time
# run minimal module (with 'sequence' strategy)
! ctwrap run minimal minimal.yaml --strategy sequence
    - `minimal`: sleeping for 0.1 * 1 = 0.1 seconds ...
    - `minimal`: sleeping for 0.2 * 1 = 0.2 seconds ...
    - `minimal`: sleeping for 0.3 * 1 = 0.3 seconds ...
    - `minimal`: sleeping for 0.4 * 1 = 0.4 seconds ...
    - `minimal`: sleeping for 0.5 * 1 = 0.5 seconds ...
    - `minimal`: sleeping for 0.6 * 1 = 0.6 seconds ...
    - `minimal`: sleeping for 0.7 * 1 = 0.7 seconds ...
    - `minimal`: sleeping for 0.8 * 1 = 0.8 seconds ...
CPU times: user 98.5 ms, sys: 20.5 ms, total: 119 ms
Wall time: 4.44 s
[6]:
%%time
# run minimal module in parallel (with 'matrix' strategy)
! ctwrap run minimal minimal.yaml --parallel --strategy matrix
    - `minimal`: sleeping for 0.1 * 2 = 0.2 seconds ...
    - `minimal`: sleeping for 0.1 * 1 = 0.1 seconds ...
    - `minimal`: sleeping for 0.1 * 0 = 0.0 seconds ...
    - `minimal`: sleeping for 0.2 * 2 = 0.4 seconds ...
    - `minimal`: sleeping for 0.2 * 1 = 0.2 seconds ...
    - `minimal`: sleeping for 0.2 * 0 = 0.0 seconds ...
    - `minimal`: sleeping for 0.3 * 2 = 0.6 seconds ...
    - `minimal`: sleeping for 0.3 * 1 = 0.3 seconds ...
    - `minimal`: sleeping for 0.3 * 0 = 0.0 seconds ...
CPU times: user 48.6 ms, sys: 17.1 ms, total: 65.8 ms
Wall time: 2.68 s

solution Module

This example uses the YAML configuration file yaml/solution.yaml, which queries a Cantera Solution object at a range of temperatures.

[7]:
%%time
# run parameter variation using multiple cores (if made available)
! ctwrap run solution solution.yaml -v --parallel --output solution_example.csv
################################################################################
Running simulations: module `ctwrap.modules.solution`
Conditions specified in `solution.yaml`
################################################################################
Simulations for entry `state.T` with values: [300, 325, 350, 375, 400, 425, 450,
475, 500, 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825, 850,
875, 900, 925, 950, 975, 1000, 1025, 1050, 1075, 1100, 1125, 1150, 1175, 1200,
1225, 1250, 1275, 1300, 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, 1525,
1550, 1575, 1600, 1625, 1650, 1675, 1700, 1725, 1750, 1775, 1800, 1825, 1850,
1875, 1900, 1925, 1950, 1975, 2000]
 * Starting parallel batch simulation using 1 cores
 * running `case_00` (Process-1)
 * running `case_01` (Process-1)
 * running `case_02` (Process-1)
 * running `case_03` (Process-1)
 * running `case_04` (Process-1)
 * running `case_05` (Process-1)
 * running `case_06` (Process-1)
 * running `case_07` (Process-1)
 * running `case_08` (Process-1)
 * running `case_09` (Process-1)
 * running `case_10` (Process-1)
 * running `case_11` (Process-1)
 * running `case_12` (Process-1)
 * running `case_13` (Process-1)
 * running `case_14` (Process-1)
 * running `case_15` (Process-1)
 * running `case_16` (Process-1)
 * running `case_17` (Process-1)
 * running `case_18` (Process-1)
 * running `case_19` (Process-1)
 * running `case_20` (Process-1)
 * running `case_21` (Process-1)
 * running `case_22` (Process-1)
 * running `case_23` (Process-1)
 * running `case_24` (Process-1)
 * running `case_25` (Process-1)
 * running `case_26` (Process-1)
 * running `case_27` (Process-1)
 * running `case_28` (Process-1)
 * running `case_29` (Process-1)
 * running `case_30` (Process-1)
 * running `case_31` (Process-1)
 * running `case_32` (Process-1)
 * running `case_33` (Process-1)
 * running `case_34` (Process-1)
 * running `case_35` (Process-1)
 * running `case_36` (Process-1)
 * running `case_37` (Process-1)
 * running `case_38` (Process-1)
 * running `case_39` (Process-1)
 * running `case_40` (Process-1)
 * running `case_41` (Process-1)
 * running `case_42` (Process-1)
 * running `case_43` (Process-1)
 * running `case_44` (Process-1)
 * running `case_45` (Process-1)
 * running `case_46` (Process-1)
 * running `case_47` (Process-1)
 * running `case_48` (Process-1)
 * running `case_49` (Process-1)
 * running `case_50` (Process-1)
 * running `case_51` (Process-1)
 * running `case_52` (Process-1)
 * running `case_53` (Process-1)
 * running `case_54` (Process-1)
 * running `case_55` (Process-1)
 * running `case_56` (Process-1)
 * running `case_57` (Process-1)
 * running `case_58` (Process-1)
 * running `case_59` (Process-1)
 * running `case_60` (Process-1)
 * running `case_61` (Process-1)
 * running `case_62` (Process-1)
 * running `case_63` (Process-1)
 * running `case_64` (Process-1)
 * running `case_65` (Process-1)
 * running `case_66` (Process-1)
 * running `case_67` (Process-1)
 * running `case_68` (Process-1)
CPU times: user 107 ms, sys: 38.2 ms, total: 146 ms
Wall time: 6.55 s
[8]:
# delete output file
! rm solution_example.csv
[ ]: