zoomy_core.model.models.derived_system module

zoomy_core.model.models.derived_system module#

Reusable derived equation systems.

A DerivedSystem holds a set of depth-integrated equations that are basis-independent. You derive it once from the INS, then reuse it with different bases, materials, or levels without re-deriving.

Usage:

from zoomy_core.model.models.derived_system import DerivedSystem, sme, vam

# Pre-derived SME (hydrostatic, basis-independent) system = sme()

# Try different bases leg_eqs = system.with_basis(Legendre_shifted, level=2, field_map={“u”: alphas}) spl_eqs = system.with_basis(SplineBasis, level=3, field_map={“u”: alphas})

# Apply material later viscous = system.with_material(Newtonian(state))

# Describe print(system.describe())

class zoomy_core.model.models.derived_system.SystemBoundaryConditions(equation_names)#

Bases: object

Boundary conditions for a PDE system, per equation and per tag.

Each equation has a dict of {tag: BoundaryConditionSpec}. Apply shortcuts set BCs for all equations at once:

system.boundary_conditions.apply(Periodic(), tag="left")
system.x_momentum.boundary_conditions.apply(Wall(), tag="right")

The Wall BC is system-aware: when applied at the system level, it automatically assigns Extrapolation to scalar equations and normal/tangential momentum reflection to vector (momentum) equations.

apply(bc, tag=None)#

Apply a BC to all equations.

If bc is a system-level BC like Wall, it dispatches appropriately per equation type. Otherwise it applies uniformly.

set(equation_name, bc, tag=None)#

Set a BC for a specific equation and tag.

get(equation_name, tag)#

Get the BC for a specific equation and tag.

get_all(tag)#

Get all equation BCs for a given tag. Returns {eq_name: bc}.

property tags#

All unique tags across all equations.

property equation_names#
remove_equation(equation_name)#

Remove BCs for a deleted equation.

add_equation(equation_name)#

Add BC slots for a new equation.

class zoomy_core.model.models.derived_system.System(name, state, equations=None, assumptions=None)#

Bases: object

A mutable system of symbolic PDE equations.

Equations are Expression objects accessed by name via dot syntax (system.continuity) or dict syntax (system.equations["continuity"]).

Operations are applied in place:

system = System("INS", state)
system.add_equation("continuity", du_dx + dw_dz)
system.add_equation("x_momentum", ..., term_groups={...})
system.apply(HydrostaticPressure(state))
system.x_momentum.apply_to_term(5, ProductRule())
system.describe()
name#

Human-readable name (e.g. “INS”, “SME”)

Type:

str

equations#

{name: Expression}

Type:

dict

state#

The shared symbolic state

Type:

StateSpace

assumptions#

Operations applied during derivation

Type:

list of str

add_equation(name, expr, term_groups=None)#

Add an equation to the system.

Parameters:
  • name (str) – Equation name (e.g. “continuity”, “x_momentum”).

  • expr (Expression or sympy expr) – The equation (= 0).

  • term_groups (dict, optional) – Named term groups for ordered display.

remove_equation(name)#

Remove an equation and its boundary conditions.

apply(operation)#

Apply an operation or relation to all equations in place.

apply_to_term(equation_name, term_index, *operations)#

Apply operations to a specific term of a specific equation in place.

Usage:

system.apply_to_term("x_momentum", 5, ProductRule())
with_material(material)#

Apply a material model. Returns a new DerivedSystem (immutable).

with_assumption(assumption)#

Apply an assumption. Returns a new System (immutable).

with_basis(basis, level, field_map, z_var=None, test_mode=None)#

Project all equations onto a basis.

Parameters:
  • basis (Basisfunction class) –

  • level (int) –

  • field_map (dict) – {field_name: [alpha_0, alpha_1, ...]}

  • z_var (Symbol, optional) – Vertical coordinate (default: self.state.z)

  • test_mode (int or None) – Galerkin test function mode

Returns:

Projected equations with basis matrix products

Return type:

dict of Expression

describe(header=True, assumptions=True, final_equation=True, parameters=False, strip_args=False)#

Composable description of this equation system.

Returns a Description that renders as markdown in Jupyter.

Parameters:
  • header (bool) – System name and equation list.

  • assumptions (bool) – List assumptions applied.

  • final_equation (bool) – Show equations.

  • parameters (bool) – List free symbols.

  • strip_args (bool) – Display u instead of u(t, x, z).

save(path)#

Save to file for reuse without re-derivation.

classmethod load(path)#

Load a previously saved system.

zoomy_core.model.models.derived_system.DerivedSystem#

alias of System

zoomy_core.model.models.derived_system.sme(state=None, material=None)#

Derive the depth-integrated SME (hydrostatic shallow moment equations).

Returns a DerivedSystem that is basis-independent. Apply a basis later with .with_basis(), or add viscosity with .with_material().

Parameters:
  • state (StateSpace, optional) – Default: StateSpace(dimension=2) (xz plane)

  • material (Relation, optional) – If provided, applied before depth integration

Return type:

DerivedSystem

zoomy_core.model.models.derived_system.vam(state=None, material=None)#

Derive the depth-integrated VAM (non-hydrostatic, with z-momentum).

Returns a DerivedSystem with mass, x-momentum, and z-momentum equations. Pressure is NOT substituted — it remains as an unknown.

Parameters:
Return type:

DerivedSystem