mod_particle_base Module

Module with shared functionality for all the particle movers


Uses

  • module~~mod_particle_base~~UsesGraph module~mod_particle_base mod_particle_base mod_physics mod_physics module~mod_particle_base->mod_physics module~mod_comm_lib mod_comm_lib module~mod_particle_base->module~mod_comm_lib module~mod_constants mod_constants module~mod_particle_base->module~mod_constants module~mod_global_parameters mod_global_parameters module~mod_particle_base->module~mod_global_parameters module~mod_mpi_wrapper mod_mpi_wrapper module~mod_particle_base->module~mod_mpi_wrapper module~mod_random mod_random module~mod_particle_base->module~mod_random module~mod_global_parameters->module~mod_constants 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_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_mpi_wrapper->mpi module~mod_variables->module~mod_basic_types

Used by

  • module~~mod_particle_base~~UsedByGraph module~mod_particle_base mod_particle_base module~mod_particle_advect mod_particle_advect module~mod_particle_advect->module~mod_particle_base module~mod_particle_gca mod_particle_gca module~mod_particle_gca->module~mod_particle_base module~mod_particle_lorentz mod_particle_lorentz module~mod_particle_lorentz->module~mod_particle_base module~mod_particle_sample mod_particle_sample module~mod_particle_sample->module~mod_particle_base module~mod_particles mod_particles module~mod_particles->module~mod_particle_base module~mod_particles->module~mod_particle_advect module~mod_particles->module~mod_particle_gca module~mod_particles->module~mod_particle_lorentz module~mod_particles->module~mod_particle_sample module~mod_point_searching mod_point_searching module~mod_point_searching->module~mod_particle_base proc~advance advance proc~advance->module~mod_particles proc~main main proc~main->module~mod_particles proc~resettree resettree proc~resettree->module~mod_particles proc~saveamrfile saveamrfile proc~saveamrfile->module~mod_particles proc~timeintegration timeintegration proc~timeintegration->module~mod_particles

Variables

Type Visibility Attributes Name Initial
integer, public, allocatable :: bp(:)

Variable index for magnetic field

double precision, public :: const_dt_particles

If positive, a constant time step for the particles

character(len=60), public :: csv_format

Format string used in CSV files

character(len=400), public :: csv_header

Header string used in CSV files

integer, public :: downsample_particles

Particle downsampling factor in CSV output

double precision, public :: dtheta
double precision, public :: dtsave_particles

Time interval to save particles

integer, public, allocatable :: ep(:)

Variable index for electric field

integer, public :: igrid_working

set the current igrid for the particle integrator:

integer, public :: integrator

Integrator to be used for particles

character(len=name_len), public :: integrator_type_particles = ""

String describing the particle integrator type

double precision, public :: integrator_velocity_factor(3)

Normalization factor for velocity in the integrator

integer, public :: ipart_working

set the current ipart for the particle integrator:

integer, public, allocatable :: ipe_neighbor(:)
integer, public :: it_particles

Iteration number of paritcles

integer, public, allocatable :: jp(:)

Variable index for current

logical, public :: losses
double precision, public :: min_particle_time

Minimum time of all particles

integer, public :: n_output_destroyed

Output count for ensembles of destroyed particles

integer, public :: ndefpayload

Number of default payload variables for a particle

integer, public :: ngridvars

Number of variables for grid field

integer, public :: nparticles

Identity number and total number of particles

integer, public :: nparticles_active_on_mype

Number of active particles in current processor

integer, public :: nparticles_on_mype

Number of particles in current processor

integer, public :: nparticles_per_cpu_hi

Maximum number of particles in one processor

integer, public :: nparticleshi

Maximum number of particles

integer, public :: npayload

Number of total payload variables for a particle

integer, public :: npe_neighbors
integer, public :: num_particles

Number of particles

integer, public :: nusrpayload

Number of user-defined payload variables for a particle

type(particle_ptr), public, dimension(:), allocatable :: particle
integer, public, dimension(:), allocatable :: particles_active_on_mype

Array of identity numbers of active particles in current processor

double precision, public :: particles_cfl

Particle CFL safety factor

procedure(sub_define_additional_gridvars), public, pointer :: particles_define_additional_gridvars => null()
double precision, public :: particles_eta

Resistivity

double precision, public :: particles_etah

Resistivity

procedure(sub_fill_additional_gridvars), public, pointer :: particles_fill_additional_gridvars => null()
procedure(sub_fill_gridvars), public, pointer :: particles_fill_gridvars => null()
procedure(sub_integrate), public, pointer :: particles_integrate => null()
integer, public, dimension(:), allocatable :: particles_on_mype

Array of identity numbers of particles in current processor

character(len=name_len), public :: physics_type_particles = ""

String describing the particle physics type

logical, public :: relativistic

Use a relativistic particle mover?

integer, public :: rhop

Variable index for density

type(rng_t), public :: rng
double precision, public :: t_next_output

Time to write next particle output

double precision, public :: tmax_particles

Time limit of particles

integer, public :: type_particle
integer, public, parameter :: unitparticles = 15
procedure(fun_destroy), public, pointer :: usr_destroy_particle => null()
integer, public, allocatable :: vp(:)

Variable index for fluid velocity

logical, public :: write_ensemble

Whether to write ensemble output

logical, public :: write_individual

Whether to write individual particle output (followed particles)

logical, public :: write_snapshot

Whether to write particle snapshots


Interfaces

interface

  • public function fun_destroy(myparticle)

    Arguments

    Type IntentOptional Attributes Name
    type(particle_ptr), intent(in) :: myparticle

    Return Value logical

interface

  • public subroutine sub_define_additional_gridvars(ngridvars)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout) :: ngridvars

interface

  • public subroutine sub_fill_additional_gridvars()

    Arguments

    None

interface

  • public subroutine sub_fill_gridvars()

    Arguments

    None

interface

  • public subroutine sub_integrate(end_time)

    Arguments

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

Derived Types

type, public ::  particle_ptr

Components

Type Visibility Attributes Name Initial
integer, public :: igrid
integer, public :: ipe
double precision, public, allocatable :: payload(:)

extra information carried by the particle

type(particle_t), public, pointer :: self

type, public ::  particle_t

Components

Type Visibility Attributes Name Initial
double precision, public :: dt

time step

logical, public :: follow

follow the history of the particle

integer, public :: index

identity number

double precision, public :: m

mass

double precision, public :: q

charge

double precision, public :: time

time

double precision, public :: u(3)

velocity, momentum, or special ones

double precision, public :: x(3)

coordinates


Functions

public function make_particle_filename(tout, index, type)

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: tout
integer, intent(in) :: index
character(len=*), intent(in) :: type

Return Value character(len=128)

public function particle_in_domain(x)

Check if particle is inside computational domain

Arguments

Type IntentOptional Attributes Name
double precision, intent(in), dimension(ndim) :: x

Return Value logical

public function particle_in_igrid(ipart, igrid)

Quick check if particle is still in igrid

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ipart
integer, intent(in) :: igrid

Return Value logical

public function point_in_igrid_ghostc(x, igrid, ngh)

Quick check if particle coordinate is inside igrid (ghost cells included, except the last ngh)

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: x(ndim)
integer, intent(in) :: igrid
integer, intent(in) :: ngh

Return Value logical


Subroutines

public subroutine advance_particles(end_time, steps_taken)

Routine handles the particle evolution

Arguments

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

Advance at most up to this time

integer, intent(out) :: steps_taken

public subroutine append_to_snapshot(myparticle, mypayload)

Arguments

Type IntentOptional Attributes Name
type(particle_t), intent(in) :: myparticle
double precision :: mypayload(1:npayload)

public subroutine apply_periodB(particle, igrid_particle, ipe_particle, BC_applied)

Arguments

Type IntentOptional Attributes Name
type(particle_t), intent(inout) :: particle
integer, intent(inout) :: igrid_particle
integer, intent(inout) :: ipe_particle
logical, intent(out) :: BC_applied

public subroutine comm_particles()

Arguments

None

public subroutine comm_particles_global()

Arguments

None

public subroutine cross(a, b, c)

Arguments

Type IntentOptional Attributes Name
double precision, intent(in), dimension(ndir) :: a
double precision, intent(in), dimension(ndir) :: b
double precision, intent(out), dimension(ndir) :: c

public subroutine destroy_particles(destroy_n_particles_mype, particle_index_to_be_destroyed)

clean up destroyed particles on all cores

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: destroy_n_particles_mype
integer, intent(in), dimension(1:destroy_n_particles_mype) :: particle_index_to_be_destroyed

public subroutine fields_from_mhd(igrid, w_mhd, w_part)

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)

public subroutine fill_gridvars_default()

This routine fills the particle grid variables with the default for mhd, i.e. only E and B

Arguments

None

public subroutine find_particle_ipe(x, igrid_particle, ipe_particle)

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: x(3)
integer, intent(out) :: igrid_particle
integer, intent(out) :: ipe_particle

public subroutine finish_gridvars()

Deallocate grid variables for particles

Arguments

None

public subroutine fix_phi_crossing(xp, igrid)

Fix particle position when crossing the 0,2pi boundary in noncartesian coordinates

Arguments

Type IntentOptional Attributes Name
double precision, intent(inout) :: xp(1:3)
integer, intent(in) :: igrid

public subroutine get_bfield(igrid, x, tloc, b)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: igrid
double precision, intent(in), dimension(3) :: x
double precision, intent(in) :: tloc
double precision, intent(out), dimension(ndir) :: b

public subroutine get_efield(igrid, x, tloc, e)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: igrid
double precision, intent(in), dimension(3) :: x
double precision, intent(in) :: tloc
double precision, intent(out), dimension(ndir) :: e

public pure subroutine get_lfac(u, lfac)

Get Lorentz factor from relativistic momentum

Arguments

Type IntentOptional Attributes Name
double precision, intent(in), dimension(3) :: u
double precision, intent(out) :: lfac

public pure subroutine get_lfac_from_velocity(v, lfac)

Get Lorentz factor from velocity

Arguments

Type IntentOptional Attributes Name
double precision, intent(in), dimension(3) :: v
double precision, intent(out) :: lfac

public subroutine get_maxwellian_velocity(v, velocity)

Arguments

Type IntentOptional Attributes Name
double precision, intent(out) :: v(3)
double precision, intent(in) :: velocity

public subroutine get_uniform_pos(x)

Arguments

Type IntentOptional Attributes Name
double precision, intent(out) :: x(3)

public subroutine get_vec(ix, igrid, x, tloc, vec)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ix(ndir)

Indices in gridvars

integer, intent(in) :: igrid
double precision, intent(in), dimension(3) :: x
double precision, intent(in) :: tloc
double precision, intent(out), dimension(ndir) :: vec

public subroutine handle_particles()

Let particles evolve in time. The routine also handles grid variables and output.

Arguments

None

public subroutine init_gridvars()

Initialize grid variables for particles

Arguments

None

public subroutine init_particles_com()

Initialize communicators for particles

Arguments

None

public subroutine init_particles_output()

Arguments

None

public subroutine interpolate_var(igrid, ixImin1, ixImin2, ixImin3, ixImax1, ixImax2, ixImax3, ixOmin1, ixOmin2, ixOmin3, ixOmax1, ixOmax2, ixOmax3, gf, x, xloc, gfloc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: igrid
integer, intent(in) :: ixImin1
integer, intent(in) :: ixImin2
integer, intent(in) :: ixImin3
integer, intent(in) :: ixImax1
integer, intent(in) :: ixImax2
integer, intent(in) :: ixImax3
integer, intent(in) :: ixOmin1
integer, intent(in) :: ixOmin2
integer, intent(in) :: ixOmin3
integer, intent(in) :: ixOmax1
integer, intent(in) :: ixOmax2
integer, intent(in) :: ixOmax3
double precision, intent(in) :: gf(ixImin1:ixImax1,ixImin2:ixImax2,ixImin3:ixImax3)
double precision, intent(in) :: x(ixImin1:ixImax1,ixImin2:ixImax2,ixImin3:ixImax3,1:ndim)
double precision, intent(in) :: xloc(1:3)
double precision, intent(out) :: gfloc

public subroutine ipe_cf(i1, i2, i3, igrid, ipe_is_neighbor)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i1
integer, intent(in) :: i2
integer, intent(in) :: i3
integer, intent(in) :: igrid
logical, intent(inout) :: ipe_is_neighbor(0:npe-1)

public subroutine ipe_fc(i1, i2, i3, igrid, ipe_is_neighbor)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i1
integer, intent(in) :: i2
integer, intent(in) :: i3
integer, intent(in) :: igrid
logical, intent(inout) :: ipe_is_neighbor(0:npe-1)

public subroutine ipe_srl(i1, i2, i3, igrid, ipe_is_neighbor)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i1
integer, intent(in) :: i2
integer, intent(in) :: i3
integer, intent(in) :: igrid
logical, intent(inout) :: ipe_is_neighbor(0:npe-1)

public pure subroutine limit_dt_endtime(t_left, dt_p)

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: t_left
double precision, intent(inout) :: dt_p

public subroutine locate_particle(index, igrid_particle, ipe_particle)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: index
integer, intent(out) :: igrid_particle
integer, intent(out) :: ipe_particle

public subroutine output_ensemble(send_n_particles_for_output, send_particles, send_payload, typefile)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: send_n_particles_for_output
type(particle_t), intent(in), dimension(send_n_particles_for_output) :: send_particles
double precision, intent(in), dimension(npayload,send_n_particles_for_output) :: send_payload
character(len=*), intent(in) :: typefile

public subroutine output_individual()

Arguments

None

public subroutine output_particle(myparticle, payload, ipe, file_unit)

Arguments

Type IntentOptional Attributes Name
type(particle_t), intent(in) :: myparticle
double precision, intent(in) :: payload(npayload)
integer, intent(in) :: ipe
integer, intent(in) :: file_unit

public subroutine partcoord_from_cartesian(xp, xpcart)

Convert to noncartesian coordinates

Arguments

Type IntentOptional Attributes Name
double precision, intent(out) :: xp(1:3)
double precision, intent(in) :: xpcart(1:3)

public subroutine partcoord_to_cartesian(xp, xpcart)

Convert position to Cartesian coordinates

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: xp(1:3)
double precision, intent(out) :: xpcart(1:3)

public subroutine particle_base_init()

Give initial values to parameters

Arguments

None

public subroutine particle_get_current(w, ixImin1, ixImin2, ixImin3, ixImax1, ixImax2, ixImax3, ixOmin1, ixOmin2, ixOmin3, ixOmax1, ixOmax2, ixOmax3, idirmin, current)

Calculate idirmin and the idirmin:3 components of the common current array make sure that dxlevel(^D) is set correctly.

Arguments

Type IntentOptional Attributes Name
double precision :: w(ixImin1:ixImax1,ixImin2:ixImax2,ixImin3:ixImax3,1:nw)
integer :: ixImin1
integer :: ixImin2
integer :: ixImin3
integer :: ixImax1
integer :: ixImax2
integer :: ixImax3
integer :: ixOmin1
integer :: ixOmin2
integer :: ixOmin3
integer :: ixOmax1
integer :: ixOmax2
integer :: ixOmax3
integer :: idirmin
double precision :: current(ixImin1:ixImax1,ixImin2:ixImax2,ixImin3:ixImax3,7-2*ndir:3)

public subroutine particles_finish()

Finalize the particles module

Arguments

None

public subroutine particles_params_read(files)

Read this module's parameters from a file

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: files(:)

public subroutine partvec_from_cartesian(xp, up, upcart)

Convert vector from Cartesian coordinates

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: xp(1:3)
double precision, intent(out) :: up(1:3)
double precision, intent(in) :: upcart(1:3)

public subroutine partvec_to_cartesian(xp, up, upcart)

Convert vector to Cartesian coordinates

Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: xp(1:3)
double precision, intent(in) :: up(1:3)
double precision, intent(out) :: upcart(1:3)

public subroutine pull_particle_from_particles_on_mype(ipart)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ipart

public subroutine push_particle_into_particles_on_mype(ipart)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ipart

public subroutine read_from_snapshot()

Arguments

None

public subroutine read_particles_snapshot(file_exists)

Arguments

Type IntentOptional Attributes Name
logical, intent(out) :: file_exists

public subroutine select_active_particles(end_time)

Arguments

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

public subroutine set_neighbor_ipe()

Arguments

None

public subroutine time_spent_on_particles()

Arguments

None

public subroutine update_gridvars()

update grid variables for particles

Arguments

None

public subroutine write_particle_output()

Arguments

None

public subroutine write_particles_snapshot()

Arguments

None