30 character(len=*),
intent(in) :: tabledir
33 character(len=:),
allocatable :: amrvac_dir, path_table_dir
35 call get_environment_variable(
"AMRVAC_DIR", amrvac_dir)
36 path_table_dir = trim(amrvac_dir)//
"/src/rhd/CAK_tables/"//trim(tabledir)
47 subroutine set_cak_opacity(rho, temp, alpha_output, Qbar_output, Q0_output, kappae_output)
49 double precision,
intent(in) :: rho, temp
50 double precision,
intent(out) :: alpha_output, qbar_output, q0_output, kappae_output
53 double precision :: d_input, t_input, kappa_cak
58 d_input = min(-7.d0-1.d-5, d_input)
59 d_input = max(-16.d0+1.d-5, d_input)
60 t_input = min(5d0-1.d-5, t_input)
61 t_input = max(4d0+1.d-5, t_input)
65 alpha_output, qbar_output, q0_output, kappae_output)
73 character(*),
intent(in) :: filename
74 double precision,
intent(out) :: K(iDmin:iDmax,iTmin:iTmax), D(iDmin:iDmax), T(iTmin:iTmax)
80 open(unit=1, status=
'old', file=trim(filename))
83 read(1,*) dum, t(itmin:itmax)
87 read(1,*) d(row), k(row,itmin:itmax)
97 logD_list, logT_list, D, T, &
100 double precision,
intent(in) :: K1_vals(iDmin:iDmax,iTmin:iTmax)
101 double precision,
intent(in) :: K2_vals(iDmin:iDmax,iTmin:iTmax)
102 double precision,
intent(in) :: K3_vals(iDmin:iDmax,iTmin:iTmax)
103 double precision,
intent(in) :: K4_vals(iDmin:iDmax,iTmin:iTmax)
104 double precision,
intent(in) :: logD_list(iDmin:iDmax), logT_list(iTmin:iTmax)
105 double precision,
intent(in) :: D, T
106 double precision,
intent(out) :: K1, K2, K3, K4
109 integer :: low_D_index, up_D_index, low_T_index, up_T_index
111 if (d .gt. maxval(logd_list))
then
113 low_d_index = idmax-1
115 elseif (d .lt. minval(logd_list))
then
123 if (t .gt. maxval(logt_list))
then
125 low_t_index = itmax-1
127 elseif (t .lt. minval(logt_list))
then
135 call interpolate_krt(low_d_index, up_d_index, low_t_index, up_t_index, &
136 logd_list, logt_list, k1_vals, d, t, k1)
138 call interpolate_krt(low_d_index, up_d_index, low_t_index, up_t_index, &
139 logd_list, logt_list, k2_vals, d, t, k2)
141 call interpolate_krt(low_d_index, up_d_index, low_t_index, up_t_index, &
142 logd_list, logt_list, k3_vals, d, t, k3)
144 call interpolate_krt(low_d_index, up_d_index, low_t_index, up_t_index, &
145 logd_list, logt_list, k4_vals, d, t, k4)
153 integer,
intent(in) :: imin, imax
154 double precision,
intent(in) :: var_in, var_list(imin:imax)
155 integer,
intent(out) :: low_i, up_i
158 double precision :: low_val, up_val, res(imin:imax)
160 res = var_list - var_in
163 up_val = minval(res, mask = res .ge. 0) + var_in
164 low_val = maxval(res, mask = res .le. 0) + var_in
167 up_i = minloc(abs(var_list - up_val),1) + imin -1
168 low_i = minloc(abs(var_list - low_val),1) + imin -1
170 if (up_i .eq. low_i) low_i = low_i - 1
175 subroutine interpolate_krt(low_r, up_r, low_t, up_t, logD_list, logT_list, Kappa_vals, D, T, kappa_interp)
177 integer,
intent(in) :: low_r, up_r, low_t, up_t
178 double precision,
intent(in) :: Kappa_vals(iDmin:iDmax,iTmin:iTmax)
179 double precision,
intent(in) :: logD_list(iDmin:iDmax), logT_list(iTmin:iTmax)
180 double precision,
intent(in) :: D, T
181 double precision,
intent(out) :: kappa_interp
184 double precision :: r1, r2, t1, t2, k1, k2, k3, k4, ka, kb
203 r1 = logd_list(low_r)
205 t1 = logt_list(low_t)
208 k1 = kappa_vals(low_r, low_t)
209 k2 = kappa_vals(low_r, up_t)
210 k3 = kappa_vals(up_r, low_t)
211 k4 = kappa_vals(up_r, up_t)
222 double precision,
intent(in) :: x, x1, x2, y1, y2
223 double precision,
intent(out) :: y
225 y = y1 + (x-x1)*(y2-y1)/(x2-x1)
This module reads in CAK line opacities in the Gayley (1995) notation (alpha, Qbar,...
double precision, dimension(itmin:itmax), public logt_list
double precision, dimension(idmin:idmax, itmin:itmax), public q0_vals
double precision, dimension(idmin:idmax, itmin:itmax), public qbar_vals
integer, parameter idmin
min and max indices for R,T-range in opacity table
double precision, dimension(idmin:idmax, itmin:itmax), public alpha_vals
The opacity tables are read once and stored globally.
subroutine, public set_cak_opacity(rho, temp, alpha_output, Qbar_output, Q0_output, kappae_output)
This subroutine calculates the opacity for a given temperature-density structure. Opacities are read ...
subroutine get_val_comb(K1_vals, K2_vals, K3_vals, K4_vals, logD_list, logT_list, D, T, K1, K2, K3, K4)
This subroutine looks in the table for the four couples (T,rho) surrounding a given input T and rho.
double precision, dimension(idmin:idmax), public logd_list
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 interpolate_krt(low_r, up_r, low_t, up_t, logD_list, logT_list, Kappa_vals, D, T, kappa_interp)
This subroutine does a bilinear interpolation in the R,T-plane.
subroutine interpolate1d(x1, x2, x, y1, y2, y)
Interpolation in one dimension.
subroutine, public init_cak_table(tabledir)
This routine is called when the FLD radiation module is initialised.
subroutine read_table(D, T, K, filename)
This routine reads in 1-D (T,rho) values from a line opacity table and gives back as output the 1-D (...
double precision, dimension(idmin:idmax, itmin:itmax), public kappae_vals