cosapp.drivers.abstractsolver

Classes

AbstractSolver(name, owner, **kwargs)

Solve a System

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

Bases: cosapp.drivers.driver.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
initial_values
load_solution(solution: Union[Dict[str, Union[numbers.Number, numpy.ndarray]], AnyStr], case: Optional[str] = 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
property raw_problem

raw problem defined at solver level

Type

MathematicalProblem

reset_problem()None[source]

Reset mathematical problem

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

SolverResults

run_once()None[source]

Run solver once, assuming driver has already been initialized.

save_solution(file: Optional[str] = None)Dict[str, Union[numbers.Number, List[numbers.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