2D CRM

Contents

2D CRM#

This script details the setup and execution of a steady-state Reynolds-Averaged Navier-Stokes (RANS) simulation for the NASA CRM-HL 2D multi-element airfoil configuration using the Flow360 Python API. It covers geometry import and preparation, automated mesh generation with multiple refinement zones, definition of simulation parameters using the SI unit system, configuration of the Spalart-Allmaras turbulence model, and submission of the simulation case.

  1import flow360 as fl
  2from flow360.examples import Tutorial2DCRM
  3
  4Tutorial2DCRM.get_files()
  5
  6project = fl.Project.from_geometry(Tutorial2DCRM.geometry, name="Tutorial 2D CRM from Python")
  7geometry = project.geometry
  8
  9# show face and edge groupings
 10geometry.show_available_groupings(verbose_mode=True)
 11geometry.group_faces_by_tag("faceName")
 12geometry.group_edges_by_tag("edgeName")
 13
 14
 15with fl.SI_unit_system:
 16    cylinders = [
 17        fl.Cylinder(
 18            name=f"cylinder{i+1}",
 19            axis=[0, 1, 0],
 20            center=[0.7, 0.5, 0],
 21            outer_radius=outer_radius,
 22            height=1.0,
 23        )
 24        for i, outer_radius in enumerate([1.1, 2.2, 3.3, 4.5])
 25    ]
 26    cylinder5 = fl.Cylinder(
 27        name="cylinder5", axis=[-1, 0, 0], center=[6.5, 0.5, 0], outer_radius=6.5, height=10
 28    )
 29    farfield = fl.AutomatedFarfield(method="quasi-3d")
 30    params = fl.SimulationParams(
 31        meshing=fl.MeshingParams(
 32            defaults=fl.MeshingDefaults(
 33                surface_edge_growth_rate=1.17,
 34                surface_max_edge_length=1.1,
 35                curvature_resolution_angle=12 * fl.u.deg,
 36                boundary_layer_growth_rate=1.17,
 37                boundary_layer_first_layer_thickness=1.8487111e-06,
 38            ),
 39            refinement_factor=1.35,
 40            gap_treatment_strength=0.5,
 41            volume_zones=[farfield],
 42            refinements=[
 43                fl.UniformRefinement(name="refinement1", spacing=0.1, entities=[cylinders[0]]),
 44                fl.UniformRefinement(name="refinement2", spacing=0.15, entities=[cylinders[1]]),
 45                fl.UniformRefinement(name="refinement3", spacing=0.225, entities=[cylinders[2]]),
 46                fl.UniformRefinement(name="refinement4", spacing=0.275, entities=[cylinders[3]]),
 47                fl.UniformRefinement(name="refinement5", spacing=0.325, entities=[cylinder5]),
 48                fl.SurfaceRefinement(name="wing", max_edge_length=0.74, faces=[geometry["wing"]]),
 49                fl.SurfaceRefinement(
 50                    name="flap-slat",
 51                    max_edge_length=0.55,
 52                    faces=[geometry["flap"], geometry["slat"]],
 53                ),
 54                fl.SurfaceRefinement(
 55                    name="trailing",
 56                    max_edge_length=0.36,
 57                    faces=[
 58                        geometry["*Trailing"],
 59                    ],
 60                ),
 61                fl.SurfaceEdgeRefinement(
 62                    name="edges",
 63                    method=fl.HeightBasedRefinement(value=0.0007),
 64                    edges=[
 65                        geometry["*trailingEdge"],
 66                        geometry["*leadingEdge"],
 67                    ],
 68                ),
 69                fl.SurfaceEdgeRefinement(
 70                    name="symmetry", method=fl.ProjectAnisoSpacing(), edges=[geometry["symmetry"]]
 71                ),
 72            ],
 73        ),
 74        reference_geometry=fl.ReferenceGeometry(
 75            moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01
 76        ),
 77        operating_condition=fl.operating_condition_from_mach_reynolds(
 78            mach=0.2,
 79            reynolds=5e6,
 80            project_length_unit=1 * fl.u.m,
 81            temperature=272.1,
 82            alpha=16 * fl.u.deg,
 83            beta=0 * fl.u.deg,
 84        ),
 85        time_stepping=fl.Steady(
 86            max_steps=3000, CFL=fl.RampCFL(initial=20, final=300, ramp_steps=500)
 87        ),
 88        models=[
 89            fl.Wall(
 90                surfaces=[
 91                    geometry["*"],
 92                ],
 93            ),
 94            fl.Freestream(surfaces=farfield.farfield),
 95            fl.SlipWall(surfaces=farfield.symmetry_planes),
 96            fl.Fluid(
 97                navier_stokes_solver=fl.NavierStokesSolver(
 98                    absolute_tolerance=1e-11,
 99                    linear_solver=fl.LinearSolver(max_iterations=35),
100                    kappa_MUSCL=0.33,
101                ),
102                turbulence_model_solver=fl.SpalartAllmaras(
103                    absolute_tolerance=1e-10,
104                    linear_solver=fl.LinearSolver(max_iterations=25),
105                    equation_evaluation_frequency=1,
106                ),
107            ),
108        ],
109        outputs=[
110            fl.VolumeOutput(
111                output_fields=[
112                    "primitiveVars",
113                    "vorticity",
114                    "residualNavierStokes",
115                    "residualTurbulence",
116                    "Cp",
117                    "Mach",
118                    "qcriterion",
119                    "mut",
120                ],
121            ),
122            fl.SurfaceOutput(
123                surfaces=geometry["*"],
124                output_fields=["primitiveVars", "Cp", "Cf", "CfVec", "yPlus"],
125            ),
126        ],
127    )
128
129
130project.run_case(params=params, name="Case of tutorial 2D CRM from Python")

Notes#

  • fl.AutomatedFarfield with method="quasi-3d" is employed to generate farfield and symmetry boundary conditions suitable for this 2D configuration.

  • Multiple mesh refinement strategies (fl.UniformRefinement, fl.SurfaceRefinement, fl.SurfaceEdgeRefinement) are used to control grid resolution near the airfoil surfaces and in the wake.

  • The simulation utilizes the Spalart-Allmaras turbulence model (fl.SpalartAllmaras).