zoomy_core.model.derivation.operations#
Derivation operations that do more than a substitution: SolveFor, SolveLinearSystem,
ChangeOfVariables. They follow the Operation protocol of zoomy_core.model.operations and act
on a Model before it is lifted to a SystemModel.
Module Contents#
Classes#
Reorient an equation in place into |
|
Solve a coupled linear system |
|
Structural level an Operation acts on: |
|
Rename a coefficient family |
Functions#
Return the Granularity of an operation from its |
API#
- class zoomy_core.model.derivation.operations.SolveFor(variable, name=None)#
Bases:
zoomy_core.model.operations.OperationReorient an equation in place into
variable = solution. Pipeline counterpart ofequation.solve_for(var), which returns a new equation.Initialization
Store the variable to isolate.
- apply_to_equation(eq)#
Replace the equation by the oriented relation
variable = solution.
- class zoomy_core.model.derivation.operations.SolveLinearSystem(equations, variables, name='solve_linear_system')#
Solve a coupled linear system
A v = bfor a family of variables withsympy.linsolve.solve()returns an indexable MomentFamily of oriented rowsv_i = solution_ithat can be passed to.apply.Initialization
Store the equations and the unknown variables.
- solve()#
Solve the system, hiding opaque Galerkin brackets behind symbols during the solve.
Returns
MomentFamily whose component
iisvariables[i] = solution_i.
- class zoomy_core.model.derivation.operations.Granularity#
Structural level an Operation acts on:
LEAF,TERM,EQUATIONorSYSTEM.- LEAF#
‘LEAF’
- TERM#
‘TERM’
- EQUATION#
‘EQUATION’
- SYSTEM#
‘SYSTEM’
- zoomy_core.model.derivation.operations.granularity_of(op) str#
Return the Granularity of an operation from its
system_level/whole_model_op/single_term_onlyflags.Args
op: an Operation instance.
- class zoomy_core.model.derivation.operations.ChangeOfVariables(old, new, relation, name=None)#
Bases:
zoomy_core.model.operations.OperationRename a coefficient family
a(i, ...) -> relation(q(i, ...))across the model and swapaforqin the unknowns. The unknown swap (model.redeclare_unknown) is what distinguishes it from a plain substitution.Args
old: name of the family currently inQ.new: name of the replacing family.relation: callable mapping the appliednewfunction to the substituted expression.
Initialization
Store the family names and the relation.
- whole_model_op#
True
- transforms_bcs#
True
- apply_to_model(model)#
Rewrite every equation and relation, then redeclare the unknowns
old -> new.