switching to high quality piper tts and added label translations
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from sympy.physics.units.systems.mks import MKS
|
||||
from sympy.physics.units.systems.mksa import MKSA
|
||||
from sympy.physics.units.systems.natural import natural
|
||||
from sympy.physics.units.systems.si import SI
|
||||
|
||||
__all__ = ['MKS', 'MKSA', 'natural', 'SI']
|
||||
@@ -0,0 +1,82 @@
|
||||
from sympy.core.singleton import S
|
||||
from sympy.functions.elementary.miscellaneous import sqrt
|
||||
from sympy.physics.units import UnitSystem, centimeter, gram, second, coulomb, charge, speed_of_light, current, mass, \
|
||||
length, voltage, magnetic_density, magnetic_flux
|
||||
from sympy.physics.units.definitions import coulombs_constant
|
||||
from sympy.physics.units.definitions.unit_definitions import statcoulomb, statampere, statvolt, volt, tesla, gauss, \
|
||||
weber, maxwell, debye, oersted, ohm, farad, henry, erg, ampere, coulomb_constant
|
||||
from sympy.physics.units.systems.mks import dimsys_length_weight_time
|
||||
|
||||
One = S.One
|
||||
|
||||
dimsys_cgs = dimsys_length_weight_time.extend(
|
||||
[],
|
||||
new_dim_deps={
|
||||
# Dimensional dependencies for derived dimensions
|
||||
"impedance": {"time": 1, "length": -1},
|
||||
"conductance": {"time": -1, "length": 1},
|
||||
"capacitance": {"length": 1},
|
||||
"inductance": {"time": 2, "length": -1},
|
||||
"charge": {"mass": S.Half, "length": S(3)/2, "time": -1},
|
||||
"current": {"mass": One/2, "length": 3*One/2, "time": -2},
|
||||
"voltage": {"length": -One/2, "mass": One/2, "time": -1},
|
||||
"magnetic_density": {"length": -One/2, "mass": One/2, "time": -1},
|
||||
"magnetic_flux": {"length": 3*One/2, "mass": One/2, "time": -1},
|
||||
}
|
||||
)
|
||||
|
||||
cgs_gauss = UnitSystem(
|
||||
base_units=[centimeter, gram, second],
|
||||
units=[],
|
||||
name="cgs_gauss",
|
||||
dimension_system=dimsys_cgs)
|
||||
|
||||
|
||||
cgs_gauss.set_quantity_scale_factor(coulombs_constant, 1)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(statcoulomb, charge)
|
||||
cgs_gauss.set_quantity_scale_factor(statcoulomb, centimeter**(S(3)/2)*gram**(S.Half)/second)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(coulomb, charge)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(statampere, current)
|
||||
cgs_gauss.set_quantity_scale_factor(statampere, statcoulomb/second)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(statvolt, voltage)
|
||||
cgs_gauss.set_quantity_scale_factor(statvolt, erg/statcoulomb)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(volt, voltage)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(gauss, magnetic_density)
|
||||
cgs_gauss.set_quantity_scale_factor(gauss, sqrt(gram/centimeter)/second)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(tesla, magnetic_density)
|
||||
|
||||
cgs_gauss.set_quantity_dimension(maxwell, magnetic_flux)
|
||||
cgs_gauss.set_quantity_scale_factor(maxwell, sqrt(centimeter**3*gram)/second)
|
||||
|
||||
# SI units expressed in CGS-gaussian units:
|
||||
cgs_gauss.set_quantity_scale_factor(coulomb, 10*speed_of_light*statcoulomb)
|
||||
cgs_gauss.set_quantity_scale_factor(ampere, 10*speed_of_light*statcoulomb/second)
|
||||
cgs_gauss.set_quantity_scale_factor(volt, 10**6/speed_of_light*statvolt)
|
||||
cgs_gauss.set_quantity_scale_factor(weber, 10**8*maxwell)
|
||||
cgs_gauss.set_quantity_scale_factor(tesla, 10**4*gauss)
|
||||
cgs_gauss.set_quantity_scale_factor(debye, One/10**18*statcoulomb*centimeter)
|
||||
cgs_gauss.set_quantity_scale_factor(oersted, sqrt(gram/centimeter)/second)
|
||||
cgs_gauss.set_quantity_scale_factor(ohm, 10**5/speed_of_light**2*second/centimeter)
|
||||
cgs_gauss.set_quantity_scale_factor(farad, One/10**5*speed_of_light**2*centimeter)
|
||||
cgs_gauss.set_quantity_scale_factor(henry, 10**5/speed_of_light**2/centimeter*second**2)
|
||||
|
||||
# Coulomb's constant:
|
||||
cgs_gauss.set_quantity_dimension(coulomb_constant, 1)
|
||||
cgs_gauss.set_quantity_scale_factor(coulomb_constant, 1)
|
||||
|
||||
__all__ = [
|
||||
'ohm', 'tesla', 'maxwell', 'speed_of_light', 'volt', 'second', 'voltage',
|
||||
'debye', 'dimsys_length_weight_time', 'centimeter', 'coulomb_constant',
|
||||
'farad', 'sqrt', 'UnitSystem', 'current', 'charge', 'weber', 'gram',
|
||||
'statcoulomb', 'gauss', 'S', 'statvolt', 'oersted', 'statampere',
|
||||
'dimsys_cgs', 'coulomb', 'magnetic_density', 'magnetic_flux', 'One',
|
||||
'length', 'erg', 'mass', 'coulombs_constant', 'henry', 'ampere',
|
||||
'cgs_gauss',
|
||||
]
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
from sympy.core.singleton import S
|
||||
|
||||
from sympy.core.numbers import pi
|
||||
|
||||
from sympy.physics.units import DimensionSystem, hertz, kilogram
|
||||
from sympy.physics.units.definitions import (
|
||||
G, Hz, J, N, Pa, W, c, g, kg, m, s, meter, gram, second, newton,
|
||||
joule, watt, pascal)
|
||||
from sympy.physics.units.definitions.dimension_definitions import (
|
||||
acceleration, action, energy, force, frequency, momentum,
|
||||
power, pressure, velocity, length, mass, time)
|
||||
from sympy.physics.units.prefixes import PREFIXES, prefix_unit
|
||||
from sympy.physics.units.prefixes import (
|
||||
kibi, mebi, gibi, tebi, pebi, exbi
|
||||
)
|
||||
from sympy.physics.units.definitions import (
|
||||
cd, K, coulomb, volt, ohm, siemens, farad, henry, tesla, weber, dioptre,
|
||||
lux, katal, gray, becquerel, inch, hectare, liter, julian_year,
|
||||
gravitational_constant, speed_of_light, elementary_charge, planck, hbar,
|
||||
electronvolt, avogadro_number, avogadro_constant, boltzmann_constant,
|
||||
stefan_boltzmann_constant, atomic_mass_constant, molar_gas_constant,
|
||||
faraday_constant, josephson_constant, von_klitzing_constant,
|
||||
acceleration_due_to_gravity, magnetic_constant, vacuum_permittivity,
|
||||
vacuum_impedance, coulomb_constant, atmosphere, bar, pound, psi, mmHg,
|
||||
milli_mass_unit, quart, lightyear, astronomical_unit, planck_mass,
|
||||
planck_time, planck_temperature, planck_length, planck_charge,
|
||||
planck_area, planck_volume, planck_momentum, planck_energy, planck_force,
|
||||
planck_power, planck_density, planck_energy_density, planck_intensity,
|
||||
planck_angular_frequency, planck_pressure, planck_current, planck_voltage,
|
||||
planck_impedance, planck_acceleration, bit, byte, kibibyte, mebibyte,
|
||||
gibibyte, tebibyte, pebibyte, exbibyte, curie, rutherford, radian, degree,
|
||||
steradian, angular_mil, atomic_mass_unit, gee, kPa, ampere, u0, kelvin,
|
||||
mol, mole, candela, electric_constant, boltzmann, angstrom
|
||||
)
|
||||
|
||||
|
||||
dimsys_length_weight_time = DimensionSystem([
|
||||
# Dimensional dependencies for MKS base dimensions
|
||||
length,
|
||||
mass,
|
||||
time,
|
||||
], dimensional_dependencies={
|
||||
# Dimensional dependencies for derived dimensions
|
||||
"velocity": {"length": 1, "time": -1},
|
||||
"acceleration": {"length": 1, "time": -2},
|
||||
"momentum": {"mass": 1, "length": 1, "time": -1},
|
||||
"force": {"mass": 1, "length": 1, "time": -2},
|
||||
"energy": {"mass": 1, "length": 2, "time": -2},
|
||||
"power": {"length": 2, "mass": 1, "time": -3},
|
||||
"pressure": {"mass": 1, "length": -1, "time": -2},
|
||||
"frequency": {"time": -1},
|
||||
"action": {"length": 2, "mass": 1, "time": -1},
|
||||
"area": {"length": 2},
|
||||
"volume": {"length": 3},
|
||||
})
|
||||
|
||||
|
||||
One = S.One
|
||||
|
||||
|
||||
# Base units:
|
||||
dimsys_length_weight_time.set_quantity_dimension(meter, length)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(meter, One)
|
||||
|
||||
# gram; used to define its prefixed units
|
||||
dimsys_length_weight_time.set_quantity_dimension(gram, mass)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(gram, One)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(second, time)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(second, One)
|
||||
|
||||
# derived units
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(newton, force)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(newton, kilogram*meter/second**2)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(joule, energy)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(joule, newton*meter)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(watt, power)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(watt, joule/second)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(pascal, pressure)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(pascal, newton/meter**2)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(hertz, frequency)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(hertz, One)
|
||||
|
||||
# Other derived units:
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(dioptre, 1 / length)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(dioptre, 1/meter)
|
||||
|
||||
# Common volume and area units
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(hectare, length**2)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(hectare, (meter**2)*(10000))
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(liter, length**3)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(liter, meter**3/1000)
|
||||
|
||||
|
||||
# Newton constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(gravitational_constant, length ** 3 * mass ** -1 * time ** -2)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(gravitational_constant, 6.67430e-11*m**3/(kg*s**2))
|
||||
|
||||
# speed of light
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(speed_of_light, velocity)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(speed_of_light, 299792458*meter/second)
|
||||
|
||||
|
||||
# Planck constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(planck, action)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(planck, 6.62607015e-34*joule*second)
|
||||
|
||||
# Reduced Planck constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
dimsys_length_weight_time.set_quantity_dimension(hbar, action)
|
||||
dimsys_length_weight_time.set_quantity_scale_factor(hbar, planck / (2 * pi))
|
||||
|
||||
|
||||
__all__ = [
|
||||
'mmHg', 'atmosphere', 'newton', 'meter', 'vacuum_permittivity', 'pascal',
|
||||
'magnetic_constant', 'angular_mil', 'julian_year', 'weber', 'exbibyte',
|
||||
'liter', 'molar_gas_constant', 'faraday_constant', 'avogadro_constant',
|
||||
'planck_momentum', 'planck_density', 'gee', 'mol', 'bit', 'gray', 'kibi',
|
||||
'bar', 'curie', 'prefix_unit', 'PREFIXES', 'planck_time', 'gram',
|
||||
'candela', 'force', 'planck_intensity', 'energy', 'becquerel',
|
||||
'planck_acceleration', 'speed_of_light', 'dioptre', 'second', 'frequency',
|
||||
'Hz', 'power', 'lux', 'planck_current', 'momentum', 'tebibyte',
|
||||
'planck_power', 'degree', 'mebi', 'K', 'planck_volume',
|
||||
'quart', 'pressure', 'W', 'joule', 'boltzmann_constant', 'c', 'g',
|
||||
'planck_force', 'exbi', 's', 'watt', 'action', 'hbar', 'gibibyte',
|
||||
'DimensionSystem', 'cd', 'volt', 'planck_charge', 'angstrom',
|
||||
'dimsys_length_weight_time', 'pebi', 'vacuum_impedance', 'planck',
|
||||
'farad', 'gravitational_constant', 'u0', 'hertz', 'tesla', 'steradian',
|
||||
'josephson_constant', 'planck_area', 'stefan_boltzmann_constant',
|
||||
'astronomical_unit', 'J', 'N', 'planck_voltage', 'planck_energy',
|
||||
'atomic_mass_constant', 'rutherford', 'elementary_charge', 'Pa',
|
||||
'planck_mass', 'henry', 'planck_angular_frequency', 'ohm', 'pound',
|
||||
'planck_pressure', 'G', 'avogadro_number', 'psi', 'von_klitzing_constant',
|
||||
'planck_length', 'radian', 'mole', 'acceleration',
|
||||
'planck_energy_density', 'mebibyte', 'length',
|
||||
'acceleration_due_to_gravity', 'planck_temperature', 'tebi', 'inch',
|
||||
'electronvolt', 'coulomb_constant', 'kelvin', 'kPa', 'boltzmann',
|
||||
'milli_mass_unit', 'gibi', 'planck_impedance', 'electric_constant', 'kg',
|
||||
'coulomb', 'siemens', 'byte', 'atomic_mass_unit', 'm', 'kibibyte',
|
||||
'kilogram', 'lightyear', 'mass', 'time', 'pebibyte', 'velocity',
|
||||
'ampere', 'katal',
|
||||
]
|
||||
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
MKS unit system.
|
||||
|
||||
MKS stands for "meter, kilogram, second".
|
||||
"""
|
||||
|
||||
from sympy.physics.units import UnitSystem
|
||||
from sympy.physics.units.definitions import gravitational_constant, hertz, joule, newton, pascal, watt, speed_of_light, gram, kilogram, meter, second
|
||||
from sympy.physics.units.definitions.dimension_definitions import (
|
||||
acceleration, action, energy, force, frequency, momentum,
|
||||
power, pressure, velocity, length, mass, time)
|
||||
from sympy.physics.units.prefixes import PREFIXES, prefix_unit
|
||||
from sympy.physics.units.systems.length_weight_time import dimsys_length_weight_time
|
||||
|
||||
dims = (velocity, acceleration, momentum, force, energy, power, pressure,
|
||||
frequency, action)
|
||||
|
||||
units = [meter, gram, second, joule, newton, watt, pascal, hertz]
|
||||
all_units = []
|
||||
|
||||
# Prefixes of units like gram, joule, newton etc get added using `prefix_unit`
|
||||
# in the for loop, but the actual units have to be added manually.
|
||||
all_units.extend([gram, joule, newton, watt, pascal, hertz])
|
||||
|
||||
for u in units:
|
||||
all_units.extend(prefix_unit(u, PREFIXES))
|
||||
all_units.extend([gravitational_constant, speed_of_light])
|
||||
|
||||
# unit system
|
||||
MKS = UnitSystem(base_units=(meter, kilogram, second), units=all_units, name="MKS", dimension_system=dimsys_length_weight_time, derived_units={
|
||||
power: watt,
|
||||
time: second,
|
||||
pressure: pascal,
|
||||
length: meter,
|
||||
frequency: hertz,
|
||||
mass: kilogram,
|
||||
force: newton,
|
||||
energy: joule,
|
||||
velocity: meter/second,
|
||||
acceleration: meter/(second**2),
|
||||
})
|
||||
|
||||
|
||||
__all__ = [
|
||||
'MKS', 'units', 'all_units', 'dims',
|
||||
]
|
||||
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
MKS unit system.
|
||||
|
||||
MKS stands for "meter, kilogram, second, ampere".
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from sympy.physics.units.definitions import Z0, ampere, coulomb, farad, henry, siemens, tesla, volt, weber, ohm
|
||||
from sympy.physics.units.definitions.dimension_definitions import (
|
||||
capacitance, charge, conductance, current, impedance, inductance,
|
||||
magnetic_density, magnetic_flux, voltage)
|
||||
from sympy.physics.units.prefixes import PREFIXES, prefix_unit
|
||||
from sympy.physics.units.systems.mks import MKS, dimsys_length_weight_time
|
||||
from sympy.physics.units.quantities import Quantity
|
||||
|
||||
dims = (voltage, impedance, conductance, current, capacitance, inductance, charge,
|
||||
magnetic_density, magnetic_flux)
|
||||
|
||||
units = [ampere, volt, ohm, siemens, farad, henry, coulomb, tesla, weber]
|
||||
|
||||
all_units: list[Quantity] = []
|
||||
for u in units:
|
||||
all_units.extend(prefix_unit(u, PREFIXES))
|
||||
all_units.extend(units)
|
||||
|
||||
all_units.append(Z0)
|
||||
|
||||
dimsys_MKSA = dimsys_length_weight_time.extend([
|
||||
# Dimensional dependencies for base dimensions (MKSA not in MKS)
|
||||
current,
|
||||
], new_dim_deps={
|
||||
# Dimensional dependencies for derived dimensions
|
||||
"voltage": {"mass": 1, "length": 2, "current": -1, "time": -3},
|
||||
"impedance": {"mass": 1, "length": 2, "current": -2, "time": -3},
|
||||
"conductance": {"mass": -1, "length": -2, "current": 2, "time": 3},
|
||||
"capacitance": {"mass": -1, "length": -2, "current": 2, "time": 4},
|
||||
"inductance": {"mass": 1, "length": 2, "current": -2, "time": -2},
|
||||
"charge": {"current": 1, "time": 1},
|
||||
"magnetic_density": {"mass": 1, "current": -1, "time": -2},
|
||||
"magnetic_flux": {"length": 2, "mass": 1, "current": -1, "time": -2},
|
||||
})
|
||||
|
||||
MKSA = MKS.extend(base=(ampere,), units=all_units, name='MKSA', dimension_system=dimsys_MKSA, derived_units={
|
||||
magnetic_flux: weber,
|
||||
impedance: ohm,
|
||||
current: ampere,
|
||||
voltage: volt,
|
||||
inductance: henry,
|
||||
conductance: siemens,
|
||||
magnetic_density: tesla,
|
||||
charge: coulomb,
|
||||
capacitance: farad,
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Naturalunit system.
|
||||
|
||||
The natural system comes from "setting c = 1, hbar = 1". From the computer
|
||||
point of view it means that we use velocity and action instead of length and
|
||||
time. Moreover instead of mass we use energy.
|
||||
"""
|
||||
|
||||
from sympy.physics.units import DimensionSystem
|
||||
from sympy.physics.units.definitions import c, eV, hbar
|
||||
from sympy.physics.units.definitions.dimension_definitions import (
|
||||
action, energy, force, frequency, length, mass, momentum,
|
||||
power, time, velocity)
|
||||
from sympy.physics.units.prefixes import PREFIXES, prefix_unit
|
||||
from sympy.physics.units.unitsystem import UnitSystem
|
||||
|
||||
|
||||
# dimension system
|
||||
_natural_dim = DimensionSystem(
|
||||
base_dims=(action, energy, velocity),
|
||||
derived_dims=(length, mass, time, momentum, force, power, frequency)
|
||||
)
|
||||
|
||||
units = prefix_unit(eV, PREFIXES)
|
||||
|
||||
# unit system
|
||||
natural = UnitSystem(base_units=(hbar, eV, c), units=units, name="Natural system")
|
||||
@@ -0,0 +1,377 @@
|
||||
"""
|
||||
SI unit system.
|
||||
Based on MKSA, which stands for "meter, kilogram, second, ampere".
|
||||
Added kelvin, candela and mole.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from sympy.physics.units import DimensionSystem, Dimension, dHg0
|
||||
|
||||
from sympy.physics.units.quantities import Quantity
|
||||
|
||||
from sympy.core.numbers import (Rational, pi)
|
||||
from sympy.core.singleton import S
|
||||
from sympy.functions.elementary.miscellaneous import sqrt
|
||||
from sympy.physics.units.definitions.dimension_definitions import (
|
||||
acceleration, action, current, impedance, length, mass, time, velocity,
|
||||
amount_of_substance, temperature, information, frequency, force, pressure,
|
||||
energy, power, charge, voltage, capacitance, conductance, magnetic_flux,
|
||||
magnetic_density, inductance, luminous_intensity
|
||||
)
|
||||
from sympy.physics.units.definitions import (
|
||||
kilogram, newton, second, meter, gram, cd, K, joule, watt, pascal, hertz,
|
||||
coulomb, volt, ohm, siemens, farad, henry, tesla, weber, dioptre, lux,
|
||||
katal, gray, becquerel, inch, liter, julian_year, gravitational_constant,
|
||||
speed_of_light, elementary_charge, planck, hbar, electronvolt,
|
||||
avogadro_number, avogadro_constant, boltzmann_constant, electron_rest_mass,
|
||||
stefan_boltzmann_constant, Da, atomic_mass_constant, molar_gas_constant,
|
||||
faraday_constant, josephson_constant, von_klitzing_constant,
|
||||
acceleration_due_to_gravity, magnetic_constant, vacuum_permittivity,
|
||||
vacuum_impedance, coulomb_constant, atmosphere, bar, pound, psi, mmHg,
|
||||
milli_mass_unit, quart, lightyear, astronomical_unit, planck_mass,
|
||||
planck_time, planck_temperature, planck_length, planck_charge, planck_area,
|
||||
planck_volume, planck_momentum, planck_energy, planck_force, planck_power,
|
||||
planck_density, planck_energy_density, planck_intensity,
|
||||
planck_angular_frequency, planck_pressure, planck_current, planck_voltage,
|
||||
planck_impedance, planck_acceleration, bit, byte, kibibyte, mebibyte,
|
||||
gibibyte, tebibyte, pebibyte, exbibyte, curie, rutherford, radian, degree,
|
||||
steradian, angular_mil, atomic_mass_unit, gee, kPa, ampere, u0, c, kelvin,
|
||||
mol, mole, candela, m, kg, s, electric_constant, G, boltzmann
|
||||
)
|
||||
from sympy.physics.units.prefixes import PREFIXES, prefix_unit
|
||||
from sympy.physics.units.systems.mksa import MKSA, dimsys_MKSA
|
||||
|
||||
derived_dims = (frequency, force, pressure, energy, power, charge, voltage,
|
||||
capacitance, conductance, magnetic_flux,
|
||||
magnetic_density, inductance, luminous_intensity)
|
||||
base_dims = (amount_of_substance, luminous_intensity, temperature)
|
||||
|
||||
units = [mol, cd, K, lux, hertz, newton, pascal, joule, watt, coulomb, volt,
|
||||
farad, ohm, siemens, weber, tesla, henry, candela, lux, becquerel,
|
||||
gray, katal]
|
||||
|
||||
all_units: list[Quantity] = []
|
||||
for u in units:
|
||||
all_units.extend(prefix_unit(u, PREFIXES))
|
||||
|
||||
all_units.extend(units)
|
||||
all_units.extend([mol, cd, K, lux])
|
||||
|
||||
|
||||
dimsys_SI = dimsys_MKSA.extend(
|
||||
[
|
||||
# Dimensional dependencies for other base dimensions:
|
||||
temperature,
|
||||
amount_of_substance,
|
||||
luminous_intensity,
|
||||
])
|
||||
|
||||
dimsys_default = dimsys_SI.extend(
|
||||
[information],
|
||||
)
|
||||
|
||||
SI = MKSA.extend(base=(mol, cd, K), units=all_units, name='SI', dimension_system=dimsys_SI, derived_units={
|
||||
power: watt,
|
||||
magnetic_flux: weber,
|
||||
time: second,
|
||||
impedance: ohm,
|
||||
pressure: pascal,
|
||||
current: ampere,
|
||||
voltage: volt,
|
||||
length: meter,
|
||||
frequency: hertz,
|
||||
inductance: henry,
|
||||
temperature: kelvin,
|
||||
amount_of_substance: mole,
|
||||
luminous_intensity: candela,
|
||||
conductance: siemens,
|
||||
mass: kilogram,
|
||||
magnetic_density: tesla,
|
||||
charge: coulomb,
|
||||
force: newton,
|
||||
capacitance: farad,
|
||||
energy: joule,
|
||||
velocity: meter/second,
|
||||
})
|
||||
|
||||
One = S.One
|
||||
|
||||
SI.set_quantity_dimension(radian, One)
|
||||
|
||||
SI.set_quantity_scale_factor(ampere, One)
|
||||
|
||||
SI.set_quantity_scale_factor(kelvin, One)
|
||||
|
||||
SI.set_quantity_scale_factor(mole, One)
|
||||
|
||||
SI.set_quantity_scale_factor(candela, One)
|
||||
|
||||
# MKSA extension to MKS: derived units
|
||||
|
||||
SI.set_quantity_scale_factor(coulomb, One)
|
||||
|
||||
SI.set_quantity_scale_factor(volt, joule/coulomb)
|
||||
|
||||
SI.set_quantity_scale_factor(ohm, volt/ampere)
|
||||
|
||||
SI.set_quantity_scale_factor(siemens, ampere/volt)
|
||||
|
||||
SI.set_quantity_scale_factor(farad, coulomb/volt)
|
||||
|
||||
SI.set_quantity_scale_factor(henry, volt*second/ampere)
|
||||
|
||||
SI.set_quantity_scale_factor(tesla, volt*second/meter**2)
|
||||
|
||||
SI.set_quantity_scale_factor(weber, joule/ampere)
|
||||
|
||||
|
||||
SI.set_quantity_dimension(lux, luminous_intensity / length ** 2)
|
||||
SI.set_quantity_scale_factor(lux, steradian*candela/meter**2)
|
||||
|
||||
# katal is the SI unit of catalytic activity
|
||||
|
||||
SI.set_quantity_dimension(katal, amount_of_substance / time)
|
||||
SI.set_quantity_scale_factor(katal, mol/second)
|
||||
|
||||
# gray is the SI unit of absorbed dose
|
||||
|
||||
SI.set_quantity_dimension(gray, energy / mass)
|
||||
SI.set_quantity_scale_factor(gray, meter**2/second**2)
|
||||
|
||||
# becquerel is the SI unit of radioactivity
|
||||
|
||||
SI.set_quantity_dimension(becquerel, 1 / time)
|
||||
SI.set_quantity_scale_factor(becquerel, 1/second)
|
||||
|
||||
#### CONSTANTS ####
|
||||
|
||||
# elementary charge
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(elementary_charge, charge)
|
||||
SI.set_quantity_scale_factor(elementary_charge, 1.602176634e-19*coulomb)
|
||||
|
||||
# Electronvolt
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(electronvolt, energy)
|
||||
SI.set_quantity_scale_factor(electronvolt, 1.602176634e-19*joule)
|
||||
|
||||
# Avogadro number
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(avogadro_number, One)
|
||||
SI.set_quantity_scale_factor(avogadro_number, 6.02214076e23)
|
||||
|
||||
# Avogadro constant
|
||||
|
||||
SI.set_quantity_dimension(avogadro_constant, amount_of_substance ** -1)
|
||||
SI.set_quantity_scale_factor(avogadro_constant, avogadro_number / mol)
|
||||
|
||||
# Boltzmann constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(boltzmann_constant, energy / temperature)
|
||||
SI.set_quantity_scale_factor(boltzmann_constant, 1.380649e-23*joule/kelvin)
|
||||
|
||||
# Stefan-Boltzmann constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(stefan_boltzmann_constant, energy * time ** -1 * length ** -2 * temperature ** -4)
|
||||
SI.set_quantity_scale_factor(stefan_boltzmann_constant, pi**2 * boltzmann_constant**4 / (60 * hbar**3 * speed_of_light ** 2))
|
||||
|
||||
# Atomic mass
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(atomic_mass_constant, mass)
|
||||
SI.set_quantity_scale_factor(atomic_mass_constant, 1.66053906660e-24*gram)
|
||||
|
||||
# Molar gas constant
|
||||
# REF: NIST SP 959 (June 2019)
|
||||
|
||||
SI.set_quantity_dimension(molar_gas_constant, energy / (temperature * amount_of_substance))
|
||||
SI.set_quantity_scale_factor(molar_gas_constant, boltzmann_constant * avogadro_constant)
|
||||
|
||||
# Faraday constant
|
||||
|
||||
SI.set_quantity_dimension(faraday_constant, charge / amount_of_substance)
|
||||
SI.set_quantity_scale_factor(faraday_constant, elementary_charge * avogadro_constant)
|
||||
|
||||
# Josephson constant
|
||||
|
||||
SI.set_quantity_dimension(josephson_constant, frequency / voltage)
|
||||
SI.set_quantity_scale_factor(josephson_constant, 0.5 * planck / elementary_charge)
|
||||
|
||||
# Von Klitzing constant
|
||||
|
||||
SI.set_quantity_dimension(von_klitzing_constant, voltage / current)
|
||||
SI.set_quantity_scale_factor(von_klitzing_constant, hbar / elementary_charge ** 2)
|
||||
|
||||
# Acceleration due to gravity (on the Earth surface)
|
||||
|
||||
SI.set_quantity_dimension(acceleration_due_to_gravity, acceleration)
|
||||
SI.set_quantity_scale_factor(acceleration_due_to_gravity, 9.80665*meter/second**2)
|
||||
|
||||
# magnetic constant:
|
||||
|
||||
SI.set_quantity_dimension(magnetic_constant, force / current ** 2)
|
||||
SI.set_quantity_scale_factor(magnetic_constant, 4*pi/10**7 * newton/ampere**2)
|
||||
|
||||
# electric constant:
|
||||
|
||||
SI.set_quantity_dimension(vacuum_permittivity, capacitance / length)
|
||||
SI.set_quantity_scale_factor(vacuum_permittivity, 1/(u0 * c**2))
|
||||
|
||||
# vacuum impedance:
|
||||
|
||||
SI.set_quantity_dimension(vacuum_impedance, impedance)
|
||||
SI.set_quantity_scale_factor(vacuum_impedance, u0 * c)
|
||||
|
||||
# Electron rest mass
|
||||
SI.set_quantity_dimension(electron_rest_mass, mass)
|
||||
SI.set_quantity_scale_factor(electron_rest_mass, 9.1093837015e-31*kilogram)
|
||||
|
||||
# Coulomb's constant:
|
||||
SI.set_quantity_dimension(coulomb_constant, force * length ** 2 / charge ** 2)
|
||||
SI.set_quantity_scale_factor(coulomb_constant, 1/(4*pi*vacuum_permittivity))
|
||||
|
||||
SI.set_quantity_dimension(psi, pressure)
|
||||
SI.set_quantity_scale_factor(psi, pound * gee / inch ** 2)
|
||||
|
||||
SI.set_quantity_dimension(mmHg, pressure)
|
||||
SI.set_quantity_scale_factor(mmHg, dHg0 * acceleration_due_to_gravity * kilogram / meter**2)
|
||||
|
||||
SI.set_quantity_dimension(milli_mass_unit, mass)
|
||||
SI.set_quantity_scale_factor(milli_mass_unit, atomic_mass_unit/1000)
|
||||
|
||||
SI.set_quantity_dimension(quart, length ** 3)
|
||||
SI.set_quantity_scale_factor(quart, Rational(231, 4) * inch**3)
|
||||
|
||||
# Other convenient units and magnitudes
|
||||
|
||||
SI.set_quantity_dimension(lightyear, length)
|
||||
SI.set_quantity_scale_factor(lightyear, speed_of_light*julian_year)
|
||||
|
||||
SI.set_quantity_dimension(astronomical_unit, length)
|
||||
SI.set_quantity_scale_factor(astronomical_unit, 149597870691*meter)
|
||||
|
||||
# Fundamental Planck units:
|
||||
|
||||
SI.set_quantity_dimension(planck_mass, mass)
|
||||
SI.set_quantity_scale_factor(planck_mass, sqrt(hbar*speed_of_light/G))
|
||||
|
||||
SI.set_quantity_dimension(planck_time, time)
|
||||
SI.set_quantity_scale_factor(planck_time, sqrt(hbar*G/speed_of_light**5))
|
||||
|
||||
SI.set_quantity_dimension(planck_temperature, temperature)
|
||||
SI.set_quantity_scale_factor(planck_temperature, sqrt(hbar*speed_of_light**5/G/boltzmann**2))
|
||||
|
||||
SI.set_quantity_dimension(planck_length, length)
|
||||
SI.set_quantity_scale_factor(planck_length, sqrt(hbar*G/speed_of_light**3))
|
||||
|
||||
SI.set_quantity_dimension(planck_charge, charge)
|
||||
SI.set_quantity_scale_factor(planck_charge, sqrt(4*pi*electric_constant*hbar*speed_of_light))
|
||||
|
||||
# Derived Planck units:
|
||||
|
||||
SI.set_quantity_dimension(planck_area, length ** 2)
|
||||
SI.set_quantity_scale_factor(planck_area, planck_length**2)
|
||||
|
||||
SI.set_quantity_dimension(planck_volume, length ** 3)
|
||||
SI.set_quantity_scale_factor(planck_volume, planck_length**3)
|
||||
|
||||
SI.set_quantity_dimension(planck_momentum, mass * velocity)
|
||||
SI.set_quantity_scale_factor(planck_momentum, planck_mass * speed_of_light)
|
||||
|
||||
SI.set_quantity_dimension(planck_energy, energy)
|
||||
SI.set_quantity_scale_factor(planck_energy, planck_mass * speed_of_light**2)
|
||||
|
||||
SI.set_quantity_dimension(planck_force, force)
|
||||
SI.set_quantity_scale_factor(planck_force, planck_energy / planck_length)
|
||||
|
||||
SI.set_quantity_dimension(planck_power, power)
|
||||
SI.set_quantity_scale_factor(planck_power, planck_energy / planck_time)
|
||||
|
||||
SI.set_quantity_dimension(planck_density, mass / length ** 3)
|
||||
SI.set_quantity_scale_factor(planck_density, planck_mass / planck_length**3)
|
||||
|
||||
SI.set_quantity_dimension(planck_energy_density, energy / length ** 3)
|
||||
SI.set_quantity_scale_factor(planck_energy_density, planck_energy / planck_length**3)
|
||||
|
||||
SI.set_quantity_dimension(planck_intensity, mass * time ** (-3))
|
||||
SI.set_quantity_scale_factor(planck_intensity, planck_energy_density * speed_of_light)
|
||||
|
||||
SI.set_quantity_dimension(planck_angular_frequency, 1 / time)
|
||||
SI.set_quantity_scale_factor(planck_angular_frequency, 1 / planck_time)
|
||||
|
||||
SI.set_quantity_dimension(planck_pressure, pressure)
|
||||
SI.set_quantity_scale_factor(planck_pressure, planck_force / planck_length**2)
|
||||
|
||||
SI.set_quantity_dimension(planck_current, current)
|
||||
SI.set_quantity_scale_factor(planck_current, planck_charge / planck_time)
|
||||
|
||||
SI.set_quantity_dimension(planck_voltage, voltage)
|
||||
SI.set_quantity_scale_factor(planck_voltage, planck_energy / planck_charge)
|
||||
|
||||
SI.set_quantity_dimension(planck_impedance, impedance)
|
||||
SI.set_quantity_scale_factor(planck_impedance, planck_voltage / planck_current)
|
||||
|
||||
SI.set_quantity_dimension(planck_acceleration, acceleration)
|
||||
SI.set_quantity_scale_factor(planck_acceleration, speed_of_light / planck_time)
|
||||
|
||||
# Older units for radioactivity
|
||||
|
||||
SI.set_quantity_dimension(curie, 1 / time)
|
||||
SI.set_quantity_scale_factor(curie, 37000000000*becquerel)
|
||||
|
||||
SI.set_quantity_dimension(rutherford, 1 / time)
|
||||
SI.set_quantity_scale_factor(rutherford, 1000000*becquerel)
|
||||
|
||||
|
||||
# check that scale factors are the right SI dimensions:
|
||||
for _scale_factor, _dimension in zip(
|
||||
SI._quantity_scale_factors.values(),
|
||||
SI._quantity_dimension_map.values()
|
||||
):
|
||||
dimex = SI.get_dimensional_expr(_scale_factor)
|
||||
if dimex != 1:
|
||||
# XXX: equivalent_dims is an instance method taking two arguments in
|
||||
# addition to self so this can not work:
|
||||
if not DimensionSystem.equivalent_dims(_dimension, Dimension(dimex)): # type: ignore
|
||||
raise ValueError("quantity value and dimension mismatch")
|
||||
del _scale_factor, _dimension
|
||||
|
||||
__all__ = [
|
||||
'mmHg', 'atmosphere', 'inductance', 'newton', 'meter',
|
||||
'vacuum_permittivity', 'pascal', 'magnetic_constant', 'voltage',
|
||||
'angular_mil', 'luminous_intensity', 'all_units',
|
||||
'julian_year', 'weber', 'exbibyte', 'liter',
|
||||
'molar_gas_constant', 'faraday_constant', 'avogadro_constant',
|
||||
'lightyear', 'planck_density', 'gee', 'mol', 'bit', 'gray',
|
||||
'planck_momentum', 'bar', 'magnetic_density', 'prefix_unit', 'PREFIXES',
|
||||
'planck_time', 'dimex', 'gram', 'candela', 'force', 'planck_intensity',
|
||||
'energy', 'becquerel', 'planck_acceleration', 'speed_of_light',
|
||||
'conductance', 'frequency', 'coulomb_constant', 'degree', 'lux', 'planck',
|
||||
'current', 'planck_current', 'tebibyte', 'planck_power', 'MKSA', 'power',
|
||||
'K', 'planck_volume', 'quart', 'pressure', 'amount_of_substance',
|
||||
'joule', 'boltzmann_constant', 'Dimension', 'c', 'planck_force', 'length',
|
||||
'watt', 'action', 'hbar', 'gibibyte', 'DimensionSystem', 'cd', 'volt',
|
||||
'planck_charge', 'dioptre', 'vacuum_impedance', 'dimsys_default', 'farad',
|
||||
'charge', 'gravitational_constant', 'temperature', 'u0', 'hertz',
|
||||
'capacitance', 'tesla', 'steradian', 'planck_mass', 'josephson_constant',
|
||||
'planck_area', 'stefan_boltzmann_constant', 'base_dims',
|
||||
'astronomical_unit', 'radian', 'planck_voltage', 'impedance',
|
||||
'planck_energy', 'Da', 'atomic_mass_constant', 'rutherford', 'second', 'inch',
|
||||
'elementary_charge', 'SI', 'electronvolt', 'dimsys_SI', 'henry',
|
||||
'planck_angular_frequency', 'ohm', 'pound', 'planck_pressure', 'G', 'psi',
|
||||
'dHg0', 'von_klitzing_constant', 'planck_length', 'avogadro_number',
|
||||
'mole', 'acceleration', 'information', 'planck_energy_density',
|
||||
'mebibyte', 's', 'acceleration_due_to_gravity', 'electron_rest_mass',
|
||||
'planck_temperature', 'units', 'mass', 'dimsys_MKSA', 'kelvin', 'kPa',
|
||||
'boltzmann', 'milli_mass_unit', 'planck_impedance', 'electric_constant',
|
||||
'derived_dims', 'kg', 'coulomb', 'siemens', 'byte', 'magnetic_flux',
|
||||
'atomic_mass_unit', 'm', 'kibibyte', 'kilogram', 'One', 'curie', 'u',
|
||||
'time', 'pebibyte', 'velocity', 'ampere', 'katal',
|
||||
]
|
||||
Reference in New Issue
Block a user