cosapp.drivers.abstractsolver

Classes

AbstractSolver(name[, owner])

Solve a System

class cosapp.drivers.abstractsolver.AbstractSolver(name: str, owner: cosapp.systems.System | None = None, **kwargs)[source]

Bases: Driver

Solve a System

Parameters:
  • name (str) – Name of the driver

  • owner (System, optional) – System to which driver belongs; defaults to None

  • **kwargs (Any) – Keyword arguments will be used to set driver options

compute_before()[source]

Contains the customized Module calculation, to execute before children.

force_init: bool
initial_values
load_solution(solution: Dict[str, Number | ndarray] | AnyStr, case: str | None = None)[source]

Load the provided solution to initialize the solver.

The solution can be provided directly as a dictionary or from a filename to be read.

Parameters:
  • solution (Dict[str, Union[Number, numpy.ndarray]] or str) – Dictionary of the latest solution to load or the filename in JSON format to read from.

  • case (str, optional) – Case to initialize with the solution; default None (i.e. will be guessed from variable name)

problem: MathematicalProblem
property raw_problem: MathematicalProblem

raw problem defined at solver level

Type:

MathematicalProblem

reset_problem() None[source]

Reset mathematical problem

abstract resolution_method(fresidues: Callable[[Sequence[float], float | str, bool], ndarray], x0: Sequence[float], args: Tuple[float | str] = (), options: OptionsDictionary | 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:

SolverResults

run_once() None[source]

Run solver once, assuming driver has already been initialized.

save_solution(file: str | None = None) Dict[str, Number | List[Number]][source]

Save the latest solver solution.

If file is specified, the solution will be saved in it in JSON format.

Parameters:

file (str, optional) – Filename to save the answer in; default None (i.e. data will not be saved)

Returns:

Dictionary of the latest solution

Return type:

Dict[str, Union[Number, List[Number]]]

abstract set_iteratives(x: Sequence[float]) None[source]
setup_run() None[source]

Set up the mathematical problem.

solution: Dict[str, float]
touch_unknowns()[source]