BF-PHYSICS - Physics
Ver. 1.0.0 (2023-02-04)
This module provides models and templates for physics.
- class mlpro.bf.physics.basics.TransferFunction(p_name: str, p_id: int = None, p_type: int = None, p_unit_in: str = None, p_unit_out: str = None, p_dt: float = 0.01, p_logging=True, **p_args)
Bases:
ScientificObject
,Log
,PersonalisedStamp
This class serves as a base class of transfer functions, which provides the main attributes of a transfer function. By default, there are several ready-to-use transfer function types available. If none of them suits to your transfer function, then you can also select a ‘custom’ type of transfer function and design your own function. Another possibility is to use a function approximation functionality provided by MLPro (coming soon).
- Parameters:
p_name (str) – name of the transfer function.
p_id (int) – unique id of the transfer function. Default: None.
p_type (int) – type of the transfer function. Default: None.
p_unit_in (str) – unit of the transfer function’s input. Default: None.
p_unit_out (str) – unit of the transfer function’s output. Default: None.
p_dt (float) – delta time. Default: 0.01.
p_logging – Log level (see constants of class Log). Default: Log.C_LOG_ALL.
p_args (dict) – extra parameter for each specific transfer function.
- C_TYPE
type of the base class. Default: ‘TransferFunction’.
- Type:
str
- C_NAME
name of the transfer function. Default: ‘’.
- Type:
str
- C_TRF_FUNC_LINEAR
linear function. Default: 0.
- Type:
int
- C_TRF_FUNC_CUSTOM
custom transfer function. Default: 1.
- Type:
int
- C_TRF_FUNC_APPROX
function approximation. Default: 2.
- Type:
int
- C_TYPE = 'TransferFunction'
- C_TRF_FUNC_LINEAR = 0
- C_TRF_FUNC_CUSTOM = 1
- C_TRF_FUNC_APPROX = 2
- C_NAME = ''
- get_units()
This method provides a functionality to get the SI units of the input and output data.
- Returns:
self._unit_in (str) – the SI unit of the input data.
self._unit_out (str) – the SI unit of the output data.
- _set_type(p_type: int)
This method provides a functionality to set the type of the transfer function.
- Parameters:
p_type (int) – the type of the transfer function.
- get_type() int
This method provides a functionality to get the type of the transfer function.
- Returns:
the type of the transfer function.
- Return type:
int
- _set_function_parameters(p_args: dict) bool
This method provides a functionality to set the parameters of the transfer function.
- Parameters:
p_args (dict) – set of parameters of the transfer function.
- Returns:
true means no parameters are missing.
- Return type:
bool
- _linear(p_input: float, p_range=None) float
This method provides a functionality for linear transfer function.
Formula –> y = mx+b y = output m = slope x = input b = y-intercept
- Parameters:
p_input (float) – input value.
p_range – range of the calculation. None means 0. Default: None.
- Returns:
output value.
- Return type:
float
- _custom_function(p_input, p_range=None)
This function represents the template to create a custom function and must be redefined.
- Parameters:
p_input – input value.
p_range – range of the calculation. None means 0. Default: None.
- Returns:
output value.
- Return type:
float
- plot(p_x_init: float, p_x_end: float)
This methods provides functionality to plot the defined function within a range.
- Parameters:
p_x_init (float) – The initial value of the input (x-axis).
p_x_end (float) – The end value of the input (x-axis).
- _function_approximation(p_input, p_range=None)
The function approximation is not yet ready (coming soon).
- Parameters:
p_input (TYPE) – DESCRIPTION.
- Returns:
DESCRIPTION.
- Return type:
bool