zoomy_core.model.models.derived_model module#
DerivedModel — chainable base class for equation-derived models.
The derivation graph is the Python class hierarchy. Each subclass
overrides derive_model() and uses self.apply(...) to transform
the equations inherited from its parent (via super().derive_model()).
Every apply call auto-registers the operation so that describe()
can reconstruct the full derivation path without any manual bookkeeping.
Example:
class INSModel(DerivedModel):
def derive_model(self):
state = StateSpace(dimension=2)
ins = FullINS(state)
self._init_system("INS", {
"continuity": ins.continuity,
"x_momentum": ins.x_momentum,
}, state)
class SMEModel(INSModel):
projectable = True
def derive_model(self):
super().derive_model()
self.apply(HydrostaticPressure(self.state))
self.apply(Newtonian(self.state))
self.depth_integrate()
model = SMEModel(level=2)
model.describe(derivation='mermaid')
- zoomy_core.model.models.derived_model.get_cached_matrices(basis, level, integrator)#
- zoomy_core.model.models.derived_model.clear_matrix_cache()#
- class zoomy_core.model.models.derived_model.DerivedModel(level=0, n_layers=1, basis_type=<class 'zoomy_core.model.models.basisfunctions.Legendre_shifted'>, eigenvalue_mode=None, dimension=None, **kwargs)#
Bases:
ModelBase class for models derived via a chain of symbolic operations.
Derivation graph = class hierarchy. - Each class is a node. -
derive_model()is the edge: it callssuper().derive_model()to get the parent’s equations, then
self.apply(...)to refine.apply()auto-registers every operation fordescribe().
Set
projectable = Trueon the final class to make it solver-ready.- projectable = False#
- level = 0#
- n_layers = 1#
- basis_type#
alias of
Legendre_shifted
- derive_model()#
Override to build/refine the equation system.
Root classes: call
self._init_system(...)to create equations. Child classes: callsuper().derive_model()thenself.apply(...)to transform.
- apply(operation)#
Apply a relation or operation to all equations.
Accepts two kinds of arguments:
Relation (Assumption, Material): substitutes symbols in all equations (
lhs → rhs).Operation (DepthIntegrate, etc.): applies a callable transformation to each equation.
Mutates
self._systemin place and auto-registers the operation fordescribe().
- property state#
The shared symbolic StateSpace.
- property applied_operations: List[dict]#
Operations applied by this class’s derive_model().
- describe(header=True, derivation=False, assumptions=True, final_equation=True, parameters=False, strip_args=False, verbose=False)#
Composable description of this model.
- Parameters:
header (bool) – Model class name + system info.
derivation (False, 'mermaid', or 'markdown') – Show the derivation path from parent to self. Compact (default): parent → one edge → self. Verbose (
verbose=True): parent → edge per apply → self.assumptions (bool) – List assumptions.
final_equation (bool) – Show final equations.
parameters (bool) – List free symbols.
strip_args (bool) – Display
uinstead ofu(t, x, z).verbose (bool) – In derivation mode, show one edge per apply() call instead of summarizing all on a single edge.
- get_primitives()#
- mass_matrix()#
- mass_matrix_inverse()#
- flux()#
Flux.
- hydrostatic_pressure()#
Hydrostatic pressure.
- nonconservative_matrix()#
Nonconservative matrix.
- source()#
Source.
- newtonian_viscosity()#