Run case with fork#
This example demonstrates the process of initiating a baseline simulation and subsequently creating variations by forking from existing cases using the Flow360 Python API.
The script begins by setting up and running an initial simulation for the OM6 wing geometry.
It then illustrates how to modify simulation parameters and utilize the fork_from
argument within the Project.run_case
method to start new simulations based on the state of previous ones.
1import flow360 as fl
2from flow360.examples import OM6wing
3
4OM6wing.get_files()
5
6project = fl.Project.from_volume_mesh(OM6wing.mesh_filename, name="Forking cases from Python")
7vm = project.volume_mesh
8
9with fl.SI_unit_system:
10 params = fl.SimulationParams(
11 reference_geometry=fl.ReferenceGeometry(
12 area=1.15315084119231,
13 moment_center=[0, 0, 0],
14 moment_length=[1.47602, 0.801672958512342, 1.47602],
15 ),
16 operating_condition=fl.AerospaceCondition(velocity_magnitude=286, alpha=3.06 * fl.u.deg),
17 time_stepping=fl.Steady(max_steps=500),
18 models=[
19 fl.Wall(surfaces=vm["1"]),
20 fl.SlipWall(surfaces=vm["2"]),
21 fl.Freestream(surfaces=vm["3"]),
22 ],
23 outputs=[
24 fl.SurfaceOutput(output_fields=["primitiveVars", "Cp", "Cf"], surfaces=[vm["1"]]),
25 fl.VolumeOutput(output_fields=["primitiveVars", "Mach"]),
26 ],
27 )
28
29case = project.run_case(params, "OM6Wing-default-0")
30
31# fork a case
32case.params.time_stepping.max_steps = 300
33case_fork_1 = project.run_case(case.params, "OM6Wing-fork-1", fork_from=case)
34
35# create another fork
36case_fork_1.params.time_stepping.max_steps = 200
37case_fork_2 = project.run_case(case_fork_1.params, "OM6Wing-fork-2", fork_from=case_fork_1)
38
39# create fork by providing parent case id:
40case_fork = project.run_case(params, "OM6Wing-fork-1-0", fork_from=case)
Notes#
New simulations can be initialized from the state of a completed simulation by passing the parent Case object to the
fork_from
parameter inproject.run_case
.Simulation parameters for the new (forked) case can be adjusted by modifying the
params
attribute of the parentCase
object before submitting the forked simulation.