-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinitions.py
32 lines (29 loc) · 1.3 KB
/
definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sympy.physics.units.definitions import *
from sympy.physics.units import Quantity
from sympy.physics.units.prefixes import micro, milli, kilo, mega, nano
from .sympy_helpers import unit_relative_to, unit_with_prefix
from sympy import Rational, pi
uN = unit_with_prefix(micro, N)
mN = unit_with_prefix(milli, N)
mV = unit_with_prefix(milli, V)
kHz = unit_with_prefix(kilo, Hz)
rpm = unit_relative_to(Quantity("rpm"), Rational("1/60"), 1/s)
kohm = unit_with_prefix(kilo, ohm)
Mohm = unit_with_prefix(mega, ohm)
mohm = unit_with_prefix(milli, ohm)
uF = unit_with_prefix(micro, farad)
nF = unit_with_prefix(nano, farad)
mH = unit_with_prefix(milli, henry)
uH = unit_with_prefix(micro, henry)
mA = unit_with_prefix(milli, A)
uA = unit_with_prefix(micro, A)
# I'm not sure how one would define or convert from angular frequency to
# pulsing frequency with sympy (it doesn't help that these units are not
# defined in the module).
# ``convert_to(2*pi*rad/seg, Hz)`` gives us ``2*pi*Hz`` instead of Hz, so it
# would seem like sympy has no notion of angular frequency vs pulsing
# frequency.
rps = unit_relative_to(Quantity(
"radians_per_second", abbrev="rps", latex_repr="\\text{rad/s}"), 1/(2*pi), 1/s)
rpms = unit_relative_to(Quantity(
"radians_per_millisecond", abbrev="rpms", latex_repr="\\text{rad/ms}"), kilo, rps)