mksa.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """
  2. MKS unit system.
  3. MKS stands for "meter, kilogram, second, ampere".
  4. """
  5. from __future__ import annotations
  6. from sympy.physics.units.definitions import Z0, ampere, coulomb, farad, henry, siemens, tesla, volt, weber, ohm
  7. from sympy.physics.units.definitions.dimension_definitions import (
  8. capacitance, charge, conductance, current, impedance, inductance,
  9. magnetic_density, magnetic_flux, voltage)
  10. from sympy.physics.units.prefixes import PREFIXES, prefix_unit
  11. from sympy.physics.units.systems.mks import MKS, dimsys_length_weight_time
  12. from sympy.physics.units.quantities import Quantity
  13. dims = (voltage, impedance, conductance, current, capacitance, inductance, charge,
  14. magnetic_density, magnetic_flux)
  15. units = [ampere, volt, ohm, siemens, farad, henry, coulomb, tesla, weber]
  16. all_units: list[Quantity] = []
  17. for u in units:
  18. all_units.extend(prefix_unit(u, PREFIXES))
  19. all_units.extend(units)
  20. all_units.append(Z0)
  21. dimsys_MKSA = dimsys_length_weight_time.extend([
  22. # Dimensional dependencies for base dimensions (MKSA not in MKS)
  23. current,
  24. ], new_dim_deps={
  25. # Dimensional dependencies for derived dimensions
  26. "voltage": {"mass": 1, "length": 2, "current": -1, "time": -3},
  27. "impedance": {"mass": 1, "length": 2, "current": -2, "time": -3},
  28. "conductance": {"mass": -1, "length": -2, "current": 2, "time": 3},
  29. "capacitance": {"mass": -1, "length": -2, "current": 2, "time": 4},
  30. "inductance": {"mass": 1, "length": 2, "current": -2, "time": -2},
  31. "charge": {"current": 1, "time": 1},
  32. "magnetic_density": {"mass": 1, "current": -1, "time": -2},
  33. "magnetic_flux": {"length": 2, "mass": 1, "current": -1, "time": -2},
  34. })
  35. MKSA = MKS.extend(base=(ampere,), units=all_units, name='MKSA', dimension_system=dimsys_MKSA, derived_units={
  36. magnetic_flux: weber,
  37. impedance: ohm,
  38. current: ampere,
  39. voltage: volt,
  40. inductance: henry,
  41. conductance: siemens,
  42. magnetic_density: tesla,
  43. charge: coulomb,
  44. capacitance: farad,
  45. })