zoomy_core.model.derivation.modal

zoomy_core.model.derivation.modal#

Modal separation of variables: turns a field u(t, x, zeta) into an unexpanded sum over a basis, with the index bookkeeping ResolveBasis needs. Sits at the start of the moment/Galerkin derivation on a derivation Model.

Module Contents#

Classes#

ModalIndexRegistry

Per-model registry of coeff_name -> (index, basis) plus a field_head -> coeff_name map. Every field gets a distinct summation index, otherwise products of two sums would silently lose their cross terms.

SeparationOfVariables

Model operation that replaces a field’s decorated head by its unexpanded modal sum and swaps the unknown family in Q. Built by separation_of_variables; it rewrites every equation and registers the index and basis in model._modal_registry.

TensorSeparationOfVariables

Model operation for a concretely expanded tensor-product Galerkin ansatz over a vertical and a lateral separation coordinate. Heads are matched by name (the field and its sigma-decorated sibling) and the sum is expanded with integer orders, so there are no shared dummies.

Functions#

modal_index

Return an integer, non-negative trial summation-index symbol.

test_index

Return an integer, non-negative Galerkin test/moment index symbol; the name l is reserved for it.

modal_bound

Return a fresh abstract integer, non-negative truncation-bound symbol.

reset_modal_indices

Clear the model’s modal-index registry so index assignment is deterministic.

build_modal_sum

Build the unexpanded modal sum Sum_i coeff(i, *coords) * phi(i, zeta) for a field.

separation_of_variables

Return a SeparationOfVariables operation approximating field by Sum_i coeff(i, *coords) * phi(i, zeta) with a distinct registry index.

API#

zoomy_core.model.derivation.modal.modal_index(name='i')#

Return an integer, non-negative trial summation-index symbol.

zoomy_core.model.derivation.modal.test_index(name='l')#

Return an integer, non-negative Galerkin test/moment index symbol; the name l is reserved for it.

zoomy_core.model.derivation.modal.modal_bound(name='N_u')#

Return a fresh abstract integer, non-negative truncation-bound symbol.

class zoomy_core.model.derivation.modal.ModalIndexRegistry#

Per-model registry of coeff_name -> (index, basis) plus a field_head -> coeff_name map. Every field gets a distinct summation index, otherwise products of two sums would silently lose their cross terms.

Initialization

Create an empty registry.

assign(coeff_name, *, basis=None, field_head=None, index=None)#

Register or update a coefficient entry and return its (memoised) index.

fresh(key=None)#

Return a new index, or the memoised one for the given coefficient name.

coeff_name_for(target)#

Resolve a name, coefficient or field head (bare or applied) to its coefficient name, or None.

index_for(target)#

Return the registered summation index of a field or coefficient, or None.

basis_for(target)#

Return the registered basis of a field or coefficient, or None.

register(name)#

Mint a user test/moment index, raising if the name collides with an existing index.

reset()#

Clear all entries and indices.

zoomy_core.model.derivation.modal.reset_modal_indices(model)#

Clear the model’s modal-index registry so index assignment is deterministic.

zoomy_core.model.derivation.modal.build_modal_sum(field, coeff, basis, order, index)#

Build the unexpanded modal sum Sum_i coeff(i, *coords) * phi(i, zeta) for a field.

Args

  • field: Applied field; its last argument is the separation coordinate zeta.

  • coeff: Coefficient head, or applied coefficient carrying its own coords.

  • basis: Basis supplying the opaque phi head, or a bare phi head.

  • order: Truncation bound N.

  • index: Summation index.

class zoomy_core.model.derivation.modal.SeparationOfVariables(field, coeff, basis, order, *, index=None, name='separation_of_variables')#

Bases: zoomy_core.model.operations.Operation

Model operation that replaces a field’s decorated head by its unexpanded modal sum and swaps the unknown family in Q. Built by separation_of_variables; it rewrites every equation and registers the index and basis in model._modal_registry.

References

  • Kowalski, Torrilhon 2019, https://doi.org/10.4208/cicp.OA-2017-0263

Initialization

Store the field, coefficient, basis, truncation order and optional index.

whole_model_op#

True

apply_to_model(model)#

Expand every application of the field head into a modal sum, each with a distinct dummy index, and redeclare the unknown as the coefficient family. Boundary evaluations u(t, x, 0/1) expand too, so the ansatz may follow a field-level boundary condition.

class zoomy_core.model.derivation.modal.TensorSeparationOfVariables(field, coeff_head, *, pos_z, basis_z, order_z, pos_y, basis_y, order_y, scale_y=1, name='tensor_sov')#

Bases: zoomy_core.model.operations.Operation

Model operation for a concretely expanded tensor-product Galerkin ansatz over a vertical and a lateral separation coordinate. Heads are matched by name (the field and its sigma-decorated sibling) and the sum is expanded with integer orders, so there are no shared dummies.

Args

  • field: Original field application, e.g. u(t, x, y, z).

  • coeff_head: Tensor coefficient family, applied as q(j, i, *kept_args) with lateral j outer, vertical i inner.

  • pos_z, basis_z, order_z: Position, basis and truncation order of the vertical coordinate.

  • pos_y, basis_y, order_y: Same for the lateral coordinate.

  • scale_y: Lateral slot carries y = scale_y * eta, so the coefficient’s eta is arg / scale_y.

Initialization

Store the field, coefficient family and per-direction positions, bases and orders.

whole_model_op#

True

apply_to_model(model)#

Replace the field head and its decorated sibling by the tensor-product sum in every equation.

zoomy_core.model.derivation.modal.separation_of_variables(field, coeff, basis, order, *, index=None)#

Return a SeparationOfVariables operation approximating field by Sum_i coeff(i, *coords) * phi(i, zeta) with a distinct registry index.

Args

  • field: Original field application, e.g. u(t, x, z).

  • coeff: Coefficient head or applied coefficient, e.g. a(t, x).

  • basis: Basis supplying the opaque phi.

  • order: Truncation bound N.

  • index: Override of the summation index.

Returns

Operation for model.apply(…).

References

  • Kowalski, Torrilhon 2019, https://doi.org/10.4208/cicp.OA-2017-0263