Your first input file¶
Simulation user
We now rebuild the counter loop from scratch, in three steps. Each step is a
complete input file you can run with onikarun <file>.msp.
Step 1: one operator¶
simulation is the entry point: a list of operators run in order.
message: "..." runs the built-in message operator. It is a shortcut
for message: { mesg: "..." }: in general, an operator takes a map of
slot values.
Note
Onika always loads main-config.msp (from data/config) before your
file. Your simulation replaces the default one. To keep the default
initialization (MPI, GPU, unit system) and only add your own operators,
define run instead of simulation. See The default file: main-config.msp.
Step 2: values and slots¶
global:
timestep: 0
dt: 1.0
print_timestep:
rebind: { value: timestep }
body:
- print_int: { prefix: "timestep = ", suffix: "\n" }
simulation:
- global
- next_time_step
- print_timestep
globalcreates one output slot per entry:timestep(an integer) anddt(a real). The type comes from the value.next_time_stepreadsdtand updatestimestepandphysical_time.print_timestepis a batch: a named group of operators. You define it once at the top level, then use its name like any operator. Itsrebindconnects thevalueslot ofprint_inttotimestep.
Step 3: a loop¶
global:
timestep: 0
dt: 1.0
nsteps: 5
compute_loop_continue: true
print_timestep:
rebind: { value: timestep }
body:
- print_int: { prefix: "Current timestep = ", suffix: "\n" }
compute_loop_stop:
rebind: { end_at: nsteps , result: compute_loop_continue }
body:
- sim_continue
compute_loop:
loop: true
condition: compute_loop_continue
body:
- print_timestep
- next_time_step
- compute_loop_stop
simulation:
- global
- compute_loop
loop: true+condition: compute_loop_continue: run the body again while the boolean slotcompute_loop_continueis true.sim_continuesets itsresultto false oncetimestepgoes pastend_at. The rebind maps them tocompute_loop_continueandnsteps.
Apart from nsteps and the setup operators, this is data/exemples/print_loop.msp
(Your first run). Everything used here is
described in The input file language, and the operators in Built-in operators.
Next step: Your first operator, to add your own operator to this loop.