quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
Loading...
Searching...
No Matches
Electrical Cross-Unit Arithmetic

Operators combining quantities of different kinds according to circuit theory. More...

Functions

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< ampere_unit, R1, P1 > &i, const quantity< ohm_unit, R2, P2 > &r)
 Ohm's law: current x resistance = voltage.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< ohm_unit, R1, P1 > &r, const quantity< ampere_unit, R2, P2 > &i)
 Ohm's law: resistance x current = voltage.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< volt_unit, R1, P1 > &v, const quantity< ohm_unit, R2, P2 > &r)
 Ohm's law: voltage / resistance = current.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< volt_unit, R1, P1 > &v, const quantity< ampere_unit, R2, P2 > &i)
 Ohm's law: voltage / current = resistance.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< volt_unit, R1, P1 > &v, const quantity< ampere_unit, R2, P2 > &i)
 Power law: voltage x current = power.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< ampere_unit, R1, P1 > &i, const quantity< volt_unit, R2, P2 > &v)
 Power law: current x voltage = power.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< watt_unit, R1, P1 > &p, const quantity< volt_unit, R2, P2 > &v)
 Power law: power / voltage = current.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< watt_unit, R1, P1 > &p, const quantity< ampere_unit, R2, P2 > &i)
 Power law: power / current = voltage.
 
template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator* (const quantity< ampere_unit, R1, P1 > &i, const D &t)
 Charge: current x time = charge.
 
template<duration_like D, typename R1 , typename P1 >
constexpr auto quanta::electro::operator* (const D &t, const quantity< ampere_unit, R1, P1 > &i)
 Charge: time x current = charge.
 
template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator/ (const quantity< coulomb_unit, R1, P1 > &q, const D &t)
 Charge: charge / time = current.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< coulomb_unit, R1, P1 > &q, const quantity< ampere_unit, R2, P2 > &i)
 Charge: charge / current = time.
 
template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator* (const quantity< watt_unit, R1, P1 > &p, const D &t)
 Energy: power x time = energy.
 
template<duration_like D, typename R1 , typename P1 >
constexpr auto quanta::electro::operator* (const D &t, const quantity< watt_unit, R1, P1 > &p)
 Energy: time x power = energy.
 
template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator/ (const quantity< joule_unit, R1, P1 > &e, const D &t)
 Energy: energy / time = power.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< joule_unit, R1, P1 > &e, const quantity< watt_unit, R2, P2 > &p)
 Energy: energy / power = time.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< joule_unit, R1, P1 > &e, const quantity< volt_unit, R2, P2 > &v)
 Energy: energy / voltage = charge.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< joule_unit, R1, P1 > &e, const quantity< coulomb_unit, R2, P2 > &q)
 Energy: energy / charge = voltage.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< farad_unit, R1, P1 > &c, const quantity< volt_unit, R2, P2 > &v)
 Capacitance: capacitance x voltage = charge.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< volt_unit, R1, P1 > &v, const quantity< farad_unit, R2, P2 > &c)
 Capacitance: voltage x capacitance = charge.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< coulomb_unit, R1, P1 > &q, const quantity< volt_unit, R2, P2 > &v)
 Capacitance: charge / voltage = capacitance.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< coulomb_unit, R1, P1 > &q, const quantity< farad_unit, R2, P2 > &c)
 Capacitance: charge / capacitance = voltage.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< ohm_unit, R1, P1 > &r, const quantity< farad_unit, R2, P2 > &c)
 RC time constant: resistance x capacitance = time.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* (const quantity< farad_unit, R1, P1 > &c, const quantity< ohm_unit, R2, P2 > &r)
 RC time constant: capacitance x resistance = time.
 
template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ (const quantity< henry_unit, R1, P1 > &l, const quantity< ohm_unit, R2, P2 > &r)
 L/R time constant: inductance / resistance = time.
 

Detailed Description

Operators combining quantities of different kinds according to circuit theory.

The result precision is derived from the operand precisions, so results are exact for products (e.g. milliamperes x kiloohms yields volts) while quotients truncate for integer representations (use finer precisions or floating-point representations for fractional results).

Function Documentation

◆ operator*() [1/12]

template<duration_like D, typename R1 , typename P1 >
constexpr auto quanta::electro::operator* ( const D &  t,
const quantity< ampere_unit, R1, P1 > &  i 
)
constexpr

Charge: time x current = charge.

Definition at line 747 of file electro.hpp.

◆ operator*() [2/12]

template<duration_like D, typename R1 , typename P1 >
constexpr auto quanta::electro::operator* ( const D &  t,
const quantity< watt_unit, R1, P1 > &  p 
)
constexpr

Energy: time x power = energy.

Definition at line 783 of file electro.hpp.

◆ operator*() [3/12]

template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator* ( const quantity< ampere_unit, R1, P1 > &  i,
const D &  t 
)
constexpr

Charge: current x time = charge.

auto q = milliamperes(100) * std::chrono::hours(2); // 200 mAh
current< int64_t, std::milli > milliamperes
Current with 1 mA precision.
Definition electro.hpp:930

Definition at line 741 of file electro.hpp.

◆ operator*() [4/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< ampere_unit, R1, P1 > &  i,
const quantity< ohm_unit, R2, P2 > &  r 
)
constexpr

Ohm's law: current x resistance = voltage.

Definition at line 687 of file electro.hpp.

◆ operator*() [5/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< ampere_unit, R1, P1 > &  i,
const quantity< volt_unit, R2, P2 > &  v 
)
constexpr

Power law: current x voltage = power.

Definition at line 717 of file electro.hpp.

◆ operator*() [6/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< farad_unit, R1, P1 > &  c,
const quantity< ohm_unit, R2, P2 > &  r 
)
constexpr

RC time constant: capacitance x resistance = time.

Definition at line 855 of file electro.hpp.

◆ operator*() [7/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< farad_unit, R1, P1 > &  c,
const quantity< volt_unit, R2, P2 > &  v 
)
constexpr

Capacitance: capacitance x voltage = charge.

Definition at line 819 of file electro.hpp.

◆ operator*() [8/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< ohm_unit, R1, P1 > &  r,
const quantity< ampere_unit, R2, P2 > &  i 
)
constexpr

Ohm's law: resistance x current = voltage.

Definition at line 693 of file electro.hpp.

◆ operator*() [9/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< ohm_unit, R1, P1 > &  r,
const quantity< farad_unit, R2, P2 > &  c 
)
constexpr

RC time constant: resistance x capacitance = time.

auto tau = kiloohms(47) * microfarads(10); // 470 ms
capacitance< int64_t, std::micro > microfarads
Capacitance with 1 µF precision.
Definition electro.hpp:993
resistance< int64_t, std::kilo > kiloohms
Resistance with 1 kΩ precision.
Definition electro.hpp:945

Definition at line 849 of file electro.hpp.

◆ operator*() [10/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< volt_unit, R1, P1 > &  v,
const quantity< ampere_unit, R2, P2 > &  i 
)
constexpr

Power law: voltage x current = power.

Definition at line 711 of file electro.hpp.

◆ operator*() [11/12]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator* ( const quantity< volt_unit, R1, P1 > &  v,
const quantity< farad_unit, R2, P2 > &  c 
)
constexpr

Capacitance: voltage x capacitance = charge.

Definition at line 825 of file electro.hpp.

◆ operator*() [12/12]

template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator* ( const quantity< watt_unit, R1, P1 > &  p,
const D &  t 
)
constexpr

Energy: power x time = energy.

auto e = watts(100) * std::chrono::hours(5); // 500 Wh
power< int64_t > watts
Power with 1 W precision.
Definition electro.hpp:956

Definition at line 777 of file electro.hpp.

◆ operator/() [1/13]

template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator/ ( const quantity< coulomb_unit, R1, P1 > &  q,
const D &  t 
)
constexpr

Charge: charge / time = current.

Definition at line 753 of file electro.hpp.

◆ operator/() [2/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< coulomb_unit, R1, P1 > &  q,
const quantity< ampere_unit, R2, P2 > &  i 
)
constexpr

Charge: charge / current = time.

auto runtime = milliampere_hours(2000) / milliamperes(100); // 20 h
charge< int64_t, std::ratio< 18, 5 > > milliampere_hours
Charge with 1 mAh (3.6 C) precision.
Definition electro.hpp:971

Definition at line 765 of file electro.hpp.

◆ operator/() [3/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< coulomb_unit, R1, P1 > &  q,
const quantity< farad_unit, R2, P2 > &  c 
)
constexpr

Capacitance: charge / capacitance = voltage.

Definition at line 837 of file electro.hpp.

◆ operator/() [4/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< coulomb_unit, R1, P1 > &  q,
const quantity< volt_unit, R2, P2 > &  v 
)
constexpr

Capacitance: charge / voltage = capacitance.

Definition at line 831 of file electro.hpp.

◆ operator/() [5/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< henry_unit, R1, P1 > &  l,
const quantity< ohm_unit, R2, P2 > &  r 
)
constexpr

L/R time constant: inductance / resistance = time.

auto tau = millihenries(10) / ohms(2); // 5 ms
inductance< int64_t, std::milli > millihenries
Inductance with 1 mH precision.
Definition electro.hpp:1004
resistance< int64_t > ohms
Resistance with 1 Ω precision.
Definition electro.hpp:943

Definition at line 867 of file electro.hpp.

◆ operator/() [6/13]

template<typename R1 , typename P1 , duration_like D>
constexpr auto quanta::electro::operator/ ( const quantity< joule_unit, R1, P1 > &  e,
const D &  t 
)
constexpr

Energy: energy / time = power.

Definition at line 789 of file electro.hpp.

◆ operator/() [7/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< joule_unit, R1, P1 > &  e,
const quantity< coulomb_unit, R2, P2 > &  q 
)
constexpr

Energy: energy / charge = voltage.

Definition at line 813 of file electro.hpp.

◆ operator/() [8/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< joule_unit, R1, P1 > &  e,
const quantity< volt_unit, R2, P2 > &  v 
)
constexpr

Energy: energy / voltage = charge.

auto capacity = watt_hours(100) / volts(5); // 20 Ah
energy< int64_t, std::ratio< 3600 > > watt_hours
Energy with 1 Wh (3600 J) precision.
Definition electro.hpp:984
voltage< int64_t > volts
Voltage with 1 V precision.
Definition electro.hpp:923

Definition at line 807 of file electro.hpp.

◆ operator/() [9/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< joule_unit, R1, P1 > &  e,
const quantity< watt_unit, R2, P2 > &  p 
)
constexpr

Energy: energy / power = time.

Definition at line 795 of file electro.hpp.

◆ operator/() [10/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< volt_unit, R1, P1 > &  v,
const quantity< ampere_unit, R2, P2 > &  i 
)
constexpr

Ohm's law: voltage / current = resistance.

Definition at line 705 of file electro.hpp.

◆ operator/() [11/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< volt_unit, R1, P1 > &  v,
const quantity< ohm_unit, R2, P2 > &  r 
)
constexpr

Ohm's law: voltage / resistance = current.

Definition at line 699 of file electro.hpp.

◆ operator/() [12/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< watt_unit, R1, P1 > &  p,
const quantity< ampere_unit, R2, P2 > &  i 
)
constexpr

Power law: power / current = voltage.

Definition at line 729 of file electro.hpp.

◆ operator/() [13/13]

template<typename R1 , typename P1 , typename R2 , typename P2 >
constexpr auto quanta::electro::operator/ ( const quantity< watt_unit, R1, P1 > &  p,
const quantity< volt_unit, R2, P2 > &  v 
)
constexpr

Power law: power / voltage = current.

Definition at line 723 of file electro.hpp.