fields_from_mhd Subroutine

public subroutine fields_from_mhd(igrid, w_mhd, w_part)

Uses

  • proc~~fields_from_mhd~~UsesGraph proc~fields_from_mhd fields_from_mhd module~mod_geometry mod_geometry proc~fields_from_mhd->module~mod_geometry module~mod_global_parameters mod_global_parameters proc~fields_from_mhd->module~mod_global_parameters module~mod_comm_lib mod_comm_lib module~mod_geometry->module~mod_comm_lib module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Determine fields from MHD variables

Arguments

Type IntentOptional 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)

Calls

proc~~fields_from_mhd~~CallsGraph proc~fields_from_mhd fields_from_mhd phys_to_primitive phys_to_primitive proc~fields_from_mhd->phys_to_primitive proc~particle_get_current particle_get_current proc~fields_from_mhd->proc~particle_get_current proc~curlvector curlvector proc~particle_get_current->proc~curlvector dcos dcos proc~curlvector->dcos dsin dsin proc~curlvector->dsin proc~mpistop mpistop proc~curlvector->proc~mpistop mpi_abort mpi_abort proc~mpistop->mpi_abort

Called by

proc~~fields_from_mhd~~CalledByGraph proc~fields_from_mhd fields_from_mhd proc~fill_gridvars_default fill_gridvars_default proc~fill_gridvars_default->proc~fields_from_mhd proc~gca_fill_gridvars gca_fill_gridvars proc~gca_fill_gridvars->proc~fill_gridvars_default proc~lorentz_fill_gridvars lorentz_fill_gridvars proc~lorentz_fill_gridvars->proc~fill_gridvars_default

Source Code

  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