Lorentz_get_particle_dt Function

private function Lorentz_get_particle_dt(partp, end_time) result(dt_p)

Uses

  • proc~~lorentz_get_particle_dt~~UsesGraph proc~lorentz_get_particle_dt Lorentz_get_particle_dt module~mod_geometry mod_geometry proc~lorentz_get_particle_dt->module~mod_geometry module~mod_global_parameters mod_global_parameters proc~lorentz_get_particle_dt->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

Arguments

Type IntentOptional Attributes Name
type(particle_ptr), intent(in) :: partp
double precision, intent(in) :: end_time

Return Value double precision


Calls

proc~~lorentz_get_particle_dt~~CallsGraph proc~lorentz_get_particle_dt Lorentz_get_particle_dt proc~get_lfac get_lfac proc~lorentz_get_particle_dt->proc~get_lfac proc~get_vec get_vec proc~lorentz_get_particle_dt->proc~get_vec proc~limit_dt_endtime limit_dt_endtime proc~lorentz_get_particle_dt->proc~limit_dt_endtime proc~interpolate_var interpolate_var proc~get_vec->proc~interpolate_var proc~mpistop mpistop proc~interpolate_var->proc~mpistop mpi_abort mpi_abort proc~mpistop->mpi_abort

Called by

proc~~lorentz_get_particle_dt~~CalledByGraph proc~lorentz_get_particle_dt Lorentz_get_particle_dt proc~lorentz_integrate_particles Lorentz_integrate_particles proc~lorentz_integrate_particles->proc~lorentz_get_particle_dt

Source Code

  function Lorentz_get_particle_dt(partp, end_time) result(dt_p)
    use mod_global_parameters
    use mod_geometry
    type(particle_ptr), intent(in)   :: partp
    double precision, intent(in)     :: end_time
    double precision                 :: dt_p
    integer                          :: ipart, iipart, nout
    double precision,dimension(ndir) :: b,v
    double precision                 :: lfac,absb,dt_cfl
    double precision                 :: tout
    double precision, parameter      :: cfl = 0.5d0

    if (const_dt_particles > 0) then
      dt_p = const_dt_particles
      return
    end if

    call get_vec(bp, partp%igrid,partp%self%x,partp%self%time,b)
    absb = sqrt(sum(b(:)**2))
    call get_lfac(partp%self%u,lfac)

    ! CFL timestep
    ! make sure we step only one cell at a time:
    v(:) = abs(partp%self%u(:) / lfac)

!    ! convert to angular velocity:
!    if(coordinate ==cylindrical.and.phi_>0) then
!      v(phi_) = abs(v(phi_)/partp%self%x(r_))
!    end if

    dt_cfl = min(bigdouble, rnode(rpdx1_,partp%igrid)/max(v(1), smalldouble),&
       rnode(rpdx2_,partp%igrid)/max(v(2), smalldouble),rnode(rpdx3_,&
       partp%igrid)/max(v(3), smalldouble))

    if(coordinate ==cylindrical.and.phi_>0) then
      ! phi-momentum leads to radial velocity:
      if(phi_ .gt. ndim) dt_cfl = min(dt_cfl, sqrt(rnode(rpdx1_,&
         partp%igrid)/partp%self%x(r_)) / v(phi_))
      ! limit the delta phi of the orbit (just for aesthetic reasons):
      dt_cfl = min(dt_cfl,0.1d0/max(v(phi_), smalldouble))
      ! take some care at the axis:
      dt_cfl = min(dt_cfl,(partp%self%x(r_)+smalldouble)/max(v(r_),&
          smalldouble))
    end if

    dt_cfl = dt_cfl * cfl

    ! bound by gyro-rotation:
    dt_p = abs( dtheta * partp%self%m * lfac / (partp%self%q * absb) )

    dt_p = min(dt_p, dt_cfl)

    ! Make sure we don't advance beyond end_time
    call limit_dt_endtime(end_time - partp%self%time, dt_p)

  end function Lorentz_get_particle_dt