Forces#
This example outlines the procedure for executing a CFD simulation using the Flow360 Python API and subsequently retrieving the computed forces and moments. It covers accessing simulation results, converting force data into pandas DataFrames for analysis, and downloading the generated result files.
1from pylab import show
2
3import flow360 as fl
4from flow360.examples import OM6wing
5
6OM6wing.get_files()
7
8project = fl.Project.from_volume_mesh(OM6wing.mesh_filename, name="Forces results from Python")
9
10vm = project.volume_mesh
11
12with fl.SI_unit_system:
13 params = fl.SimulationParams(
14 reference_geometry=fl.ReferenceGeometry(
15 area=1.15315084119231,
16 moment_center=[0, 0, 0],
17 moment_length=[1.47602, 0.801672958512342, 1.47602],
18 ),
19 operating_condition=fl.AerospaceCondition(velocity_magnitude=286, alpha=3.06 * fl.u.deg),
20 time_stepping=fl.Steady(max_steps=500),
21 models=[
22 fl.Wall(surfaces=vm["1"]),
23 fl.SlipWall(surfaces=vm["2"]),
24 fl.Freestream(surfaces=vm["3"]),
25 ],
26 )
27
28case = project.run_case(params, "Forces results case from Python")
29
30
31# wait until the case finishes execution
32case.wait()
33
34results = case.results
35
36total_forces = results.total_forces.as_dataframe()
37print(total_forces)
38
39total_forces.plot(
40 x="pseudo_step",
41 y=["CL", "CD", "CFx", "CFy", "CFz", "CMx", "CMy", "CMz"],
42 xlabel="Pseudo Step",
43 xlim=(0, None),
44 figsize=(10, 7),
45 title="Total forces",
46)
47show()
48
49surface_forces = results.surface_forces.as_dataframe()
50print(surface_forces)
51
52results.set_destination(use_case_name=True)
53results.download(total_forces=True, surface_forces=True)
Notes#
Simulation results are accessed through the
results
attribute of the completedCase
object (e.g.,case.results
).Result files, such as
total_forces_v2.csv
andsurface_forces_v2.csv
, can be downloaded using theresults.download()
method.