X Force Distribution

Contents

X Force Distribution#

This script demonstrates the procedure for obtaining and analyzing the axial force distribution along the X-coordinate from a completed Flow360 simulation. It covers setting up and running a basic aerodynamic simulation for an airplane geometry, accessing the post-processing results for X-force slicing, and utilizing filtering options to visualize the cumulative drag coefficient (CD) contribution from selected geometry components.

 1from pylab import show
 2
 3import flow360 as fl
 4from flow360.examples import Airplane
 5
 6project = fl.Project.from_geometry(Airplane.geometry, name="X force distribution from Python")
 7geo = project.geometry
 8
 9geo.show_available_groupings(verbose_mode=True)
10geo.group_faces_by_tag("groupName")
11
12
13with fl.SI_unit_system:
14    params = fl.SimulationParams(
15        meshing=fl.MeshingParams(
16            defaults=fl.MeshingDefaults(
17                boundary_layer_first_layer_thickness=0.001, surface_max_edge_length=1
18            ),
19            volume_zones=[fl.AutomatedFarfield()],
20        ),
21        reference_geometry=fl.ReferenceGeometry(),
22        operating_condition=fl.AerospaceCondition(velocity_magnitude=100, alpha=5 * fl.u.deg),
23        time_stepping=fl.Steady(max_steps=1000),
24        models=[
25            fl.Wall(
26                surfaces=[geo["*"]],
27            ),
28            fl.Freestream(surfaces=[fl.AutomatedFarfield().farfield]),
29        ],
30        outputs=[fl.SurfaceOutput(surfaces=geo["*"], output_fields=["Cp", "Cf", "yPlus", "CfVec"])],
31    )
32
33project.run_case(params=params, name="Case of Simple Airplane from Python")
34
35case = project.case
36
37
38cd_curve = case.results.x_slicing_force_distribution
39# wait for postprocessing to finish
40cd_curve.wait()
41
42print(cd_curve)
43print(cd_curve.entities)
44
45# plot CD vs X curve using all entities
46cd_curve.as_dataframe().plot(x="X", y="totalCumulative_CD_Curve")
47show()
48
49
50# plot CD vs X curve using "include" filter
51cd_curve.filter(include="*Wing*")
52print(cd_curve)
53
54cd_curve.as_dataframe().plot(x="X", y="totalCumulative_CD_Curve")
55show()
56
57
58# plot CD vs X curve using "exclude" filter
59cd_curve.filter(exclude="*fuselage*")
60cd_curve.as_dataframe().plot(x="X", y="totalCumulative_CD_Curve")
61show()
62
63
64# plot CD vs X curve using explicit names
65cd_curve.filter(include=["fluid/leftWing", "fluid/rightWing"])
66cd_curve.as_dataframe().plot(x="X", y="totalCumulative_CD_Curve")
67show()

Notes#

  • The axial force distribution is accessed via the case.results.x_slicing_force_distribution attribute.

  • Use the .wait() method on the result object to ensure the post-processing data is available before accessing it.

  • The .filter() method allows for selective analysis of force contributions from specific geometry parts using include, exclude, or explicit lists of entity names.