cottax.ode.consumers.declaration module¶
The ODE declarations, OdeDeclaring, chosen as a part of a study’s surface, and its one kind, Rate.
- check_named(rate: Rate)[source]¶
A history and an initial value each a state’s, and a history recorded at times.
- Return type:
Iterator[Violation]
- class Rate[N: Label, V: Place](fn: Body, function_reads: tuple[PlaceWithValue[V], ...], outputs: tuple[V, ...], record: OrderedMap[V, V], times: Optional[PlaceWithValue[V]], initial: OrderedMap[V, PlaceWithValue[V]], span: Optional[PlaceWithValue[V]], *, output_tags: Tags[V] = {})[source]¶
Bases:
Paired[N,V],Generic[N,V]A function writing ^rate.x per state (its outputs), in that order, and at ^solve.at the ODE determining the states from their initial values (initial, else ^initial.x) over the span (span, else ^span of the first state). Where a study names a history (record, at times) the ODE is declared driven, by Integration(trajectory=True), so a model reading a history is coupled to it from the declaration on.
- record: OrderedMap[V, V]¶
The place each recorded state’s history is written to.
- times: Optional[PlaceWithValue[V]]¶
Where the times a history is saved at are read.
- initial: OrderedMap[V, PlaceWithValue[V]]¶
Where each named state’s initial value is read.
- span: Optional[PlaceWithValue[V]]¶
Where the span is read.
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_named>,)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- property function_outputs: tuple[V, ...]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- property terms: tuple[PlaceWithValue[V], ...]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- property condition: OdeCondition[V]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- condition_node(at: N)[source]¶
The ODE, driven where a history is recorded: the times where times says, each history where record names it, else at ^trajectory.x.
- Return type:
- property problem: N¶
Where its ODE binds, the rate handed to declare loose: ^solve.<fn>.
- given_at[V](surface: Declaring, x: V, written: Any, value_at: PlaceToPlace[V])[source]¶
What is written where a place about x is due, a value given at value_at(x): the surface’s term, zero too a value here (a state starting at rest, a span from zero).
- Return type:
- record_of[V](surface: Declaring, fn: Any, outputs: tuple[V, ...], record: Any)[source]¶
record=: each recorded state’s history, a mapping or one for the one state there is.
- Return type:
OrderedMap[V,V]
- initial_of[V](surface: Declaring, fn: Any, outputs: tuple[V, ...], initial: Any)[source]¶
initial=: each named state’s initial value, a place or a value given at ^initial.x.
- Return type:
OrderedMap[V,PlaceWithValue[V]]
- per_problem(purpose: Mint)[source]¶
times= or span=: a place, or a value given at purpose’s name of the first state.
- class OdeDeclaring(locator: Locator[V, N], conventions: ~cottax.consumers.declaration.conventions.Conventions = Conventions(reads=ParameterReads(by_name=True), term=<function term_of>, per_place=<function per_place_of>))[source]¶
Bases:
DeclaringThe ODE declarations: a rate per state, and the ODE integrating it.
- rate¶
A function returning the rate of each state, and the ODE determining the states: rate(fn, *states), or @rate(*states). initial= (a mapping, or one for the one state) and span= say where those are read, a value written there given; two rates joined by combine read one span. record={‘x’: ‘x_history’} with times=’ts’ declares the ODE driven, writing each named state at every time.
- class NotAState(fn: str, keyword: str, places: tuple)[source]¶
Bases:
Violation- fn: str¶
- keyword: str¶
- places: tuple¶
- template: AbstractClassVar[str] = '{fn}: `{keyword}=` names {places!r}, which are not its states'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class RecordUnpaired(fn: str, given: str, missing: str)[source]¶
Bases:
Violation- fn: str¶
- given: str¶
- missing: str¶
- template: AbstractClassVar[str] = '{fn}: `{given}=` is given without `{missing}=` -- a history is saved at times, so name both or neither'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording