35  real(8), 
allocatable, 
private :: ay(:), wy(:), aphi(:), wphi(:)
 
   38  real(8), 
private :: cak_gamma
 
   41  real(8), 
private :: lum, dlum, drstar, dke, dclight
 
   44  real(8), 
private :: tfloor
 
   50  integer, 
parameter, 
private :: radstream=0, fdisc=1, fdisc_cutoff=2
 
   79    character(len=*), 
intent(in) :: files(:)
 
   89       open(
unitpar, file=trim(files(n)), status=
"old")
 
   90       read(
unitpar, cak_list, 
end=111)
 
 
  101    real(8), 
intent(in) :: phys_gamma
 
  103    cak_gamma = phys_gamma
 
  116      gcak1_ = var_set_extravar(
"gcak1", 
"gcak1")
 
  117      fdf_   = var_set_extravar(
"fdfac", 
"fdfac")
 
  121      gcak1_ = var_set_extravar(
"gcak1", 
"gcak1")
 
  122      gcak2_ = var_set_extravar(
"gcak2", 
"gcak2")
 
  123      gcak3_ = var_set_extravar(
"gcak3", 
"gcak3")
 
  129      call mpistop(
'CAK error: choose alpha in [0,1[')
 
  133      call mpistop(
'CAK error: chosen Qbar or Q0 is < 0')
 
  137      call mpistop(
'CAK error: choose either 1-D or vector force')
 
 
  147    real(8), 
intent(in) :: rstar, twind
 
 
  163    integer, 
intent(in)    :: ixI^L, ixO^L
 
  164    real(8), 
intent(in)    :: qdt, x(ixI^S,1:ndim), wCT(ixI^S,1:nw)
 
  165    real(8), 
intent(inout) :: w(ixI^S,1:nw)
 
  166    logical, 
intent(in)    :: energy, qsourcesplit
 
  167    logical, 
intent(inout) :: active
 
  170    real(8) :: gl(ixO^S,1:3), ge(ixO^S), ptherm(ixI^S), pmin(ixI^S)
 
  180      gl(ixo^s,1:3) = 0.0d0
 
  187        call mpistop(
"No valid force option")
 
  192        if (idir == 1) gl(ixo^s,idir) = gl(ixo^s,idir) + ge(ixo^s)
 
  194        w(ixo^s,iw_mom(idir)) = w(ixo^s,iw_mom(idir)) &
 
  195                                + qdt * gl(ixo^s,idir) * wct(ixo^s,iw_rho)
 
  198          w(ixo^s,iw_e) = w(ixo^s,iw_e) + qdt * gl(ixo^s,idir) * wct(ixo^s,iw_mom(idir))
 
  204        call phys_get_pthermal(w,x,ixi^l,ixo^l,ptherm)
 
  205        pmin(ixo^s) = w(ixo^s,iw_rho) * tfloor
 
  207        where (ptherm(ixo^s) < pmin(ixo^s))
 
  208          w(ixo^s,iw_e) = w(ixo^s,iw_e) + (pmin(ixo^s) - ptherm(ixo^s))/(cak_gamma - 1.0d0)
 
 
  220    integer, 
intent(in)    :: ixI^L, ixO^L
 
  221    real(8), 
intent(in)    :: wCT(ixI^S,1:nw), x(ixI^S,1:ndim)
 
  222    real(8), 
intent(inout) :: w(ixI^S,1:nw)
 
  223    real(8), 
intent(inout) :: gcak(ixO^S,1:3)
 
  226    real(8) :: vr(ixI^S), dvrdr(ixO^S)
 
  227    real(8) :: beta_fd(ixO^S), fdfac(ixO^S), taus(ixO^S), ge(ixO^S)
 
  229    vr(ixi^s) = wct(ixi^s,iw_mom(1)) / wct(ixi^s,iw_rho)
 
  232    if (physics_type == 
'hd') 
then 
  234      dvrdr(ixo^s) = abs(dvrdr(ixo^s))
 
  237      dvrdr(ixo^s) = max(dvrdr(ixo^s), smalldouble)
 
  245    case(radstream, fdisc)
 
  246      taus(ixo^s)   = 
gayley_qbar * dke * dclight * wct(ixo^s,iw_rho)/dvrdr(ixo^s)
 
  251      taus(ixo^s)   = 
gayley_q0 * dke * dclight * wct(ixo^s,iw_rho)/dvrdr(ixo^s)
 
  253                      * ( (1.0d0 + taus(ixo^s))**(1.0d0 - 
cak_alpha) - 1.0d0 ) &
 
  256      call mpistop(
"Error in force computation.")
 
  260    beta_fd(ixo^s) = ( 1.0d0 - vr(ixo^s)/(x(ixo^s,1) * dvrdr(ixo^s)) ) &
 
  261                      * (drstar/x(ixo^s,1))**2.0d0
 
  266    case(fdisc, fdisc_cutoff)
 
  267      where (beta_fd(ixo^s) >= 1.0d0)
 
  269      elsewhere (beta_fd(ixo^s) < -1.0d10)
 
  271      elsewhere (abs(beta_fd(ixo^s)) > 1.0
d-3)
 
  272        fdfac(ixo^s) = (1.0d0 - (1.0d0 - beta_fd(ixo^s))**(1.0d0 + 
cak_alpha)) &
 
  275        fdfac(ixo^s) = 1.0d0 - 0.5d0*
cak_alpha*beta_fd(ixo^s) &
 
  276                       * (1.0d0 + 1.0d0/3.0d0 * (1.0d0 - 
cak_alpha)*beta_fd(ixo^s))
 
  281    gcak(ixo^s,1) = gcak(ixo^s,1) * fdfac(ixo^s)
 
  282    gcak(ixo^s,2) = 0.0d0
 
  283    gcak(ixo^s,3) = 0.0d0
 
  286    w(ixo^s,
gcak1_) = gcak(ixo^s,1)
 
  287    w(ixo^s,
fdf_)   = fdfac(ixo^s)
 
 
  297    integer, 
intent(in)    :: ixI^L, ixO^L
 
  298    real(8), 
intent(in)    :: wCT(ixI^S,1:nw), x(ixI^S,1:ndim)
 
  299    real(8), 
intent(inout) :: w(ixI^S,1:nw)
 
  300    real(8), 
intent(inout) :: gcak(ixO^S,1:3)
 
  303    real(8) :: a1, a2, a3, wyray, y, wpray, phiray, wtot, mustar, dvndn
 
  304    real(8) :: costp, costp2, sintp, cospp, sinpp, cott0
 
  305    real(8) :: vr(ixI^S), vt(ixI^S), vp(ixI^S)
 
  306    real(8) :: vrr(ixI^S), vtr(ixI^S), vpr(ixI^S)
 
  307    real(8) :: dvrdr(ixO^S), dvtdr(ixO^S), dvpdr(ixO^S)
 
  308    real(8) :: dvrdt(ixO^S), dvtdt(ixO^S), dvpdt(ixO^S)
 
  309    real(8) :: dvrdp(ixO^S), dvtdp(ixO^S), dvpdp(ixO^S)
 
  310    integer :: ix^D, itray, ipray
 
  313    vt(ixo^s) = 0.0d0; vtr(ixo^s) = 0.0d0
 
  314    vp(ixo^s) = 0.0d0; vpr(ixo^s) = 0.0d0
 
  316    dvrdr(ixo^s) = 0.0d0; dvtdr(ixo^s) = 0.0d0; dvpdr(ixo^s) = 0.0d0
 
  317    dvrdt(ixo^s) = 0.0d0; dvtdt(ixo^s) = 0.0d0; dvpdt(ixo^s) = 0.0d0
 
  318    dvrdp(ixo^s) = 0.0d0; dvtdp(ixo^s) = 0.0d0; dvpdp(ixo^s) = 0.0d0
 
  321    vr(ixi^s)  = wct(ixi^s,iw_mom(1)) / wct(ixi^s,iw_rho)
 
  322    vrr(ixi^s) = vr(ixi^s) / x(ixi^s,1)
 
  325    vt(ixi^s)  = wct(ixi^s,iw_mom(2)) / wct(ixi^s,iw_rho)
 
  326    vtr(ixi^s) = vt(ixi^s) / x(ixi^s,1)
 
  329      vp(ixi^s)  = wct(ixi^s,iw_mom(3)) / wct(ixi^s,iw_rho)
 
  330      vpr(ixi^s) = vp(ixi^s) / x(ixi^s,1)
 
  354    {
do ix^db=ixomin^db,ixomax^db\}
 
  375          mustar = sqrt(max(1.0d0 - (drstar/x(ix^d,1))**2.0d0, 0.0d0))
 
  376          costp  = 1.0d0 - y*(1.0d0 - mustar)
 
  378          sintp  = sqrt(max(1.0d0 - costp2, 0.0d0))
 
  381          {^nooned cott0  = cos(x(ix^d,2))/sin(x(ix^d,2))}
 
  384          wtot  = wyray * wpray * (1.0d0 - mustar)
 
  392          dvndn = a1*a1 * dvrdr(ix^d) + a2*a2 * (dvtdt(ix^d) + vrr(ix^d))  &
 
  393                 + a3*a3 * (dvpdp(ix^d) + cott0 * vtr(ix^d) + vrr(ix^d))   &
 
  394                 + a1*a2 * (dvtdr(ix^d) + dvrdt(ix^d) - vtr(ix^d))         &
 
  395                 + a1*a3 * (dvpdr(ix^d) + dvrdp(ix^d) - vpr(ix^d))         &
 
  396                 + a2*a3 * (dvpdt(ix^d) + dvtdp(ix^d) - cott0 * vpr(ix^d))
 
  403          gcak(ix^d,1) = gcak(ix^d,1) + (dvndn/wct(ix^d,iw_rho))**
cak_alpha * a1 * wtot
 
  404          gcak(ix^d,2) = gcak(ix^d,2) + (dvndn/wct(ix^d,iw_rho))**
cak_alpha * a2 * wtot
 
  405          gcak(ix^d,3) = gcak(ix^d,3) + (dvndn/wct(ix^d,iw_rho))**
cak_alpha * a3 * wtot
 
  413                    * dlum/(4.0d0*dpi*drstar**2.0d0 * dclight**(1.0d0+
cak_alpha)) &
 
  417      gcak(ixo^s,2) = 0.0d0
 
  418      gcak(ixo^s,3) = 0.0d0
 
  422    w(ixo^s,
gcak1_) = gcak(ixo^s,1)
 
  423    w(ixo^s,
gcak2_) = gcak(ixo^s,2)
 
  424    w(ixo^s,
gcak3_) = gcak(ixo^s,3)
 
 
  432    integer, 
intent(in) :: ixI^L, ixO^L
 
  433    real(8), 
intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
 
  434    real(8), 
intent(out):: ge(ixO^S)
 
  436    ge(ixo^s) = dke * dlum/(4.0d0*dpi * dclight * x(ixo^s,1)**2.0d0)
 
 
  444    integer, 
intent(in)    :: ixI^L, ixO^L
 
  445    real(8), 
intent(in)    :: dx^D, x(ixI^S,1:ndim)
 
  446    real(8), 
intent(in)    :: w(ixI^S,1:nw)
 
  447    real(8), 
intent(inout) :: dtnew
 
  450    real(8) :: ge(ixO^S), max_gr, dt_cak
 
  457    max_gr = max( maxval(abs(ge(ixo^s) + w(ixo^s,
gcak1_))), epsilon(1.0d0) )
 
  458    dt_cak = minval( sqrt(
block%dx(ixo^s,1)/max_gr) )
 
  463      max_gr = max( maxval(abs(w(ixo^s,
gcak2_))), epsilon(1.0d0) )
 
  464      dt_cak = minval( sqrt(
block%dx(ixo^s,1) * 
block%dx(ixo^s,2)/max_gr) )
 
  468      max_gr = max( maxval(abs(w(ixo^s,
gcak3_))), epsilon(1.0d0) )
 
  469      dt_cak = minval( sqrt(
block%dx(ixo^s,1) * sin(
block%dx(ixo^s,3))/max_gr) )
 
 
  481    integer, 
intent(in)  :: ixI^L, ixO^L, idir
 
  482    real(8), 
intent(in)  :: vfield(ixI^S), x(ixI^S,1:ndim)
 
  483    real(8), 
intent(out) :: grad_vn(ixO^S)
 
  486    real(8) :: forw(ixO^S), backw(ixO^S), cent(ixO^S)
 
  487    integer :: jrx^L, hrx^L{^NOONED,jtx^L, htx^L}{^IFTHREED,jpx^L, hpx^L}
 
  490    jrx^l=ixo^l+
kr(1,^
d);
 
  491    hrx^l=ixo^l-
kr(1,^
d);
 
  495    jtx^l=ixo^l+
kr(2,^
d);
 
  496    htx^l=ixo^l-
kr(2,^
d);
 
  501    jpx^l=ixo^l+
kr(3,^
d);
 
  502    hpx^l=ixo^l-
kr(3,^
d);
 
  508      forw(ixo^s)  = (x(ixo^s,1) - x(hrx^s,1)) * vfield(jrx^s) &
 
  509                      / ((x(jrx^s,1) - x(ixo^s,1)) * (x(jrx^s,1) - x(hrx^s,1)))
 
  511      backw(ixo^s) = -(x(jrx^s,1) - x(ixo^s,1)) * vfield(hrx^s) &
 
  512                      / ((x(ixo^s,1) - x(hrx^s,1)) * (x(jrx^s,1) - x(hrx^s,1)))
 
  514      cent(ixo^s)  = (x(jrx^s,1) + x(hrx^s,1) - 2.0d0*x(ixo^s,1)) * vfield(ixo^s) &
 
  515                      / ((x(ixo^s,1) - x(hrx^s,1)) * (x(jrx^s,1) - x(ixo^s,1)))
 
  518      forw(ixo^s)  = (x(ixo^s,2) - x(htx^s,2)) * vfield(jtx^s) &
 
  519                      / (x(ixo^s,1) * (x(jtx^s,2) - x(ixo^s,2)) * (x(jtx^s,2) - x(htx^s,2)))
 
  521      backw(ixo^s) = -(x(jtx^s,2) - x(ixo^s,2)) * vfield(htx^s) &
 
  522                      / ( x(ixo^s,1) * (x(ixo^s,2) - x(htx^s,2)) * (x(jtx^s,2) - x(htx^s,2)))
 
  524      cent(ixo^s)  = (x(jtx^s,2) + x(htx^s,2) - 2.0d0*x(ixo^s,2)) * vfield(ixo^s) &
 
  525                      / ( x(ixo^s,1) * (x(ixo^s,2) - x(htx^s,2)) * (x(jtx^s,2) - x(ixo^s,2)))
 
  529      forw(ixo^s)  = (x(ixo^s,3) - x(hpx^s,3)) *  vfield(jpx^s) &
 
  530                      / ( x(ixo^s,1)*sin(x(ixo^s,2)) * (x(jpx^s,3) - x(ixo^s,3)) * (x(jpx^s,3) - x(hpx^s,3)))
 
  532      backw(ixo^s) = -(x(jpx^s,3) - x(ixo^s,3)) *  vfield(hpx^s) &
 
  533                      / ( x(ixo^s,1)*sin(x(ixo^s,2)) * (x(ixo^s,3) - x(hpx^s,3)) * (x(jpx^s,3) - x(hpx^s,3)))
 
  535      cent(ixo^s)  = (x(jpx^s,3) + x(hpx^s,3) - 2.0d0*x(ixo^s,3)) *  vfield(ixo^s) &
 
  536                      / ( x(ixo^s,1)*sin(x(ixo^s,2)) * (x(ixo^s,3) - x(hpx^s,3)) * (x(jpx^s,3) - x(ixo^s,3)))
 
  541    grad_vn(ixo^s) = backw(ixo^s) + cent(ixo^s) + forw(ixo^s)
 
 
  550    integer, 
intent(in) :: ntheta_point, nphi_point
 
  553    real(8) :: ymin, ymax, phipmin, phipmax, adum
 
  565      allocate(ay(ntheta_point))
 
  566      allocate(wy(ntheta_point))
 
  567      allocate(aphi(nphi_point))
 
  568      allocate(wphi(nphi_point))
 
  593      print*, 
'===========================' 
  594      print*, 
'    Radiation ray setup    ' 
  595      print*, 
'===========================' 
  596      print*, 
'Theta ray points + weights ' 
  597      do ii = 1,ntheta_point
 
  598        print*,ii,ay(ii),wy(ii)
 
  601      print*, 
'Phi ray points + weights   ' 
  603        print*,ii,aphi(ii),wphi(ii)
 
  614      call mpi_bcast(ntheta_point,1,mpi_integer,0,
icomm,
ierrmpi)
 
  615      call mpi_bcast(nphi_point,1,mpi_integer,0,
icomm,
ierrmpi)
 
  618        allocate(ay(ntheta_point))
 
  619        allocate(wy(ntheta_point))
 
  620        allocate(aphi(nphi_point))
 
  621        allocate(wphi(nphi_point))
 
  624      call mpi_bcast(ay,ntheta_point,mpi_double_precision,0,
icomm,
ierrmpi)
 
  625      call mpi_bcast(wy,ntheta_point,mpi_double_precision,0,
icomm,
ierrmpi)
 
  626      call mpi_bcast(aphi,nphi_point,mpi_double_precision,0,
icomm,
ierrmpi)
 
  627      call mpi_bcast(wphi,nphi_point,mpi_double_precision,0,
icomm,
ierrmpi)
 
 
  640    real(8), 
intent(in)  :: xlow, xhi
 
  641    integer, 
intent(in)  :: n
 
  642    real(8), 
intent(out) :: x(n), w(n)
 
  645    real(8) :: p1, p2, p3, pp, xl, xm, z, z1
 
  646    real(8), 
parameter :: error=3.0
d-14
 
  650    xm = 0.5d0*(xhi + xlow)
 
  651    xl = 0.5d0*(xhi - xlow)
 
  654      z = cos( dpi * (i - 0.25d0)/(n + 0.5d0) )
 
  657      do while (abs(z1 - z) > error)
 
  664          p1 = ( (2.0d0*j - 1.0d0)*z*p2 - (j - 1.0d0)*p3 )/j
 
  667        pp = n*(z*p1 - p2) / (z*z - 1.0d0)
 
  674      w(i)     = 2.0d0*xl / ((1.0d0 - z*z) * pp*pp)
 
 
Module to include CAK radiation line force in (magneto)hydrodynamic models Computes both the force fr...
 
real(8), public gayley_qbar
 
subroutine cak_get_dt(w, ixil, ixol, dtnew, dxd, x)
Check time step for total radiation contribution.
 
real(8), public gayley_q0
 
logical cak_split
To treat source term in split or unsplit (default) fashion.
 
subroutine cak_init(phys_gamma)
Initialize the module.
 
subroutine cak_params_read(files)
Public method.
 
subroutine gauss_legendre_quadrature(xlow, xhi, n, x, w)
Fast Gauss-Legendre N-point quadrature algorithm by G. Rybicki.
 
real(8), public cak_alpha
Line-ensemble parameters in the Gayley (1995) formalism.
 
subroutine cak_add_source(qdt, ixil, ixol, wct, w, x, energy, qsourcesplit, active)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO
 
subroutine, public set_cak_force_norm(rstar, twind)
Compute some (unitless) variables for CAK force normalisation.
 
logical fix_vector_force_1d
To activate the pure radial vector CAK line force computation.
 
integer gcak1_
Extra slots to store quantities in w-array.
 
logical cak_vector_force
To activate the vector CAK line force computation.
 
subroutine get_velocity_gradient(ixil, ixol, vfield, x, idir, grad_vn)
Compute velocity gradient in direction 'idir' on a non-uniform grid.
 
integer cak_1d_opt
Switch to choose between the 1-D CAK line force options.
 
subroutine get_cak_force_radial(ixil, ixol, wct, w, x, gcak)
1-D CAK line force in the Gayley line-ensemble distribution parametrisation
 
subroutine get_gelectron(ixil, ixol, w, x, ge)
Compute continuum radiation force from Thomson scattering.
 
subroutine get_cak_force_vector(ixil, ixol, wct, w, x, gcak)
Vector CAK line force in the Gayley line-ensemble distribution parametrisation.
 
logical cak_1d_force
To activate the original CAK 1-D line force computation.
 
integer nthetaray
Amount of rays in radiation polar and radiation azimuthal direction.
 
subroutine rays_init(ntheta_point, nphi_point)
Initialise (theta',phi') radiation angles coming from stellar disc.
 
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
 
Module for physical and numeric constants.
 
double precision, parameter dpi
Pi.
 
double precision, parameter const_kappae
 
double precision, parameter const_c
 
double precision, parameter const_sigma
 
This module contains definitions of global parameters and variables and some generic functions/subrou...
 
type(state), pointer block
Block pointer for using one block and its previous state.
 
double precision unit_time
Physical scaling factor for time.
 
double precision unit_density
Physical scaling factor for density.
 
integer, parameter unitpar
file handle for IO
 
integer, dimension(3, 3) kr
Kronecker delta tensor.
 
double precision unit_length
Physical scaling factor for length.
 
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
 
integer ndir
Number of spatial dimensions (components) for vector variables.
 
double precision courantpar
The Courant (CFL) number used for the simulation.
 
integer ierrmpi
A global MPI error return code.
 
integer npe
The number of MPI tasks.
 
double precision unit_velocity
Physical scaling factor for velocity.
 
double precision unit_temperature
Physical scaling factor for temperature.
 
This module defines the procedures of a physics module. It contains function pointers for the various...
 
procedure(sub_get_pthermal), pointer phys_get_pthermal
 
character(len=name_len) physics_type
String describing the physics type of the simulation.
 
Module with all the methods that users can customize in AMRVAC.