7 integer,
parameter ::
rmin = 2
8 integer,
parameter ::
rmax = 20
9 integer,
parameter ::
tmin = 7
10 integer,
parameter ::
tmax = 76
39 double precision,
intent(in) :: he_abundance
40 character(6),
intent(in) :: tablename
43 double precision :: y1 = 0.1000
44 double precision :: y2 = 0.0999
47 CALL get_environment_variable(
"AMRVAC_DIR",
amrvac_dir)
112 double precision,
intent(in) :: rho, temp
113 double precision,
intent(out) :: kappa
115 double precision :: r_input, t_input, k_output
117 r_input = rho/(temp*1d-6)**3
120 r_input = dlog10(r_input)
121 t_input = dlog10(t_input)
126 do while (k_output .gt. 9.0d0)
128 r_input = r_input + 0.5
133 do while (k_output .eq. 0.0d0)
135 r_input = r_input - 0.5d0
139 kappa = 10d0**k_output
147 double precision,
intent(out) :: K(7:76,2:20), R(2:20), T(7:76)
148 character(*),
intent(in) :: filename
153 OPEN(1,status =
'old', file=trim(
fileplace)//filename)
161 READ(1,*) dum,r(2:20)
167 READ(1,
'(f4.2,19f7.3)') t(row), k(row,2:20)
179 double precision,
intent(in) :: K1(7:76,2:20), K2(7:76,2:20)
180 double precision,
intent(in) :: Y1, Y2, Y_in
181 double precision,
intent(out) :: K_interp(7:76,2:20)
187 call interpolate1d(y1,y2,y_in,k1(row,colum),k2(row,colum),k_interp(row,colum))
196 subroutine get_kappa(Kappa_vals, Log_R_list, Log_T_list, R, T, K)
198 double precision,
intent(in) :: Kappa_vals(7:76,2:20)
199 double precision,
intent(in) :: Log_R_list(2:20)
200 double precision,
intent(in) :: Log_T_list(7:76)
202 double precision,
intent(in) :: R, T
203 double precision,
intent(out) :: K
205 integer :: low_r_index, up_r_index
206 integer :: low_t_index, up_t_index
208 if (r .gt. maxval(log_r_list))
then
212 elseif (r .lt. minval(log_r_list))
then
220 if (t .gt. maxval(log_t_list))
then
224 elseif ( t .lt. minval(log_t_list))
then
232 call interpolate_krt(low_r_index, up_r_index, low_t_index, up_t_index, log_r_list, log_t_list, kappa_vals, r, t, k)
240 integer,
intent(in) :: imin, imax
241 double precision,
intent(in) :: x
242 double precision,
intent(in) :: x_list(imin:imax)
244 integer,
intent(out) :: low_i, up_i
246 double precision :: low_val, up_val
247 double precision :: res(imin:imax)
251 up_val = minval(res, mask = res .ge. 0) + x
252 low_val = maxval(res, mask = res .le. 0) + x
254 up_i = minloc(abs(x_list - up_val),1) + imin -1
255 low_i = minloc(abs(x_list - low_val),1) + imin -1
258 if (up_i .eq. low_i) low_i = low_i - 1
263 subroutine interpolate_krt(low_r, up_r, low_t, up_t, Log_R_list, Log_T_list, Kappa_vals, R, T, k_interp)
265 integer,
intent(in) :: low_r, up_r, low_t, up_t
266 double precision,
intent(in) :: Kappa_vals(7:76,2:20)
267 double precision,
intent(in) :: Log_R_list(2:20)
268 double precision,
intent(in) :: Log_T_list(7:76)
269 double precision,
intent(in) :: R,T
270 double precision,
intent(out) :: k_interp
272 double precision :: r1,r2,t1,t2
273 double precision :: k1, k2, k3, k4
274 double precision :: ka, kb
294 r1 = log_r_list(low_r)
295 r2 = log_r_list(up_r)
296 t1 = log_t_list(low_t)
297 t2 = log_t_list(up_t)
299 k1 = kappa_vals(low_t, low_r)
300 k2 = kappa_vals(low_t, up_r)
301 k3 = kappa_vals(up_t, low_r)
302 k4 = kappa_vals(up_t, up_r)
314 double precision,
intent(in) :: x, x1, x2
315 double precision,
intent(in) :: y1, y2
316 double precision,
intent(out) :: y
318 y = y1 + (x-x1)*(y2-y1)/(x2-x1)
327 double precision,
intent(in) :: x, x1, x2
328 double precision,
intent(in) :: y1, y2
329 double precision,
intent(out) :: y
331 double precision :: expx, expx1, expx2
332 double precision :: expy1, expy2
341 y = expy1 + (expx-expx1)*(expy2-expy1)/(expx2-expx1)
subroutine log_interpolate1d(x1, x2, x, y1, y2, y)
Interpolation on logarithmic scale.
This module reads in opacities from opal tables.
double precision, dimension(2:20), public log_r_list
subroutine get_kappa(Kappa_vals, Log_R_list, Log_T_list, R, T, K)
This subroutine looks in the table for the four couples (T,R)
integer, parameter rmin
min and max indices for R,T-range in opacity table
double precision, dimension(7:76, 2:20), public kappa_vals
The opacity tables are read once and stored globally in Kappa_vals.
subroutine interpolate_two_tables(Y1, Y2, Y_in, K1, K2, K_interp)
This subroutine creates a new table for a given He abundance,.
subroutine get_low_up_index(x, x_list, imin, imax, low_i, up_i)
this subroutine finds the indexes in R and T arrays of the two values surrounding the input R and T
subroutine interpolate_krt(low_r, up_r, low_t, up_t, Log_R_list, Log_T_list, Kappa_vals, R, T, k_interp)
This subroutine does a bilinear interpolation in the R,T-plane.
character(255), public fileplace
double precision, dimension(7:76, 2:20), public kappa_vals2
double precision, dimension(7:76), public log_t_list
subroutine, public set_opal_opacity(rho, temp, kappa)
This subroutine calculates the opacity for a given temperature-density structure. The opacities are r...
subroutine interpolate1d(x1, x2, x, y1, y2, y)
Interpolation in one dimension.
double precision, dimension(7:76, 2:20), public kappa_vals1
subroutine, public init_opal(He_abundance, tablename)
This routine is called when the fld radiation module is initialised. Here, the tables for different H...
character(255), public amrvac_dir
subroutine read_table(R, T, K, filename)
This routine reads out values and arguments from an opacity table.