mks.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. MKS unit system.
  3. MKS stands for "meter, kilogram, second".
  4. """
  5. from sympy.physics.units import UnitSystem
  6. from sympy.physics.units.definitions import gravitational_constant, hertz, joule, newton, pascal, watt, speed_of_light, gram, kilogram, meter, second
  7. from sympy.physics.units.definitions.dimension_definitions import (
  8. acceleration, action, energy, force, frequency, momentum,
  9. power, pressure, velocity, length, mass, time)
  10. from sympy.physics.units.prefixes import PREFIXES, prefix_unit
  11. from sympy.physics.units.systems.length_weight_time import dimsys_length_weight_time
  12. dims = (velocity, acceleration, momentum, force, energy, power, pressure,
  13. frequency, action)
  14. units = [meter, gram, second, joule, newton, watt, pascal, hertz]
  15. all_units = []
  16. # Prefixes of units like gram, joule, newton etc get added using `prefix_unit`
  17. # in the for loop, but the actual units have to be added manually.
  18. all_units.extend([gram, joule, newton, watt, pascal, hertz])
  19. for u in units:
  20. all_units.extend(prefix_unit(u, PREFIXES))
  21. all_units.extend([gravitational_constant, speed_of_light])
  22. # unit system
  23. MKS = UnitSystem(base_units=(meter, kilogram, second), units=all_units, name="MKS", dimension_system=dimsys_length_weight_time, derived_units={
  24. power: watt,
  25. time: second,
  26. pressure: pascal,
  27. length: meter,
  28. frequency: hertz,
  29. mass: kilogram,
  30. force: newton,
  31. energy: joule,
  32. velocity: meter/second,
  33. acceleration: meter/(second**2),
  34. })
  35. __all__ = [
  36. 'MKS', 'units', 'all_units', 'dims',
  37. ]