Module with shared functionality for all the particle movers
| 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_ptr), | intent(in) | :: | myparticle |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | ngridvars |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | end_time |
| 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 | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | tout | |||
| integer, | intent(in) | :: | index | |||
| character(len=*), | intent(in) | :: | type |
Check if particle is inside computational domain
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in), | dimension(ndim) | :: | x |
Quick check if particle is still in igrid
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ipart | |||
| integer, | intent(in) | :: | igrid |
Quick check if particle coordinate is inside igrid (ghost cells included, except the last ngh)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | x(ndim) | |||
| integer, | intent(in) | :: | igrid | |||
| integer, | intent(in) | :: | ngh |
Routine handles the particle evolution
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | end_time |
Advance at most up to this time |
||
| integer, | intent(out) | :: | steps_taken |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_t), | intent(in) | :: | myparticle | |||
| double precision | :: | mypayload(1:npayload) |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_t), | intent(inout) | :: | particle | |||
| integer, | intent(inout) | :: | igrid_particle | |||
| integer, | intent(inout) | :: | ipe_particle | |||
| logical, | intent(out) | :: | BC_applied |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in), | dimension(ndir) | :: | a | ||
| double precision, | intent(in), | dimension(ndir) | :: | b | ||
| double precision, | intent(out), | dimension(ndir) | :: | c |
clean up destroyed particles on all cores
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | destroy_n_particles_mype | |||
| integer, | intent(in), | dimension(1:destroy_n_particles_mype) | :: | particle_index_to_be_destroyed |
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) |
This routine fills the particle grid variables with the default for mhd, i.e. only E and B
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | x(3) | |||
| integer, | intent(out) | :: | igrid_particle | |||
| integer, | intent(out) | :: | ipe_particle |
Deallocate grid variables for particles
Fix particle position when crossing the 0,2pi boundary in noncartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(inout) | :: | xp(1:3) | |||
| integer, | intent(in) | :: | igrid |
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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 |
Get Lorentz factor from relativistic momentum
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in), | dimension(3) | :: | u | ||
| double precision, | intent(out) | :: | lfac |
Get Lorentz factor from velocity
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in), | dimension(3) | :: | v | ||
| double precision, | intent(out) | :: | lfac |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(out) | :: | v(3) | |||
| double precision, | intent(in) | :: | velocity |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(out) | :: | x(3) |
| Type | Intent | Optional | 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 |
Let particles evolve in time. The routine also handles grid variables and output.
Initialize grid variables for particles
Initialize communicators for particles
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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) |
| Type | Intent | Optional | 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) |
| Type | Intent | Optional | 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) |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | t_left | |||
| double precision, | intent(inout) | :: | dt_p |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | index | |||
| integer, | intent(out) | :: | igrid_particle | |||
| integer, | intent(out) | :: | ipe_particle |
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_t), | intent(in) | :: | myparticle | |||
| double precision, | intent(in) | :: | payload(npayload) | |||
| integer, | intent(in) | :: | ipe | |||
| integer, | intent(in) | :: | file_unit |
Convert to noncartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(out) | :: | xp(1:3) | |||
| double precision, | intent(in) | :: | xpcart(1:3) |
Convert position to Cartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | xp(1:3) | |||
| double precision, | intent(out) | :: | xpcart(1:3) |
Give initial values to parameters
Calculate idirmin and the idirmin:3 components of the common current array make sure that dxlevel(^D) is set correctly.
| Type | Intent | Optional | 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) |
Finalize the particles module
Read this module's parameters from a file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | files(:) |
Convert vector from Cartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | xp(1:3) | |||
| double precision, | intent(out) | :: | up(1:3) | |||
| double precision, | intent(in) | :: | upcart(1:3) |
Convert vector to Cartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | xp(1:3) | |||
| double precision, | intent(in) | :: | up(1:3) | |||
| double precision, | intent(out) | :: | upcart(1:3) |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ipart |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ipart |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(out) | :: | file_exists |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(in) | :: | end_time |
update grid variables for particles