sysloss.components
==================

.. py:module:: sysloss.components

.. autoapi-nested-parse::

   Components that can be added to the system.

   Constants
   ---------
   LIMITS_DEFAULT = {
       | "vi": [0.0, 1.0e6], # input voltage (V)
       | "vo": [0.0, 1.0e6], # output voltage (V)
       | "vd": [0.0, 1.0e6], # voltage difference, vi-vo (V)
       | "ii": [0.0, 1.0e6], # input current (A)
       | "io": [0.0, 1.0e6], # output current (A)
       | "pi": [0.0, 1.0e6], # input power (W)
       | "po": [0.0, 1.0e6], # output power (W)
       | "pl": [0.0, 1.0e6], # power loss (W)
       | "tr": [0.0, 1.0e6], # temperature rise (°C)
       | "tp": [-1.0e6, 1.0e6]} # peak temperature (°C)



Classes
-------

.. autoapisummary::

   sysloss.components.Source
   sysloss.components.PLoad
   sysloss.components.ILoad
   sysloss.components.RLoad
   sysloss.components.RLoss
   sysloss.components.VLoss
   sysloss.components.Converter
   sysloss.components.LinReg
   sysloss.components.PSwitch
   sysloss.components.PMux
   sysloss.components.Rectifier


Module Contents
---------------

.. py:class:: Source(name: str, *, vo: float, rs: float = 0.0, limits: dict = LIMITS_DEFAULT)



   Voltage source.

   The Source component must be the root of a system or subsystem.

   :param name: Source name.
   :type name: str
   :param vo: Output voltage (V).
   :type vo: float
   :param rs: Source resistance (Ohm), by default 0.0
   :type rs: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: io, po, pl.
   :type limits: dict, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: PLoad(name: str, *, pwr: float, limits: dict = LIMITS_DEFAULT, pwrs: float = 0.0, rt: float = 0.0, loss: bool = False)



   Power load.

   A power load represents a constant power sink, referenced to 0V. Other components can not be connected to a PLoad.
   The load can optionally be configured as a loss.

   :param name: Load name.
   :type name: str
   :param pwr: Load power (W).
   :type pwr: float
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, ii, tr, tp
   :type limits: dict, optional
   :param pwrs: Load sleep power (W), by default 0.0.
   :type pwrs: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional
   :param loss: Count power as a loss, by default False
   :type loss: bool, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: ILoad(name: str, *, ii: float, limits: dict = LIMITS_DEFAULT, iis: float = 0.0, rt: float = 0.0, loss: bool = False)



   Current load.

   A current load represents a constant current sink, referenced to 0V. Other components can not be connected to an ILoad.
   The load can optionally be configured as a loss.

   :param name: Load name.
   :type name: str
   :param ii: Load current (A).
   :type ii: float
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, pi, tr, tp
   :type limits: dict, optional
   :param iis: Load sleep current (A), by default 0.0.
   :type iis: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional
   :param loss: Count power as a loss, by default False
   :type loss: bool, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: RLoad(name: str, *, rs: float, rt: float = 0.0, limits: dict = LIMITS_DEFAULT, loss: bool = False)



   Resistive load.

   A resisitve load represents a constant resistance, referenced to 0V. Other components can not be connected to an RLoad.
   The load can optionally be configured as a loss.

   :param name: Load name.
   :type name: str
   :param rs: Load resistance (Ohm).
   :type rs: float
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, ii, pi, tr, tp
   :type limits: dict, optional
   :param loss: Count power as a loss, by default False
   :type loss: bool, optional

   :raises ValueError: If rs==0.0 or a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: RLoss(name: str, *, rs: float, rt: float = 0.0, limits: dict = LIMITS_DEFAULT)



   Resistive series loss.

   A series resisitve loss represents a constant resistance connected in series with other components.

   :param name: Loss name.
   :type name: str
   :param rs: Loss resistance (Ohm).
   :type rs: float
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: VLoss(name: str, *, vdrop: float | dict, rt: float = 0.0, limits: dict = LIMITS_DEFAULT)



   Voltage series loss.

   This voltage loss element is connected in series with other elements.
   The voltage drop can be either a constant (float) or interpolated.
   Interpolation data dict for voltage drop can be either 1D (function of output current only):

   ``vdrop= {"vi":[2.5], "io":[0.1, 0.5, 0.9], "vdrop":[[0.23, 0.41, 0.477]]}``

   Or 2D (function of input voltage and output current):

   ``vdrop = {"vi":[2.5, 5.0, 12.0], "io":[0.1, 0.5, 0.9], "vdrop":[[0.23, 0.34, 0.477], [0.27, 0.39, 0.51], [0.3, 0.41, 0.57]]}``

   :param name: Loss name.
   :type name: str
   :param vdrop: Voltage drop (V), a constant value (float) or interpolation data (dict).
   :type vdrop: float | dict
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: Converter(name: str, *, vo: float, eff: float | dict, iq: float = 0.0, limits: dict = LIMITS_DEFAULT, iis: float = 0.0, rt: float = 0.0)



   Voltage converter.

   The converter efficiency can be either a constant (float) or interpolated.
   Interpolation data dict for efficiency can be either 1D (function of output current only):

   ``eff = {"vi":[3.3], "io":[0.1, 0.5, 0.9], "eff":[[0.55, 0.78, 0.92]]}``

   Or 2D (function of input voltage and output current):

   ``eff = {"vi":[3.3, 5.0, 12.0], "io":[0.1, 0.5, 0.9], "eff":[[0.55, 0.78, 0.92], [0.5, 0.74, 0.83], [0.4, 0.6, 0.766]]}``

   :param name: Converter name.
   :type name: str
   :param vo: Output voltage (V).
   :type vo: float
   :param eff: Converter efficiency, a constant value (float) or interpolation data (dict).
   :type eff: float | dict
   :param iq: Quiescent (no-load) current (A), by default 0.0.
   :type iq: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional
   :param iis: Sleep (shut-down) current (A), by default 0.0.
   :type iis: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional

   :raises ValueError: If efficiency is 0.0 or > 1.0 or limit value has invalid format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: LinReg(name: str, *, vo: float, vdrop: float = 0.0, iq: float = 0.0, ig: float = 0.0, limits: dict = LIMITS_DEFAULT, iis: float = 0.0, rt: float = 0.0)



   Linear voltage regulator.

   If vi - vo < vdrop, the output voltage is reduced to vi - vdrop during analysis.

   The regulator ground current (ig) can be either a constant (float) or interpolated.
   Interpolation data dict for ground current can be either 1D (function of output current only):

   ``ig = {"vi":[5.0], "io":[0.0, 0.05, 0.1], "ig":[[2.0e-6, 0.5e-3, 0.85e-3]]}``

   Or 2D (function of input voltage and output current):

   ``ig = {"vi":[2.5, 5.0], "io":[0.0, 0.05, 0.1], "ig":[[1.2e-6, 0.34e-3, 0.64e-3], [2.0e-6, 0.5e-3, 0.85e-3]]}``

   :param name: Converter name.
   :type name: str
   :param vo: Output voltage (V).
   :type vo: float
   :param vdrop: Dropout voltage (V), by default 0.0.
   :type vdrop: float, optional
   :param iq: Ground current (A), by default 0.0. iq is deprecated and will be removed in a future version, use ig instead.
   :type iq: float | dict, optional
   :param ig: Ground current (A), by default 0.0.
   :type ig: float | dict, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional
   :param iis: Sleep (shut-down) current (A), by default 0.0.
   :type iis: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional

   :raises ValueError: If vdrop > vo or limit value has invalid format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read LinReg parameters from .toml file.

      :param name: LinReg name
      :type name: str
      :param fname: File name.
      :type fname: str



.. py:class:: PSwitch(name: str, *, rs: float = 0.0, ig: float = 0.0, limits: dict = LIMITS_DEFAULT, iis: float = 0.0, rt: float = 0.0)



   Power switch.

   The power switch ground current (ig) can be either a constant (float) or interpolated.
   Interpolation data dict for ground current can be either 1D (function of output current only):

   ``ig = {"vi":[3.6], "io":[0.005, 0.05, 0.5], "ig":[[36e-6, 37e-6, 35e-6]]}``

   Or 2D (function of input voltage and output current):

   ``ig = {"vi":[0.9, 1.8, 3.6], "io":[0.005, 0.05, 0.5], "ig":[[5e-6, 5e-6, 5e-6], [7e-6, 7e-6, 7e-6], [36e-6, 37e-6, 35e-6]]}``

   :param name: Power switch name.
   :type name: str
   :param rs: Switch resistance (Ohm), by default 0.0
   :type rs: float, optional
   :param ig: Ground current (A), by default 0.0.
   :type ig: float | dict, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional
   :param iis: Sleep (shut-down) current (A), by default 0.0.
   :type iis: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional

   :raises ValueError: If a limits value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: PMux(name: str, *, rs: float = 0.0, ig: float = 0.0, limits: dict = LIMITS_DEFAULT, iis: float = 0.0, rt: float = 0.0)



   Power multiplexer/switcher.

   The power mux can have up to 4 inputs and connects one of the inputs to the output in prioritized order.
   The first input that is active (not turned off) will be selected. If all inputs are off, the output will also be off.
   The ON resistance can be individually specified for each input. There can only be one PMux in a a system.

   The power mux ground current (ig) can be either a constant (float) or interpolated.
   Interpolation data dict for ground current can be either 1D (function of output current only):

   ``ig = {"vi":[5.0], "io":[0.005, 0.05, 0.5], "ig":[[36e-6, 37e-6, 35e-6]]}``

   Or 2D (function of input voltage and output current):

   ``ig = {"vi":[3.3, 5.0, 12.0], "io":[0.005, 0.05, 0.5], "ig":[[5e-6, 5e-6, 5e-6], [7e-6, 7e-6, 7e-6], [36e-6, 37e-6, 35e-6]]}``

   :param name: Power mux name.
   :type name: str
   :param rs: Mux on-resistance (Ohm), by default 0.0
   :type rs: float | list, optional
   :param ig: Ground current (A), by default 0.0.
   :type ig: float | dict, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional
   :param iis: Sleep (shut-down) current (A), by default 0.0.
   :type iis: float, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional

   :raises ValueError: If a parameter value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



.. py:class:: Rectifier(name: str, *, vdrop: float | dict = 0.0, rs: float = 0.0, ig: float = 0.0, iq: float = 0.0, limits: dict = LIMITS_DEFAULT, rt: float = 0.0)



   Full bridge rectifier.

   If the voltage drop (vdrop) is set to non-zero, a diode rectifier will be modelled. The rs, ig, iq and iis
   parameters are then ignored. Note that vdrop represents the forward voltage of a single diode. Total voltage drop
   will be 2 x vdrop. The voltage drop can be either a constant (float) or interpolated.
   Interpolation data dict for voltage drop can be either 1D (function of output current only):

   ``vdrop= {"vi":[2.5], "io":[0.1, 0.5, 0.9], "vdrop":[[0.23, 0.41, 0.477]]}``

   Or 2D (function of input voltage and output current):

   ``vdrop = {"vi":[2.5, 5.0, 12.0], "io":[0.1, 0.5, 0.9], "vdrop":[[0.23, 0.34, 0.477], [0.27, 0.39, 0.51], [0.3, 0.41, 0.57]]}``

   If the vdrop parameter is zero, a MOSFET bridge will be modelled. The parameters rs, ig, iq and iis then apply. Note that rs
   represents the resistance in a single MOSFET. Total resistance in bridge will be 2 x rs. The rectifier ground current (ig) can
   be either a constant (float) or interpolated.
   Interpolation data dict for ground current can be either 1D (function of output current only):

   ``ig = {"vi":[5.0], "io":[0.005, 0.05, 0.5], "ig":[[36e-6, 37e-6, 35e-6]]}``

   Or 2D (function of input voltage and output current):

   ``ig = {"vi":[3.3, 5.0, 12.0], "io":[0.005, 0.05, 0.5], "ig":[[5e-6, 5e-6, 5e-6], [7e-6, 7e-6, 7e-6], [36e-6, 37e-6, 35e-6]]}``

   The output voltage of the rectifier is always positive (or zero).

   :param name: Rectifier name.
   :type name: str
   :param vdrop: Diode (each) voltage drop (V), a constant value (float) or interpolation data (dict).
   :type vdrop: float | dict
   :param rs: MOSFET (each) on-resistance (Ohm), by default 0.0
   :type rs: float | list, optional
   :param ig: Total ground current (A), by default 0.0.
   :type ig: float | dict, optional
   :param iq: Quiescent (no-load) current (A), by default 0.0.
   :type iq: float, optional
   :param limits: Voltage, current and power limits, by default LIMITS_DEFAULT. The following limits apply: vi, vo, vd, ii, io, pi, po, pl, tr, tp
   :type limits: dict, optional
   :param rt: Thermal resistance (°C/W), by default 0.0.
   :type rt: float, optional

   :raises ValueError: If a parameter value is not of the correct format.


   .. py:method:: from_file(name: str, *, fname: str)
      :classmethod:


      Read component parameters from .toml file.

      :param name: Component name
      :type name: str
      :param fname: File name.
      :type fname: str

      :raises ValueError: If parameter value is not of the correct type.



