56 integer,
intent(in) :: ixI^L, ixO^L
57 double precision,
intent(in) :: w(ixI^S,nw)
58 double precision,
intent(in) :: x(ixI^S,1:ndim)
59 double precision,
intent(out):: res(ixI^S)
67 double precision :: tc_k_para
70 double precision :: tc_k_perp
77 integer :: tc_slope_limiter
80 logical :: has_equi=.false.
83 logical :: tc_constant=.false.
86 logical :: tc_perpendicular=.false.
89 logical :: tc_saturate=.false.
93 procedure(
get_var_subr),
pointer,
nopass :: get_temperature_from_eint => null()
94 procedure(
get_var_subr),
pointer,
nopass :: get_temperature_from_conserved => null()
95 procedure(
get_var_subr),
pointer,
nopass :: get_temperature_equi => null()
113 double precision,
intent(in) :: phys_gamma
123 subroutine read_mhd_params(fl)
128 end subroutine read_mhd_params
132 fl%tc_slope_limiter=1
137 call read_mhd_params(fl)
139 if(fl%tc_k_para==0.d0 .and. fl%tc_k_perp==0.d0)
then
151 if(
mype .eq. 0) print*,
"Spitzer MHD: par: ",fl%tc_k_para, &
152 " ,perp: ",fl%tc_k_perp
154 fl%tc_constant=.true.
164 subroutine read_hd_params(fl)
169 end subroutine read_hd_params
176 call read_hd_params(fl)
178 if(fl%tc_k_para==0.d0 )
then
186 if(
mype .eq. 0) print*,
"Spitzer HD par: ",fl%tc_k_para
195 subroutine read_ffhd_params(fl)
199 end subroutine read_ffhd_params
206 call read_ffhd_params(fl)
207 if(fl%tc_k_para==0.d0 )
then
215 if(
mype .eq. 0) print*,
"Spitzer ffHD par: ",fl%tc_k_para
217 fl%tc_constant=.true.
229 integer,
intent(in) :: ixi^
l, ixo^
l
230 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
231 double precision,
intent(in) :: w(ixi^s,1:nw)
232 double precision :: dtnew
234 double precision :: mf(ixo^s,1:
ndim),te(ixi^s),rho(ixi^s),gradt(ixi^s)
235 double precision :: tmp(ixo^s),hfs(ixo^s)
236 double precision :: dtdiff_tcond,maxtmp2
237 integer :: idims,ix^
d
240 call fl%get_temperature_from_conserved(w,x,ixi^
l,ixi^
l,te)
243 {
do ix^db=ixomin^db,ixomax^db\}
245 ^
d&mf({ix^
d},^
d)=w({ix^
d},iw_mag(^
d))+
block%B0({ix^
d},^
d,0)\
247 ^
d&mf({ix^
d},^
d)=w({ix^
d},iw_mag(^
d))\
250 tmp(ix^
d)=(^
d&mf({ix^
d},^
d)**2+)
252 if(tmp(ix^
d)/=0.d0)
then
253 ^
d&mf({ix^
d},^
d)=mf({ix^
d},^
d)**2/tmp({ix^
d})\
255 ^
d&mf({ix^
d},^
d)=1.d0\
260 call fl%get_rho(w,x,ixi^l,ixo^l,rho)
263 if(fl%tc_constant)
then
264 tmp(ixo^s)=fl%tc_k_para
266 if(fl%tc_saturate)
then
270 tmp(ixo^s)=te(ixo^s)**2/rho(ixo^s)*7093.9239487765044d0*unit_temperature**2/(unit_numberdensity*unit_length)
272 call gradient(te,ixi^l,ixo^l,idims,gradt)
274 hfs(ixo^s)=gradt(ixo^s)*sqrt(mf(ixo^s,idims))
276 hfs(ixo^s)=hfs(ixo^s)+gradt(ixo^s)*sqrt(mf(ixo^s,idims))
280 tmp(ixo^s)=fl%tc_k_para*dsqrt(te(ixo^s)**5)/(1.d0+4.2d0*tmp(ixo^s)*dabs(hfs(ixo^s))/te(ixo^s))
283 tmp(ixo^s)=fl%tc_k_para*dsqrt(te(ixo^s)**5)
287 if(slab_uniform)
then
290 maxtmp2=maxval(tmp(ixo^s)*mf(ixo^s,idims)/(rho(ixo^s)*dxlevel(idims)))
292 dtdiff_tcond=dxlevel(idims)/(
tc_gamma_1*maxtmp2+smalldouble)
294 dtnew=min(dtnew,dtdiff_tcond)
299 maxtmp2=maxval(tmp(ixo^s)*mf(ixo^s,idims)/(rho(ixo^s)*block%ds(ixo^s,idims)**2))
301 dtdiff_tcond=1.d0/(
tc_gamma_1*maxtmp2+smalldouble)
303 dtnew=min(dtnew,dtdiff_tcond)
306 dtnew=dtnew/dble(ndim)
314 integer,
intent(in) :: ixi^
l, ixo^
l, igrid, nflux
315 double precision,
intent(in) :: x(ixi^s,1:
ndim)
316 double precision,
intent(in) :: w(ixi^s,1:nw)
317 double precision,
intent(inout) :: wres(ixi^s,1:nw)
318 double precision,
intent(in) :: my_dt
319 logical,
intent(in) :: fix_conserve_at_step
323 double precision :: qd(ixo^s)
324 double precision :: rho(ixi^s),te(ixi^s)
325 double precision :: qvec(ixi^s,1:
ndim)
326 double precision :: fluxall(ixi^s,1,1:
ndim)
327 double precision :: alpha,dxinv(
ndim)
328 double precision,
allocatable,
dimension(:^D&,:) :: qvec_equi
329 integer :: idims,ixa^
l
340 call fl%get_temperature_from_eint(w, x, ixi^
l, ixi^
l, te)
341 call fl%get_rho(w, x, ixi^
l, ixi^
l, rho)
344 allocate(qvec_equi(ixi^s,1:
ndim))
345 call fl%get_temperature_equi(w, x, ixi^
l, ixi^
l, te)
346 call fl%get_rho_equi(w, x, ixi^
l, ixi^
l, rho)
349 ixamax^
d=ixomax^
d; ixamin^
d=ixomin^
d-
kr(idims,^
d);
350 qvec(ixa^s,idims)=qvec(ixa^s,idims)-qvec_equi(ixa^s,idims)
352 deallocate(qvec_equi)
357 ixamax^
d=ixomax^
d; ixamin^
d=ixomin^
d-
kr(idims,^
d);
358 qvec(ixa^s,idims)=dxinv(idims)*qvec(ixa^s,idims)
359 ixa^
l=ixo^
l-
kr(idims,^
d);
361 qd(ixo^s)=qvec(ixo^s,idims)-qvec(ixa^s,idims)
363 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixa^s,idims)
368 ixamax^
d=ixomax^
d; ixamin^
d=ixomin^
d-
kr(idims,^
d);
369 qvec(ixa^s,idims)=qvec(ixa^s,idims)*
block%surfaceC(ixa^s,idims)
370 ixa^
l=ixo^
l-
kr(idims,^
d);
372 qd(ixo^s)=qvec(ixo^s,idims)-qvec(ixa^s,idims)
374 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixa^s,idims)
377 qd(ixo^s)=qd(ixo^s)/
block%dvolume(ixo^s)
380 if(fix_conserve_at_step)
then
382 ixamax^
d=ixomax^
d; ixamin^
d=ixomin^
d-
kr(idims,^
d);
383 fluxall(ixa^s,1,idims)=my_dt*qvec(ixa^s,idims)
388 wres(ixo^s,fl%e_)=qd(ixo^s)
393 integer,
intent(in) :: ixI^L, ixO^L
394 double precision,
intent(in) :: x(ixI^S,1:ndim)
395 double precision,
intent(in) :: w(ixI^S,1:nw)
397 double precision,
intent(in) :: rho(ixI^S),Te(ixI^S)
398 double precision,
intent(in) :: alpha
399 double precision,
intent(out) :: qvec(ixI^S,1:ndim)
402 double precision,
dimension(ixI^S,1:ndim) :: mf,Bc,Bcf,gradT
403 double precision,
dimension(ixI^S) :: ka,kaf,ke,kef,qdd,Bnorm
404 double precision :: minq,maxq,qd(ixI^S,2**(ndim-1))
405 integer :: idims,idir,ix^D,ix^L,ixC^L,ixA^L,ixB^L
412 {
do ix^db=ixmin^db,ixmax^db\}
413 ^d&mf({ix^d},^d)=w({ix^d},iw_mag(^d))+
block%B0({ix^d},^d,0)\
415 bnorm(ix^d)=dsqrt(^d&mf({ix^d},^d)**2+)
416 if(bnorm(ix^d)/=0.d0)
then
417 bnorm(ix^d)=1.d0/bnorm(ix^d)
419 bnorm(ix^d)=bigdouble
422 ^d&mf({ix^d},^d)=mf({ix^d},^d)*bnorm({ix^d})\
425 {
do ix^db=ixmin^db,ixmax^db\}
427 bnorm(ix^d)=dsqrt(^d&w({ix^d},iw_mag(^d))**2+)
428 if(bnorm(ix^d)/=0.d0)
then
429 bnorm(ix^d)=1.d0/bnorm(ix^d)
431 bnorm(ix^d)=bigdouble
434 ^d&mf({ix^d},^d)=w({ix^d},iw_mag(^d))*bnorm({ix^d})\
438 ixcmax^d=ixomax^d; ixcmin^d=ixomin^d-1;
442 {
do ix^db=ixcmin^db,ixcmax^db\}
443 bc(ix^d,idims)=0.125d0*(mf(ix1,ix2,ix3,idims)+mf(ix1+1,ix2,ix3,idims)&
444 +mf(ix1,ix2+1,ix3,idims)+mf(ix1+1,ix2+1,ix3,idims)&
445 +mf(ix1,ix2,ix3+1,idims)+mf(ix1+1,ix2,ix3+1,idims)&
446 +mf(ix1,ix2+1,ix3+1,idims)+mf(ix1+1,ix2+1,ix3+1,idims))
452 {
do ix^db=ixcmin^db,ixcmax^db\}
453 bc(ix^d,idims)=0.25d0*(mf(ix1,ix2,idims)+mf(ix1+1,ix2,idims)&
454 +mf(ix1,ix2+1,idims)+mf(ix1+1,ix2+1,idims))
461 ixbmax^d=ixmax^d-kr(idims,^d);
462 call gradientc(te,x,ixi^l,ixb^l,idims,gradt(ixi^s,idims))
464 if(fl%tc_constant)
then
465 if(fl%tc_perpendicular)
then
466 ka(ixc^s)=fl%tc_k_para-fl%tc_k_perp
467 ke(ixc^s)=fl%tc_k_perp
469 ka(ixc^s)=fl%tc_k_para
474 {
do ix^db=ixmin^db,ixmax^db\}
475 if(te(ix^d) < block%wextra(ix^d,fl%Tcoff_))
then
476 qdd(ix^d)=fl%tc_k_para*sqrt(block%wextra(ix^d,fl%Tcoff_)**5)
478 qdd(ix^d)=fl%tc_k_para*sqrt(te(ix^d)**5)
482 qdd(ix^s)=fl%tc_k_para*sqrt(te(ix^s)**5)
486 {
do ix^db=ixcmin^db,ixcmax^db\}
487 ka(ix^d)=0.125d0*(qdd(ix1,ix2,ix3)+qdd(ix1+1,ix2,ix3)&
488 +qdd(ix1,ix2+1,ix3)+qdd(ix1+1,ix2+1,ix3)&
489 +qdd(ix1,ix2,ix3+1)+qdd(ix1+1,ix2,ix3+1)&
490 +qdd(ix1,ix2+1,ix3+1)+qdd(ix1+1,ix2+1,ix3+1))
494 {
do ix^db=ixcmin^db,ixcmax^db\}
495 ka(ix^d)=0.25d0*(qdd(ix1,ix2)+qdd(ix1+1,ix2)&
496 +qdd(ix1,ix2+1)+qdd(ix1+1,ix2+1))
500 if(fl%tc_perpendicular)
then
501 qdd(ix^s)=fl%tc_k_perp*rho(ix^s)**2*bnorm(ix^s)**2/dsqrt(te(ix^s))
503 {
do ix^db=ixcmin^db,ixcmax^db\}
504 ke(ix^d)=0.125d0*(qdd(ix1,ix2,ix3)+qdd(ix1+1,ix2,ix3)&
505 +qdd(ix1,ix2+1,ix3)+qdd(ix1+1,ix2+1,ix3)&
506 +qdd(ix1,ix2,ix3+1)+qdd(ix1+1,ix2,ix3+1)&
507 +qdd(ix1,ix2+1,ix3+1)+qdd(ix1+1,ix2+1,ix3+1))
508 if(ke(ix^d)<ka(ix^d))
then
509 ka(ix^d)=ka(ix^d)-ke(ix^d)
517 {
do ix^db=ixcmin^db,ixcmax^db\}
518 ke(ix^d)=0.25d0*(qdd(ix1,ix2)+qdd(ix1+1,ix2)&
519 +qdd(ix1,ix2+1)+qdd(ix1+1,ix2+1))
520 if(ke(ix^d)<ka(ix^d))
then
521 ka(ix^d)=ka(ix^d)-ke(ix^d)
530 if(fl%tc_slope_limiter==0)
then
536 if({ ix^d==0 .and. ^d==idims | .or.})
then
537 ixbmin^d=ixcmin^d+ix^d;
538 ixbmax^d=ixcmax^d+ix^d;
539 qdd(ixc^s)=qdd(ixc^s)+gradt(ixb^s,idims)
543 qvec(ixc^s,idims)=qdd(ixc^s)*0.5d0**(ndim-1)
546 qdd(ixc^s)=sum(qvec(ixc^s,1:ndim)*bc(ixc^s,1:ndim),dim=ndim+1)
549 gradt(ixc^s,idims)=ka(ixc^s)*bc(ixc^s,idims)*qdd(ixc^s)
550 if(fl%tc_perpendicular) gradt(ixc^s,idims)=gradt(ixc^s,idims)+ke(ixc^s)*qvec(ixc^s,idims)
555 ixb^l=ixo^l-kr(idims,^d);
556 ixamax^d=ixomax^d; ixamin^d=ixbmin^d;
558 if({ ix^d==0 .and. ^d==idims | .or.})
then
559 ixbmin^d=ixamin^d-ix^d;
560 ixbmax^d=ixamax^d-ix^d;
561 qvec(ixa^s,idims)=qvec(ixa^s,idims)+gradt(ixb^s,idims)
564 qvec(ixa^s,idims)=qvec(ixa^s,idims)*0.5d0**(ndim-1)
565 if(fl%tc_saturate)
then
570 if({ ix^d==0 .and. ^d==idims | .or.})
then
571 ixbmin^d=ixamin^d-ix^d;
572 ixbmax^d=ixamax^d-ix^d;
573 bcf(ixa^s,idims)=bcf(ixa^s,idims)+bc(ixb^s,idims)
577 bcf(ixa^s,idims)=bcf(ixa^s,idims)*0.5d0**(ndim-1)
578 ixb^l=ixa^l+kr(idims,^d);
579 qdd(ixa^s)=2.75d0*(rho(ixa^s)+rho(ixb^s))*dsqrt(0.5d0*(te(ixa^s)+te(ixb^s)))**3*dabs(bcf(ixa^s,idims))
580 {
do ix^db=ixamin^db,ixamax^db\}
581 if(dabs(qvec(ix^d,idims))>qdd(ix^d))
then
582 qvec(ix^d,idims)=sign(1.d0,qvec(ix^d,idims))*qdd(ix^d)
590 ixamax^d=ixomax^d; ixamin^d=ixomin^d-kr(idims,^d);
593 {
do ix^db=ixamin^db,ixamax^db\}
595 ^d&bcf({ix^d},^d)=0.25d0*(bc({ix^d},^d)+bc(ix1,ix2-1,ix3,^d)&
596 +bc(ix1,ix2,ix3-1,^d)+bc(ix1,ix2-1,ix3-1,^d))\
597 kaf(ix^d)=0.25d0*(ka(ix1,ix2,ix3)+ka(ix1,ix2-1,ix3)&
598 +ka(ix1,ix2,ix3-1)+ka(ix1,ix2-1,ix3-1))
600 if(fl%tc_perpendicular) &
601 kef(ix^d)=0.25d0*(ke(ix1,ix2,ix3)+ke(ix1,ix2-1,ix3)&
602 +ke(ix1,ix2,ix3-1)+ke(ix1,ix2-1,ix3-1))
604 else if(idims==2)
then
605 {
do ix^db=ixamin^db,ixamax^db\}
606 ^d&bcf({ix^d},^d)=0.25d0*(bc({ix^d},^d)+bc(ix1-1,ix2,ix3,^d)&
607 +bc(ix1,ix2,ix3-1,^d)+bc(ix1-1,ix2,ix3-1,^d))\
608 kaf(ix^d)=0.25d0*(ka(ix1,ix2,ix3)+ka(ix1-1,ix2,ix3)&
609 +ka(ix1,ix2,ix3-1)+ka(ix1-1,ix2,ix3-1))
610 if(fl%tc_perpendicular) &
611 kef(ix^d)=0.25d0*(ke(ix1,ix2,ix3)+ke(ix1-1,ix2,ix3)&
612 +ke(ix1,ix2,ix3-1)+ke(ix1-1,ix2,ix3-1))
615 {
do ix^db=ixamin^db,ixamax^db\}
616 ^d&bcf({ix^d},^d)=0.25d0*(bc({ix^d},^d)+bc(ix1,ix2-1,ix3,^d)&
617 +bc(ix1-1,ix2,ix3,^d)+bc(ix1-1,ix2-1,ix3,^d))\
618 kaf(ix^d)=0.25d0*(ka(ix1,ix2,ix3)+ka(ix1,ix2-1,ix3)&
619 +ka(ix1-1,ix2,ix3)+ka(ix1-1,ix2-1,ix3))
620 if(fl%tc_perpendicular) &
621 kef(ix^d)=0.25d0*(ke(ix1,ix2,ix3)+ke(ix1,ix2-1,ix3)&
622 +ke(ix1-1,ix2,ix3)+ke(ix1-1,ix2-1,ix3))
628 {
do ix^db=ixamin^db,ixamax^db\}
629 ^d&bcf({ix^d},^d)=0.5d0*(bc(ix1,ix2,^d)+bc(ix1,ix2-1,^d))\
630 kaf(ix^d)=0.5d0*(ka(ix1,ix2)+ka(ix1,ix2-1))
631 if(fl%tc_perpendicular) &
632 kef(ix^d)=0.5d0*(ke(ix1,ix2)+ke(ix1,ix2-1))
635 {
do ix^db=ixamin^db,ixamax^db\}
636 ^d&bcf({ix^d},^d)=0.5d0*(bc(ix1,ix2,^d)+bc(ix1-1,ix2,^d))\
637 kaf(ix^d)=0.5d0*(ka(ix1,ix2)+ka(ix1-1,ix2))
638 if(fl%tc_perpendicular) &
639 kef(ix^d)=0.5d0*(ke(ix1,ix2)+ke(ix1-1,ix2))
647 {
do ix^db=ixcmin^db,ixcmax^db\}
648 qdd(ix^d)=0.25d0*(gradt(ix1,ix2,ix3,idims)+gradt(ix1,ix2+1,ix3,idims)&
649 +gradt(ix1,ix2,ix3+1,idims)+gradt(ix1,ix2+1,ix3+1,idims))
651 else if(idims==2)
then
652 {
do ix^db=ixcmin^db,ixcmax^db\}
653 qdd(ix^d)=0.25d0*(gradt(ix1,ix2,ix3,idims)+gradt(ix1+1,ix2,ix3,idims)&
654 +gradt(ix1,ix2,ix3+1,idims)+gradt(ix1+1,ix2,ix3+1,idims))
657 {
do ix^db=ixcmin^db,ixcmax^db\}
658 qdd(ix^d)=0.25d0*(gradt(ix1,ix2,ix3,idims)+gradt(ix1+1,ix2,ix3,idims)&
659 +gradt(ix1,ix2+1,ix3,idims)+gradt(ix1+1,ix2+1,ix3,idims))
665 {
do ix^db=ixcmin^db,ixcmax^db\}
666 qdd(ix^d)=0.5d0*(gradt(ix1,ix2,idims)+gradt(ix1,ix2+1,idims))
669 {
do ix^db=ixcmin^db,ixcmax^db\}
670 qdd(ix^d)=0.5d0*(gradt(ix1,ix2,idims)+gradt(ix1+1,ix2,idims))
677 {
do ix^db=ixamin^db,ixamax^db\}
678 minq=min(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
679 maxq=max(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
680 if(qdd(ix^d)<minq)
then
682 else if(qdd(ix^d)>maxq)
then
687 if(qdd(ix1,ix2-1,ix3)<minq)
then
689 else if(qdd(ix1,ix2-1,ix3)>maxq)
then
692 qd(ix^d,2)=qdd(ix1,ix2-1,ix3)
694 if(qdd(ix1,ix2,ix3-1)<minq)
then
696 else if(qdd(ix1,ix2,ix3-1)>maxq)
then
699 qd(ix^d,3)=qdd(ix1,ix2,ix3-1)
701 if(qdd(ix1,ix2-1,ix3-1)<minq)
then
703 else if(qdd(ix1,ix2-1,ix3-1)>maxq)
then
706 qd(ix^d,4)=qdd(ix1,ix2-1,ix3-1)
708 qvec(ix^d,idims)=kaf(ix^d)*0.25d0*(bc(ix^d,idims)**2*qd(ix^d,1)+bc(ix1,ix2-1,ix3,idims)**2*qd(ix^d,2)&
709 +bc(ix1,ix2,ix3-1,idims)**2*qd(ix^d,3)+bc(ix1,ix2-1,ix3-1,idims)**2*qd(ix^d,4))
710 if(fl%tc_perpendicular) &
711 qvec(ix^d,idims)=qvec(ix^d,idims)+kef(ix^d)*0.25d0*(qd(ix^d,1)+qd(ix^d,2)+qd(ix^d,3)+qd(ix^d,4))
713 else if(idims==2)
then
714 {
do ix^db=ixamin^db,ixamax^db\}
715 minq=min(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
716 maxq=max(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
717 if(qdd(ix^d)<minq)
then
719 else if(qdd(ix^d)>maxq)
then
724 if(qdd(ix1-1,ix2,ix3)<minq)
then
726 else if(qdd(ix1-1,ix2,ix3)>maxq)
then
729 qd(ix^d,2)=qdd(ix1-1,ix2,ix3)
731 if(qdd(ix1,ix2,ix3-1)<minq)
then
733 else if(qdd(ix1,ix2,ix3-1)>maxq)
then
736 qd(ix^d,3)=qdd(ix1,ix2,ix3-1)
738 if(qdd(ix1-1,ix2,ix3-1)<minq)
then
740 else if(qdd(ix1-1,ix2,ix3-1)>maxq)
then
743 qd(ix^d,4)=qdd(ix1-1,ix2,ix3-1)
745 qvec(ix^d,idims)=kaf(ix^d)*0.25d0*(bc(ix^d,idims)**2*qd(ix^d,1)+bc(ix1-1,ix2,ix3,idims)**2*qd(ix^d,2)&
746 +bc(ix1,ix2,ix3-1,idims)**2*qd(ix^d,3)+bc(ix1-1,ix2,ix3-1,idims)**2*qd(ix^d,4))
747 if(fl%tc_perpendicular) &
748 qvec(ix^d,idims)=qvec(ix^d,idims)+kef(ix^d)*0.25d0*(qd(ix^d,1)+qd(ix^d,2)+qd(ix^d,3)+qd(ix^d,4))
751 {
do ix^db=ixamin^db,ixamax^db\}
752 minq=min(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
753 maxq=max(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
754 if(qdd(ix^d)<minq)
then
756 else if(qdd(ix^d)>maxq)
then
761 if(qdd(ix1-1,ix2,ix3)<minq)
then
763 else if(qdd(ix1-1,ix2,ix3)>maxq)
then
766 qd(ix^d,2)=qdd(ix1-1,ix2,ix3)
768 if(qdd(ix1,ix2-1,ix3)<minq)
then
770 else if(qdd(ix1,ix2-1,ix3)>maxq)
then
773 qd(ix^d,3)=qdd(ix1,ix2-1,ix3)
775 if(qdd(ix1-1,ix2-1,ix3)<minq)
then
777 else if(qdd(ix1-1,ix2-1,ix3)>maxq)
then
780 qd(ix^d,4)=qdd(ix1-1,ix2-1,ix3)
782 qvec(ix^d,idims)=kaf(ix^d)*0.25d0*(bc(ix^d,idims)**2*qd(ix^d,1)+bc(ix1-1,ix2,ix3,idims)**2*qd(ix^d,2)&
783 +bc(ix1,ix2-1,ix3,idims)**2*qd(ix^d,3)+bc(ix1-1,ix2-1,ix3,idims)**2*qd(ix^d,4))
784 if(fl%tc_perpendicular) &
785 qvec(ix^d,idims)=qvec(ix^d,idims)+kef(ix^d)*0.25d0*(qd(ix^d,1)+qd(ix^d,2)+qd(ix^d,3)+qd(ix^d,4))
791 {
do ix^db=ixamin^db,ixamax^db\}
792 minq=min(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
793 maxq=max(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
794 if(qdd(ix^d)<minq)
then
796 else if(qdd(ix^d)>maxq)
then
801 if(qdd(ix1,ix2-1)<minq)
then
803 else if(qdd(ix1,ix2-1)>maxq)
then
806 qd(ix^d,2)=qdd(ix1,ix2-1)
808 qvec(ix^d,idims)=kaf(ix^d)*0.5d0*(bc(ix1,ix2,idims)**2*qd(ix^d,1)+bc(ix1,ix2-1,idims)**2*qd(ix^d,2))
809 if(fl%tc_perpendicular) &
810 qvec(ix^d,idims)=qvec(ix^d,idims)+kef(ix^d)*0.5d0*(qd(ix^d,1)+qd(ix^d,2))
813 {
do ix^db=ixamin^db,ixamax^db\}
814 minq=min(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
815 maxq=max(alpha*gradt(ix^d,idims),gradt(ix^d,idims)/alpha)
816 if(qdd(ix^d)<minq)
then
818 else if(qdd(ix^d)>maxq)
then
823 if(qdd(ix1-1,ix2)<minq)
then
825 else if(qdd(ix1-1,ix2)>maxq)
then
828 qd(ix^d,2)=qdd(ix1-1,ix2)
830 qvec(ix^d,idims)=kaf(ix^d)*0.5d0*(bc(ix1,ix2,idims)**2*qd(ix^d,1)+bc(ix1-1,ix2,idims)**2*qd(ix^d,2))
831 if(fl%tc_perpendicular) &
832 qvec(ix^d,idims)=qvec(ix^d,idims)+kef(ix^d)*0.5d0*(qd(ix^d,1)+qd(ix^d,2))
837 ixb^l=ixa^l+kr(idims,^d);
838 bnorm(ixa^s)=0.5d0*(mf(ixa^s,idims)+mf(ixb^s,idims))
841 ixbmax^d=ixamax^d+kr(idims,^d);
843 if(idir==idims) cycle
844 qdd(ixi^s)=
slope_limiter(gradt(ixi^s,idir),ixi^l,ixb^l,idir,-1,fl%tc_slope_limiter)
845 qdd(ixi^s)=
slope_limiter(qdd,ixi^l,ixa^l,idims,1,fl%tc_slope_limiter)
846 qvec(ixa^s,idims)=qvec(ixa^s,idims)+kaf(ixa^s)*bnorm(ixa^s)*bcf(ixa^s,idir)*qdd(ixa^s)
848 if(fl%tc_saturate)
then
851 ixb^l=ixa^l+kr(idims,^d);
852 qdd(ixa^s)=2.75d0*(rho(ixa^s)+rho(ixb^s))*dsqrt(0.5d0*(te(ixa^s)+te(ixb^s)))**3*dabs(bnorm(ixa^s))
853 {
do ix^db=ixamin^db,ixamax^db\}
854 if(dabs(qvec(ix^d,idims))>qdd(ix^d))
then
855 qvec(ix^d,idims)=sign(1.d0,qvec(ix^d,idims))*qdd(ix^d)
865 integer,
intent(in) :: ixi^
l, ixo^
l, idims, pm
866 double precision,
intent(in) :: f(ixi^s)
867 double precision :: lf(ixi^s)
868 integer,
intent(in) :: tc_slope_limiter
870 double precision :: signf(ixi^s)
873 ixb^
l=ixo^
l+pm*
kr(idims,^
d);
874 signf(ixo^s)=sign(1.d0,f(ixo^s))
875 select case(tc_slope_limiter)
878 lf(ixo^s)=two*signf(ixo^s)* &
879 max(zero,min(dabs(f(ixo^s)),signf(ixo^s)*f(ixb^s),&
880 signf(ixo^s)*quarter*(f(ixb^s)+f(ixo^s))))
883 lf(ixo^s)=signf(ixo^s)*max(0.d0,min(abs(f(ixo^s)),signf(ixo^s)*f(ixb^s)))
886 lf(ixo^s)=signf(ixo^s)* &
887 max(zero,min(two*dabs(f(ixo^s)),signf(ixo^s)*f(ixb^s)),&
888 min(dabs(f(ixo^s)),two*signf(ixo^s)*f(ixb^s)))
891 lf(ixo^s)=signf(ixo^s)* &
892 max(zero,min(two*dabs(f(ixo^s)),two*signf(ixo^s)*f(ixb^s),&
893 (two*f(ixb^s)*signf(ixo^s)+dabs(f(ixo^s)))*third))
895 call mpistop(
"Unknown slope limiter for thermal conduction")
902 integer,
intent(in) :: ixI^L, ixO^L, idir
903 double precision,
intent(in) :: q(ixI^S),x(ixI^S,1:ndim)
904 double precision,
intent(inout) :: gradq(ixI^S)
907 jxo^l=ixo^l+
kr(idir,^
d);
908 select case(coordinate)
910 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/
dxlevel(idir)
911 case(cartesian_stretched)
912 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/(x(jxo^s,idir)-x(ixo^s,idir))
916 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/(x(jxo^s,1)-x(ixo^s,1))
919 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/( (x(jxo^s,2)-x(ixo^s,2))*x(ixo^s,1) )
923 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/( (x(jxo^s,3)-x(ixo^s,3))*x(ixo^s,1)*dsin(x(ixo^s,2)) )
928 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/((x(jxo^s,
phi_)-x(ixo^s,
phi_))*x(ixo^s,
r_))
930 gradq(ixo^s)=(q(jxo^s)-q(ixo^s))/(x(jxo^s,idir)-x(ixo^s,idir))
933 call mpistop(
'Unknown geometry')
943 integer,
intent(in) :: ixi^
l, ixo^
l
944 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
945 double precision,
intent(in) :: w(ixi^s,1:nw)
947 double precision :: dtnew
949 double precision :: tmp(ixo^s),tmp2(ixo^s),te(ixi^s),rho(ixi^s),hfs(ixo^s),gradt(ixi^s)
950 double precision :: dtdiff_tcond,maxtmp2
953 call fl%get_temperature_from_conserved(w,x,ixi^
l,ixi^
l,te)
954 call fl%get_rho(w,x,ixi^
l,ixo^
l,rho)
956 if(fl%tc_saturate)
then
963 call gradient(te,ixi^
l,ixo^
l,idim,gradt)
964 hfs(ixo^s)=hfs(ixo^s)+gradt(ixo^s)**2
967 tmp(ixo^s)=fl%tc_k_para*dsqrt((te(ixo^s))**5)/(rho(ixo^s)*(1.d0+4.2d0*tmp2(ixo^s)*sqrt(hfs(ixo^s))/te(ixo^s)))
969 tmp(ixo^s)=fl%tc_k_para*dsqrt((te(ixo^s))**5)/rho(ixo^s)
976 tmp2(ixo^s)=tmp(ixo^s)/
dxlevel(idim)
977 maxtmp2=maxval(tmp2(ixo^s))
981 dtnew=min(dtnew,dtdiff_tcond)
986 tmp2(ixo^s)=tmp(ixo^s)/
block%ds(ixo^s,idim)
987 maxtmp2=maxval(tmp2(ixo^s)/
block%ds(ixo^s,idim))
989 dtdiff_tcond=1.d0/(
tc_gamma_1*maxtmp2+smalldouble)
991 dtnew=min(dtnew,dtdiff_tcond)
994 dtnew=dtnew/dble(
ndim)
1001 integer,
intent(in) :: ixi^
l, ixo^
l, igrid, nflux
1002 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1003 double precision,
intent(in) :: w(ixi^s,1:nw)
1004 double precision,
intent(inout) :: wres(ixi^s,1:nw)
1005 double precision,
intent(in) :: my_dt
1006 logical,
intent(in) :: fix_conserve_at_step
1009 double precision :: te(ixi^s),rho(ixi^s)
1010 double precision :: qvec(ixi^s,1:
ndim),qd(ixi^s)
1011 double precision,
allocatable,
dimension(:^D&,:) :: qvec_equi
1012 double precision,
allocatable,
dimension(:^D&,:,:) :: fluxall
1014 double precision :: dxinv(
ndim)
1015 integer :: idims,ix^
l,ixb^
l
1022 call fl%get_temperature_from_eint(w, x, ixi^
l, ixi^
l, te)
1023 call fl%get_rho(w, x, ixi^
l, ixi^
l, rho)
1025 if(fl%has_equi)
then
1026 allocate(qvec_equi(ixi^s,1:
ndim))
1027 call fl%get_temperature_equi(w, x, ixi^
l, ixi^
l, te)
1028 call fl%get_rho_equi(w, x, ixi^
l, ixi^
l, rho)
1031 qvec(ix^s,idims)=qvec(ix^s,idims) - qvec_equi(ix^s,idims)
1033 deallocate(qvec_equi)
1039 qvec(ix^s,idims)=dxinv(idims)*qvec(ix^s,idims)
1040 ixb^
l=ixo^
l-
kr(idims,^
d);
1041 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixb^s,idims)
1045 qvec(ix^s,idims)=qvec(ix^s,idims)*
block%surfaceC(ix^s,idims)
1046 ixb^
l=ixo^
l-
kr(idims,^
d);
1047 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixb^s,idims)
1049 qd(ixo^s)=qd(ixo^s)/
block%dvolume(ixo^s)
1052 if(fix_conserve_at_step)
then
1053 allocate(fluxall(ixi^s,1,1:
ndim))
1054 fluxall(ixi^s,1,1:
ndim)=my_dt*qvec(ixi^s,1:
ndim)
1058 wres(ixo^s,fl%e_)=qd(ixo^s)
1063 integer,
intent(in) :: ixI^L, ixO^L
1064 double precision,
intent(in) :: x(ixI^S,1:ndim)
1065 double precision,
intent(in) :: w(ixI^S,1:nw)
1067 double precision,
intent(in) :: Te(ixI^S),rho(ixI^S)
1068 double precision,
intent(out) :: qvec(ixI^S,1:ndim)
1069 double precision :: gradT(ixI^S,1:ndim),ke(ixI^S),qd(ixI^S)
1070 integer :: idims,ix^D,ix^L,ixC^L,ixA^L,ixB^L,ixD^L
1074 ixcmax^d=ixomax^d; ixcmin^d=ixomin^d-1;
1080 ixbmax^d=ixmax^d-
kr(idims,^d);
1081 call gradientc(te,x,ixi^l,ixb^l,idims,ke)
1084 if({ix^d==0 .and. ^d==idims |.or. })
then
1085 ixbmin^d=ixcmin^d+ix^d;
1086 ixbmax^d=ixcmax^d+ix^d;
1087 qd(ixc^s)=qd(ixc^s)+ke(ixb^s)
1091 qvec(ixc^s,idims)=qd(ixc^s)*0.5d0**(ndim-1)
1096 where(te(ix^s) < block%wextra(ix^s,fl%Tcoff_))
1097 qd(ix^s)=fl%tc_k_para*dsqrt(block%wextra(ix^s,fl%Tcoff_))**5
1099 qd(ix^s)=fl%tc_k_para*dsqrt(te(ix^s))**5
1102 qd(ix^s)=fl%tc_k_para*dsqrt(te(ix^s))**5
1106 ixbmin^d=ixcmin^d+ix^d;
1107 ixbmax^d=ixcmax^d+ix^d;
1108 ke(ixc^s)=ke(ixc^s)+qd(ixb^s)
1111 ke(ixc^s)=0.5d0**ndim*ke(ixc^s)
1114 gradt(ixc^s,idims)=ke(ixc^s)*qvec(ixc^s,idims)
1117 if(fl%tc_saturate)
then
1120 qd(ix^s)=5.5d0*rho(ix^s)*dsqrt(te(ix^s)**3)
1124 ixbmin^d=ixcmin^d+ix^d;
1125 ixbmax^d=ixcmax^d+ix^d;
1126 ke(ixc^s)=ke(ixc^s)+qd(ixb^s)
1129 ke(ixc^s)=0.5d0**ndim*ke(ixc^s)
1131 qd(ixc^s)=norm2(gradt(ixc^s,:),dim=ndim+1)
1132 {
do ix^db=ixcmin^db,ixcmax^db\}
1133 if(qd(ix^d)>ke(ix^d))
then
1134 ke(ix^d)=ke(ix^d)/(qd(ix^d)+smalldouble)
1135 ^d&gradt({ix^d},^d)=ke({ix^d})*gradt({ix^d},^d)\
1143 ixb^l=ixo^l-kr(idims,^d);
1144 ixamax^d=ixomax^d; ixamin^d=ixbmin^d;
1146 if({ ix^d==0 .and. ^d==idims | .or.})
then
1147 ixbmin^d=ixamin^d-ix^d;
1148 ixbmax^d=ixamax^d-ix^d;
1149 qvec(ixa^s,idims)=qvec(ixa^s,idims)+gradt(ixb^s,idims)
1152 qvec(ixa^s,idims)=qvec(ixa^s,idims)*0.5d0**(ndim-1)
1163 integer,
intent(in) :: ixi^
l, ixo^
l
1164 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
1165 double precision,
intent(in) :: w(ixi^s,1:nw)
1166 double precision :: dtnew
1167 double precision :: mf(ixo^s,1:
ndim),te(ixi^s),rho(ixi^s),gradt(ixi^s)
1168 double precision :: tmp2(ixo^s),tmp(ixo^s),hfs(ixo^s)
1169 double precision :: dtdiff_tcond,maxtmp2
1173 call fl%get_temperature_from_conserved(w,x,ixi^
l,ixi^
l,te)
1177 call fl%get_rho(w,x,ixi^
l,ixo^
l,rho)
1180 if(fl%tc_constant)
then
1181 tmp(ixo^s)=fl%tc_k_para
1183 if(fl%tc_saturate)
then
1190 call gradient(te,ixi^
l,ixo^
l,idims,gradt)
1191 hfs(ixo^s)=hfs(ixo^s)+gradt(ixo^s)*sqrt(mf(ixo^s,idims))
1194 tmp(ixo^s)=fl%tc_k_para*dsqrt(te(ixo^s)**5)/(1.d0+4.2d0*tmp2(ixo^s)*dabs(hfs(ixo^s))/te(ixo^s))
1197 tmp(ixo^s)=fl%tc_k_para*dsqrt(te(ixo^s)**5)
1204 tmp2(ixo^s)=tmp(ixo^s)*mf(ixo^s,idims)/(rho(ixo^s)*
dxlevel(idims))
1205 maxtmp2=maxval(tmp2(ixo^s))
1209 dtnew=min(dtnew,dtdiff_tcond)
1214 tmp2(ixo^s)=tmp(ixo^s)*mf(ixo^s,idims)/(rho(ixo^s)*
block%ds(ixo^s,idims))
1215 maxtmp2=maxval(tmp2(ixo^s)/
block%ds(ixo^s,idims))
1217 dtdiff_tcond=1.d0/(
tc_gamma_1*maxtmp2+smalldouble)
1219 dtnew=min(dtnew,dtdiff_tcond)
1222 dtnew=dtnew/dble(
ndim)
1230 integer,
intent(in) :: ixi^
l, ixo^
l, igrid, nflux
1231 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1232 double precision,
intent(in) :: w(ixi^s,1:nw)
1233 double precision,
intent(inout) :: wres(ixi^s,1:nw)
1234 double precision,
intent(in) :: my_dt
1235 logical,
intent(in) :: fix_conserve_at_step
1238 double precision :: qd(ixi^s)
1239 double precision :: rho(ixi^s),te(ixi^s)
1240 double precision :: qvec(ixi^s,1:
ndim)
1241 double precision,
allocatable,
dimension(:^D&,:) :: qvec_equi
1242 double precision,
allocatable,
dimension(:^D&,:,:) :: fluxall
1243 double precision :: alpha,dxinv(
ndim)
1244 integer :: idims,idir,ix^
d,ix^
l,ixc^
l,ixa^
l,ixb^
l
1254 call fl%get_temperature_from_eint(w, x, ixi^
l, ixi^
l, te)
1255 call fl%get_rho(w, x, ixi^
l, ixi^
l, rho)
1261 qvec(ix^s,idims)=dxinv(idims)*qvec(ix^s,idims)
1262 ixb^
l=ixo^
l-
kr(idims,^
d);
1263 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixb^s,idims)
1267 qvec(ix^s,idims)=qvec(ix^s,idims)*
block%surfaceC(ix^s,idims)
1268 ixb^
l=ixo^
l-
kr(idims,^
d);
1269 qd(ixo^s)=qd(ixo^s)+qvec(ixo^s,idims)-qvec(ixb^s,idims)
1271 qd(ixo^s)=qd(ixo^s)/
block%dvolume(ixo^s)
1274 if(fix_conserve_at_step)
then
1275 allocate(fluxall(ixi^s,1,1:
ndim))
1276 fluxall(ixi^s,1,1:
ndim)=my_dt*qvec(ixi^s,1:
ndim)
1280 wres(ixo^s,fl%e_)=qd(ixo^s)
1285 integer,
intent(in) :: ixI^L, ixO^L
1286 double precision,
intent(in) :: x(ixI^S,1:ndim)
1287 double precision,
intent(in) :: w(ixI^S,1:nw)
1289 double precision,
intent(in) :: rho(ixI^S),Te(ixI^S)
1290 double precision,
intent(in) :: alpha
1291 double precision,
intent(out) :: qvec(ixI^S,1:ndim)
1293 double precision :: qd(ixI^S)
1294 double precision,
dimension(ixI^S,1:ndim) :: mf,Bc,Bcf
1295 double precision,
dimension(ixI^S,1:ndim) :: gradT
1296 double precision,
dimension(ixI^S) :: ka,kaf,ke,kef,qdd,qe,Binv,minq,maxq,Bnorm
1297 double precision,
allocatable,
dimension(:^D&,:,:) :: fluxall
1298 integer,
dimension(ndim) :: lowindex
1299 integer :: idims,idir,ix^D,ix^L,ixC^L,ixA^L,ixB^L,ixA^D,ixB^D
1305 mf(ixi^s,1:ndim)=
block%B0(ixi^s,1:ndim,0)
1307 ixcmax^d=ixomax^d; ixcmin^d=ixomin^d-1;
1311 ixamin^d=ixcmin^d+ix^d;
1312 ixamax^d=ixcmax^d+ix^d;
1313 bc(ixc^s,1:ndim)=bc(ixc^s,1:ndim)+mf(ixa^s,1:ndim)
1315 bc(ixc^s,1:ndim)=bc(ixc^s,1:ndim)*0.5d0**ndim
1319 ixbmax^d=ixmax^d-kr(idims,^d);
1320 call gradientc(te,x,ixi^l,ixb^l,idims,minq)
1321 gradt(ixb^s,idims)=minq(ixb^s)
1323 if(fl%tc_constant)
then
1324 ka(ixc^s)=fl%tc_k_para
1329 {
do ix^db=ixmin^db,ixmax^db\}
1330 if(minq(ix^d) < block%wextra(ix^d,fl%Tcoff_))
then
1331 minq(ix^d)=block%wextra(ix^d,fl%Tcoff_)
1334 minq(ix^s)=fl%tc_k_para*sqrt(minq(ix^s)**5)
1336 minq(ix^s)=fl%tc_k_para*sqrt(te(ix^s)**5)
1340 ixbmin^d=ixcmin^d+ix^d;
1341 ixbmax^d=ixcmax^d+ix^d;
1342 ka(ixc^s)=ka(ixc^s)+minq(ixb^s)
1345 ka(ixc^s)=0.5d0**ndim*ka(ixc^s)
1347 if(fl%tc_slope_limiter==0)
then
1353 if({ ix^d==0 .and. ^d==idims | .or.})
then
1354 ixbmin^d=ixcmin^d+ix^d;
1355 ixbmax^d=ixcmax^d+ix^d;
1356 qd(ixc^s)=qd(ixc^s)+gradt(ixb^s,idims)
1360 qvec(ixc^s,idims)=qd(ixc^s)*0.5d0**(ndim-1)
1365 qd(ixc^s)=qvec(ixc^s,idims)*bc(ixc^s,idims)+qd(ixc^s)
1369 gradt(ixc^s,idims)=ka(ixc^s)*bc(ixc^s,idims)*qd(ixc^s)
1374 ixb^l=ixo^l-kr(idims,^d);
1375 ixamax^d=ixomax^d; ixamin^d=ixbmin^d;
1377 if({ ix^d==0 .and. ^d==idims | .or.})
then
1378 ixbmin^d=ixamin^d-ix^d;
1379 ixbmax^d=ixamax^d-ix^d;
1380 qvec(ixa^s,idims)=qvec(ixa^s,idims)+gradt(ixb^s,idims)
1383 qvec(ixa^s,idims)=qvec(ixa^s,idims)*0.5d0**(ndim-1)
1384 if(fl%tc_saturate)
then
1389 if({ ix^d==0 .and. ^d==idims | .or.})
then
1390 ixbmin^d=ixamin^d-ix^d;
1391 ixbmax^d=ixamax^d-ix^d;
1392 bcf(ixa^s,idims)=bcf(ixa^s,idims)+bc(ixb^s,idims)
1396 bcf(ixa^s,idims)=bcf(ixa^s,idims)*0.5d0**(ndim-1)
1397 ixb^l=ixa^l+kr(idims,^d);
1398 qd(ixa^s)=2.75d0*(rho(ixa^s)+rho(ixb^s))*dsqrt(0.5d0*(te(ixa^s)+te(ixb^s)))**3*dabs(bcf(ixa^s,idims))
1399 {
do ix^db=ixamin^db,ixamax^db\}
1400 if(dabs(qvec(ix^d,idims))>qd(ix^d))
then
1401 qvec(ix^d,idims)=sign(1.d0,qvec(ix^d,idims))*qd(ix^d)
1410 ixb^l=ixo^l-kr(idims,^d);
1411 ixamax^d=ixomax^d; ixamin^d=ixbmin^d;
1413 ixb^l=ixa^l+kr(idims,^d);
1414 bnorm(ixa^s)=0.5d0*(mf(ixa^s,idims)+mf(ixb^s,idims))
1419 if({ ix^d==0 .and. ^d==idims | .or.})
then
1420 ixbmin^d=ixamin^d-ix^d;
1421 ixbmax^d=ixamax^d-ix^d;
1422 bcf(ixa^s,1:ndim)=bcf(ixa^s,1:ndim)+bc(ixb^s,1:ndim)
1423 kaf(ixa^s)=kaf(ixa^s)+ka(ixb^s)
1427 bcf(ixa^s,1:ndim)=bcf(ixa^s,1:ndim)*0.5d0**(ndim-1)
1429 kaf(ixa^s)=kaf(ixa^s)*0.5d0**(ndim-1)
1431 minq(ixa^s)=min(alpha*gradt(ixa^s,idims),gradt(ixa^s,idims)/alpha)
1432 maxq(ixa^s)=max(alpha*gradt(ixa^s,idims),gradt(ixa^s,idims)/alpha)
1437 if({ ix^d==0 .and. ^d==idims | .or.})
then
1438 ixbmin^d=ixcmin^d+ix^d;
1439 ixbmax^d=ixcmax^d+ix^d;
1440 qdd(ixc^s)=qdd(ixc^s)+gradt(ixb^s,idims)
1444 qdd(ixc^s)=qdd(ixc^s)*0.5d0**(ndim-1)
1448 qd(ixc^s)=qdd(ixc^s)
1449 if({ ix^d==0 .and. ^d==idims | .or.})
then
1450 ixbmin^d=ixamin^d-ix^d;
1451 ixbmax^d=ixamax^d-ix^d;
1452 {
do ixa^db=ixamin^db,ixamax^db
1453 ixb^db=ixa^db-ix^db\}
1454 if(qd(ixb^d)<=minq(ixa^d))
then
1455 qd(ixb^d)=minq(ixa^d)
1456 else if(qd(ixb^d)>=maxq(ixa^d))
then
1457 qd(ixb^d)=maxq(ixa^d)
1460 qvec(ixa^s,idims)=qvec(ixa^s,idims)+bc(ixb^s,idims)**2*qd(ixb^s)
1463 qvec(ixa^s,idims)=kaf(ixa^s)*qvec(ixa^s,idims)*0.5d0**(ndim-1)
1466 ixbmax^d=ixamax^d+kr(idims,^d);
1468 if(idir==idims) cycle
1469 qd(ixi^s)=
slope_limiter(gradt(ixi^s,idir),ixi^l,ixb^l,idir,-1,fl%tc_slope_limiter)
1470 qd(ixi^s)=
slope_limiter(qd,ixi^l,ixa^l,idims,1,fl%tc_slope_limiter)
1471 qvec(ixa^s,idims)=qvec(ixa^s,idims)+kaf(ixa^s)*bnorm(ixa^s)*bcf(ixa^s,idir)*qd(ixa^s)
1473 if(fl%tc_saturate)
then
1476 ixb^l=ixa^l+kr(idims,^d);
1477 qd(ixa^s)=2.75d0*(rho(ixa^s)+rho(ixb^s))*dsqrt(0.5d0*(te(ixa^s)+te(ixb^s)))**3*dabs(bnorm(ixa^s))
1478 {
do ix^db=ixamin^db,ixamax^db\}
1479 if(dabs(qvec(ix^d,idims))>qd(ix^d))
then
1482 qvec(ix^d,idims)=sign(1.d0,qvec(ix^d,idims))*qd(ix^d)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module for flux conservation near refinement boundaries.
subroutine, public store_flux(igrid, fC, idimLIM, nwfluxin)
Module with geometry-related routines (e.g., divergence, curl)
subroutine gradient(q, ixIL, ixOL, idir, gradq)
Calculate gradient of a scalar q within ixL in direction idir.
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_density
Physical scaling factor for density.
integer, parameter unitpar
file handle for IO
integer, dimension(3, 3) kr
Kronecker delta tensor.
double precision unit_numberdensity
Physical scaling factor for number density.
integer, parameter ndim
Number of spatial dimensions for grid variables.
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 mype
The rank of the current MPI task.
double precision, dimension(:), allocatable, parameter d
double precision unit_magneticfield
Physical scaling factor for magnetic field.
double precision unit_velocity
Physical scaling factor for velocity.
logical b0field
split magnetic field as background B0 field
double precision unit_temperature
Physical scaling factor for temperature.
logical si_unit
Use SI units (.true.) or use cgs units (.false.)
double precision, dimension(:,:), allocatable dx
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
integer r_
Indices for cylindrical coordinates FOR TESTS, negative value when not used:
Thermal conduction for HD and MHD or RHD and RMHD or twofl (plasma-neutral) module Adaptation of mod_...
subroutine, public sts_set_source_tc_hd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
subroutine, public tc_get_hd_params(fl, read_hd_params)
Init TC coefficients: HD case.
subroutine, public sts_set_source_tc_ffhd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
anisotropic thermal conduction with slope limited symmetric scheme Sharma 2007 Journal of Computation...
subroutine set_source_tc_mhd(ixIL, ixOL, w, x, fl, qvec, rho, Te, alpha)
subroutine gradientc(q, x, ixIL, ixOL, idir, gradq)
Calculate gradient of a scalar q at cell interfaces in direction idir.
subroutine tc_init_params(phys_gamma)
subroutine, public sts_set_source_tc_mhd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
anisotropic thermal conduction with slope limited symmetric scheme Sharma 2007 Journal of Computation...
double precision function, public get_tc_dt_hd(w, ixIL, ixOL, dxD, x, fl)
Get the explicit timestep for the TC (hd implementation)
subroutine set_source_tc_hd(ixIL, ixOL, w, x, fl, qvec, rho, Te)
double precision tc_gamma_1
The adiabatic index.
subroutine, public tc_get_mhd_params(fl, read_mhd_params)
Init TC coefficients: MHD case.
subroutine set_source_tc_ffhd(ixIL, ixOL, w, x, fl, qvec, rho, Te, alpha)
double precision function, public get_tc_dt_ffhd(w, ixIL, ixOL, dxD, x, fl)
Get the explicut timestep for the TC (ffhd implementation)
double precision function, dimension(ixi^s) slope_limiter(f, ixIL, ixOL, idims, pm, tc_slope_limiter)
subroutine, public tc_get_ffhd_params(fl, read_ffhd_params)
double precision function, public get_tc_dt_mhd(w, ixIL, ixOL, dxD, x, fl)
Get the explicut timestep for the TC (mhd implementation)