zoomy_core.model.equation module

zoomy_core.model.equation module#

Equation primitives — Term, _TermGroup, Equation.

Direct port of the framework developed in the transparent-derivation notebooks (thesis/notebooks/legacy/modeling/transparent_derivations/ sme_clean.py etc.). Same classes, same auto-history mechanics, same simplify pipeline (sp.expand → pull var-independent factors out of Derivative atoms → recover fluxes by pulling var-independent coeffs back inside Derivative arguments).

Lives in its own module so the Model class (in basemodel.py) and the derivation subclasses (sigmaref.py, sme.py, vam.py) can import Equation without dragging in the full operations / state surface.

class zoomy_core.model.equation.Term(expr, tag=None, parent=None)#

Bases: object

One additive term of an Equation.

expr#
tag#
apply(*args, **kwargs)#
class zoomy_core.model.equation.Equation(expression, name='eq', model=None)#

Bases: object

Linear list of Term carrying the LHS of one PDE/algebraic equation. apply delegates to Expression.apply (the library operation-dispatch layer) and auto-records a history entry on the parent Model if one is set.

property solver_tags#

Dict of solver tags (canonical names) → sub-expression, or empty dict if none set.

get_solver_tag(name)#

Return the sp.Expr for a solver tag, or None if not set. name is normalised through canonical_solver_tag.

untagged_remainder()#

Return self.expr - sum(solver_tags.values()), simplified. Zero ⇒ every term has been routed to a solver tag; non-zero drives collect_solver_tag’s untagged_policy.

static to_terms(expression)#
static to_expression(terms)#
property expr#
property terms#
apply(*args, **kwargs)#
simplify()#

Canonical form (three sub-steps):

  1. sp.expand — flatten Mul/Add nesting and combine like terms.

  2. Pull var-independent factors out of every Derivative argument: Derivative(g·h, x) g·Derivative(h, x), Derivative(0, x) 0.

  3. Recover fluxes — for each term c · Derivative(_, x) where c is var-independent, pull c back inside so the tagger sees the conservative atom.