zoomy_core.model.derivation.model#
The derivation Model: ordered coordinates, parameters, scalar/vector equations, the unknown
registry Q/Qaux and the operation history. It is the entry point of the derivation chain Model ->
SystemModel (SystemModel.from_model).
Module Contents#
Classes#
Vector equation: ordered component Equations with named-axis ( |
|
Indexed family of moment rows produced by |
|
Handle on a model field (typically the sigma-mapped applied form) exposing |
|
Computational-graph spine of a symbolic derivation: coordinates, parameters, equations,
unknowns (Q declared, Qaux derived) and history. Operations are applied with
|
|
Tracked-operation form of |
Functions#
Moment-axis shape bump: specialise the abstract Galerkin test index of a row to concrete
modes and group the rows as a MomentFamily (scalar |
API#
- class zoomy_core.model.derivation.model.VectorEquation(name, shape, components)#
Vector equation: ordered component Equations with named-axis (
.x/.y/.z) and index access. Components are also flattened into the model’s_equationsas<name>_<axis>.Initialization
Wrap the component equations of a vector row of length 1, 2 or 3.
- property components#
List of component equations.
- replace_axis(axis, replacement)#
Swap the component at
axis(name or index), e.g. for a MomentFamily after a moment-axis bump.
- apply(*args, **kwargs)#
Broadcast an operation across every component.
- describe(strip_args=False)#
Markdown description of the components.
- class zoomy_core.model.derivation.model.MomentFamily(name, modes, components, index=None)#
Indexed family of moment rows produced by
resolve_modes(model.mass[l],model.momentum.x[l]). Rows are also flattened into the model’s_equationsas<base>_<mode>.Initialization
Store the family name, mode list, per-mode rows and the symbolic index.
- property components#
List of moment rows.
- apply(*args, **kwargs)#
Broadcast an operation across every moment row.
- describe(strip_args=False)#
Markdown description of the moment rows.
- class zoomy_core.model.derivation.model.FieldHandle(applied)#
Handle on a model field (typically the sigma-mapped applied form) exposing
.head,.expr,.at(value)and call syntax. Sympifiable; handles live onModel.functionsonly.Initialization
Wrap the applied field.
- property head#
Function class of the field.
- property expr#
Applied field expression.
- at(value)#
Field evaluated at
valuein its last (vertical) argument.
- class zoomy_core.model.derivation.model.Model(coords=(_coords.t, _coords.x, _coords.z), parameters=None, name='model')#
Computational-graph spine of a symbolic derivation: coordinates, parameters, equations, unknowns (Q declared, Qaux derived) and history. Operations are applied with
model.apply(op); the result is lifted to a SystemModel.Initialization
Create an empty model over
coords(defaultt, x, z) with positive-Symbolparametersgiven as{name: default}.- parameter(name, default=0.0)#
Return the positive Symbol for parameter
name, creating it withdefaultif it is not yet declared.
- property coords#
Ordered tuple of coordinates.
- property vertical#
Vertical coordinate: the mapped
zetaafter a PDETransformation, else the last coordinate.
- property horizontal#
Horizontal coordinates: all but time and vertical.
- declare_state(*fields)#
Add fields to
Qas primary (state) unknowns; used by equation blueprints.
- declare_closure(*fields)#
Record fields as closure variables (present in the equations, routed to
Qauxunless substituted).
- add_equation(name, shape_or_expr=None, expr=None, *, group='model', _refresh=True)#
Register a scalar equation, a vector equation (
name, shape, [exprs]), a blueprint, or an oriented relation such as a KinematicBC (stored as an assumption).Args
group:"model"for the final PDE system or"aux"for auxiliary relations that never reach the SystemModel.
Returns
The Equation, VectorEquation or stored relation.
- remove(name)#
Remove a named equation, vector row or stored assumption; returns
self.
- apply(op, **kwargs)#
Apply an operation:
system_levelops once to the model,whole_model_opops viaapply_to_model, all others broadcast over every scalar equation.
- property Q#
Declared unknowns as a Zstruct.
- property Qaux#
Derived auxiliaries: every field in the equations that is not in
Q, not a coordinate and not a parameter.
- explicit_state()#
One applied field per time-derivative row of the primary equations, with modal families flattened; the state vector for
SystemModel.from_model.
- property functions#
Registry of every field by its original name as a FieldHandle (bulk form, vertical argument normalised to
zetaafter the sigma map).
- move_to_aux(*fields)#
Demote fields (given data such as the bed
b) fromQtoQauxeven if they stay in a primary equation; returnsself.
- register_group(slot, index, relation)#
Record
relationas componentindexof function groupslot(e.g.'interpolate','project'), parsed into the matching SystemModel slot byfrom_model.Args
relation: oriented relation, Equation, FieldHandle or bare sympy expression; only its right-hand side is stored.
Returns
self
- redeclare_unknown(old_field, new_fields, rename_key=False)#
Transfer unknown status from
old_fieldtonew_fields, keeping the logical key (decoration) or renaming it to the new family (rename_key=True).
- register_index(name)#
Mint and register a Galerkin test/moment index Symbol; the same name returns the same symbol and clashes with modal indices raise.
- modal_index(target)#
Modal-mode index assigned to a field or coefficient family by
separation_of_variables.
- modal_basis(target)#
Basis registered with the field’s separation-of-variables expansion, or None.
- describe(strip_args=False, show='model', show_tags=False, show_history=False, max_log_level=5)#
Markdown description of the model: parameters, Q and equations;
showselects"model","aux"or"all"rows.
- zoomy_core.model.derivation.model.resolve_modes(equation, *, index, modes, test_weight=None, basis_cls=None, level=None, var=None, resolver=None)#
Moment-axis shape bump: specialise the abstract Galerkin test index of a row to concrete modes and group the rows as a MomentFamily (scalar
(1,) -> (N+1,), vector component(n,) -> (n, N+1)).Args
equation: row carrying the abstractindex(model.massormodel.momentum.x).modes: concrete moment indices.test_weight,basis_cls,level,var: if given, each row is also closed byclosure.Resolve.resolver: custom per-mode closer(row, test_weight_k, k)used instead ofResolve.
Returns
The MomentFamily.
- class zoomy_core.model.derivation.model.ResolveModes(index, modes, name='resolve_modes')#
Bases:
zoomy_core.model.operations.OperationTracked-operation form of
resolve_modes; it does not close the basis brackets.Initialization
Store the abstract
indexand the concretemodes.- apply_to_equation(equation)#
Bump the equation via
resolve_modes.