Quick start (run a case from local geometry file)

Quick start (run a case from local geometry file)#

The following example deomonstrates how to create a project from a local geometry file, configure meshing and case settings. And submit to the cloud.

 1# Import necessary modules from the Flow360 library
 2import flow360 as fl
 3from flow360.examples import eVTOL
 4from flow360.log import log
 5
 6# Create a project and upload the geometry
 7project = fl.Project.from_file(eVTOL.geometry, name="EVTOL_quickstart_from_API", length_unit="m")
 8
 9log.info(f"The project id is {project.id}")
10
11# Group faces and edges by their specific tags for easier assignment of simulation parameters.
12# The tag names were assigned in the .csm script.
13geometry = project.geometry
14geometry.group_faces_by_tag("faceName")
15geometry.group_edges_by_tag("edgeName")
16
17# Create the farfield object.
18farfield_zone = fl.AutomatedFarfield()
19
20# Create a simulation params object using the SI unit system as default dimensions.
21with fl.SI_unit_system:
22    params = fl.SimulationParams(
23        # Set the meshing parameters.
24        meshing=fl.MeshingParams(
25            defaults=fl.MeshingDefaults(
26                boundary_layer_first_layer_thickness=1e-5, surface_max_edge_length=1
27            ),
28            volume_zones=[farfield_zone],
29            # Set the refinement parameters for the leading edges.
30            refinements=[
31                fl.SurfaceEdgeRefinement(
32                    name="leading_edges",
33                    edges=[geometry["leadingEdge"]],
34                    method=fl.AngleBasedRefinement(value=2 * fl.u.deg),
35                )
36            ],
37        ),
38        # Set the operating condition.
39        operating_condition=fl.AerospaceCondition(
40            velocity_magnitude=50 * fl.u.m / fl.u.s, alpha=0 * fl.u.deg
41        ),
42        # Set the time stepping parameters.
43        time_stepping=fl.Steady(max_steps=3000),
44        # Set the physics models.
45        models=[
46            # Assign each generated mesh patch as defined in the .csm file to their matching airplane subcomponents.
47            fl.Wall(surfaces=geometry["fuselage"], name="fuselage"),
48            # Notice below how we use the * operator to assign both left and right pylon to the pylons subcomponent
49            fl.Wall(surfaces=geometry["*_pylon"], name="pylons"),
50            fl.Wall(surfaces=geometry["*_wing"], name="wing"),
51            fl.Wall(surfaces=geometry["*_tail"], name="tail"),
52            fl.Freestream(surfaces=[farfield_zone.farfield], name="Freestream"),
53        ],
54        # Output format could be 'paraview' or 'tecplot' or 'both'.
55        outputs=[
56            fl.SurfaceOutput(
57                # Select all surfaces for output
58                surfaces=geometry["*"],
59                # Output fields for post-processing
60                output_fields=["Cp", "Cf", "yPlus", "CfVec"],
61                output_format="both",
62            )
63        ],
64    )
65# Run the case.
66project.run_case(params=params, name=f"EVTOL_quickstart_alpha{params.operating_condition.alpha}")
67log.info(f"The case ID is: {project.case.id} with alpha = {params.operating_condition.alpha} ")