cosapp.drivers.nonlinearsolver¶
Classes
|
Base interface for numerical system building strategy used by NonLinearSolver. |
|
System building strategy for solvers with one or more RunSingleCase sub-drivers. |
|
Solve mathematical problem with algebraic variables. |
|
System building strategy for solvers with no RunSingleCase sub-drivers. |
- class cosapp.drivers.nonlinearsolver.BaseSolverBuilder(solver: AbstractSolver)[source]¶
Bases:
ABC
Base interface for numerical system building strategy used by NonLinearSolver. Implementations will differ for single- or multi-point design.
- class cosapp.drivers.nonlinearsolver.MultipointSolverBuilder(solver: NonLinearSolver, points: List[RunSingleCase])[source]¶
Bases:
BaseSolverBuilder
System building strategy for solvers with one or more RunSingleCase sub-drivers. In this case, the actual mathematical problem is a combination of unknowns and equations declared at solver level, and of local design and off-design problems declared at case level.
- class cosapp.drivers.nonlinearsolver.NonLinearSolver(name: str, owner: cosapp.systems.System | None = None, method: NonLinearMethods | str = NonLinearMethods.NR, **kwargs)[source]¶
Bases:
AbstractSolver
Solve mathematical problem with algebraic variables.
- compute_jacobian¶
Should the Jacobian matrix be computed? ; default True
- Type:
bool
- jac_lup¶
LU decomposition of latest Jacobian matrix (if available, None otherwise)
- Type:
ndarray, optional
- jac¶
Latest Jacobian matrix computed (if available, None otherwise)
- Type:
ndarray, optional
- add_child(child: AnyDriver, execution_index: int | None = None, desc='') AnyDriver [source]¶
Add a child Driver to the current Driver.
When adding a child Driver, it is possible to specified its position in the execution order.
Child Port, inwards and outwards can also be pulled at the parent level by providing either the name of the port/inward/outward or a list of them or the name mapping of the child element (dictionary keys) to the parent element (dictionary values). If the argument is not a dictionary, the name in the parent system will be the same as in the child.
- Parameters:
child (-) – Driver to add to the current Driver
execution_index (-) – Index of the execution order list at which the Module should be inserted; default latest.
[str (- desc) – Sub-driver description in the context of its parent driver.
optional] – Sub-driver description in the context of its parent driver.
Notes
The added child will have its owner set to match the one of the current driver.
- add_equation(equation: str | Iterable[dict | str], *args, **kwargs) MathematicalProblem [source]¶
Add off-design equation(s).
More details in cosapp.core.MathematicalProblem.add_equation.
- Parameters:
rhs'] (- equation [str or Iterable of str of the kind 'lhs ==) – Equation or collection of equations to be added.
*args (-) –
Additional arguments forwarded to MathematicalProblem.add_equation.
**kwargs – Additional arguments forwarded to MathematicalProblem.add_equation.
- Returns:
The updated problem.
- Return type:
MathematicalProblem
- add_target(expression: str | Iterable[str], *args, **kwargs) MathematicalProblem [source]¶
Add deferred off-design equation(s).
More details in cosapp.core.MathematicalProblem.add_target.
- Parameters:
expression (-) – Targetted expression
*args (-) –
**kwargs (Forwarded to MathematicalProblem.add_target)
- Returns:
The modified mathematical problem
- Return type:
- add_unknown(name: str | Iterable[dict | str], *args, **kwargs) MathematicalProblem [source]¶
Add design unknown(s).
More details in cosapp.core.MathematicalProblem.add_unknown.
- Parameters:
str] (- name [str or Iterable of dictionary or) – Name of the variable or collection of variables to be added.
*args (-) –
Additional arguments forwarded to MathematicalProblem.add_unknown.
**kwargs – Additional arguments forwarded to MathematicalProblem.add_unknown.
- Returns:
The updated problem.
- Return type:
MathematicalProblem
- compute_jacobian: bool¶
- extend(problem: MathematicalProblem, *args, **kwargs) MathematicalProblem [source]¶
Extend solver inner problem.
- Parameters:
[MathematicalProblem] (- problem) – Source mathematical problem.
*args (-) –
Additional arguments forwarded to MathematicalProblem.extend.
**kwargs – Additional arguments forwarded to MathematicalProblem.extend.
- Returns:
The extended problem.
- Return type:
MathematicalProblem
- is_standalone() bool [source]¶
Is this Driver able to solve a system?
- Returns:
Ability to solve a system or not.
- Return type:
bool
- jac: numpy.ndarray | None¶
- jac_lup: Tuple[numpy.ndarray | None, numpy.ndarray | None]¶
- log_debug_message(handler: HandlerWithContextFilters, record: LogRecord, format: LogFormat = LogFormat.RAW) bool [source]¶
Callback method on the driver to log more detailed information.
This method will be called by the log handler when
log_context()
is active if the logging level is lower or equals to VERBOSE_LEVEL. It allows the object to send additional log message to help debugging a simulation.- Parameters:
handler (HandlerWithContextFilters) – Log handler on which additional message should be published.
record (logging.LogRecord) – Log record
format (LogFormat) – Format of the message
- Returns:
Should the provided record be logged?
- Return type:
bool
- property method: NonLinearMethods¶
Selected solver algorithm.
- Type:
- resolution_method(fresidues: Callable[[Sequence[float], float | str, bool], ndarray], x0: Sequence[float], args: Tuple[float | str] = (), options: Dict[str, Any] | None = None) SolverResults [source]¶
Function call to cancel the residues.
- Parameters:
fresidues (Callable[[Sequence[float], Union[float, str]], numpy.ndarray]) – Residues function taking two parameters (evaluation vector, time/ref) and returning the residues
x0 (Sequence[float]) – The initial values vector to converge to the solution
args (Tuple[Union[float, str], bool], optional) – A tuple of additional argument for fresidues starting with the time/ref parameter and the need to update residues reference
options (OptionsDictionary, optional) – Options for the numerical resolution method
- Returns:
Solution container
- Return type:
- property results: SolverResults¶
structure containing solver results, together with additional detail.
- Type:
- class cosapp.drivers.nonlinearsolver.StandaloneSolverBuilder(solver: AbstractSolver)[source]¶
Bases:
BaseSolverBuilder
System building strategy for solvers with no RunSingleCase sub-drivers. In this case, the actual mathematical problem is entirely defined by unknowns and equations declared at solver level.