Simple example of unit usage#

This simple example shows how to use units in Shamrock

8 import shamrock

The default constructor will provide SI units

12 si = shamrock.UnitSystem()
13
14 # Get the constants in SI
15 sicte = shamrock.Constants(si)
18 print("An au in SI units is", sicte.au())
An au in SI units is 149597870700.0
22 # Shamrock unit system is based on the definition of the base units relative to SI ones
23 # For example to set the time unit one you provide the given time in SI units (seconds).
24
25 # Create a unit system with time in years, length in au, mass in solar masses
26 codeu = shamrock.UnitSystem(
27     unit_time=3600 * 24 * 365,
28     unit_length=sicte.au(),
29     unit_mass=sicte.sol_mass(),
30 )
31
32 # Get the physical constants in this unit system
33 ucte = shamrock.Constants(codeu)

Total running time of the script: (0 minutes 0.490 seconds)

Estimated memory usage: 159 MB

Gallery generated by Sphinx-Gallery