Note
Go to the end to download the full example code.
Simple exemple of unit usage#
This simple example shows how to use units in Shamrock
8 import shamrock
12 # The default constructor will provide SI units
13 si = shamrock.UnitSystem()
14
15 # Get the constants in SI
16 sicte = shamrock.Constants(si)
19 print("An au in SI units is", sicte.au())
An au in SI units is 149597870700.0
23 # Shamrock unit system is based on the definition of the base units relative to SI ones
24 # For exemple to set the time unit one you provide the given time in SI units (seconds).
25
26 # Create a unit system with time in years, length in au, mass in solar masses
27 codeu = shamrock.UnitSystem(
28 unit_time=3600 * 24 * 365,
29 unit_length=sicte.au(),
30 unit_mass=sicte.sol_mass(),
31 )
32
33 # Get the physical constants in this unit system
34 ucte = shamrock.Constants(codeu)
Total running time of the script: (0 minutes 0.203 seconds)
Estimated memory usage: 71 MB