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:
object
Abstract 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:
object
Class 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)[source]¶
Bases:
AbstractResidue
Classical 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 evaluate_residue(lhs: Number | Collection | ndarray, rhs: Number | Collection | ndarray, reference: Number | Collection | ndarray | str = 1) float | ndarray [source]¶
Evaluate the normalized residue from left- and right-hand sides of an equation.
- The formula depends on the left- and right-hand side value of the equation:
residues = (lhs - rhs) / reference
- Parameters:
lhs (-) – Left-hand side of the equation
rhs (-) – Right-hand side of the equation
reference (-) – Reference value to normalize the equation with; default is unity
- Returns:
Normalized residue
- Return type:
Number or numpy.ndarray
- static residue_norm(left: Number | Collection | ndarray, right: Number | Collection | 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:
Number or 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).