aboutsummaryrefslogtreecommitdiff
path: root/src/nuc_eos/eosmodule.F90
blob: 7ac049c07c2d90f1f87c1845c28f38bcce2c07d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"
#include "cctk_Functions.h"

 module eosmodule

   implicit none
   
   integer,save :: nrho,ntemp,nye

   integer,save :: warn_from !warn from given reflevel

   real*8 :: energy_shift = 0.0d0
   
   real*8 :: precision = 1.0d-9

! min-max values:
   real*8 :: eos_rhomin,eos_rhomax
   real*8 :: eos_yemin,eos_yemax
   real*8 :: eos_tempmin,eos_tempmax

   real*8 :: t_max_hack = 240.0d0

! basics
   integer, parameter :: nvars = 19
   real*8,pointer :: alltables(:,:,:,:)
  ! index variable mapping:
  !  1 -> logpress
  !  2 -> logenergy
  !  3 -> entropy
  !  4 -> munu
  !  5 -> cs2
  !  6 -> dedT
  !  7 -> dpdrhoe
  !  8 -> dpderho
  !  9 -> muhat
  ! 10 -> mu_e
  ! 11 -> mu_p
  ! 12 -> mu_n
  ! 13 -> xa
  ! 14 -> xh
  ! 15 -> xn
  ! 16 -> xp
  ! 17 -> abar
  ! 18 -> zbar
  ! 19 -> gamma

   real*8,pointer :: logrho(:)
   real*8,pointer :: logtemp(:)
   real*8,pointer :: ye(:)

! constants
   real*8,save :: mev_to_erg = 1.60217733d-6
   real*8,save :: amu_cgs = 1.66053873d-24
   real*8,save :: amu_mev = 931.49432d0
   real*8,save :: pi = 3.14159265358979d0
   real*8,save :: ggrav = 6.672d-8
   real*8,save :: temp_mev_to_kelvin = 1.1604447522806d10
   real*8,save :: clight = 2.99792458d10
   real*8,save :: kb_erg = 1.380658d-16
   real*8,save :: kb_mev = 8.61738568d-11   


 end module eosmodule

! This function is called from within readtable.c
! It creates pointers to the arrays given as parameters into arrays
! of the eos module.
subroutine setup_eosmodule(nrho_, ntemp_, nye_, alltables_, logrho_, logtemp_, ye_, energy_shift_)
 use eosmodule
 DECLARE_CCTK_PARAMETERS

 CCTK_INT  :: nrho_, ntemp_, nye_
 CCTK_REAL, TARGET :: alltables_(nrho_, ntemp_, nye_, 19)
 CCTK_REAL, TARGET :: logrho_(nrho_)
 CCTK_REAL, TARGET :: logtemp_(ntemp_)
 CCTK_REAL, TARGET :: ye_(nye_)
 CCTK_REAL :: energy_shift_

 nrho  = nrho_
 ntemp = ntemp_
 nye   = nye_

 alltables => alltables_
 logrho    => logrho_
 logtemp   => logtemp_
 ye        => ye_


 energy_shift = energy_shift_
 if(do_energy_shift.ne.1) then
     energy_shift = 0.0d0
  endif

 ! set min-max values:
 eos_rhomin = 10.0d0**logrho(1)
 eos_rhomax = 10.0d0**logrho(nrho)

 eos_yemin = ye(1)
 eos_yemax = ye(nye)

 eos_tempmin = 10.0d0**logtemp(1)
 eos_tempmax = 10.0d0**logtemp(ntemp)

end subroutine setup_eosmodule