Skip to content

Commit 0258cb3

Browse files
committed
Merge branch 'development' into use_modulusshuffle_instead_of_yates
2 parents 7b0e42b + 66006c9 commit 0258cb3

18 files changed

Lines changed: 405 additions & 105 deletions

Docs/source/install/dependencies.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ List of Dependencies
66
WarpX depends on the following popular third party software.
77
Please see installation instructions below.
88

9-
- a mature `C++20 <https://en.wikipedia.org/wiki/C%2B%2B17>`__ compiler, e.g., GCC 12+, Clang 14, NVCC 12.4, MSVC 19.39 or newer
9+
- a mature `C++20 <https://en.wikipedia.org/wiki/C%2B%2B20>`__ compiler, e.g., GCC 12+, Clang 14, NVCC 12.4, MSVC 19.39 or newer
1010
- `CMake 3.24.0+ <https://cmake.org>`__
1111
- `Git 2.18+ <https://git-scm.com>`__
1212
- `AMReX <https://amrex-codes.github.io>`__: we automatically download and compile a copy of AMReX
@@ -23,8 +23,8 @@ Optional dependencies include:
2323
- for on-node accelerated compute *one of either*:
2424

2525
- `OpenMP 3.1+ <https://www.openmp.org>`__: for threaded CPU execution or
26-
- `CUDA Toolkit 11.7+ <https://developer.nvidia.com/cuda-downloads>`__: for Nvidia GPU support (see `matching host-compilers <https://gist.github.com/ax3l/9489132>`__) or
27-
- `ROCm 5.2+ (5.5+ recommended) <https://gpuopen.com/learn/amd-lab-notes/amd-lab-notes-rocm-installation-readme/>`__: for AMD GPU support
26+
- `CUDA Toolkit 12.2+ <https://developer.nvidia.com/cuda-downloads>`__: for Nvidia GPU support (see `matching host-compilers <https://gist.github.com/ax3l/9489132>`__) or
27+
- `ROCm 5.5+ <https://gpuopen.com/learn/amd-lab-notes/amd-lab-notes-rocm-installation-readme/>`__: for AMD GPU support
2828
- `oneAPI <https://www.intel.com/content/www/us/en/developer/tools/oneapi/overview.html>`__: for Intel GPU support
2929
- `FFTW3 <http://www.fftw.org>`__: for spectral solver (PSATD or IGF) support when running on CPU or SYCL
3030

@@ -35,10 +35,9 @@ Optional dependencies include:
3535

3636
- see `optional I/O backends <https://github.com/openPMD/openPMD-api#dependencies>`__, i.e., ADIOS2 and/or HDF5
3737
- `Ascent 0.8.0+ <https://ascent.readthedocs.io>`__: for in situ 3D visualization
38-
- `SENSEI 4.0.0+ <https://sensei-insitu.org>`__: for in situ analysis and visualization
3938
- `CCache <https://ccache.dev>`__: to speed up rebuilds (For CUDA support, needs version 3.7.9+ and 4.2+ is recommended)
4039
- `Ninja <https://ninja-build.org>`__: for faster parallel compiles
41-
- `Python 3.9+ <https://www.python.org>`__
40+
- `Python 3.11+ <https://www.python.org>`__
4241

4342
- `mpi4py <https://mpi4py.readthedocs.io>`__
4443
- `numpy <https://numpy.org>`__

Docs/source/usage/parameters.rst

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,8 @@ Details about the collision models can be found in the :ref:`theory section <mul
31003100
:default: 0
31013101
:optional:
31023102

3103-
For pairwisecoulomb collisions, whether to correct the energy and momentum after the collisions so that they are conserved.
3103+
Only for ``pairwisecoulomb`` collisions, whether to correct the energy and momentum after the collisions so that they are conserved.
3104+
This can be set for each collision using :pp:param:`<collision_name>.correct_energy_momentum`.
31043105
In binary collisions, if the weights of the colliding particles are not the same, the collision does not
31053106
exactly conserve energy and momentum. When this option is on, after the collisions, small modifications are made to the
31063107
particle momentum so that the energy and momentum are exactly conserved in each cell.
@@ -3111,25 +3112,39 @@ Details about the collision models can be found in the :ref:`theory section <mul
31113112
:default: 0.05
31123113
:optional:
31133114

3114-
For pairwisecoulomb collisions, when correcting the energy and momentum conservation, the energy correction is applied to pairs of particles in their center of momentum frame.
3115+
Only for ``pairwisecoulomb`` collisions, with :pp:param:`collisions.correct_energy_momentum` set, the energy correction is applied to pairs of particles in their center of momentum frame.
3116+
This can be set for each collision using :pp:param:`<collision_name>.energy_fraction`.
31153117
This parameter is the fraction of the relative energy in the COM frame that is used in the correction.
31163118

31173119
.. pp:param:: collisions.energy_fraction_max
31183120
:type: ``float``
31193121
:default: 0.5
31203122
:optional:
31213123

3122-
For pairwisecoulomb collisions, when correcting the energy and momentum conservation, the energy correction is applied to pairs of particles in their center of momentum frame.
3123-
This parameter is the fraction of the total relative energy in the COM frame of all pairs that is used in the correction.
3124+
Only for ``pairwisecoulomb`` collisions, with :pp:param:`collisions.correct_energy_momentum` set, the energy correction is applied to pairs of particles in their center of momentum frame.
3125+
This can be set for each collision using :pp:param:`<collision_name>.energy_fraction_max`.
3126+
This parameter sets the maximum allowed value for :pp:param:`collisions.energy_fraction`.
3127+
If residual energy error remains after a pass over all particle pairs in a cell, the algorithm increases the effective correction fraction for the next pass based on an estimate of the remaining error.
3128+
If this computed value exceeds the limit imposed by this parameter, the correction is deemed to have failed and particle velocities in the cell are restored to their pre-collision values.
31243129

31253130
.. pp:param:: collisions.beta_weight_exponent
31263131
:type: ``float``
31273132
:default: 1.
31283133
:optional:
31293134

3130-
For pairwisecoulomb collisions, when correcting the energy and momentum conservation, this parameter controls the exponent used on the particle weight when distributing the momentum correction.
3135+
Only for ``pairwisecoulomb`` collisions, with :pp:param:`collisions.correct_energy_momentum` set, this parameter controls the exponent used on the particle weight when distributing the momentum correction.
3136+
This can be set for each collision using :pp:param:`<collision_name>.beta_weight_exponent`.
31313137
With a value greater than 1, it will distribute more of the correction to particles with higher weights.
31323138

3139+
.. pp:param:: collisions.energy_correction_sort_by_weight
3140+
:type: ``bool``
3141+
:default: 0
3142+
:optional:
3143+
3144+
Only for ``pairwisecoulomb`` collisions, with :pp:param:`collisions.correct_energy_momentum` set, specifies whether the particles are sorted by weight when the energy correction is applied.
3145+
This can be set for each collision using :pp:param:`<collision_name>.energy_correction_sort_by_weight`.
3146+
When the particles have a range of weights, sorting improves the correction by applying more of it to the heavier weighted particles, which has a proportionately smaller effect on their momenta, and typically reduces the number of particles that the correction is applied to.
3147+
31333148
.. pp:param:: collisions.split_momentum_push
31343149
:type: ``bool``
31353150
:default: 1
@@ -3140,30 +3155,6 @@ Details about the collision models can be found in the :ref:`theory section <mul
31403155
This is only implemented for the explicit evolve scheme and is not available for the implicit evolve schemes, because the implicit
31413156
formulation is intrinsically energy-conserving when combined with MCC collisions, as shown in `Angus et al., J. Comput. Phys. 456, 2022 <https://doi.org/10.1016/j.jcp.2022.111030>`__.
31423157

3143-
.. pp:param:: <collision_name>.correct_energy_momentum
3144-
:type: ``bool``
3145-
:optional:
3146-
3147-
For pairwisecoulomb collisions, override the parameter :pp:param:`collisions.correct_energy_momentum` for the specific collision.
3148-
3149-
.. pp:param:: <collision_name>.energy_fraction
3150-
:type: ``float``
3151-
:optional:
3152-
3153-
For pairwisecoulomb collisions, override the parameter :pp:param:`collisions.energy_fraction` for the specific collision.
3154-
3155-
.. pp:param:: <collision_name>.energy_fraction_max
3156-
:type: ``float``
3157-
:optional:
3158-
3159-
For pairwisecoulomb collisions, override the parameter :pp:param:`collisions.energy_fraction_max` for the specific collision.
3160-
3161-
.. pp:param:: <collision_name>.beta_weight_exponent
3162-
:type: ``float``
3163-
:optional:
3164-
3165-
For pairwisecoulomb collisions, override the parameter :pp:param:`collisions.beta_weight_exponent` for the specific collision.
3166-
31673158
.. pp:param:: collisions.shuffling_method
31683159
:type: ``bool``
31693160
:default: 0

Examples/Tests/collision/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ add_warpx_test(
131131
OFF # dependency
132132
)
133133

134+
add_warpx_test(
135+
test_2d_charge_exchange_dsmc # name
136+
2 # dims
137+
1 # nprocs
138+
inputs_test_2d_charge_exchange_dsmc # inputs
139+
"analysis_test_2d_collisions_split_momentum_push.py --path diags/reducedfiles/" # analysis
140+
"analysis_default_regression.py --path diags/diag1/" # checksum
141+
OFF # dependency
142+
)
143+
134144
add_warpx_test(
135145
test_2d_collisions_split_momentum_push_electrostatic # name
136146
2 # dims

Examples/Tests/collision/analysis_test_2d_collisions_split_momentum_push.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def analyze(args: argparse.Namespace) -> None:
4242
num_particles_per_cell_array = np.array(
4343
[int(nppc) for nppc in num_particles_per_cell_list]
4444
)
45+
num_species = len(input_dict["particles.species_names"])
4546
num_particles_per_cell = np.prod(num_particles_per_cell_array)
4647
electrostatic = (
4748
True
@@ -52,9 +53,9 @@ def analyze(args: argparse.Namespace) -> None:
5253
else False
5354
)
5455
if electrostatic:
55-
equipartition_value = 1 / (6 * num_particles_per_cell + 1)
56+
equipartition_value = 1 / (3 * num_species * num_particles_per_cell + 1)
5657
else:
57-
equipartition_value = 5 / (6 * num_particles_per_cell + 5)
58+
equipartition_value = 5 / (3 * num_species * num_particles_per_cell + 5)
5859

5960
# normalize the field energy variation
6061
electron_temperature = float(input_dict["my_constants.Te"][0])
@@ -117,7 +118,7 @@ def analyze(args: argparse.Namespace) -> None:
117118
)
118119

119120
# compare the final value of the field energy variation to the reference equipartition value
120-
relative_tolerance = 1e-1 if electrostatic else 5e-1
121+
relative_tolerance = 1.1e-1 if electrostatic else 5e-1
121122
# average over the last 100 time steps to reduce noise
122123
field_energy_error_avg = np.mean(field_energy_error[-100:])
123124
if not np.isclose(
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# 2D charge exchange collision test (DSMC), with electrostatic solver.
2+
# Electrons (neutralizing background) + He+ ions + He neutrals.
3+
# He+ and He undergo DSMC charge exchange.
4+
# The electrostatic solver is active; total energy (field + particle) conservation
5+
# is verified using analysis_test_2d_collisions_split_momentum_push.py.
6+
7+
# algo
8+
algo.field_gathering = energy-conserving
9+
algo.particle_shape = 2
10+
11+
# amr
12+
amr.max_level = 0
13+
amr.n_cell = 16 16
14+
15+
# boundary
16+
boundary.field_hi = periodic periodic
17+
boundary.field_lo = periodic periodic
18+
boundary.particle_hi = periodic periodic
19+
boundary.particle_lo = periodic periodic
20+
21+
# collisions
22+
collisions.collision_names = cx_col
23+
cx_col.type = dsmc
24+
cx_col.scattering_processes = charge_exchange
25+
cx_col.species = Heplus He
26+
cx_col.product_species = He Heplus
27+
cx_col.charge_exchange_cross_section = ../../../../warpx-data/MCC_cross_sections/He/charge_exchange.dat
28+
29+
# diagnostics
30+
diagnostics.diags_names = diag1
31+
diag1.diag_type = Full
32+
diag1.format = openpmd
33+
diag1.intervals = 2000
34+
diag1.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
35+
diag1.write_species = 1
36+
diag1.species = electrons Heplus He
37+
diag1.electrons.variables = w x z ux uy uz
38+
diag1.Heplus.variables = w x z ux uy uz
39+
diag1.He.variables = w x z ux uy uz
40+
41+
# electrons (neutralizing background for He+)
42+
electrons.charge = -q_e
43+
electrons.density = n0
44+
electrons.injection_style = "NUniformPerCell"
45+
electrons.mass = m_e
46+
electrons.momentum_distribution_type = gaussian
47+
electrons.num_particles_per_cell_each_dim = 8 8
48+
electrons.profile = constant
49+
electrons.species_type = electron
50+
electrons.ux_th = sqrt(Te*q_e/m_e)/clight
51+
electrons.uy_th = sqrt(Te*q_e/m_e)/clight
52+
electrons.uz_th = sqrt(Te*q_e/m_e)/clight
53+
electrons.xmax = 10*de0
54+
electrons.xmin = 0
55+
electrons.zmax = 10*de0
56+
electrons.zmin = 0
57+
58+
# Heplus (He+ ions undergoing charge exchange)
59+
Heplus.charge = q_e
60+
Heplus.density = n0
61+
Heplus.injection_style = "NUniformPerCell"
62+
Heplus.mass = m_He
63+
Heplus.momentum_distribution_type = gaussian
64+
Heplus.num_particles_per_cell_each_dim = 8 8
65+
Heplus.profile = constant
66+
Heplus.ux_th = sqrt(Ti*q_e/m_He)/clight
67+
Heplus.uy_th = sqrt(Ti*q_e/m_He)/clight
68+
Heplus.uz_th = sqrt(Ti*q_e/m_He)/clight
69+
Heplus.xmax = 10*de0
70+
Heplus.xmin = 0
71+
Heplus.zmax = 10*de0
72+
Heplus.zmin = 0
73+
74+
# He (neutral He atoms undergoing charge exchange)
75+
He.charge = 0
76+
He.density = n0
77+
He.injection_style = "NUniformPerCell"
78+
He.mass = m_He
79+
He.momentum_distribution_type = gaussian
80+
He.num_particles_per_cell_each_dim = 8 8
81+
He.profile = constant
82+
He.ux_th = sqrt(Ti*q_e/m_He)/clight
83+
He.uy_th = sqrt(Ti*q_e/m_He)/clight
84+
He.uz_th = sqrt(Ti*q_e/m_He)/clight
85+
He.xmax = 10*de0
86+
He.xmin = 0
87+
He.zmax = 10*de0
88+
He.zmin = 0
89+
90+
# reduced diagnostics
91+
field_energy.intervals = 1
92+
field_energy.type = FieldEnergy
93+
particle_energy.intervals = 1
94+
particle_energy.type = ParticleEnergy
95+
96+
# geometry
97+
geometry.dims = 2
98+
geometry.prob_hi = 10*de0 10*de0
99+
geometry.prob_lo = 0. 0.
100+
101+
# interpolation
102+
interpolation.galerkin_scheme = 1
103+
104+
# max_step
105+
max_step = 2000
106+
107+
# my_constants
108+
my_constants.m_He = 4*m_p # He mass, kg
109+
my_constants.n0 = 1e30 # number density, m^-3
110+
my_constants.Te = 100. # electron temperature, eV
111+
my_constants.Ti = 100. # He ion/neutral temperature, eV
112+
my_constants.wpe = q_e*sqrt(n0/(m_e*epsilon0)) # electron plasma frequency, rad/s
113+
my_constants.de0 = clight/wpe # electron skin depth, m
114+
my_constants.dt = 0.1/wpe # time step (electron timescale), s
115+
116+
# particles
117+
particles.species_names = electrons Heplus He
118+
119+
# warpx
120+
warpx.const_dt = dt
121+
warpx.do_electrostatic = labframe
122+
warpx.reduced_diags_names = field_energy particle_energy
123+
warpx.serialize_initial_conditions = 1
124+
warpx.use_filter = 0
125+
warpx.verbose = 1

Examples/Tests/secondary_ion_emission/analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
# The tolerance is expressed as a fraction of the sphere radius R, and covers
9292
# only the EB discretization error (the thermal kick is removed by back-propagation).
93-
tolerance = 0.05
93+
tolerance = 0.02
9494

9595
for i in range(0, N_sec_e):
9696
# For each candidate parent ion j, back-propagate the electron from ts.t[-1]

Regression/Checksum/benchmarks_json/test_1d_charge_exchange_dsmc.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"lev=0": {
3-
"rho": 0.0007701705979872025
3+
"rho": 0.0007712764213131624
44
},
55
"H": {
66
"particle_position_x": 0.0,
77
"particle_position_y": 0.0,
8-
"particle_position_z": 2530.8479274154333,
8+
"particle_position_z": 2530.062259029084,
99
"particle_momentum_x": 0.0,
1010
"particle_momentum_y": 0.0,
1111
"particle_momentum_z": 5.948838493809116e-17,
@@ -23,7 +23,7 @@
2323
"H2plus": {
2424
"particle_position_x": 0.0,
2525
"particle_position_y": 0.0,
26-
"particle_position_z": 1021.6452859116588,
26+
"particle_position_z": 1023.4987864862421,
2727
"particle_momentum_x": 0.0,
2828
"particle_momentum_y": 0.0,
2929
"particle_momentum_z": 9.753884936303964e-28,
@@ -38,4 +38,4 @@
3838
"particle_momentum_z": 5.434778911325365e-18,
3939
"particle_weight": 1104206441820.484
4040
}
41-
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"lev=0": {
3+
"Bx": 0.0,
4+
"By": 0.0,
5+
"Bz": 0.0,
6+
"Ex": 14448333080954.348,
7+
"Ey": 0.0,
8+
"Ez": 17169859243066.512,
9+
"jx": 7.803855689663588e+18,
10+
"jy": 7.215854549193545e+18,
11+
"jz": 6.576572210896873e+18,
12+
"rho": 53358037967.6566
13+
},
14+
"He": {
15+
"particle_position_x": 0.000435321087901117,
16+
"particle_position_y": 0.0,
17+
"particle_position_z": 0.00043532495740775497,
18+
"particle_momentum_x": 4.2993604934866694e-18,
19+
"particle_momentum_y": 4.284989545488133e-18,
20+
"particle_momentum_z": 4.295691097769843e-18,
21+
"particle_weight": 2823958725036869.5
22+
},
23+
"Heplus": {
24+
"particle_position_x": 0.00043531587816417113,
25+
"particle_position_y": 0.0,
26+
"particle_position_z": 0.0004353330259468823,
27+
"particle_momentum_x": 4.306240128575128e-18,
28+
"particle_momentum_y": 4.269568445141001e-18,
29+
"particle_momentum_z": 4.2453148876079736e-18,
30+
"particle_weight": 2823958725036869.5
31+
},
32+
"electrons": {
33+
"particle_position_x": 0.00043485561435631804,
34+
"particle_position_y": 0.0,
35+
"particle_position_z": 0.0004366002075857368,
36+
"particle_momentum_x": 4.9302740059601715e-20,
37+
"particle_momentum_y": 5.076441659627337e-20,
38+
"particle_momentum_z": 4.984100225110185e-20,
39+
"particle_weight": 2823958725036869.5
40+
}
41+
}

0 commit comments

Comments
 (0)