ogstools.studies.convergence package#
functions to generate a convergence study.
- ogstools.studies.convergence.convergence_metrics(meshes, reference, variable, timestep_sizes)[source]#
Calculate convergence metrics for a given reference and variable.
- Parameters:
meshes (list[UnstructuredGrid]) – The List of meshes to be analyzed for convergence.
reference (UnstructuredGrid) – The reference mesh to compare against.
variable (Variable) – The variable of interest.
- Returns:
A pandas Dataframe containing all metrics.
- Return type:
DataFrame
- ogstools.studies.convergence.convergence_metrics_evolution(mesh_series, variable, refinement_ratio=2.0, units=('s', 's'))[source]#
Calculate convergence evolution metrics for given mesh series.
Contains convergence order and the relative error to the Richardson extrapolation for each timestep of the coarsest mesh series. and a variable
- Parameters:
meshes_series – The List of mesh series to be analyzed.
variable (Variable) – The variable of interest.
refinement_ratio (float) – Refinement ratio between the discretizations.
- Returns:
A pandas Dataframe containing all metrics.
- Return type:
DataFrame
- ogstools.studies.convergence.grid_convergence(meshes, variable, topology, refinement_ratio)[source]#
Calculate the grid convergence field for the given meshes on the topology.
The calculation is based on the last three of the given meshes. For more information on this topic see <https://www.grc.nasa.gov/www/wind/valid/tutorial/spatconv.html> or <https://curiosityfluids.com/2016/09/09/establishing-grid-convergence/>.
- Parameters:
meshes (list[UnstructuredGrid]) – At least three meshes with constant refinement.
variable (Variable) – The variable to be extrapolated.
topology (UnstructuredGrid) – The topology to evaluate.
refinement_ratio (float) – If not given, it is calculated automatically
- Return type:
UnstructuredGrid
returns: Grid convergence field of the given variable.
- ogstools.studies.convergence.plot_convergence(metrics, variable)[source]#
Plot the absolute values of the convergence metrics.
- Return type:
Figure
- ogstools.studies.convergence.plot_convergence_errors(metrics)[source]#
Plot the relative errors of the convergence metrics in loglog scale.
- Return type:
Figure
- ogstools.studies.convergence.plot_convergence_error_evolution(evolution_metrics, error_type='relative')[source]#
Plot the evolution of relative errors.
- Return type:
Figure
- ogstools.studies.convergence.plot_convergence_order_evolution(evolution_metrics)[source]#
Plot the evolution of convergence orders.
- Return type:
Figure
- ogstools.studies.convergence.richardson_extrapolation(meshes, variable, topology, refinement_ratio)[source]#
Estimate a better approximation of a variable on a mesh.
This function calculates the Richardson Extrapolation based on the change in results in the last three of the given meshes. For more information on this topic see <https://www.grc.nasa.gov/www/wind/valid/tutorial/spatconv.html> or <https://curiosityfluids.com/2016/09/09/establishing-grid-convergence/>.
- Parameters:
meshes (list[UnstructuredGrid]) – At least three meshes with constant refinement.
variable (Variable) – The variable to be extrapolated.
topology (UnstructuredGrid) – The topology on which the extrapolation is done.
refinement_ratio (float) – Refinement ratio (spatial or temporal).
- Returns:
Richardson extrapolation of the given variable.
- Return type:
UnstructuredGrid
- ogstools.studies.convergence.run_convergence_study(output_name, mesh_paths, variable_name, timevalue=0.0, refinement_ratio=2.0, reference_solution_path=None, prepare_only=False, show_progress=False)[source]#
Run a convergence study.
- Parameters:
output_name (Path) – The output path for the Jupyter notebook.
mesh_paths (list[Path]) – mesh paths of increasing resolutions.
variable_name (str) – The variable to study for convergence.
timevalue (float) – The time value for analysis.
refinement_ratio (float) – The refinement ratio between the meshes.
reference_solution_path (Path | None) – Optional reference solution for comparison.
prepare_only (bool) – If True, don’t execute the notebook.
show_progress (bool) – If True, display a progress bar.
returns: None, but generates the convergence study notebook.