zoomy_core.model.fields#
Symbols as the user-facing names of state fields and parameters.
FieldSymbols holds the state symbols of a model (Model.state(...), sm.fields) with named
groups (.momentum) and optional user aliases. Parameters is the parameter vector of a solver,
read and set by symbol, and a pytree for JAX. A symbol is identified by its name; the model’s own
symbols carry its assumptions, symbols made elsewhere with the same name refer to the same field.
Module Contents#
Classes#
A named group of state symbols, e.g. |
|
The state symbols of a model by name, its groups and optional aliases. |
|
The parameter vector of a solver, read and set by symbol: |
Functions#
The name of a symbol; anything else raises TypeError. |
|
The momentum components among |
|
The vector for |
Data#
API#
- zoomy_core.model.fields.RunResult#
‘namedtuple(…)’
- zoomy_core.model.fields.symbol_name(s, what='field')#
The name of a symbol; anything else raises TypeError.
- class zoomy_core.model.fields.FieldGroup#
Bases:
tupleA named group of state symbols, e.g.
fields.momentum(all momentum components).Initialization
Initialize self. See help(type(self)) for accurate signature.
- zoomy_core.model.fields.momentum_symbols(symbols)#
The momentum components among
symbols: the familyq(q_0,q_x_1, …).
- class zoomy_core.model.fields.FieldSymbols(symbols, groups=None, names=None)#
The state symbols of a model by name, its groups and optional aliases.
fields.his the depth symbol,fields.momentumthe group of momentum components, and withnames=("b", "h", "hu", "hv")alsofields.hu(the same symbol asfields.q_x_0).Initialization
Hold
symbols(the state in model order),groups{name: symbols} and the usernames(one per state field, in model order) as aliases.- names()#
The field names in model order.
- slot(s)#
The row of field
s(a symbol of this state) inQ:Q[fields.slot(fields.h)].
- class zoomy_core.model.fields.Parameters(names, values)#
The parameter vector of a solver, read and set by symbol:
p[n],p.set({n: 0.04}).A pytree for JAX (registered by zoomy_jax), so
jax.gradwith respect to all parameters returns aParametersof gradients:dJ[n].np.asarray(p)andjnp.asarray(p)give the vector.Initialization
Hold the parameter
names(vector order) and thevaluesvector.- set(mapping)#
A copy with the parameters in
mapping{symbol: value} replaced.
- vector(mapping=None)#
The vector, with the parameters in
mapping{symbol: value} replaced.
- names()#
The parameter names in vector order.
- zoomy_core.model.fields.parameter_vector(default, parameters)#
The vector for
run(..., parameters=...): None givesdefault(aParameters), aParametersits vector, a mapping {symbol: value}defaultwith those replaced, a vector passes through.