Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
258 commits
Select commit Hold shift + click to select a range
af196e8
Update laser_ionization.1Rank.json
EyaDammak Jan 19, 2025
78cd9de
Update PlasmaParticleContainerInit.cpp
EyaDammak Jan 20, 2025
7a725a3
Update PlasmaParticleContainer.cpp
EyaDammak Jan 22, 2025
8dc706b
Update PlasmaParticleContainer.cpp
EyaDammak Jan 23, 2025
7f8b5b3
squelette
Jan 23, 2025
fb67cde
Merge branch 'injection' of https://github.com/EyaDammak/hipace into …
Jan 23, 2025
0e45cd7
fisrt kernel: counting + make invalid
Jan 23, 2025
000a659
simplification
Jan 24, 2025
8644ef7
update MultiPlasma.H
Jan 24, 2025
a9adc38
update Hipace.cpp
Jan 24, 2025
0e395a5
num_electrons was not defined
Jan 24, 2025
fd15bc9
return issue
Jan 24, 2025
14f2385
resizing the beam particle container
Jan 24, 2025
5199d62
syntax
Jan 24, 2025
189bc16
update resizing
Jan 24, 2025
92c9f2a
update
Jan 24, 2025
c25a23a
update
Jan 24, 2025
ddf3148
include more
Jan 24, 2025
acac290
adding beam defining
Jan 24, 2025
f55078f
includes missing
Jan 24, 2025
9205322
update hiapce.cpp
Jan 24, 2025
418d6f3
update hiapce.cpp for include
Jan 24, 2025
8089c15
update hipace.cpp
Jan 24, 2025
c6e0998
missing a variable for beams
Jan 24, 2025
259e62f
fixing small issue
Jan 24, 2025
9156aa6
update plasmaparticlecontainer
Jan 24, 2025
e1e2c1d
Update PlasmaParticleContainer.cpp
EyaDammak Jan 24, 2025
3dd3910
update ppc
Jan 29, 2025
dfc0e06
Merge branch 'injection' of https://github.com/EyaDammak/hipace into …
Jan 29, 2025
390b341
update ppc
Jan 29, 2025
1dfd87c
Update PlasmaParticleContainer.cpp
EyaDammak Jan 29, 2025
d75777f
update reduce function
Jan 29, 2025
0eba01f
Merge branch 'injection' of https://github.com/EyaDammak/hipace into …
Jan 29, 2025
694891c
update ppc
Jan 29, 2025
804645d
update
Jan 29, 2025
4cd31f2
update ppc
Jan 29, 2025
40e554c
update ppc
Jan 30, 2025
38ccfde
update ppc
Jan 30, 2025
a1e14e0
ppc
Jan 30, 2025
007d434
ppc, trying something
Jan 30, 2025
2e869da
update MultiPlasma
Jan 30, 2025
093677b
Update PlasmaParticleContainer.cpp
EyaDammak Jan 31, 2025
caae128
adding the beam.can_laser_injection
Jan 31, 2025
365ff2b
make public the m_product_name
Jan 31, 2025
96d9879
forgot to save
Jan 31, 2025
eea15e7
updates
Jan 31, 2025
042f8fb
adding islice variable
Jan 31, 2025
75421f0
ppc
Jan 31, 2025
068460e
m_can_laser_injection in plasmaparticlecontainer
Jan 31, 2025
52b4946
moving all the m_product and so on in the plasma container
Jan 31, 2025
748f345
modifications
Jan 31, 2025
b0083e8
update MultiBeam.cpp
Jan 31, 2025
60e5301
hello
Jan 31, 2025
2793b7c
style
Feb 2, 2025
67a172a
Update PlasmaParticleContainer.H
EyaDammak Feb 12, 2025
28eaad7
Update PlasmaParticleContainer.cpp
EyaDammak Feb 12, 2025
e2dbff3
Update MultiPlasma.cpp
EyaDammak Feb 14, 2025
eb5a235
Update parameters.rst
EyaDammak Feb 14, 2025
093a17b
Update BeamParticleContainer.cpp
EyaDammak Feb 14, 2025
d44c240
Update PlasmaParticleContainer.cpp
EyaDammak Feb 14, 2025
a07c5f9
Update MultiPlasma.cpp
EyaDammak Feb 14, 2025
cfb2436
Update PlasmaParticleContainer.cpp
EyaDammak Feb 14, 2025
5d0eeab
Merge branch 'development' into injection
EyaDammak Feb 14, 2025
a5285e5
Merge branch 'Hi-PACE:development' into injection
EyaDammak Feb 18, 2025
39a1eed
Update PlasmaParticleContainerInit.cpp
EyaDammak Feb 18, 2025
d638b06
Update PlasmaParticleContainer.cpp
EyaDammak Feb 19, 2025
db37f78
Update PlasmaParticleContainer.cpp
EyaDammak Feb 19, 2025
06d8bba
Update PlasmaParticleContainer.cpp
EyaDammak Feb 21, 2025
fd9c525
Update MultiPlasma.cpp
EyaDammak Feb 21, 2025
332ce5e
update ppc.cpp
Feb 21, 2025
a5435e8
update ppc.cpp
Feb 21, 2025
4a27702
Update PlasmaParticleContainer.cpp
EyaDammak Feb 21, 2025
f00732d
Update PlasmaParticleContainer.cpp
EyaDammak Feb 21, 2025
d8d966f
Merge branch 'Hi-PACE:development' into injection
EyaDammak Feb 24, 2025
c08636e
update pcc.cpp
Feb 24, 2025
3a78493
update pcc.cpp
Feb 24, 2025
0c693cd
update pcc.cpp
Feb 24, 2025
b412517
ppc.cpp
Feb 24, 2025
f7f5b21
MultiPlasma update
Feb 24, 2025
06473f3
update MultiPlasma.cpp
Feb 24, 2025
f243dca
multiplasma
Feb 24, 2025
d06b8b5
MultiPlasma.cpp
Feb 24, 2025
d3c7e19
multiplasma
Feb 24, 2025
94fd2e4
multiplasma
Feb 25, 2025
7a7e8e4
Update MultiPlasma.H
EyaDammak Feb 25, 2025
4de3834
style
Feb 25, 2025
966a640
Update PlasmaParticleContainer.H
EyaDammak Feb 25, 2025
503e04f
Update parameters.rst
EyaDammak Feb 25, 2025
d8bef27
Update PlasmaParticleContainerInit.cpp
EyaDammak Feb 25, 2025
98a926f
Merge branch 'Hi-PACE:development' into injection
EyaDammak Feb 25, 2025
e7534cd
Update PlasmaParticleContainer.cpp
EyaDammak Feb 25, 2025
677dc6f
style
Feb 25, 2025
e2ed4fa
Update MultiPlasma.cpp
EyaDammak Feb 25, 2025
c916dac
Update MultiPlasma.cpp
EyaDammak Feb 26, 2025
6e413ac
Update MultiPlasma.H
EyaDammak Feb 26, 2025
721a012
Update MultiPlasma.H
EyaDammak Feb 26, 2025
64d9299
Update Hipace.cpp
EyaDammak Feb 26, 2025
3815558
Update Hipace.cpp
EyaDammak Feb 26, 2025
c0085cb
Update MultiPlasma.cpp
EyaDammak Feb 26, 2025
8b003aa
Update PlasmaParticleContainer.cpp
EyaDammak Feb 26, 2025
e98ed63
Update PlasmaParticleContainer.cpp
EyaDammak Feb 26, 2025
fba8b27
Update MultiPlasma.cpp
EyaDammak Mar 3, 2025
b96107e
Update PlasmaParticleContainer.cpp
EyaDammak Mar 3, 2025
4f133ad
Update PlasmaParticleContainer.cpp
EyaDammak Mar 3, 2025
eda0de5
Update PlasmaParticleContainer.cpp
EyaDammak Mar 3, 2025
b7082ef
Update PlasmaParticleContainer.cpp
EyaDammak Mar 3, 2025
f2b265d
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
508bed3
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
8976610
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
72cece0
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
8fd4a5a
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
4db530d
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
5d194e6
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
6daf2aa
Update MultiPlasma.cpp
EyaDammak Mar 4, 2025
6407099
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
7c78b9c
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
95a5d6d
Update PlasmaParticleContainer.cpp
EyaDammak Mar 4, 2025
e319685
debugging
Mar 5, 2025
66db249
update of the conditions
Mar 5, 2025
d569f14
Update PlasmaParticleContainer.cpp
EyaDammak Mar 5, 2025
67d56b5
Update PlasmaParticleContainer.H
EyaDammak Mar 5, 2025
afd20b0
Update PlasmaParticleContainer.cpp
EyaDammak Mar 5, 2025
b093134
Update PlasmaParticleContainer.cpp
EyaDammak Mar 5, 2025
da547bc
Update PlasmaParticleContainer.cpp
EyaDammak Mar 5, 2025
5a03435
Update MultiPlasma.cpp
EyaDammak Mar 5, 2025
55deb11
style
Mar 5, 2025
4778ead
Update MultiPlasma.cpp
EyaDammak Mar 5, 2025
bdcca33
ppc.cpp
Mar 6, 2025
7d15e0b
little error in the MultiPlasma
Mar 6, 2025
ae75ab9
issue 2 in MultiPlasma.cpp
Mar 6, 2025
7435901
ppc.cpp
Mar 7, 2025
63443f6
condition to skip if no ionized electrons on a slice
Mar 7, 2025
74ffc83
error in the last laser ionization PR in the documentation
Mar 7, 2025
acc1a90
remove unnecessary variables
Mar 7, 2025
59cf6e2
same than prevously
Mar 7, 2025
b4956aa
same
Mar 7, 2025
99ed105
issue, was not copying
Mar 7, 2025
f5c2ebc
consistancy
Mar 7, 2025
66d4884
debug
Mar 7, 2025
a321540
update ppc.cpp
Mar 7, 2025
6e9376e
ppc
Mar 7, 2025
34d030c
ppc
Mar 7, 2025
93036f0
subcycling missing
Mar 7, 2025
a491d14
; missing
Mar 7, 2025
0ca72d5
taking into account the slipped particles
Mar 10, 2025
8f79079
debugging
Mar 25, 2025
b495817
Update OpenPMDWriter.cpp
EyaDammak Mar 25, 2025
f3651d6
Update OpenPMDWriter.cpp
EyaDammak Mar 25, 2025
03a9a8b
Merge branch 'Hi-PACE:development' into injection
EyaDammak Mar 25, 2025
96c1169
Update PlasmaParticleContainer.cpp
EyaDammak Mar 25, 2025
6245ebb
updating total number of particles missing
Mar 25, 2025
be290c2
updating the values of the beam particles
Mar 28, 2025
fec4cc6
Update BeamParticleAdvance.cpp
EyaDammak Mar 28, 2025
489d161
Update PlasmaParticleContainer.cpp
EyaDammak Mar 28, 2025
fa8b6db
style
Mar 28, 2025
cdddc90
Update PlasmaParticleContainer.cpp
EyaDammak Apr 3, 2025
eba7303
dt missing in the beam weight due to change of referentiels
Apr 3, 2025
235e19c
Merge branch 'Hi-PACE:development' into injection
EyaDammak Apr 3, 2025
cdc3a05
Update PlasmaParticleContainer.cpp
EyaDammak Apr 3, 2025
712cbc2
style
Apr 3, 2025
f9b6577
new function to detect particle injected
Apr 3, 2025
a32df60
style
Apr 3, 2025
309e1ed
ppc updated
Apr 3, 2025
42ab57f
laser variable missed
Apr 3, 2025
c3acc07
multiplasma update
Apr 3, 2025
c865dea
update
Apr 3, 2025
bb0e18e
ppc
Apr 3, 2025
f26dd5f
ppc
Apr 3, 2025
9dc15d5
ppc
Apr 3, 2025
d3915d3
ppc
Apr 3, 2025
4dd4945
ppc
Apr 3, 2025
65adfeb
resize Beam Diagnostic buffer
AlexanderSinn Apr 7, 2025
dcef4ef
fix namespace
AlexanderSinn Apr 7, 2025
3bb5f1a
Update PlasmaParticleContainer.cpp
EyaDammak Apr 7, 2025
fd3691a
Update PlasmaParticleContainer.cpp
EyaDammak Apr 9, 2025
a7333c7
style
Apr 9, 2025
4feb32d
Update PlasmaParticleContainer.cpp
EyaDammak Apr 9, 2025
da5921b
Update PlasmaParticleContainer.cpp
EyaDammak Apr 9, 2025
e0849cc
avoid overflow
AlexanderSinn Apr 9, 2025
3d25b22
Update PlasmaParticleContainer.cpp
EyaDammak Apr 9, 2025
c0ce7c9
Merge pull request #5 from AlexanderSinn/resize_Beam_Diagnostic_buffer
EyaDammak Apr 10, 2025
1511ffc
Update PlasmaParticleContainer.cpp
EyaDammak Apr 10, 2025
49c39c5
Update PlasmaParticleContainer.cpp
EyaDammak Apr 10, 2025
c9d21dc
new condition
Apr 10, 2025
5f0c75c
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
8e75cf4
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
a016d61
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
2aa28ee
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
2c2d417
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
fdded8b
Update OpenPMDWriter.cpp
EyaDammak Apr 11, 2025
d5b9ca6
Update PlasmaParticleContainer.cpp
EyaDammak Apr 11, 2025
57667ac
Update PlasmaParticleContainer.cpp
EyaDammak Apr 14, 2025
2c40713
Update MultiPlasma.cpp
EyaDammak Apr 15, 2025
24c71a4
Update MultiPlasma.cpp
EyaDammak Apr 15, 2025
e366566
Update PlasmaParticleContainer.cpp
EyaDammak Apr 16, 2025
c9a4e93
Update PlasmaParticleContainer.cpp
EyaDammak Apr 16, 2025
b39fa6d
expose capture threshold as input parameter
MaxThevenet Apr 16, 2025
d517aff
injection weight factor added as parameter
Apr 16, 2025
9834a13
unique ids for beam part injected
Apr 21, 2025
a394b93
Update PlasmaParticleContainer.cpp
EyaDammak Apr 21, 2025
f860ea9
little issue
Apr 21, 2025
97b720d
remove unecessary cout
Apr 25, 2025
5e43c94
fix push
May 7, 2025
90a6688
fixing issue of uz/psi in injection
May 7, 2025
36cff67
Update PlasmaParticleContainer.cpp
EyaDammak May 9, 2025
bbe51ef
new condition for injection
May 9, 2025
0c4e258
fix the fields parameter missing
May 9, 2025
43796f3
fix issue
May 9, 2025
45f3e60
laser_arr not defined
May 9, 2025
3f369b7
Update PlasmaParticleContainer.cpp
EyaDammak May 9, 2025
7371104
Update PlasmaParticleContainer.cpp
EyaDammak May 9, 2025
99e9f9a
Update PlasmaParticleContainer.cpp
EyaDammak May 14, 2025
32a2b42
Update PlasmaParticleContainer.cpp
EyaDammak May 14, 2025
68c3102
Update PlasmaParticleContainer.cpp
EyaDammak May 15, 2025
a1cdd1a
alternative injection condition
May 16, 2025
60fb1bc
Merge branch 'Hi-PACE:development' into alternative_injection_condition
AlexanderSinn May 16, 2025
9bb6ce7
Merge dev (#8)
EyaDammak May 16, 2025
9259072
Merge pull request #9 from Hi-PACE/development
EyaDammak May 16, 2025
2ea7085
Merge pull request #1 from EyaDammak/injection_bis
AlexanderSinn May 16, 2025
b2a9d03
fix dt
AlexanderSinn May 16, 2025
f5bf268
fix init at ionization
AlexanderSinn May 16, 2025
8c52233
fix w
AlexanderSinn May 17, 2025
f4bc147
fix
AlexanderSinn May 17, 2025
8cc73da
add grid_external_E
AlexanderSinn May 20, 2025
b61006f
fix
AlexanderSinn May 20, 2025
06b1369
fix typo
AlexanderSinn May 20, 2025
0f2eb2b
merge dev
AlexanderSinn May 26, 2025
ffd426f
Merge branch 'add_grid_external_E' into alternative_injection_condition
AlexanderSinn May 26, 2025
15bcc3f
testing
AlexanderSinn May 27, 2025
d4ffef7
merge dev
AlexanderSinn Aug 1, 2025
233ef22
fix merge
AlexanderSinn Aug 1, 2025
b5e44b9
remove unused parameter
AlexanderSinn Aug 1, 2025
884d15b
cleaning
AlexanderSinn Aug 2, 2025
9cc500c
cleaning
AlexanderSinn Aug 2, 2025
24b8d71
change nsubcycles form int to Real
AlexanderSinn Aug 3, 2025
691ed58
fix
AlexanderSinn Aug 3, 2025
58eac0d
change condition and fix rho
AlexanderSinn Aug 3, 2025
7d6526a
use u half step
AlexanderSinn Aug 3, 2025
7c09bdc
merge dev
AlexanderSinn Oct 2, 2025
cd1e542
remove print
AlexanderSinn Oct 2, 2025
4136ae3
only inject ionized electrons and disable print
AlexanderSinn Oct 2, 2025
cbb01b1
Merge branch 'Hi-PACE:development' into alternative_injection_condition
AlexanderSinn Oct 7, 2025
171aec9
Merge branch 'development' into alternative_injection_condition
AlexanderSinn Dec 3, 2025
9df8e3b
fix merge
AlexanderSinn Dec 3, 2025
1d94b2b
change condition
AlexanderSinn Dec 3, 2025
b423411
fix beam push
AlexanderSinn Dec 5, 2025
83a9792
fix
AlexanderSinn Dec 5, 2025
1b7cb32
fix 2
AlexanderSinn Dec 5, 2025
dc4ff18
Merge branch 'Hi-PACE:development' into alternative_injection_condition
AlexanderSinn Dec 15, 2025
c0d2c81
remove unused variables
AlexanderSinn Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ When both are specified, the per-species value is used.
* ``<plasma name>.can_ionize`` (`bool`) optional (default `0`)
Whether this plasma can ionize. Can also be set to 1 by specifying ``<plasma name>.ionization_product``.

* ``<plasma name>.can_laser_ionize`` (`bool`) optional (default `<plasma name>.can_ionize`)
* ``<plasma name>.can_laser_ionize`` (`bool`) optional (default `0`)
Whether this plasma can be ionized by a laser.

* ``<plasma name>.initial_ion_level`` (`int`) optional (default `-1`)
Expand Down Expand Up @@ -639,6 +639,13 @@ which are valid only for certain beam types, are introduced further below under
The ideal index type is different for beam push and beam deposition so some experimentation
may be required to find the overall fastest setting for a specific simulation.

* ``<plasma name>.can_laser_injection`` (`bool`) optional (default `0`)
Whether the laser injection is enabled. Can also be set to 1 by specifying ``<plasma name>.injection_product``.

* ``<plasma name>.injection_product`` (`string`) optional (default "")
Name of the beam species that contains the new electrons that are produced
when this plasma gets ionized. Only needed if this plasma is ionizable and the laser injection is unabled.

* ``<beam name> or beams.output_ratio`` (`int`) optional (default `1`)
Set the fraction of beam particles that should be written to the openPMD output.
For example, an output ratio of 100 will output every 100th beam particle.
Expand Down
1 change: 1 addition & 0 deletions src/Hipace.H
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public:
inline static bool m_do_beam_jz_minus_rho = false;
/** Whether to deposit rho (plasma) for diagnostics */
inline static bool m_deposit_rho = false;
inline static bool m_deposit_rho_beam = false;
/** Whether to deposit rho for every individual plasma for diagnostics */
inline static bool m_deposit_rho_individual = false;
/** Whether to deposit temperature for every individual plasma for diagnostics */
Expand Down
12 changes: 10 additions & 2 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "particles/pusher/GetAndSetPosition.H"
#include "mg_solver/HpMultiGrid.H"
#include "fields/fft_poisson_solver/fft/AnyFFT.H"
#include "particles/beam/MultiBeam.H"

#include <AMReX_ParmParse.H>
#include <AMReX_IntVect.H>
Expand Down Expand Up @@ -126,6 +127,10 @@ Hipace::ReadParameters ()
queryWithParser(pph, "do_beam_jz_minus_rho", m_do_beam_jz_minus_rho);
m_deposit_rho = m_diags.needsRho();
queryWithParser(pph, "deposit_rho", m_deposit_rho);
queryWithParser(pph, "deposit_rho_beam", m_deposit_rho_beam);
if (m_deposit_rho_beam) {
m_deposit_rho = true;
}
m_deposit_rho_individual = m_diags.needsRhoIndividual();
queryWithParser(pph, "deposit_rho_individual", m_deposit_rho_individual);
m_deposit_temp_individual = m_diags.needsTempIndividual();
Expand Down Expand Up @@ -545,7 +550,7 @@ Hipace::Evolve ()
}

// Only reset plasma after receiving time step, to use proper density
m_multi_plasma.InitData(m_slice_ba, m_slice_dm, m_slice_geom, m_3D_geom);
m_multi_plasma.InitData(m_slice_ba, m_slice_dm, m_slice_geom, m_3D_geom, m_multi_beam);

m_multi_laser.SetInitialChi(m_multi_plasma);

Expand Down Expand Up @@ -805,6 +810,9 @@ Hipace::SolveOneSlice (int islice, int step)
m_multi_plasma.AdvanceParticles(m_fields, m_3D_geom, false, lev, current_N_level);
}

// injection
m_multi_plasma.DoLaserInjection(m_3D_geom, islice);

if (m_depos_order_z == 2) {
CalculateEzNext(current_N_level, step);
}
Expand All @@ -813,7 +821,7 @@ Hipace::SolveOneSlice (int islice, int step)
m_adaptive_time_step.GatherMinAccSlice(m_multi_beam, m_3D_geom[0], m_fields);

// Push beam particles
m_multi_beam.AdvanceBeamParticlesSlice(m_fields, m_3D_geom, islice, current_N_level);
m_multi_beam.AdvanceBeamParticlesSlice(m_fields, m_3D_geom, islice, current_N_level, step);

m_multi_beam.shiftSlippedParticles(islice, m_3D_geom[0]);

Expand Down
7 changes: 4 additions & 3 deletions src/diagnostics/OpenPMDWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ OpenPMDWriter::CopyBeams (MultiBeam& beams, const amrex::Vector< std::string > b
}

AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
int(m_real_beam_data[ibeam].size()) == soa.NumRealComps(),
int(m_real_beam_data[ibeam].size()) == (soa.NumRealComps() - 1),
"List of real names in openPMD Writer class does not match the beam");

for (std::size_t idx=0; idx<m_real_beam_data[ibeam].size(); idx++) {
Expand All @@ -397,9 +397,10 @@ OpenPMDWriter::CopyBeams (MultiBeam& beams, const amrex::Vector< std::string > b
std::max<uint64_t>(old_size+old_size/4, m_offset[ibeam] + np)
);
}
const int get_idx = idx >= BeamIdx::nsubcycles ? idx+1 : idx;
amrex::Gpu::copyAsync(amrex::Gpu::deviceToHost,
soa.GetRealData(idx).begin(),
soa.GetRealData(idx).begin() + np,
soa.GetRealData(get_idx).begin(),
soa.GetRealData(get_idx).begin() + np,
m_real_beam_data[ibeam][idx].data() + m_offset[ibeam]);
}
}
Expand Down
18 changes: 8 additions & 10 deletions src/particles/beam/BeamParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ struct BeamIdx
x=0, y, z, // position
w, // weight
ux, uy, uz, // momentum
real_nattribs_in_buffer,
real_nattribs=real_nattribs_in_buffer
nsubcycles, // nsubcycles: by how many subcycles was this particle pushed already
real_nattribs,
real_nattribs_in_buffer = real_nattribs
};
enum {
// no extra components stored in MultiBuffer, besides 64bit idcpu
int_nattribs_in_buffer,
// nsubcycles: by how many subcycles was this particle pushed already
// nsubcycles is not stored or communicated in MultiBuffer
nsubcycles=int_nattribs_in_buffer,
mr_level,
int_nattribs
int_nattribs,
// no extra components stored in MultiBuffer, besides 64bit idcpu
int_nattribs_in_buffer = mr_level
};
};

Expand Down Expand Up @@ -200,11 +198,11 @@ public:

bool communicateIdCpuComponent () const { return true; }
bool communicateRealComponent (int rcomp) const {
// communicate all compile-time and runtime real components
// otherwise communicate all compile-time and runtime real components
return rcomp < numRealComponents();
}
bool communicateIntComponent (int icomp) const {
// don't communicate nsubcycles or mr_level
// don't communicate mr_level
return icomp < BeamIdx::int_nattribs_in_buffer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/particles/beam/BeamParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ BeamParticleContainer::initializeSlice (int slice, int which_slice) {
ptd.m_runtime_rdata[2][ip] = ptd_init.m_runtime_rdata[2][idx_src];
}
ptd.idcpu(ip) = ptd_init.idcpu(idx_src);
ptd.idata(BeamIdx::nsubcycles)[ip] = 0;
ptd.rdata(BeamIdx::nsubcycles)[ip] = 0;
ptd.idata(BeamIdx::mr_level)[ip] = 0;
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/particles/beam/BeamParticleContainerInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace
ptd.rdata(BeamIdx::uz)[ip] = uz;
ptd.rdata(BeamIdx::w )[ip] = is_valid ? std::abs(weight) : amrex::Real{0};

ptd.idata(BeamIdx::nsubcycles)[ip] = 0;
ptd.rdata(BeamIdx::nsubcycles)[ip] = 0;
ptd.idata(BeamIdx::mr_level)[ip] = 0;

ptd.idcpu(ip) = pid + ip;
Expand Down
3 changes: 2 additions & 1 deletion src/particles/beam/MultiBeam.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public:
* \param[in] gm Geometry object at level lev
* \param[in] slice longitudinal slice
* \param[in] current_N_level number of MR levels active on the current slice
* \param[in] step time step
*/
void AdvanceBeamParticlesSlice (
const Fields& fields, amrex::Vector<amrex::Geometry> const& gm, const int slice,
int const current_N_level);
int const current_N_level, int step);

/** Compute reduced beam diagnostics of current slice, store in member variable.
* \param[in] step time step of simulation
Expand Down
4 changes: 2 additions & 2 deletions src/particles/beam/MultiBeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ MultiBeam::shiftSlippedParticles (const int slice, amrex::Geometry const& geom)
void
MultiBeam::AdvanceBeamParticlesSlice (
const Fields& fields, amrex::Vector<amrex::Geometry> const& gm, const int slice,
int const current_N_level)
int const current_N_level, int step)
{
for (int i=0; i<m_nbeams; i++) {
if (m_all_beams[i].m_do_push){
::AdvanceBeamParticlesSlice(m_all_beams[i], fields, gm, slice, current_N_level);
::AdvanceBeamParticlesSlice(m_all_beams[i], fields, gm, slice, current_N_level, step);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/particles/deposition/BeamDepositCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,
const int jyb_cmp = do_beam_jx_jy_deposition ? Comps[which_slice]["jy" +beam_str] : -1;
const int jzb_cmp = do_beam_jz_deposition ? Comps[which_slice]["jz" +beam_str] : -1;
const int rhomjzb_cmp = do_beam_rhomjz_deposition ? Comps[which_slice]["rhomjz"+beam_str] : -1;
const int rho_cmp = (which_slice == WhichSlice::This) && Hipace::m_deposit_rho_beam ? Comps[which_slice]["rho"] : -1;

// Offset for converting positions to indexes
amrex::Real const x_pos_offset = GetPosOffset(0, gm[lev], isl_fab.box());
Expand All @@ -83,6 +84,7 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,

const amrex::Real clight = phys_const.c;
const amrex::Real q = beam.m_charge;
const amrex::Real n_subcycles = static_cast<amrex::Real>(beam.m_n_subcycles);

amrex::AnyCTO(
// use compile-time options
Expand All @@ -100,7 +102,7 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,
isl_fab.array(), isl_fab.box(),
beam.getBeamSlice(which_beam_slice).getParticleTileData(),
amrex::GpuArray<int, 0>{},
amrex::GpuArray<int, 4>{jxb_cmp, jyb_cmp, jzb_cmp, rhomjzb_cmp});
amrex::GpuArray<int, 5>{jxb_cmp, jyb_cmp, jzb_cmp, rhomjzb_cmp, rho_cmp});
},
// is_valid
// return whether the particle is valid and should deposit
Expand All @@ -111,7 +113,8 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,
return ptd.id(ip).is_valid() &&
(only_highest ?
(ptd.idata(BeamIdx::mr_level)[ip] == lev) :
(ptd.idata(BeamIdx::mr_level)[ip] >= lev));
(ptd.idata(BeamIdx::mr_level)[ip] >= lev)) &&
ptd.rdata(BeamIdx::nsubcycles)[ip] <= n_subcycles;
},
// get_cell
// return the lowest cell index that the particle deposits into
Expand Down Expand Up @@ -187,6 +190,11 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,
arr.ptr(i_cell+ix, j_cell+iy, depos_idx[3]),
sx_cell[ix]*sy_cell[iy]*wqrhomjz);
}
if (depos_idx[4] != -1) { // deposit_rho
amrex::Gpu::Atomic::Add(
arr.ptr(i_cell+ix, j_cell+iy, depos_idx[4]),
sx_cell[ix]*sy_cell[iy]*wq);
}
}
}
});
Expand Down
23 changes: 12 additions & 11 deletions src/particles/deposition/PlasmaDepositCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ DepositCurrent (PlasmaParticleContainer& plasma, Fields & fields,
" (WhichSlice::Next), for the ion charge deposition (WhichSLice::RhomJzIons)"
" or for the Salame slice (WhichSlice::Salame)");

const amrex::Real max_qsa_weighting_factor = plasma.m_max_qsa_weighting_factor;
// const amrex::Real max_qsa_weighting_factor = plasma.m_max_qsa_weighting_factor;
const amrex::Real charge = (which_slice == WhichSlice::RhomJzIons) ? -plasma.m_charge : plasma.m_charge;
const amrex::Real mass = plasma.m_mass;
// only deposit rho individual on WhichSlice::This
Expand Down Expand Up @@ -201,16 +201,17 @@ DepositCurrent (PlasmaParticleContainer& plasma, Fields & fields,
+ 1._rt
);

if (gamma_psi < 0.0_rt || gamma_psi > max_qsa_weighting_factor || psi_inv < 0.0_rt)
{
// This particle violates the QSA, discard it and do not deposit its current
if (p_n_qsa_violation) {
amrex::Gpu::Atomic::Add(p_n_qsa_violation, 1);
}
ptd.rdata(PlasmaIdx::w)[ip] = 0.0_rt;
ptd.id(ip).make_invalid();
return;
}
// if (gamma_psi < 0.0_rt || (gamma_psi > max_qsa_weighting_factor && ptd.id(ip)!=3) || psi_inv < 0.0_rt)
// {
// // AMREX_DEVICE_PRINTF("gamma_psi of plasma particle: %f psi_inv: %f\n", gamma_psi, psi_inv);
// // This particle violates the QSA, discard it and do not deposit its current
// if (p_n_qsa_violation) {
// amrex::Gpu::Atomic::Add(p_n_qsa_violation, 1);
// }
// ptd.rdata(PlasmaIdx::w)[ip] = 0.0_rt;
// ptd.id(ip).make_invalid();
// return;
// }

for (int iy=0; iy <= depos_order; ++iy) {
for (int ix=0; ix <= depos_order; ++ix) {
Expand Down
12 changes: 11 additions & 1 deletion src/particles/plasma/MultiPlasma.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "PlasmaParticleContainer.H"
#include "fields/Fields.H"
#include "particles/collisions/CoulombCollision.H"
#include "particles/beam/MultiBeam.H"

class MultiPlasma
{
Expand All @@ -26,10 +27,12 @@ public:
* \param[in] slice_dm DistributionMapping of the transverse slice domain
* \param[in] slice_gm slice geometry
* \param[in] gm Geometry of the simulation, to get the cell size
* \param[in] beams MultiBeam object containing all beams
*/
void InitData (amrex::Vector<amrex::BoxArray> slice_ba,
amrex::Vector<amrex::DistributionMapping> slice_dm,
amrex::Vector<amrex::Geometry> slice_gm, amrex::Vector<amrex::Geometry> gm);
amrex::Vector<amrex::Geometry> slice_gm, amrex::Vector<amrex::Geometry> gm,
MultiBeam& beams);


/** Loop over plasma species and depose their currents into the current 2D slice in fields
Expand Down Expand Up @@ -115,6 +118,13 @@ public:
void DoLaserIonization (const int islice, const amrex::Geometry& laser_geom,
const MultiLaser& laser);

/** Do the transfer of ionized plasma particles to beam particles
*
* \param[in] gm Geometry object for the whole domain
* \param[in] islice Slice index corresponding to the current simulation slice
*/
void DoLaserInjection (amrex::Vector<amrex::Geometry> const& gm, const int islice);

/** \brief whether any plasma species uses a neutralizing background, e.g. no ion motion */
[[nodiscard]] bool
AnySpeciesNeutralizeBackground () const;
Expand Down
24 changes: 23 additions & 1 deletion src/particles/plasma/MultiPlasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* License: BSD-3-Clause-LBNL
*/
#include "MultiPlasma.H"
#include "particles/beam/MultiBeam.H"
#include "particles/deposition/PlasmaDepositCurrent.H"
#include "particles/deposition/TemperatureDeposition.H"
#include "particles/deposition/ExplicitDeposition.H"
Expand Down Expand Up @@ -41,7 +42,8 @@ MultiPlasma::ReadParameters ()
void
MultiPlasma::InitData (amrex::Vector<amrex::BoxArray> slice_ba,
amrex::Vector<amrex::DistributionMapping> slice_dm,
amrex::Vector<amrex::Geometry> slice_gm, amrex::Vector<amrex::Geometry> gm)
amrex::Vector<amrex::Geometry> slice_gm, amrex::Vector<amrex::Geometry> gm,
MultiBeam& beams)
{
for (auto& plasma : m_all_plasmas) {
// make it think there is only level 0
Expand All @@ -60,7 +62,18 @@ MultiPlasma::InitData (amrex::Vector<amrex::BoxArray> slice_ba,
plasma.InitIonizationModule(gm[0],
Hipace::m_background_density_SI); // geometry only for dz
}

if(plasma.m_can_laser_injection) {
for (int i=0; i<beams.m_names.size(); ++i) {
if(beams.m_names[i] == plasma.m_product_beam_name) {
plasma.m_product_beam_pc = &beams.m_all_beams[i];
}
}
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(plasma.m_product_beam_pc != nullptr,
"Must specify a valid product beam for laser injection using ionization_product");
}
}

}

amrex::Real
Expand Down Expand Up @@ -151,6 +164,15 @@ MultiPlasma::DoLaserIonization (
}
}

void
MultiPlasma::DoLaserInjection (
amrex::Vector<amrex::Geometry> const& gm, const int islice)
{
for (auto& plasma : m_all_plasmas) {
plasma.PlasmaToBeam(gm, islice);
}
}

bool
MultiPlasma::AnySpeciesNeutralizeBackground () const
{
Expand Down
14 changes: 14 additions & 0 deletions src/particles/plasma/PlasmaParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <AMReX_AmrParticles.H>
#include <AMReX_Particles.H>
#include <AMReX_AmrCore.H>
#include "particles/beam/MultiBeam.H"
#include "particles/beam/BeamParticleContainer.H"
#include <map>

/** \brief Map names and indices for plasma particles attributes (SoA data) */
Expand All @@ -31,6 +33,7 @@ struct PlasmaIdx
ux_half_step, // momentum half a step behind the current slice for leapfrog pusher
uy_half_step, // at the same step for AB5 pusher
psi_half_step, // never effected by temp slice
time_integral,
#ifdef HIPACE_USE_AB5_PUSH
Fx1, Fx2, Fx3, Fx4, Fx5, // AB5 force terms
Fy1, Fy2, Fy3, Fy4, Fy5, //
Expand Down Expand Up @@ -111,6 +114,13 @@ public:
const MultiLaser& laser,
const amrex::Real background_density_SI);

/** Do the transfer of particles from the plasma container to the beam container
*
* \param[in] gm Geometry object for the whole domain
* \param[in] islice Slice index corresponding to the current simulation slice
*/
void PlasmaToBeam (amrex::Vector<amrex::Geometry> const& gm, const int islice);

/** Reorder particles to speed-up current deposition
* \param[in] islice zeta slice index
*/
Expand Down Expand Up @@ -219,6 +229,10 @@ public:
amrex::Gpu::Buffer<amrex::Real> m_laser_dp_prefactor;
/** to calculate laser ionization momentum width at the second order for linear polarization */
amrex::Gpu::Buffer<amrex::Real> m_laser_dp_second_prefactor;
// laser injection:
bool m_can_laser_injection = false; /**< whether laser injection is enabled */
std::string m_product_beam_name = ""; /**< name of Injection product beam */
BeamParticleContainer* m_product_beam_pc = nullptr; /**< Injection product beam */

// plasma sorting/reordering:

Expand Down
Loading
Loading