cosapp.drivers.nonlinearsolver¶
Classes
|
Solve mathematical problem with algebraic variables. |
- class cosapp.drivers.nonlinearsolver.NonLinearSolver(name: str, owner: cosapp.systems.System | None = None, method: NonLinearMethods | str = NonLinearMethods.NR, **kwargs)[source]¶
Bases:
AbstractSolverSolve 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 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_unknown(name: str | Iterable[dict | str], *args, **kwargs) MathematicalProblem[source]¶
Add design unknown(s).
More details in 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
- get_init() ndarray[source]¶
Get the System iteratives initial values for this driver.
- Returns:
The list of iteratives initial values. The values should be in the same order as the unknowns in the get_problem.
- Return type:
numpy.ndarray
- 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: