25 character(len=*),
intent(in) :: tablename
28 character(len=256) :: amrvac_dir, path_table_dir
30 call get_environment_variable(
"AMRVAC_DIR", amrvac_dir)
33 path_table_dir = trim(amrvac_dir)//
"src/tables/OPAL_tables/"//trim(tablename)
42 double precision,
intent(in) :: rho, temp
43 double precision,
intent(out) :: kappa
45 double precision :: logr_in, logt_in, logkappa_out
48 logr_in = log10(rho/(temp*1d-6)**3)
54 do while (logkappa_out .gt. 9.0d0)
55 logr_in = logr_in + 0.5d0
60 do while (logkappa_out .eq. 0.0d0)
61 logr_in = logr_in - 0.5d0
66 kappa = 10d0**logkappa_out
73 character(*),
intent(in) :: filename
74 double precision,
intent(out) :: K(iTmin:iTmax,iRmin:iRmax), R(iRmin:iRmax), T(iTmin:iTmax)
80 open(unit=1, status=
'old', file=trim(filename))
88 read(1,*) dum, r(irmin:irmax)
93 read(1,
'(f4.2,19f7.3)') t(row), k(row,irmin:irmax)
102 subroutine get_kappa(Kappa_vals, logR_list, logT_list, R, T, K)
104 double precision,
intent(in) :: Kappa_vals(iTmin:iTmax,iRmin:iRmax)
105 double precision,
intent(in) :: logR_list(iRmin:iRmax), logT_list(iTmin:iTmax)
106 double precision,
intent(in) :: R, T
107 double precision,
intent(out) :: K
110 integer :: low_R_index, up_R_index
111 integer :: low_T_index, up_T_index
113 if (r .gt. maxval(logr_list))
then
115 low_r_index = irmax-1
117 elseif (r .lt. minval(logr_list))
then
125 if (t .gt. maxval(logt_list))
then
127 low_t_index = itmax-1
129 elseif ( t .lt. minval(logt_list))
then
137 call interpolate_krt(low_r_index, up_r_index, low_t_index, up_t_index, logr_list, logt_list, kappa_vals, r, t, k)
145 integer,
intent(in) :: imin, imax
146 double precision,
intent(in) :: var_in, var_list(imin:imax)
147 integer,
intent(out) :: low_i, up_i
150 double precision :: low_val, up_val, res(imin:imax)
152 res = var_list - var_in
155 up_val = minval(res, mask = res .ge. 0) + var_in
156 low_val = maxval(res, mask = res .le. 0) + var_in
159 up_i = minloc(abs(var_list - up_val),1) + imin -1
160 low_i = minloc(abs(var_list - low_val),1) + imin -1
162 if (up_i .eq. low_i) low_i = low_i - 1
167 subroutine interpolate_krt(low_r, up_r, low_t, up_t, logR_list, logT_list, Kappa_vals, R, T, kappa_interp)
169 integer,
intent(in) :: low_r, up_r, low_t, up_t
170 double precision,
intent(in) :: Kappa_vals(iTmin:iTmax,iRmin:iRmax)
171 double precision,
intent(in) :: logR_list(iRmin:iRmax), logT_list(iTmin:iTmax)
172 double precision,
intent(in) :: R, T
173 double precision,
intent(out) :: kappa_interp
176 double precision :: r1, r2, t1, t2, k1, k2, k3, k4, ka, kb
195 r1 = logr_list(low_r)
197 t1 = logt_list(low_t)
200 k1 = kappa_vals(low_t, low_r)
201 k2 = kappa_vals(low_t, up_r)
202 k3 = kappa_vals(up_t, low_r)
203 k4 = kappa_vals(up_t, up_r)
214 double precision,
intent(in) :: x, x1, x2, y1, y2
215 double precision,
intent(out) :: y
217 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
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,...
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 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 interpolate1d(x1, x2, x, y1, y2, y)
Interpolation in one dimension.
double precision, dimension(irmin:irmax), public logr_list
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.