zoomy_core.model.models.derived_model module

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: Model

Base 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 calls super().derive_model()

to get the parent’s equations, then self.apply(...) to refine.

  • apply() auto-registers every operation for describe().

Set projectable = True on 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: call super().derive_model() then self.apply(...) to transform.

apply(operation)#

Apply a relation or operation to all equations.

Accepts two kinds of arguments:

  1. Relation (Assumption, Material): substitutes symbols in all equations (lhs rhs).

  2. Operation (DepthIntegrate, etc.): applies a callable transformation to each equation.

Mutates self._system in place and auto-registers the operation for describe().

property system: Optional[System]#

The current equation system.

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 u instead of u(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()#
navier_slip()#