Unsteady 2D Cylinder#
This example demonstrates the configuration and execution of an unsteady simulation for laminar flow over a 2D cylinder using the Flow360 Python API. The script utilizes the operating_condition_from_mach_reynolds
helper function to define the flow conditions based on specified Mach and Reynolds numbers. It sets up appropriate boundary conditions, including no-slip walls, freestream boundaries, and slip walls for periodic boundaries, and configures unsteady time stepping parameters.
1import flow360 as fl
2from flow360.examples import Cylinder2D
3
4Cylinder2D.get_files()
5
6
7project = fl.Project.from_volume_mesh(
8 Cylinder2D.mesh_filename, name="Unsteady 2D Cylinder from Python"
9)
10
11vm = project.volume_mesh
12
13
14with fl.SI_unit_system:
15 params = fl.SimulationParams(
16 reference_geometry=fl.ReferenceGeometry(
17 area=20, moment_center=[0, 0, 0], moment_length=[1, 1, 1]
18 ),
19 operating_condition=fl.operating_condition_from_mach_reynolds(
20 reynolds=50, mach=0.1, project_length_unit=fl.u.m
21 ),
22 models=[
23 fl.Fluid(
24 navier_stokes_solver=fl.NavierStokesSolver(
25 absolute_tolerance=1e-9, linear_solver=fl.LinearSolver(max_iterations=25)
26 ),
27 turbulence_model_solver=fl.NoneSolver(),
28 ),
29 fl.Wall(surfaces=[vm["fluid/wall"]]),
30 fl.Freestream(surfaces=[vm["fluid/farfield"]]),
31 fl.SlipWall(surfaces=[vm["fluid/periodic_0_l"], vm["fluid/periodic_0_r"]]),
32 ],
33 time_stepping=fl.Unsteady(
34 max_pseudo_steps=40,
35 step_size=2,
36 steps=20,
37 ),
38 outputs=[
39 fl.SurfaceOutput(output_fields=["Cp"], surfaces=[vm["*"]]),
40 fl.VolumeOutput(
41 output_fields=[
42 "primitiveVars",
43 "vorticity",
44 "residualNavierStokes",
45 "T",
46 "Cp",
47 "mut",
48 ],
49 ),
50 ],
51 )
52
53project.run_case(params, "Unsteady 2D Cylinder case from Python")
Notes#
The
operating_condition_from_mach_reynolds
function simplifies setting flow conditions based on Reynolds and Mach numbers, automatically calculating necessary parameters like velocity and density based on the chosen length unit.Unsteady simulations are configured using the
fl.Unsteady
class within thetime_stepping
parameter, and specifying physical time step size (step_size
), total number of physical steps (steps
), and maximum inner iterations per physical step (max_pseudo_steps
).Note the use of
fl.NoneSolver()
for theturbulence_model_solver
, indicating a laminar simulation appropriate for the low Reynolds number (Re=50) used here.