cosapp.drivers.runonce

Classes

RunOnce(name[, owner])

Driver running the model on its System owner.

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

Bases: Driver

Driver running the model on its System owner.

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() None[source]

Execute drivers on all child System belonging to the driver System owner.

get_init(force_init: bool = False) ndarray[source]

Get the System iteratives initial values for this driver.

Parameters:

force_init (bool, optional) – Force the initial values to be used. Default is False.

Returns:

List of iteratives initial values, in the same order as the unknowns in get_problem().

Return type:

numpy.ndarray

get_problem() MathematicalProblem[source]

Returns the full mathematical for the case.

Returns:

The full mathematical problem to solve for the case

Return type:

MathematicalProblem

initial_values: Dict[str, Boundary]
set_init(modifications: Dict[str, Any]) None[source]

Define initial values for one or more variables.

The variable can be contextual child1.port2.var. The only rule is that it should belong to the owner System of this driver or any of its descendants.

Parameters:

modifications (Dict[str, Any]) – Dictionary of (variable name, value)

Examples

>>> driver.set_init({'myvar': 42, 'dummy': 'banana'})
setup_run()[source]

Method called once before starting any simulation.

solution: Dict[str, float]