53 integer,
intent(in) :: igrid, level
54 integer,
intent(inout) :: my_refine, my_coarsen
56 double precision :: blo, bhi
64 my_refine = 1; my_coarsen = 0
66 my_refine = -1; my_coarsen = -1
68 my_refine = 0; my_coarsen = 1
84 double precision :: tau, taumax, b0, ap, jb_err_deep, jmax, jmin, chimax, chimin
86 run_bc = [bc_h_periodic, bc_hlo_thermal, bc_hhi_thermal, bc_lo_thermal, bc_hi_thermal]
87 bc_h_periodic = .false.; bc_hlo_thermal = .true.; bc_hhi_thermal = .true.
88 bc_lo_thermal = .true.; bc_hi_thermal = .false.
91 dxg = 1.0d0; dyg = 1.0d0
94 if(.not.
allocated(mux))
call rt_sc_init()
99 ap = dble(nyg-j)/dble(nyg-1)
101 chi_g(:,j) = (taumax/dble(nyg)) * 10.0d0**(6.0d0*ap - 3.0d0)
108 call sc_sweep_2d(mux(k), muy(k))
110 jm_g(:,:) = jm_g(:,:) + wmu(k)*ii_g(:,:)
112 jmax = maxval(jm_g); jmin = minval(jm_g)
113 chimax = maxval(chi_g); chimin = minval(chi_g)
116 tau = 0.0d0; jb_err_deep = 0.0d0
118 tau = tau + chi_g(1,j)*dyg
120 if(tau > 10.0d0) jb_err_deep = max(jb_err_deep, dabs(jm_g(1,j)-b_g(1,j))/b_g(1,j))
124 print *,
"=== rt_sc_selftest (uniform-source slab, B0=1) ==="
125 print *,
" grid nxg,nyg =", nxg, nyg,
" rays =", rt_sc_nray
126 print *,
" chi per-cell range :", chimin, chimax
127 print *,
" J range :", jmin, jmax,
" (should be finite, in [0, ~B0])"
128 print *,
" max |J-B|/B for tau>10 (deep thermalisation, want <~1e-2):", jb_err_deep
129 print *,
" J at top cell (thin), col1 :", jm_g(1,nyg)
130 print *,
" J at bottom cell (deep), col1 :", jm_g(1,1)
131 if(jmax < bigdouble .and. jmin >= -1.0
d-10 .and. jb_err_deep < 5.0
d-2)
then
132 print *,
" result: pass (finite, non-negative, thermalises deep)"
134 print *,
" result: fail"
137 bc_h_periodic = run_bc(1); bc_hlo_thermal = run_bc(2); bc_hhi_thermal = run_bc(3)
138 bc_lo_thermal = run_bc(4); bc_hi_thermal = run_bc(5)
150 double precision :: taub(ixg^t), tau_up, fy_up, ww, gbuf(2), gout(2)
151 double precision,
allocatable :: tautop(:,:)
152 integer :: igrid, iblk, ih, iv, i1, i2, ig, ierr
155 if(
i_frad < 0)
call mpistop(
"rt_sc_emergent_tau1: i_frad slot not registered")
156 if(.not.
associated(rt_sc_chib))
call mpistop(
"rt_sc_emergent_tau1: opacity callback not set")
169 tau_up = tautop(ig,
wv_bj(iblk))
173 fy_up = ps(igrid)%w(i1,i2,
i_frad)
175 call hv(ih, iv, i1, i2)
179 gbuf(1) = gbuf(1) + fy_up + ww*(ps(igrid)%w(i1,i2,
i_frad)-fy_up)
180 gbuf(2) = gbuf(2) + 1.0d0
184 fy_up = ps(igrid)%w(i1,i2,
i_frad)
189 call mpi_allreduce(gbuf, gout, 2, mpi_double_precision, mpi_sum,
icomm, ierr)
201 integer,
intent(in) :: ixi^
l, ixo^
l
202 double precision,
intent(in) :: qdt, wct(ixi^s,1:nw), x(ixi^s,1:
ndim)
203 double precision,
intent(inout) :: w(ixi^s,1:nw)
206 logical,
intent(in) :: thin_share
208 logical,
intent(in) :: e_internal
211 double precision :: egas, ke, em, qlim, dn, qc, te(ixi^s), pth(ixi^s)
215 call eos%get_Te(wct, x, ixi^
l, ixo^
l, te)
216 call eos%get_thermal_pressure(wct, x, ixi^
l, ixo^
l, pth)
218 do ix2=ixomin2,ixomax2
219 do ix1=ixomin1,ixomax1
222 if(qc == 0.0d0) cycle
227 egas = wct(ix1,ix2,iw_e)
229 ke = 0.5d0*sum(wct(ix1,ix2,iw_mom(:))**2)/wct(ix1,ix2,iw_rho)
231 if(
allocated(iw_mag)) em = 0.5d0*sum(wct(ix1,ix2,iw_mag(:))**2)
232 egas = wct(ix1,ix2,iw_e) - ke - em
237 dn =
rt_sc_cfl*max(egas,smalldouble)/max(qdt,smalldouble)
238 qlim = qc*dn/max(dn,dabs(qc))
240 w(ix1,ix2,iw_e) = w(ix1,ix2,iw_e) + qdt*qlim
257 double precision,
intent(in) :: te_code
259 double precision,
intent(in) :: y_code
261 double precision,
intent(in) :: p_code
262 double precision :: w_thin, pr
274 * max(0.0d0, 1.0d0 - pr*pr)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Equation of state for AMRVAC, handled through a single eos_container object.
This module contains definitions of global parameters and variables and some generic functions/subrou...
double precision unit_pressure
Physical scaling factor for pressure.
integer, parameter ndim
Number of spatial dimensions for grid variables.
character(len=std_len), dimension(:), allocatable par_files
Which par files are used as input.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
double precision, dimension(:), allocatable, parameter d
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision unit_temperature
Physical scaling factor for temperature.
integer, parameter rpxmax0_
integer, parameter rpxmin0_
Public face of the short-characteristics (SC) radiative transfer and its coupling to the (M)HD.
pure elemental double precision function, public rt_sc_thin_weight(te_code, y_code, p_code)
Share of the radiative losses taken by the optically thin treatment, with SC taking the rest,...
subroutine, public rt_sc_add_source(qdt, ixil, ixol, wct, w, x, thin_share, e_internal)
Unsplit heating source of one block and stage, e += qdt Q, with Q read from i_qrad,...
subroutine, public rt_sc_selftest()
Self-test of the real sweep on an analytic slab. J must approach B where the slab is optically thick,...
subroutine, public rt_sc_emergent_tau1()
Horizontal mean of Fy on the tau = rt_sc_tau_emergent surface, the photosphere, into rt_sc_Ftau1....
subroutine, public rt_sc_pin_refine(igrid, level, my_refine, my_coarsen)
Hold every block overlapping an RT band on rt_sc_amr_level. Called from forcedrefine_grid after usr_r...
subroutine, public rt_sc_activate()
Switch the RT on. The physics module calls this from its initialisation when hd_radiative_transfer or...
Solvers of the short-characteristics (SC) radiative transfer and their dispatch.
subroutine rt_tau_tops(tautop)
Tau at the top face of every block row of the current band, per global column along hdim....
subroutine rt_band_blocks(ib)
List the blocks of this rank that lie in band ib, with their block position (bi, bj),...
subroutine rt_block_tau(iblk, tautop, taub)
Tau from the band top to every cell centre of block iblk, integrated down from the top face of the bl...
Parameters, resolved state and lifecycle of the short-characteristics (SC) radiative transfer,...
integer, public rt_sc_nband
logical, public rt_sc_distributed
The distributed KBA wavefront. Each rank sweeps only its own band blocks, one diagonal at a time,...
integer, public rt_sc_amr_level
The AMR level the RT runs on. The bands are held at this level so that the RT sees a uniform grid,...
double precision, public rt_sc_ftau1
Horizontal mean of the flux on the tau = rt_sc_tau_emergent surface, from rt_sc_emergent_tau1....
logical, public rt_sc_active
True when the physics module has switched the RT on, with hd_radiative_transfer or mhd_radiative_tran...
integer rg_nh
The RT grid on rt_sc_amr_level along (hdim, updim): cells across the domain, cells per block,...
subroutine, public rt_sc_reserve_slots()
Reserve the wavefront intensity slots in ps_rt, four in all, one per sweep corner,...
integer, dimension(:), allocatable wv_ig
integer, dimension(:), allocatable wv_bi
double precision, public rt_sc_cfl
pure subroutine hv(ih, iv, i1, i2)
Block indices (i1, i2) of the cell at position ih along hdim and iv along updim.
integer, public i_qrad
Extra-variable indices of the heating Q, the vertical flux F and the emergent intensity Iout,...
double precision, public rt_sc_blend_dt
integer wv_nblk
The band blocks of this rank with their block position (bi, bj), the block rows of the current band a...
double precision, dimension(rt_sc_maxband) band_lo_c
integer, dimension(:), allocatable wv_bj
double precision, public rt_sc_tau_emergent
subroutine, public rt_sc_params_read(files)
Read &rt_list from each parameter file. The values stay physical until rt_sc_setup,...
double precision, dimension(rt_sc_maxband) band_hi_c
logical, public rt_sc_valpipe
For validation, runs the ray-by-ray and pipelined waves on the same state and prints max|dQ|.
double precision, public rt_sc_blend_t0
Centre and half-width in K of the temperature gate in rt_sc_thin_weight, which divides the radiative ...
integer function var_set_extravar(name_cons, name_prim, ix)
Set extra variable in w, which is not advected and has no boundary conditions. This has to be done af...