DISPATCH
scaling.py
1 from __future__ import print_function
2 
3 class cgs:
4  name='cgs'
5  m_earth=5.972e27
6  m_sun=1.989e33
7  r_earth=6.371e8
8  grav=6.673e-8
9  yr=3.156e+7
10  au=1.498e+13
11  kms=1e+5
12  mu=2.
13  m_u=1.6726e-24
14  k_b=1.3807e-16
15  h_p=6.6260e-27
16  e=4.8032e-10
17  c=2.9979e10
18  stefan=5.6704e-8
19 
20 class SI:
21  name='SI'
22  m_earth=5.972e24
23  m_sun=1.989e30
24  r_earth=6.371e6
25  grav=6.673e-11
26  yr=3.156e+7
27  au=1.498e+11
28  kms=1e+3
29  mu=2.
30  m_u=1.6726e-27
31  k_b=1.3807e-23
32  h_p=6.62606e-34
33  e=1.6022e-19
34  c=2.9979e8
35  stefan=5.6704e-5
36 
37 def scaling(type='ISM',units=cgs,verbose=0,mu=2):
38  '''
39  Return a structure with scaling constants. Use e.g.
40 
41  scgs=scaling(cgs)
42  sSI=scaling(SI)
43  print (cgs.k_b, SI.k_b)
44  '''
45  if verbose>0:
46  print("using "+units.name+" units")
47  class s:
48  system=units.name
49  if type=='ISM':
50  l=units.pc
51  d=1e-24
52  v=1e5
53  t=l/v
54  elif type=='solar':
55  l=1e8
56  t=1e2
57  d=1e-7
58  v=l/t
59  m=d*l**3
60  p=d*v**2
61  g=units.grav*d*t**2
62  u=units.kms
63  e=m*u**2
64  temp = mu*(units.m_u)/(units.k_b)*v**2
65  return s