pyrc.core.components.input#
- class Input(settings: ~pyrc.core.settings.Settings = <pyrc.core.settings.Settings object>)#
Bases:
objectEach Input can be called as function to get its value during solving depending on the time step/ temperature or last input value.
- self.static#
If True, a static value is assumed and no time-dependent calculations were done. NOTE: You may take a look on the ConstantInput class for such cases to remain performant. This also serves as a switch to first just use static values during network solving until a stationary state is reached and then activate the dynamic calculation.
- Type:
bool, optional
Super class for all inputs.
Mainly used for calculation boundary conditions both time-independent and time-dependent.
The simplest way of using this class would be to just return one static value, no matter which solving time, temperature or input_vector is given. Because the __call__method is run every solver iteration it should be as performant as possible. Therefor, for constant Inputs it’s recommended to use the ConstantInput class.
- __init__(settings: ~pyrc.core.settings.Settings = <pyrc.core.settings.Settings object>)#
Super class for all inputs.
Mainly used for calculation boundary conditions both time-independent and time-dependent.
The simplest way of using this class would be to just return one static value, no matter which solving time, temperature or input_vector is given. Because the __call__method is run every solver iteration it should be as performant as possible. Therefor, for constant Inputs it’s recommended to use the ConstantInput class.
- calculate_dynamic(tau, temp_vector, _input_vector, *args, **kwargs)#
Should be overwritten for all time-dependent inputs.
Is used, when self.static = False to calculate time-dependent inputs.
Each function in the dict must have the possibility to get along with *args and **kwargs.
- Parameters:
tau (float) – The current time of the solving process.
temp_vector (np.ndarray) – The temperature vector of the last solution during iteration. In the first iteration it is the initial one.
_input_vector – The input vector used for the last solution during iteration. In the first iteration it is the initial one.
kwargs (dict, optional) – Further values that can be used for just some calculations.
- Returns:
A new input value for the input vector
- Return type:
float | int | np.number
- abstractmethod calculate_static(tau, temp_vector, _input_vector, *args, **kwargs)#
Calculate static values.
Each function in the dict must have the possibility to get along with *args and **kwargs.
- Parameters:
tau
temp_vector
_input_vector
kwargs
- get_kwargs_functions() dict#
Used to calculate keyword arguments for calculate_static/dynamic that only need to be calculated once for all objects.
The main reason for this method is speed up during calculation/iteration/solving, because some/most of the boundary conditions only need to be calculated once per time step. So these BCs should be calculated in here and passed to each Input object so that they can use the value for their calculation.
Each function in the dict must have the possibility to get along with *args and **kwargs.
- Returns:
The names of the values that must be passed to calculate_static/dynamic and the function to calculate this values. If for example the exterior temperature is needed for calculate_dynamic, the dict looks like this: {“exterior_temperature”: lambda tau: my_fancy_algorithm_to_calculate/get_the_exterior_temperature(tau)} To use it, this dict must be passed to calculate_dynamic like this: my_obj.calculate_dynamic(tau, temp_vector, _input_vector, **the_get_kwargs_dict)
- Return type:
dict
- abstract property index: int#
Returns the index of self in the input vector/matrix.
- Returns:
The index of self in the input vector/matrix.
- Return type:
int
- abstract property initial_value#
- property static#