cosapp.drivers.time.scenario¶
Classes
|
Creates an executable assignment to handle time boundary conditions of the kind lhs = F(t, data), where F is an interpolation function of some dataset at time t, and where lhs refers to a variable name in system context. |
|
Class describing a function defined from tabulated data, based on interpolating function interpolator. |
|
Class managing boundary and initial conditions for time simulations |
|
Creates an executable assignment to handle time boundary conditions of the kind lhs = F(t, data), where F is a function of some dataset at time t, and where lhs refers to a variable name in system context. |
-
class
cosapp.drivers.time.scenario.InterpolAssignString(lhs: str, rhs: Callable[[float], Any], context: cosapp.systems.system.System)[source]¶ Bases:
cosapp.drivers.time.scenario.TimeAssignStringCreates an executable assignment to handle time boundary conditions of the kind lhs = F(t, data), where F is an interpolation function of some dataset at time t, and where lhs refers to a variable name in system context. This class is very similar to cosapp.core.eval_str.AssignString, except the right-hand side is a function. In order to limit the scope of the callable function, the rhs can only be of type Interpolator.
-
class
cosapp.drivers.time.scenario.Interpolator(data, kind=<Kind.Linear: <class 'scipy.interpolate._interpolate.interp1d'>>)[source]¶ Bases:
objectClass describing a function defined from tabulated data, based on interpolating function interpolator. Function interpolator must return a callable function x -> f(x), interpolating [y_0, …, y_n] at points [x_0, …, x_n].
-
class
Kind(value)[source]¶ Bases:
enum.EnumInterpolator kind
-
CubicSpline= <class 'scipy.interpolate._cubic.CubicSpline'>¶
-
Linear= <class 'scipy.interpolate._interpolate.interp1d'>¶
-
Pchip= <class 'scipy.interpolate._cubic.PchipInterpolator'>¶
-
-
property
data¶
-
property
kind¶
-
class
-
class
cosapp.drivers.time.scenario.Scenario(name: str, owner: cosapp.drivers.driver.Driver)[source]¶ Bases:
objectClass managing boundary and initial conditions for time simulations
-
add_init(modifications: Dict[str, Any]) → None[source]¶ Add a set of initial conditions, from a dictionary of the kind {‘variable’: value, …}
- Parameters
modifications (Dict[str, Any]) – Dictionary of (variable name, value)
Examples
>>> scenario.add_init({'myvar': 42, 'port.dummy': '-2 * alpha'})
-
add_values(modifications: Dict[str, Any]) → None[source]¶ Add a set of variables to the list of case values, from a dictionary of the kind {‘variable’: value, …}
Each variable and its value can be contextual, as in {‘child1.port2.var’: ‘2 * child2.foo’}, as long as they are both evaluable in the context of the driver’s owner. Explicit time dependency can be given using variable ‘t’ in values, as in ‘exp(-t / tau)’
- Parameters
modifications (Dict[str, Any]) – Dictionary of (variable name, value)
Examples
>>> scenario.add_values({'myvar': 42, 'port.dummy': 'cos(omega * t)'})
-
property
case_values¶ list of boundary conditions
- Type
List[AssignString]
-
property
context¶ evaluation context of initial and boundary conditions, that is the system controled by owner driver
- Type
-
property
init_values¶ list of initial conditions
- Type
List[AssignString]
-
classmethod
make(name: str, driver: cosapp.drivers.driver.Driver, init: Dict[str, Any], values: Dict[str, Any]) → cosapp.drivers.time.scenario.Scenario[source]¶ Scenario factory
-
set_init(modifications: Dict[str, Any]) → None[source]¶ Set initial conditions, from a dictionary of the kind {‘variable’: value, …}
See add_init for further detail.
-
-
class
cosapp.drivers.time.scenario.TimeAssignString(lhs: str, rhs: Callable[[float], Any], context: cosapp.systems.system.System)[source]¶ Bases:
objectCreates an executable assignment to handle time boundary conditions of the kind lhs = F(t, data), where F is a function of some dataset at time t, and where lhs refers to a variable name in system context. This class is very similar to cosapp.core.eval_str.AssignString, except the right-hand side is a callable function.
-
property
constant¶
-
exec(t: Optional[float] = None) → None[source]¶ Evaluates rhs(t), and executes assignment lhs <- rhs(t). If time t is not specified, uses context time.
-
property
locals¶ Context attributes required to evaluate the string expression.
- Type
Dict[str, Any]
-
property