cosapp.core.numerics.residues¶
Classes
|
Abstract class defining residue for solvers. |
|
Class representing a residue whose left-hand side evaluation is deferred. |
|
Classical residue definition based on an equality equation |
- class cosapp.core.numerics.residues.AbstractResidue(context: System, name: str)[source]¶
Bases:
objectAbstract class defining residue for solvers.
- Parameters:
context (-) – CoSApp Module in which this residue is defined
name (-) – Residue name
- abstract copy() AbstractResidue[source]¶
Copy the object.
- Returns:
The duplicated object.
- Return type:
- property name: str¶
Residue name
- Type:
str
- property reference: Number | ndarray¶
Reference value to normalize the residue with.
- Type:
Number or numpy.ndarray
- abstract update(**kwargs) Number | ndarray[source]¶
Update the value of the residue.
- Returns:
The updated value
- Return type:
Number or numpy.ndarray
- property value: Number | ndarray¶
residue’s value.
- Type:
Number or numpy.ndarray
- class cosapp.core.numerics.residues.DeferredResidue(context: System, target: str, reference=1.0)[source]¶
Bases:
objectClass representing a residue whose left-hand side evaluation is deferred.
The right-hand side of the residue is a targetted quantity. Upon request, a Residue object is generated, with lhs = value(target).
- Parameters:
context (-) – CoSApp System to which residue is linked.
target (-) – Targetted quantity, and left-hand side of the equation.
reference (-) – Reference value to normalize the residue; default is unity.
variables (-) – Names of variables involved in the residue
- make_residue(reference=None) Residue[source]¶
Generates the residue corresponding to equation ‘target == value(target)’
- property target: str¶
targetted quantity
- Type:
str
- property variables: FrozenSet[str]¶
names of variables involved in residue
- Type:
FrozenSet[str]
- class cosapp.core.numerics.residues.Residue(context: System, equation: str, name: str | None = None, reference: Number | Collection | numpy.ndarray | str = 1.0)[source]¶
Bases:
AbstractResidueClassical residue definition based on an equality equation
Left-hand side == Right-hand side
The right-hand side is assumed null if not specified.
The residue can be defined by providing directly the numerical values of the left and right-hand sides. An alternative is to provide an string expression to be evaluated.
- Parameters:
context (-) – CoSApp System to which residue is linked
lhs (-) – Left-hand side of the equation.
rhs (-) – Right-hand side of the equation; default None (i.e. equals zeros).
name (-) – Residue name; default None (built from lhs and rhs)
reference (-) – Reference value to normalized the residue; default is unity
- property equation: str¶
Equation defining the residue
- Type:
str
- static residue_norm(left: Number | Iterable | ndarray, right: Number | Iterable | ndarray = None) Number | ndarray[source]¶
Computes the order of magnitude of left- and right-hand sides to approximate the reference value.
- Parameters:
left (-) – Left-hand side of the equation
right (-) – Right-hand side of the equation if not None
- Returns:
An approximated reference value
- Return type:
Union[Number, numpy.ndarray]
- static split_equation(equation: str) Tuple[str, str][source]¶
Parses and splits an equation of the kind ‘lhs == rhs’. Returns string tuple (lhs, rhs).
- to_dict() Dict[str, Any][source]¶
Returns a JSONable representation of the equation.
- Returns:
JSONable representation
- Return type:
Dict[str, Any]
- update() Number | ndarray[source]¶
Update the residue value
- Returns:
The updated residues
- Return type:
Number or numpy.ndarray
- property variables¶
set of variable names involved in residue.
- Type:
frozenset
- cosapp.core.numerics.residues.object__getstate__(self, /)¶
Helper for pickle.