GaPFlow.Problem#
- class GaPFlow.Problem(options: dict, grid: dict, numerics: dict, prop: dict, geo: dict, gp: dict | None = None, database: Database | None = None, extra_field: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None)#
Bases:
objectProblem driver for GaPFlow simulations.
Sets up field collections, constitutive models (pressure, wall stress, bulk stress), optional Gaussian-process surrogate databases, time-stepping parameters, and I/O.
Notes
Calling the constructor
__init__()directly expects properly formatted input dictionaries. It is recommended to use thefrom_yaml()orfrom_string()class methods, which automatically sanitize the simulation input.Examples
>>> from GaPFlow import Problem >>> myProblem = Problem.from_yaml('my_input_file.yaml')
- __init__(options: dict, grid: dict, numerics: dict, prop: dict, geo: dict, gp: dict | None = None, database: Database | None = None, extra_field: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None) None#
Constructor.
- Parameters:
options (dict) – general simulation options.
grid (dict) – Parameters controlling spatial discretization.
numerics (dict) – Time integration parameters.
prop (dict) – Material properties.
geo (dict) – Geometry settings.
gp (dict or None) – Parameters controlling the GP surrogate models.
database (GaPFlow.db.Database or None) – A database object, handling the GP training data with an attached MD runner.
extra_field (numpy.ndarray or None) – An additional field, whose entries can be used as GP features (besides the solution itself and the topography).
Methods
__init__(options, grid, numerics, prop, geo)Constructor.
animate([save, seconds])Create an animation of the solution time series.
from_string(ymlstring)Create a Problem instance from a YAML string.
from_yaml(fname)Create a Problem instance from a YAML file.
plot([ax])Plot a snapshot of the solution and the current stress state.
plot_topo([show_defo, show_pressure])Plot the gap topography, optionally in deformed state and with pressure profile.
run([keep_open])Run the time-stepping loop until convergence, maximum iterations, or until a termination signal is received.
update()Performs a single time step using the MacCormack [1] predictor corrector scheme.
write([scalars, fields])Write scalars, fields and hyperparameters to disk as configured.
Attributes
Current CFL number.
Return True if residuals in the buffer are below tolerance.
Critical timestep determined by grid spacing and sound speed.
Total kinetic energy (scalar).
Total mass integrated over domain (scalar).
Full density field
Check for NaNs in the solution field.
Check for negative densities in the solution field.
Validity flag for the solution field.
Maximum speed in the domain (scalar).
- animate(save: bool = False, seconds: float = 10.0) None#
Create an animation of the solution time series.
Checks if simulation has run already and if output has been generated. For 1D elastic simulations, height and deformation are included.
- Parameters:
save (bool, optional) – Whether to save the animation as an .mp4 file, by default False.
seconds (float, optional) – Duration of the animation in seconds (if saved), by default 10.0
- property cfl: floating#
Current CFL number.
- property converged: bool#
Return True if residuals in the buffer are below tolerance.
- property dt_crit: floating#
Critical timestep determined by grid spacing and sound speed.
- classmethod from_string(ymlstring: str) Self#
Create a Problem instance from a YAML string.
- Parameters:
ymlstring (str) – YAML content as a string.
- Returns:
Instantiated Problem object.
- Return type:
- classmethod from_yaml(fname: str) Self#
Create a Problem instance from a YAML file.
- Parameters:
fname (str) – Path to YAML configuration file.
- Returns:
Instantiated Problem object.
- Return type:
- property kinetic_energy: floating#
Total kinetic energy (scalar).
- property mass: floating#
Total mass integrated over domain (scalar).
- plot(ax=None) None#
Plot a snapshot of the solution and the current stress state.
- Parameters:
ax (matplotlib.pyplot.axis, optional) – An axis to plot into, if None or wrong shape a new axis is created
- plot_topo(show_defo=False, show_pressure=False) None#
Plot the gap topography, optionally in deformed state and with pressure profile.
- Parameters:
show_defo (bool) – Flag for showing deformation, default is False
show_pressure (bool) – Flag for showing pressure, default is False
- property q: ndarray[tuple[Any, ...], dtype[floating]]#
Full density field
- property q_has_nan: bool#
Check for NaNs in the solution field.
- property q_has_negative_density: bool#
Check for negative densities in the solution field.
- property q_is_valid: bool#
Validity flag for the solution field.
- run(keep_open: bool = False) None#
Run the time-stepping loop until convergence, maximum iterations, or until a termination signal is received.
- Parameters:
keep_open (bool, optional) – If True, keeps files open after run for following runs to be written in the same files, by default False.
- update() None#
Performs a single time step using the MacCormack [1] predictor corrector scheme.
References
- property v_max: floating#
Maximum speed in the domain (scalar).
- write(scalars: bool = True, fields: bool = True) None#
Write scalars, fields and hyperparameters to disk as configured.