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() → cosapp.core.numerics.residues.AbstractResidue[source]¶ Copy the object.
- Returns
The duplicated object.
- Return type
-
property
name¶ Residue name
- Type
str
-
property
reference¶ Reference value to normalize the residue with.
- Type
Number or numpy.ndarray
-
abstract
update(**kwargs) → Union[numbers.Number, numpy.ndarray][source]¶ Update the value of the residue.
- Returns
The updated value
- Return type
Number or numpy.ndarray
-
property
value¶ 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) → cosapp.core.numerics.residues.Residue[source]¶ Generates the residue corresponding to equation ‘target == value(target)’
-
property
target¶ targetted quantity
- Type
str
-
property
variables¶ names of variables involved in residue
- Type
Set[str]
-
class
cosapp.core.numerics.residues.Residue(context: System, equation: str, name: Optional[str] = None, reference: Union[numbers.Number, collections.abc.Collection, numpy.ndarray, str] = 1)[source]¶ Bases:
cosapp.core.numerics.residues.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
-
copy() → cosapp.core.numerics.residues.Residue[source]¶ Copy the residue object.
- Returns
The duplicated residue
- Return type
-
property
equation¶ Equation defining the residue
- Type
str
-
static
evaluate_residue(lhs: Union[numbers.Number, collections.abc.Collection, numpy.ndarray], rhs: Union[numbers.Number, collections.abc.Collection, numpy.ndarray], reference: Union[numbers.Number, collections.abc.Collection, numpy.ndarray, str] = 1) → Union[float, numpy.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: Union[numbers.Number, collections.abc.Collection, numpy.ndarray], right: Optional[Union[numbers.Number, collections.abc.Collection, numpy.ndarray]] = None) → Union[numbers.Number, numpy.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).