Monitors

Contents

Monitors#

This script demonstrates the configuration and utilization of monitors within a Flow360 simulation using the Python API. Specifically, it illustrates how to define probe points using ProbeOutput to track flow variables at specified locations during a simulation of the ONERA M6 wing. Furthermore, it shows the process for retrieving, processing, and downloading the monitored data upon simulation completion.

 1import flow360 as fl
 2from flow360.examples import OM6wing
 3
 4OM6wing.get_files()
 5
 6project = fl.Project.from_volume_mesh(OM6wing.mesh_filename, name="Monitors results from Python")
 7
 8vm = project.volume_mesh
 9
10with fl.SI_unit_system:
11    params = fl.SimulationParams(
12        reference_geometry=fl.ReferenceGeometry(
13            area=1.15315084119231,
14            moment_center=[0, 0, 0],
15            moment_length=[1.47602, 0.801672958512342, 1.47602],
16        ),
17        operating_condition=fl.operating_condition_from_mach_reynolds(
18            reynolds=14.6e6, mach=0.84, alpha=3.06 * fl.u.deg, project_length_unit=fl.u.m
19        ),
20        time_stepping=fl.Steady(max_steps=500),
21        models=[
22            fl.Fluid(
23                navier_stokes_solver=fl.NavierStokesSolver(absolute_tolerance=1e-10),
24                turbulence_model_solver=fl.SpalartAllmaras(absolute_tolerance=1e-8),
25            ),
26            fl.Wall(surfaces=vm["1"]),
27            fl.SlipWall(surfaces=vm["2"]),
28            fl.Freestream(surfaces=vm["3"]),
29        ],
30        outputs=[
31            fl.ProbeOutput(
32                output_fields=["primitiveVars", "vorticity", "T", "s", "Cp", "mut"],
33                probe_points=[
34                    fl.Point(name="Probe1", location=[0.12, 0.34, 0.262] * fl.u.m),
35                    fl.Point(name="Probe2", location=[2, 0.01, 0.03] * fl.u.m),
36                    fl.Point(name="Probe3", location=[3, 0.01, 0.04] * fl.u.m),
37                    fl.Point(name="Probe4", location=[4, 0.01, 0.04] * fl.u.m),
38                ],
39            )
40        ],
41    )
42
43case = project.run_case(params, "Monitors results case from Python")
44
45
46# wait until the case finishes execution
47case.wait()
48
49results = case.results
50
51for name in results.monitors.monitor_names:
52    monitor = results.monitors.get_monitor_by_name(name)
53    print(monitor.as_dataframe())
54    monitor.download(to_folder=case.name)

Notes#

  • ProbeOutput enables monitoring of specified output_fields at defined spatial coordinates, which are defined using Point.

  • Post-simulation, monitor data is accessible through the case.results.monitors attribute after ensuring completion with case.wait().

  • Individual monitor datasets can be accessed via results.monitors.get_monitor_by_name() and subsequently downloaded or converted into a pandas DataFrame using .as_dataframe().