sysloss.utils
=============

.. py:module:: sysloss.utils

.. autoapi-nested-parse::

   Utilities.

   sysLoss utility functions.



Attributes
----------

.. autoapisummary::

   sysloss.utils.RHO
   sysloss.utils.TCR
   sysloss.utils.MILS2MM
   sysloss.utils.OZ2MM


Functions
---------

.. autoapisummary::

   sysloss.utils.trace_res
   sysloss.utils.plane_res


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

.. py:data:: RHO
   :value: 1.724e-08


   Copper resistance, Ohm-meter (IPC spec for copper bulk resistivity at 20°C)

.. py:data:: TCR
   :value: 0.00386


   Copper temperature coefficient of resistance, Ohm/°C

.. py:data:: MILS2MM
   :value: 0.0254


   mils to mm conversion factor

.. py:data:: OZ2MM
   :value: 0.034798


   oz/ft^2 (copper ounce per square feet) to mm conversion factor

.. py:function:: trace_res(*, w1_mm: float, w2_mm: float, l_mm: float, t_mm: float, rho: float = RHO, temp: float = 20.0, tcr: float = TCR) -> float

   Calculate PCB trace resistance.

   Trace resistance is calculated as :math:`R=\frac{\rho L}{A}`, where *A* is the cross-sectional
   area of the trace, *L* is trace length and :math:`\rho` is material resistance.
   If the temperature is set to other than 20°C, the resistance value is adjusted
   with :math:`R_t = R \cdot (1 + tcr \cdot (temp - 20))`.


   :param w1_mm: Lower trace width in mm.
   :type w1_mm: float
   :param w2_mm: Upper trace width in mm.
   :type w2_mm: float
   :param l_mm: Trace length in mm.
   :type l_mm: float
   :param t_mm: Trace thickness in mm.
   :type t_mm: float
   :param rho: Material resistance (Ohm-m), by default :py:attr:`~RHO`.
   :type rho: float, optional
   :param temp: Ambient temperature, by default 20°C.
   :type temp: float, optional
   :param tcr: Temperature coefficient of resistance (Ohm/°C), by default :py:attr:`~TCR`.
   :type tcr: float, optional

   :returns: Trace resistance (Ohm)
   :rtype: float

   .. rubric:: Examples

   >>> rs = trace_res(w1_mm=1, w2_mm=1, l_mm=15, t_mm=35e-3)
   >>> # convert dimensions in mils and oz/ft^2 to mm by predefined constants:
   >>> rs = trace_res(w1_mm=7*MILS2MM, w2_mm=6*MILS2MM, l_mm=350*MILS2MM, t_mm=2*OZ2MM, temp=50)


.. py:function:: plane_res(*, w: float, l: float, t_mm: float, rho: float = RHO, temp: float = 20.0, tcr: float = TCR) -> float

   Calculate PCB plane resistance.

   Plane (or sheet) resistance is calculated as :math:`R=R_s \frac{L}{W}`, where *W* is the plane width,
   *L* is the plane length and *Rs* is the sheet resistance. *Rs* is calculated as :math:`R_s=\frac{\rho}{t}`,
   where :math:`\rho` is material resistance and *t* is plane thickness.
   If the temperature is set to other than 20°C, the resistance value is adjusted
   with :math:`R_t = R \cdot (1 + tcr \cdot (temp - 20))`.


   :param w: Plane width (unitless).
   :type w: float
   :param l: Plane length (unitless).
   :type l: float
   :param t_mm: Plane thickness in mm.
   :type t_mm: float
   :param rho: Material resistance (Ohm-m), by default :py:attr:`~RHO`.
   :type rho: float, optional
   :param temp: Ambient temperature, by default 20°C.
   :type temp: float, optional
   :param tcr: Temperature coefficient of resistance (Ohm/°C), by default :py:attr:`~TCR`.
   :type tcr: float, optional

   :returns: Plane resistance (Ohm)
   :rtype: float

   .. rubric:: Examples

   >>> rs = plane_res(w=25, l=80, t_mm=35e-3)
   >>> # convert dimension oz/ft^2 to mm by predefined constant:
   >>> rs = plane_res(w=800, l=500, t_mm==2*OZ2MM, temp=50)


