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: System)[source]¶
Bases:
TimeAssignString
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. 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)[source]¶
Bases:
object
Class 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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Interpolator kind
- CubicSpline = <class 'scipy.interpolate._cubic.CubicSpline'>¶
- Linear = <class 'scipy.interpolate._interpolate.interp1d'>¶
- Pchip = <class 'scipy.interpolate._cubic.PchipInterpolator'>¶
- property data: ndarray¶
- class cosapp.drivers.time.scenario.Scenario(name: str, owner: Driver)[source]¶
Bases:
object
Class 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[AssignString]¶
list of boundary conditions
- Type:
List[AssignString]
- property context: System¶
evaluation context of initial and boundary conditions, that is the system controled by owner driver
- Type:
- property init_values: List[AssignString]¶
list of initial conditions
- Type:
List[AssignString]
- classmethod make(name: str, driver: Driver, init: Dict[str, Any], values: Dict[str, Any]) 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: System)[source]¶
Bases:
object
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. This class is very similar to cosapp.core.eval_str.AssignString, except the right-hand side is a callable function.
- property constant¶
- property rhs: Callable[[float], Any]¶
assignment right-hand side function
- Type:
Callable