StoppingCriterion#

class StoppingCriterion[source]#

Bases: Flow360BaseModel

StoppingCriterion class for RunControl.stopping_criteria settings.

Note

tolerance_window_size counts data points, not solver iterations. A “data point” is one row written by monitor_output, and its meaning depends on the simulation type:

  • Steady simulations. The solver writes one row per 10 pseudo-steps, so tolerance_window_size = N checks the last \(10 N\) pseudo-steps.

  • Time-accurate (unsteady) simulations. Only the final value per physical step contributes to the window — intermediate pseudo-step writes are filtered out. tolerance_window_size = N checks the last \(N\) physical (time) steps.

Example

Define a stopping criterion on a ProbeOutput with a tolerance of 0.01. The ProbeOutput monitors the moving range of Helicity in a moving window of 10 steps, at the location of (0, 0, 0,005) * fl.u.m.

>>> monitored_variable = fl.UserVariable(
...     name="Helicity_user",
...     value=fl.math.dot(fl.solution.velocity, fl.solution.vorticity),
... )
>>> criterion = fl.StoppingCriterion(
...     name="Criterion_1",
...     monitor_output=fl.ProbeOutput(
...         name="Helicity_probe",
...         output_fields=[
...             monitored_variable,
...         ],
...         probe_points=fl.Point(name="Point1", location=(0, 0, 0.005) * fl.u.m),
...         moving_statistic = fl.MovingStatistic(method = "range", moving_window_size = 10)
...     ),
...     monitor_field=monitored_variable,
...     tolerance=0.01,
... )

Attributes

name: str, optional#

Name of this criterion.

Default:

'StoppingCriterion'

monitor_field: UserVariable | str#

The field to be monitored. This field must be present in the output_fields of monitor_output.

monitor_output: ForceOutput | SurfaceIntegralOutput | ProbeOutput | SurfaceProbeOutput | str#

The monitored output or its id.

tolerance: Expression | UnytQuantity | float#

The tolerance threshold of this criterion.

tolerance_window_size: int, optional#

The number of data points from the monitor_output to be used to check whether the \(|max-min|/2\) of the monitored field within this window is below tolerance or not. If not set, the criterion will directly compare the latest value with tolerance. See StoppingCriterion for what a data point is.

Default:

None

Additional Constructors

preprocess(*, params=None, exclude=None, required_by=None, flow360_unit_system=None)[source]#

Convert all dimensioned fields to flow360 base unit system, recursively.

Parameters:
Return type:

Flow360BaseModel

Methods

classmethod check_tolerance_value_for_string_monitor_field(v, info)[source]#

Ensure the tolerance is float when string field is used.

Parameters:

info (ValidationInfo)