cosapp.drivers.utils¶
Functions
|
Resolve unknown aliasing in problem due to pulling connectors (if any) in context system. |
Classes
|
Named tuple representing a non-negative constraint of the kind lhs <op> rhs, where <op> is either == (equality) or >= (inequality constraint), depending on Boolean attribute is_inequality. |
|
Enum covering constraint types |
|
Class managing tied design and off-design problems, including unknown aliasing. |
|
Class containing data collected on a system, to be shared between different drivers. |
- class cosapp.drivers.utils.Constraint(lhs: str, rhs: str, is_inequality: bool = True)[source]¶
Bases:
NamedTuple
Named tuple representing a non-negative constraint of the kind lhs <op> rhs, where <op> is either == (equality) or >= (inequality constraint), depending on Boolean attribute is_inequality.
Attributes:¶
lhs [str]: left-hand side.
rhs [str]: right-hand side.
is_inequality [bool].
Properties:¶
expression [str]: non-negative constraint lhs - rhs.
- property expression: str¶
- is_inequality: bool¶
Alias for field number 2
- lhs: str¶
Alias for field number 0
- rhs: str¶
Alias for field number 1
- class cosapp.drivers.utils.ConstraintParser[source]¶
Bases:
object
- classmethod parse(expression: str | List[str]) Set[Constraint] [source]¶
Parse a string expression or a list thereof as a set of non-negative constraints to be used in solvers.
Parameters:¶
- expression [str or List[str]]:
Human-readable equality or inequality constraints, such as ‘x >= y’, ‘0 < alpha < 1’, or a list thereof.
Returns:¶
- constraints [Set[Constraint]]:
Set of Constraint named tuple objects.
- classmethod types() Dict[str, ConstraintType] [source]¶
- class cosapp.drivers.utils.ConstraintType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Enum covering constraint types
- EQ = {'operator': '==', 'sort': <function ConstraintType.<lambda>>}¶
- GE = {'operator': '>=', 'sort': <function ConstraintType.<lambda>>}¶
- LE = {'operator': '<=', 'sort': <function ConstraintType.<lambda>>}¶
- property description: str¶
- property is_inequality: bool¶
- property operator: str¶
- class cosapp.drivers.utils.DesignProblemHandler(system: 'cosapp.systems.System' | None = None)[source]¶
Bases:
SystemAnalyzer
Class managing tied design and off-design problems, including unknown aliasing.
- check_context(design: MathematicalProblem, offdesign: MathematicalProblem) None [source]¶
- copy(prune=True) DesignProblemHandler [source]¶
Returns a copy of the current object.
Parameters:¶
- prune, Optional[bool]:
If True (default), resolve unknown aliasing first. If False, returned handler contains copies of object problems.
- copy_problems(prune=True) Tuple[MathematicalProblem, MathematicalProblem] [source]¶
Export design and off-design problems.
Parameters:¶
- prune, Optional[bool]:
If True (default), resolve unknown aliasing first. If False, returned problems are copies of object attributes.
Results:¶
- (design, offdesign): Copies of design and off-design problems,
as a tuple of MathematicalProblem objects.
- extend(other: DesignProblemHandler, prune=True, copy=True, overwrite=False) DesignProblemHandler [source]¶
Extend both design and off-design problems from other handler.
- Parameters:
[bool (- overwrite) – If True (default), added problems are pruned before being added.
optional] – If True (default), added problems are pruned before being added.
[bool – Determines whether problem copies should be made before extension.
optional] – Determines whether problem copies should be made before extension.
[bool – Overwrite option, forwarded to MathematicalProblem.extend.
optional] – Overwrite option, forwarded to MathematicalProblem.extend.
- classmethod make(design: MathematicalProblem, offdesign: MathematicalProblem) DesignProblemHandler [source]¶
- merged_problem(name='merged', offdesign_prefix='offdesign', copy=True) MathematicalProblem [source]¶
Merge design and off-design problems into a single MathematicalProblem instance.
- Parameters:
[str (- offdesign_prefix) – Merged problem name (default: ‘merged’).
optional] – Merged problem name (default: ‘merged’).
[str – If not empty or None, applies a prefix to dict keys in off-design unknowns and equations.
optional] – If not empty or None, applies a prefix to dict keys in off-design unknowns and equations.
[bool (- copy) – Perform copies if True (default).
optional] – Perform copies if True (default).
- new_problem(name: str) MathematicalProblem [source]¶
Create new MathematicalProblem instance
- property problems: Tuple[MathematicalProblem, MathematicalProblem]¶
design and off-design problems as a tuple
- Type:
- class cosapp.drivers.utils.SystemAnalyzer(system: 'cosapp.systems.System' | None = None)[source]¶
Bases:
object
Class containing data collected on a system, to be shared between different drivers.
- cosapp.drivers.utils.dealias_problem(problem: MathematicalProblem, name=None) MathematicalProblem [source]¶
Resolve unknown aliasing in problem due to pulling connectors (if any) in context system.
Parameters:¶
- problem [MathematicalProblem]:
Mathematical problem to be de-aliased.
- name [str, optional]:
Name of output MathematicalProblem object.
Returns:¶
- MathematicalProblem:
New mathematical problem, with identical equations as source problem, but de-aliased unknowns.