26 character(len=*),
intent(in) :: tablename
29 character(len=:),
allocatable :: amrvac_dir, path_table_dir
31 call get_environment_variable(
"AMRVAC_DIR", amrvac_dir)
34 path_table_dir = trim(amrvac_dir)//
"/src/rhd/OPAL_tables/"//trim(tablename)
45 double precision,
intent(in) :: rho, temp
46 double precision,
intent(out) :: kappa
49 double precision :: logr_in, logt_in, logkappa_out
52 logr_in = log10(rho/(temp*1d-6)**3)
58 do while (logkappa_out .gt. 9.0d0)
59 logr_in = logr_in + 0.5d0
64 do while (logkappa_out .eq. 0.0d0)
65 logr_in = logr_in - 0.5d0
70 kappa = 10d0**logkappa_out
78 character(*),
intent(in) :: filename
79 double precision,
intent(out) :: K(iTmin:iTmax,iRmin:iRmax), R(iRmin:iRmax), T(iTmin:iTmax)
85 open(unit=1, status=
'old', file=trim(filename))
93 read(1,*) dum, r(irmin:irmax)
98 read(1,
'(f4.2,19f7.3)') t(row), k(row,irmin:irmax)
107 subroutine get_kappa(Kappa_vals, logR_list, logT_list, R, T, K)
109 double precision,
intent(in) :: Kappa_vals(iTmin:iTmax,iRmin:iRmax)
110 double precision,
intent(in) :: logR_list(iRmin:iRmax), logT_list(iTmin:iTmax)
111 double precision,
intent(in) :: R, T
112 double precision,
intent(out) :: K
115 integer :: low_R_index, up_R_index
116 integer :: low_T_index, up_T_index
118 if (r .gt. maxval(logr_list))
then
120 low_r_index = irmax-1
122 elseif (r .lt. minval(logr_list))
then
130 if (t .gt. maxval(logt_list))
then
132 low_t_index = itmax-1
134 elseif ( t .lt. minval(logt_list))
then
142 call interpolate_krt(low_r_index, up_r_index, low_t_index, up_t_index, logr_list, logt_list, kappa_vals, r, t, k)
150 integer,
intent(in) :: imin, imax
151 double precision,
intent(in) :: var_in, var_list(imin:imax)
152 integer,
intent(out) :: low_i, up_i
155 double precision :: low_val, up_val, res(imin:imax)
157 res = var_list - var_in
160 up_val = minval(res, mask = res .ge. 0) + var_in
161 low_val = maxval(res, mask = res .le. 0) + var_in
164 up_i = minloc(abs(var_list - up_val),1) + imin -1
165 low_i = minloc(abs(var_list - low_val),1) + imin -1
167 if (up_i .eq. low_i) low_i = low_i - 1
172 subroutine interpolate_krt(low_r, up_r, low_t, up_t, logR_list, logT_list, Kappa_vals, R, T, kappa_interp)
174 integer,
intent(in) :: low_r, up_r, low_t, up_t
175 double precision,
intent(in) :: Kappa_vals(iTmin:iTmax,iRmin:iRmax)
176 double precision,
intent(in) :: logR_list(iRmin:iRmax), logT_list(iTmin:iTmax)
177 double precision,
intent(in) :: R, T
178 double precision,
intent(out) :: kappa_interp
181 double precision :: r1, r2, t1, t2, k1, k2, k3, k4, ka, kb
200 r1 = logr_list(low_r)
202 t1 = logt_list(low_t)
205 k1 = kappa_vals(low_t, low_r)
206 k2 = kappa_vals(low_t, up_r)
207 k3 = kappa_vals(up_t, low_r)
208 k4 = kappa_vals(up_t, up_r)
219 double precision,
intent(in) :: x, x1, x2, y1, y2
220 double precision,
intent(out) :: y
222 y = y1 + (x-x1)*(y2-y1)/(x2-x1)
This module reads in Rosseland-mean opacities from OPAL tables. Table opacity values are given in bas...
integer, parameter irmin
min and max indices for R,T-range in opacity table
double precision, dimension(itmin:itmax), public logt_list
subroutine, public init_opal_table(tablename)
This subroutine is called when the FLD radiation module is initialised. The OPAL tables for different...
double precision, dimension(itmin:itmax, irmin:irmax), public kappa_vals
The opacity tables are read once and stored globally in Kappa_vals.
subroutine, public set_opal_opacity(rho, temp, kappa)
This subroutine calculates the opacity for a given temperature-density structure. Opacities are read ...
subroutine get_low_up_index(var_in, var_list, imin, imax, low_i, up_i)
This subroutine finds the indices in rho and T arrays of the two values surrounding the input rho and...
subroutine interpolate1d(x1, x2, x, y1, y2, y)
Interpolation in one dimension.
subroutine get_kappa(Kappa_vals, logR_list, logT_list, R, T, K)
This subroutine looks in the table for the four couples (T,rho) surrounding a given input T and rho.
subroutine interpolate_krt(low_r, up_r, low_t, up_t, logR_list, logT_list, Kappa_vals, R, T, kappa_interp)
This subroutine does a bilinear interpolation in the R,T-plane.
double precision, dimension(irmin:irmax), public logr_list
subroutine read_table(R, T, K, filename)
This routine reads in 1-D (rho,T) values from an opacity table and gives back as output the 1-D (rho,...