Determine fields from MHD variables
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | igrid | |||
| double precision, | intent(in) | :: | w_mhd(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,nw) | |||
| double precision, | intent(inout) | :: | w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,ngridvars) |
subroutine fields_from_mhd(igrid, w_mhd, w_part) use mod_global_parameters use mod_geometry integer, intent(in) :: igrid double precision, intent(in) :: w_mhd(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,nw) double precision, intent(inout) :: w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,ngridvars) integer :: idirmin, idir double precision :: current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,7-2*ndir:3) double precision :: w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,1:nw) dxlevel(1)=rnode(rpdx1_,igrid);dxlevel(2)=rnode(rpdx2_,igrid) dxlevel(3)=rnode(rpdx3_,igrid); w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,1:nw) = w_mhd(ixGlo1:ixGhi1,& ixGlo2:ixGhi2,ixGlo3:ixGhi3,1:nw) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,bp(1):bp(3)) = 0.0d0 w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,ep(1):ep(3)) = 0.0d0 call phys_to_primitive(ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,ixGlo1,& ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,w,ps(igrid)%x) ! fill with density: w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,rhop) = w(ixGlo1:ixGhi1,& ixGlo2:ixGhi2,ixGlo3:ixGhi3,iw_rho) ! fill with velocity: w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,vp(:)) = w(ixGlo1:ixGhi1,& ixGlo2:ixGhi2,ixGlo3:ixGhi3,iw_mom(:)) ! fill with magnetic field: if (B0field) then do idir = 1, ndir w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(idir))=w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mag(idir))+ps(igrid)%B0(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,idir,0) end do else w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(:)) = w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,iw_mag(:)) end if ! fill with current current = zero call particle_get_current(w,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,& ixGlo1+1,ixGlo2+1,ixGlo3+1,ixGhi1-1,ixGhi2-1,ixGhi3-1,idirmin,current) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& jp(:)) = current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,:) ! fill with electric field select case (coordinate) case (Cartesian,Cartesian_stretched,spherical) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(1)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(2)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(3)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(3)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(2)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,1) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(2)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(3)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(1)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(1)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(3)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,2) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(3)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(1)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(2)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(2)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(1)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,3) case (cylindrical) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(r_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(phi_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(z_)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(z_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(phi_)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,r_) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(phi_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(z_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(r_)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(r_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(z_)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,phi_) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(z_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(r_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(phi_)) - w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(phi_)) * w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_mom(r_)) + particles_eta * current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,z_) end select ! Hall term if (particles_etah > zero) then select case (coordinate) case (Cartesian,Cartesian_stretched,spherical) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(1)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(1)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_rho) * (current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 2) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(3)) - current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 3) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,bp(2))) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(2)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(2)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_rho) * (-current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 1) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(3)) + current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 3) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,bp(1))) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(3)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(3)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& iw_rho) * (current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 1) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& bp(2)) - current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& 2) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,bp(1))) case (cylindrical) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(r_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(r_)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,iw_rho) * (current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,phi_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(z_)) - current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,z_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(phi_))) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(phi_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(phi_)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,iw_rho) * (-current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,r_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(z_)) + current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,z_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(r_))) w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(z_)) = w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,& ep(z_)) + particles_etah/w(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,iw_rho) * (current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,r_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(phi_)) - current(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,phi_) * w_part(ixGlo1:ixGhi1,ixGlo2:ixGhi2,& ixGlo3:ixGhi3,bp(r_))) end select end if end subroutine fields_from_mhd