Model#
A Model is a symbolic PDE system: state, parameters, equations, boundary and initial conditions.
It has no mesh and no numerics.
SystemModel.from_model(model) lifts it to the SystemModel.
What a Model has#
zoomy_core.model.basemodel.Model, configured by keyword arguments.
setting |
meaning |
|---|---|
|
spatial dimension. The derived models ( |
|
state fields, a name or |
|
auxiliary fields, for example derivatives a closure needs |
|
|
|
one condition per mesh tag, below |
|
|
|
the same for the auxiliary fields |
|
|
|
well-balanced reconstruction: |
The equations come in one of two forms.
Operators: the model overrides
flux,nonconservative_matrix,source,diffusion_matrix, … (SWE).Derived rows:
derive_modelbuilds the equations symbolically from a full system and an ansatz (SME,VAM, the multilayer models).model.derivation.describe()prints them with the derivation history.
model.describe() prints the equations of either form.
Closures live on the derived models: closures=[...] takes pieces of zoomy_core.model.models.closures.
closes |
closures |
|---|---|
bulk stress |
|
bed |
|
free surface |
|
layer interfaces |
|
The smallest model: SWE#
SWE() in zoomy_core/model/models/swe.py, written as operators.
Generated from the code by SWE().summarize_model():
State \(Q\): \(b\), \(h\), \(hu\)
Parameters: g = 9.81, n_m = 0.0, h_in = 0.0, q_in = 0.0, vel_eps = 1e-12, wet_dry_eps = 0.01
Implemented models#
zoomy_core.model.models:
model |
|
|---|---|
|
shallow water with bed and Manning friction, written as operators |
|
viscous wetting and drying SWE in two horizontal directions |
|
shallow moment equations, |
|
SME with the Elder eddy viscosity and a rough-wall bed |
|
SME with transported k and epsilon |
|
KESME with |
|
non-hydrostatic vertically averaged moments, u, w and the non-hydrostatic pressure in one basis |
|
VAM in the weak-viscosity limit |
|
multilayer SWE, layers moving with the free surface |
|
multilayer SME, a moment column per layer |
|
multilayer VAM, a VAM column per layer. Details |
The settings of a model are param parameters:
from zoomy_core.model.models import SME
list(SME.param) # every setting
SME.param["stress"].objects # allowed values: [Stress.shallow, Stress.full]
SME.param["closures"].doc # documentation of one setting
An unknown setting raises a TypeError naming the closest match.
An option given as a plain string raises with the typed value to use (stress="full": use Stress.full).
Boundary conditions#
zoomy_core.model.boundary_conditions, each on one mesh tag, given as a list to the model (boundary_conditions=[...]) or attached later with sm.attach_boundary_conditions([...]).
class |
meaning |
|---|---|
|
reflecting free-slip wall |
|
a boundary the model derives, for example the free-slip wall of every moment |
|
prescribed value of a field, a number or an expression in the model’s symbols |
|
prescribed normal gradient |
|
zero gradient, transmissive |
|
prescribe some fields, extrapolate the rest, |
|
periodic pair |
|
face values from a user function |
|
preCICE interface, see Backends |
Fields and parameters by symbol#
A field or parameter can be named by its symbol. SME.state(level=0, dimension=2) gives the state symbols before the model exists, sm.fields after (.momentum is the group of momentum components, names=("b", "h", "hu") adds aliases). sm.parameters holds the parameter symbols. Row numbers and field names keep working, symbols are recommended: a symbol that is not in the state fails at once, a row number silently means another field after a model change.
s = SME.state(level=0, dimension=2) # b, h, q_0
model = SME(level=0, dimension=2, parameters={"n": 0.03, "h_tail": 0.6}, closures=[...],
boundary_conditions=[Dirichlet("left", on=s.q_0, value=0.5),
Dirichlet("right", on=s.h, value=sp.Symbol("h_tail") - s.b)])
use case |
by row or name |
by symbol |
|---|---|---|
fix a field |
|
|
value from other fields, time, position |
|
|
value with a parameter |
|
|
several fields |
|
|
all momentum components |
|
|
wall vectors |
|
|
far field |
|
|
initial state |
|
|
read a result |
|
|
set a parameter |
|
|
derivative |
|
solver.run returns (time, Q, Qaux) with the names .time, .Q, .Qaux.
Tutorial: Model and SystemModel.
API: zoomy_core.model.