unit_converters

Modules

functions module

Unit conversion and mathematical operation functions.

Mathematical Formulation:

  1. Temperature Conversions: a) Kelvin to Celsius:

    \[T_{C} = T_{K} - 273.15\]

    where: - \(T_{C}\) is temperature in Celsius - \(T_{K}\) is temperature in Kelvin

    1. Celsius to Kelvin:

      \[T_{K} = T_{C} + 273.15\]
  2. Mathematical Operations: a) Multiplication by Constant:

    \[y = x \cdot c\]

    where \(c\) is the constant factor

    1. Regularization:

      \[y = \max(x, l)\]

      where \(l\) is the lower limit

    2. Addition:

      \[y = \sum_{i=1}^{n} f_i(x_i)\]

      where \(f_i\) are conversion functions

    3. Multiplication:

      \[y = \prod_{i=1}^{n} f_i(x_i)\]
    4. Integration:

      \[y(t) = y(t-\Delta t) + f(x(t)) \cdot \Delta t\]

      where: - \(y(t)\) is the integrated value at time t - \(\Delta t\) is the time step - \(f(x(t))\) is the conversion function

class add(obj, idx, conversion=<function do_nothing>)[source]

Bases: object

call(x, step_size=None)[source]
class add_attr(obj, attr)[source]

Bases: object

call(x, step_size=None)[source]
class get(obj, idx, conversion=<function do_nothing>)[source]

Bases: object

call(x, step_size=None)[source]
class integrate(obj, idx, conversion=<function do_nothing>)[source]

Bases: object

call(x, step_size=None)[source]
class multiply(obj, idx, conversion=<function do_nothing>)[source]

Bases: object

call(x, step_size=None)[source]
class multiply_const(factor)[source]

Bases: object

call(x, step_size=None)[source]
class regularize(limit)[source]

Bases: object

call(x, step_size=None)[source]
change_sign(x, step_size=None)[source]
do_nothing(x, step_size=None)[source]
to_degC_from_degK(K, step_size=None)[source]
to_degK_from_degC(C, step_size=None)[source]

to_degC_from_degK module

class ToDegCFromDegK[source]

Bases: System

System for converting temperature from Kelvin to Celsius.

Mathematical Formulation:

\[T_{C} = T_{K} - 273.15\]

where: - \(T_{C}\) is temperature in Celsius - \(T_{K}\) is temperature in Kelvin

do_step(secondTime=None, dateTime=None, step_size=None)[source]

Do a single step of the system.

Parameters:
  • secondTime (float) – The current time in seconds.

  • dateTime (datetime.datetime) – The current date and time.

  • step_size (int) – The step size of the simulation in seconds.

  • stepIndex (int) – The current step index.

initialize(start_time=None, end_time=None, step_size=None, model=None)[source]

Initialize the system.

Parameters:
  • start_time (datetime.datetime) – The start time of the simulation.

  • end_time (datetime.datetime) – The end time of the simulation.

  • step_size (int) – The step size of the simulation in seconds.

  • simulator (core.Simulator) – The simulator.

to_degK_from_degC module

class ToDegKFromDegC[source]

Bases: System

System for converting temperature from Celsius to Kelvin.

Mathematical Formulation:

\[T_{K} = T_{C} + 273.15\]

where: - \(T_{K}\) is temperature in Kelvin - \(T_{C}\) is temperature in Celsius

do_step(secondTime=None, dateTime=None, step_size=None)[source]

Do a single step of the system.

Parameters:
  • secondTime (float) – The current time in seconds.

  • dateTime (datetime.datetime) – The current date and time.

  • step_size (int) – The step size of the simulation in seconds.

  • stepIndex (int) – The current step index.

initialize(start_time=None, end_time=None, step_size=None, model=None)[source]

Initialize the system.

Parameters:
  • start_time (datetime.datetime) – The start time of the simulation.

  • end_time (datetime.datetime) – The end time of the simulation.

  • step_size (int) – The step size of the simulation in seconds.

  • simulator (core.Simulator) – The simulator.