cosapp.drivers.nonlinearsolver¶
Classes
|
Solve mathematical problem with algebraic variables. |
-
class
cosapp.drivers.nonlinearsolver.NonLinearSolver(name: str, owner: Optional[cosapp.systems.System] = None, method: Union[cosapp.core.numerics.enum.NonLinearMethods, str] = <NonLinearMethods.NR: 'cosapp'>, **kwargs)[source]¶ Bases:
cosapp.drivers.abstractsolver.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: Optional[int] = None) → 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 (Module) – Module to add to the current Module
execution_index (int, optional) – Index of the execution order list at which the Module should be inserted; default is latest.
Notes
The added child will have its owner set to match the one of the current driver.
-
add_equation(equation: Union[str, Iterable[Union[dict, str]]], *args, **kwargs) → cosapp.core.numerics.basics.MathematicalProblem[source]¶ Add off-design equation(s).
More details in MathematicalProblem.add_equation.
- Parameters
equation [str or Iterable of str of the kind 'lhs == rhs'] (-) – 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: Union[str, Iterable[Union[dict, str]]], *args, **kwargs) → cosapp.core.numerics.basics.MathematicalProblem[source]¶ Add design unknown(s).
More details in MathematicalProblem.add_unknown.
- Parameters
name [str or Iterable of dictionary or str] (-) – 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¶
-
extend(problem: cosapp.core.numerics.basics.MathematicalProblem, *args, **kwargs) → cosapp.core.numerics.basics.MathematicalProblem[source]¶ Extend solver inner problem.
- Parameters
problem [MathematicalProblem] (-) – 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() → numpy.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¶
-
jac_lup¶
-
log_debug_message(handler: HandlerWithContextFilters, record: logging.LogRecord, format: cosapp.utils.logging.LogFormat = <LogFormat.RAW: 0>) → 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¶ Selected solver algorithm.
- Type
-
resolution_method(fresidues: Callable[[Sequence[float], Union[float, str], bool], numpy.ndarray], x0: Sequence[float], args: Tuple[Union[float, str]] = (), options: Optional[Dict[str, Any]] = None) → cosapp.core.numerics.basics.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¶ structure containing solver results, together with additional detail.
- Type
-