DISPATCH
scaling_mod.f90
1 !===============================================================================
2 !> Define code units, in terms of (here) CGS units
3 !===============================================================================
4 MODULE scaling_mod
5  USE units_mod
6  USE io_mod
7  USE trace_mod
8  USE math_mod
9  implicit none
10  private
11  !-----------------------------------------------------------------------------
12  ! Extend the units_t data type, which contains only the three fundamental
13  ! units: length, mass, and time (cf. CGS and MKS)
14  !-----------------------------------------------------------------------------
15  type, public, extends(units_t):: scaling_t
16  real(kind=8):: d, e, ee, p, u, temp, grav, mu, kr, b
17  contains
18  procedure:: init
19  end type
20  type(scaling_t), public:: scaling
21 CONTAINS
22 !===============================================================================
23 !> Initialize code units:
24 !===============================================================================
25 SUBROUTINE init (self)
26  class(scaling_t):: self
27  logical, save:: first_time=.true.
28  !-----------------------------------------------------------------------------
29  if (.not.first_time) return
30  call trace%begin ('scaling_t%init')
31  if (io%master) print *, &
32  '-------------------------------- scaling_mod -------------------------'
33  first_time = .false.
34  call cgs%init
35  !--------------------------- defining quantities ---------------------
36  self%system = 'cgs' ! pass on to Python
37  self%l = 1d0 ! length = 1Mm = 1e8 cm
38  self%d = 1d0 ! photospheric density
39  self%t = 1d0 ! time = 100 sec
40  !--------------------------- derived quantities ----------------------
41  self%u = self%l/self%t ! speed
42  self%m = self%d*self%l**3 ! mass
43  self%p = self%d*self%u**2 ! pressure = energy density [dyne / cm2]
44  self%kr = 1.0/(self%d*self%l) ! rosseland opacity [cm2/g]
45  self%ee = self%u**2 ! specific energy
46  self%e = self%m*self%u**2 ! energy
47  self%b = self%l**(-0.5)*self%m**0.5*self%t**(-1) ! magnetic flux density
48  self%mu = 2.4
49  self%temp = self%mu*(cgs%m_u/self%m)/(cgs%k_b/self%e) ! temperature for given mu
50  self%grav = cgs%grav*(self%m/self%l**3)*self%t**2 ! constant of gravity
51  if (io%master) then
52  print 1,' CODE UNITS: (cgs):'
53  print 1,' length: ',self%l
54  print 1,' mass: ',self%m
55  print 1,' time: ',self%t
56  print 1,' velocity: ',self%u
57  print 1,' density: ',self%d
58  print 1,' pressure: ',self%p
59  print 1,'magnetic flux density: ',self%b
60  print 1,' energy: ',self%e
61  print 1,' gravity: ',self%grav
62  print 1,' temperature: ',self%temp
63  1 format(1x,a,1p,e11.3)
64  end if
65  call self%output
66  call trace%end()
67 END SUBROUTINE init
68 END MODULE scaling_mod
Define code units, in terms of (here) CGS units.
Definition: scaling_mod.f90:4
Fundamental constants in CGS and SI units.
Definition: units_mod.f90:4
Fundamental constants in CGS and SI units.
Definition: math_mod.f90:4
Definition: io_mod.f90:4