Nbody6
 All Files Functions Variables
units.f
Go to the documentation of this file.
1  SUBROUTINE units
2 *
3 *
4 * Initialization of units & scaling factors.
5 * ------------------------------------------
6 *
7  include 'common6.h'
8 *
9 *
10 * Define GM, AU and PC in cgs units (2009 IAU values).
11  gm = 1.327 124 420 99 d+26
12  au = 1.49597870700 d+13
13  pc = 1296000.0d0/twopi*au
14 *
15 * Form scaling factors for binary periods A*SQRT(A/M) to yrs and days.
16  yrs = (rbar*1296000.0d0/twopi)**1.5/sqrt(zmbar)
17  days = 365.25*yrs
18 *
19 * Specify conversion factors for lengths to solar radii & AU.
20  rsun = 6.960d+10
21  su = pc/rsun*rbar
22  rau = pc/au*rbar
23 *
24 * Copy solar mass scaling to new variable (M = BODY*<M>).
25  smu = zmbar
26 *
27 * Form time scale in seconds and velocity scale in km/sec.
28  tstar = sqrt(pc/gm)*pc
29  vstar = 1.0d-05*sqrt(gm/pc)
30 *
31 * Convert time scale from units of seconds to million years.
32  tstar = tstar/(3.15576d+07*1.0d+06)
33 *
34 * Ensure ZMBAR & RBAR > 0 (=0: assume <M>/Sun = 1, RBAR = 1 pc).
35  IF (zmbar.LE.0.0d0) zmbar = float(n)/zmass
36  IF (rbar.LE.0.0d0) rbar = 1.0
37 *
38 * Scale to working units of RBAR in pc & ZMBAR in solar masses.
39  tstar = tstar*sqrt(rbar**3/(zmass*zmbar))
40  vstar = vstar*sqrt(zmass*zmbar/rbar)
41 *
42 * Copy TSTAR to secondary time-scale factor (just in case).
43  tscale = tstar
44 *
45 * Physical scaling: X, M, V, T from RBAR*X, ZMBAR*M, VSTAR*V, TSTAR*T.
46  WRITE (6,10) rbar, zmbar, vstar, tstar, bodym*zmbar, su
47  10 FORMAT (/,12x,'PHYSICAL SCALING: R* =',f5.2,' M* =',f8.1,
48  & ' V* =',f6.3,' T* =',f6.3,' <M> =',f5.2,
49  & ' SU =',1p,e8.1)
50 *
51 * Define relevant parameter for the GR case (RZ = 6*<m>/c^2).
52  IF (kz(27).EQ.3.OR.kz(28).GT.0) THEN
53  clight = 3.0d+05/vstar
54  rz = 6.0*zmass/(float(n)*clight**2)
55  WRITE (6,20) vstar, clight, rz
56  20 FORMAT (/,12x,'GR SCALING: V* =',1p,e10.2,' C =',e10.2,
57  & ' RZ =',e10.2)
58  ELSE
59  rz = 0.0
60  clight = 0.0
61  END IF
62 *
63  RETURN
64 *
65  END