-
Notifications
You must be signed in to change notification settings - Fork 5
/
cooling.f90
89 lines (64 loc) · 2.32 KB
/
cooling.f90
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
!>
!! \brief This module contains data and subroutines for radiative cooling
!!
!! Module for Capreole / C2-Ray (f90)
!!
!! \b Author: Garrelt Mellema
!!
!! \b Date:
!!
!! \b Version: Collisional Ionization Equilibrium cooling
module radiative_cooling
! This module file contains subroutines for radiative cooling
! - coolin - calculate cooling rate
! - setup_cool - setup cooling table
! Version: CIE cooling
use precision, only: dp
implicit none
private
integer,parameter :: temppoints=61 !< number of points in cooling table
real(kind=dp),dimension(temppoints) :: cie_cool !< CIE cooling curve
real(kind=dp) :: mintemp !< lowest log10(temperature) in table
real(kind=dp) :: dtemp !< steps in log10(temperature) in table
public :: coolin, setup_cool
contains
!===========================================================================
!> Calculate the cooling rate
function coolin(nucldens,eldens,xh,temp0)
real(kind=dp) :: coolin
real(kind=dp),intent(in) :: nucldens !< number density
real(kind=dp),intent(in) :: eldens !< electron density
real(kind=dp),dimension(0:1),intent(in) :: xh !< H ionization fractions
real(kind=dp),intent(in) :: temp0 !< temperature
real(kind=dp) :: tpos, dtpos
integer :: itpos,itpos1
tpos=(log10(temp0)-mintemp)/dtemp+1.0d0
itpos=min(temppoints-1,max(1,int(tpos)))
dtpos=tpos-real(itpos)
itpos1=min(temppoints,itpos+1)
! Cooling curve
coolin=nucldens*eldens* &
(cie_cool(itpos)+(cie_cool(itpos1)-cie_cool(itpos))*dtpos)
end function coolin
!===========================================================================
!> Read in and set up the cooling table(s)
subroutine setup_cool ()
real(kind=dp),dimension(temppoints) :: temp
integer :: itemp
integer :: element,ion,nchck
! Open cooling table (CIE)
open(unit=22,file='tables/corocool.tab',status='old')
! Read the cooling data
do itemp=1,temppoints
read(22,*) temp(itemp),cie_cool(itemp)
enddo
close(22)
mintemp=temp(1)
dtemp=temp(2)-temp(1)
! not needed: maxtemp=temp(temppoints)
! Convert cooling to from log to linear
do itemp=1,temppoints
cie_cool(itemp)=10.0d0**cie_cool(itemp)
enddo
end subroutine setup_cool
end module radiative_cooling