Skip to content

Commit 886fde7

Browse files
committed
Got rid of unnecessary file. Unified variable type declaration.
1 parent 4dc43c7 commit 886fde7

File tree

5 files changed

+88
-79
lines changed

5 files changed

+88
-79
lines changed

include/picongpu/param/fusion.param

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
#pragma once
2121

22-
#include "picongpu/param/particleFilters.param"
2322
#include "picongpu/particles/fusion/fusion.def"
24-
#include "picongpu/plugins/misc/SpeciesFilter.hpp"
2523

2624
#include <pmacc/meta/conversion/MakeSeq.hpp>
2725

@@ -41,13 +39,61 @@ namespace picongpu
4139
/** Define your fusion reactions here.
4240
* See documentation: https://picongpu.readthedocs.io/en/latest/usage/workflows/fusionReactions.html
4341
*/
44-
4542
using FusionPipeline = pmacc::mp_list<>;
4643

44+
/** Memory allocation control: chunk size for cell list storage.
45+
*
46+
* Sets the memory allocation chunk size for the cell-based particle lists
47+
* used during fusion collision detection. Should typically be set to
48+
* TYPICAL_PARTICLES_PER_CELL to match the expected particle density.
49+
*/
4750
constexpr uint32_t cellListChunkSize = TYPICAL_PARTICLES_PER_CELL;
51+
52+
/** Minimum weighting threshold for fusion product macro-particles.
53+
*
54+
* Sets the minimum allowed weighting (statistical weight) for newly created
55+
* product macro-particles. When the fusion production multiplier (Fmult) would
56+
* create products lighter than this threshold, Fmult is reduced to ensure
57+
* products have at least this weighting. Lower values allow more, lighter products
58+
* but increase memory usage and computation time.
59+
*/
4860
constexpr float_X productMinWeighting = 16.1;
49-
constexpr uint32_t maxFmult = 1e6;
61+
62+
/** Maximum fusion production multiplier (Fmult).
63+
*
64+
* Controls how the consumed reactant weight is split into multiple product
65+
* macro-particles. Higher values create more, lighter products (down to the
66+
* productMinWeighting threshold). Lower values create fewer, heavier products.
67+
*
68+
* Algorithm per fused pair:
69+
* - Start with Fmult = maxFmult
70+
* - Compute productWeighting = minWeighting / Fmult
71+
* - If productWeighting < productMinWeighting, reduce Fmult to
72+
* max(1, minWeighting / productMinWeighting) and recompute
73+
*
74+
* The base productWeighting is then distributed across reactant sites and
75+
* product species while conserving total weight.
76+
*
77+
* Note: This distribution can result in creation of product particles with
78+
* weighting smaller than productMinWeighting.
79+
*/
80+
constexpr uint32_t maxFmult = 1'000'000;
81+
82+
/** Enable debug output for fusion processes.
83+
*
84+
* When true, enables detailed debugging information for fusion reactions
85+
* including collision pair information, cross-sections, and product creation.
86+
* If enabled, may create enormous amounts of output data if using gpu.
87+
*/
5088
constexpr bool debugFusion = false;
89+
90+
/** Force 100% fusion probability (debug flag).
91+
*
92+
* When true, forces all eligible reactant pairs to fuse regardless of the
93+
* calculated fusion cross-section probability. This is a debug/test feature
94+
* and should be false for realistic physics simulations. Useful for testing
95+
* fusion product creation and energy conservation.
96+
*/
5197
constexpr bool alwaysFuseQ = false;
5298
} // namespace fusion
5399
} // namespace particles

include/picongpu/particles/fusion/detail/Creation.hpp

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <pmacc/lockstep.hpp>
3131
#include <pmacc/mappings/kernel/AreaMapping.hpp>
3232
#include <pmacc/math/Vector.hpp>
33+
#include <pmacc/math/functions/Round.hpp>
3334
#include <pmacc/math/operation.hpp>
3435
#include <pmacc/memory/shared/Allocate.hpp>
3536
#include <pmacc/mpi/MPIReduce.hpp>
@@ -64,13 +65,13 @@ namespace picongpu::particles::fusion
6465
T truncated = static_cast<long long>(x);
6566
T fraction = x - truncated;
6667

67-
if(fraction >= 0.5)
68+
if(fraction >= T{0.5})
6869
{
69-
return truncated + 1.0;
70+
return truncated + T{1.0};
7071
}
71-
if(fraction <= -0.5)
72+
if(fraction <= T{-0.5})
7273
{
73-
return truncated - 1.0;
74+
return truncated - T{1.0};
7475
}
7576
return truncated;
7677
}
@@ -85,10 +86,10 @@ namespace picongpu::particles::fusion
8586
float_COLL c4)
8687
{
8788
// clang-format off
88-
return (W1 >= 0.0_X && W1 <= c3 &&
89-
W3 >= 0.0_X && W3 <= c3 &&
90-
W2 >= 0.0_X && W2 <= c4 &&
91-
W4 >= 0.0_X && W4 <= c4);
89+
return (W1 >= 0.0_COLL && W1 <= c3 &&
90+
W3 >= 0.0_COLL && W3 <= c3 &&
91+
W2 >= 0.0_COLL && W2 <= c4 &&
92+
W4 >= 0.0_COLL && W4 <= c4);
9293
// clang-format on
9394
}
9495

@@ -118,8 +119,7 @@ namespace picongpu::particles::fusion
118119
float_COLL q4,
119120
float_COLL m4)
120121
{
121-
constexpr float_COLL tolerance
122-
= static_cast<precision::float_COLL>(10) * std::numeric_limits<float_COLL>::epsilon();
122+
constexpr float_COLL tolerance = 10.0_COLL * std::numeric_limits<float_COLL>::epsilon();
123123

124124
float_COLL const Q = q1 + q2;
125125
float_COLL const M = m1 + m2;
@@ -130,7 +130,7 @@ namespace picongpu::particles::fusion
130130
{
131131
float_COLL const c3 = (Q * m4 - q4 * M) / det;
132132
float_COLL const c4 = (q3 * M - Q * m3) / det;
133-
bool const ok = (c3 >= 0.0_X && c4 >= 0.0_X);
133+
bool const ok = (c3 >= 0.0_COLL && c4 >= 0.0_COLL);
134134
return StoichiometryCaps{c3, c4, ok};
135135
}
136136

@@ -140,17 +140,17 @@ namespace picongpu::particles::fusion
140140
if(std::abs(sQ) > tolerance)
141141
{
142142
float_COLL const c = Q / sQ; // c3=c4 ensures global charge; mass follows when q/m are identical
143-
return StoichiometryCaps{c, c, c >= 0.0_X};
143+
return StoichiometryCaps{c, c, c >= 0.0_COLL};
144144
}
145145

146146
// If both products are effectively neutral, rely on mass-only symmetric split
147147
float_COLL const sM = m3 + m4;
148148
if(std::abs(sM) > tolerance)
149149
{
150150
float_COLL const c = M / sM;
151-
return StoichiometryCaps{c, c, c >= 0.0_X};
151+
return StoichiometryCaps{c, c, c >= 0.0_COLL};
152152
}
153-
return StoichiometryCaps{0.0_X, 0.0_X, false};
153+
return StoichiometryCaps{0.0_COLL, 0.0_COLL, false};
154154
}
155155

156156
// New: local mass+charge solver under caps. Solve site-1 2x2 and derive site-2 via caps.
@@ -166,12 +166,11 @@ namespace picongpu::particles::fusion
166166
float_COLL c3,
167167
float_COLL c4)
168168
{
169-
constexpr float_COLL tolerance
170-
= static_cast<precision::float_COLL>(10) * std::numeric_limits<float_COLL>::epsilon();
169+
constexpr float_COLL tolerance = 10.0_COLL * std::numeric_limits<float_COLL>::epsilon();
171170

172171
float_COLL const det = q3 * m4 - q4 * m3;
173172
if(std::abs(det) < tolerance)
174-
return WeightResult{0.0_X, 0.0_X, 0.0_X, 0.0_X, false};
173+
return WeightResult{0.0_COLL, 0.0_COLL, 0.0_COLL, 0.0_COLL, false};
175174

176175
// Solve for site-1 weights (W1,W2)
177176
float_COLL const W1 = (q1 * m4 - q4 * m1) / det;
@@ -181,7 +180,7 @@ namespace picongpu::particles::fusion
181180

182181
// Check bounds
183182
if(!areWeightsValidWithCaps(W1, W2, W3, W4, c3, c4))
184-
return WeightResult{0.0_X, 0.0_X, 0.0_X, 0.0_X, false};
183+
return WeightResult{0.0_COLL, 0.0_COLL, 0.0_COLL, 0.0_COLL, false};
185184

186185
// Verify site-2 consistency
187186
float_COLL const q2_chk = W3 * q3 + W4 * q4;
@@ -199,13 +198,12 @@ namespace picongpu::particles::fusion
199198
float_COLL c3,
200199
float_COLL c4)
201200
{
202-
constexpr float_COLL tolerance
203-
= static_cast<precision::float_COLL>(10) * std::numeric_limits<float_COLL>::epsilon();
201+
constexpr float_COLL tolerance = 10.0_COLL * std::numeric_limits<float_COLL>::epsilon();
204202

205203
// Both neutral: minimize macro creation -> put all at site 2
206204
if(std::abs(q3) < tolerance && std::abs(q4) < tolerance)
207205
{
208-
return WeightResult{0.0_X, 0.0_X, c3, c4, true};
206+
return WeightResult{0.0_COLL, 0.0_COLL, c3, c4, true};
209207
}
210208

211209
// Second product neutral
@@ -214,7 +212,7 @@ namespace picongpu::particles::fusion
214212
float_COLL const W1 = q1 / q3;
215213
float_COLL const W3 = c3 - W1;
216214
// Place all neutral at site 2
217-
float_COLL const W2 = 0.0_X;
215+
float_COLL const W2 = 0.0_COLL;
218216
float_COLL const W4 = c4;
219217
bool const ok = areWeightsValidWithCaps(W1, W2, W3, W4, c3, c4)
220218
&& (std::abs(q1 - (W1 * q3 + W2 * q4)) < tolerance);
@@ -226,7 +224,7 @@ namespace picongpu::particles::fusion
226224
{
227225
float_COLL const W2 = q1 / q4;
228226
float_COLL const W4 = c4 - W2;
229-
float_COLL const W1 = 0.0_X;
227+
float_COLL const W1 = 0.0_COLL;
230228
float_COLL const W3 = c3;
231229
bool const ok = areWeightsValidWithCaps(W1, W2, W3, W4, c3, c4)
232230
&& (std::abs(q1 - (W1 * q3 + W2 * q4)) < tolerance);
@@ -236,18 +234,18 @@ namespace picongpu::particles::fusion
236234
// Both charged: try single-product split first
237235
{
238236
float_COLL const W1a = q1 / q3;
239-
if(W1a >= 0.0_X && W1a <= c3)
237+
if(W1a >= 0.0_COLL && W1a <= c3)
240238
{
241239
float_COLL const W1 = W1a;
242-
float_COLL const W2 = 0.0_X;
240+
float_COLL const W2 = 0.0_COLL;
243241
float_COLL const W3 = c3 - W1;
244242
float_COLL const W4 = c4;
245243
return WeightResult{W1, W2, W3, W4, true};
246244
}
247245
float_COLL const W2a = q1 / q4;
248-
if(W2a >= 0.0_X && W2a <= c4)
246+
if(W2a >= 0.0_COLL && W2a <= c4)
249247
{
250-
float_COLL const W1 = 0.0_X;
248+
float_COLL const W1 = 0.0_COLL;
251249
float_COLL const W2 = W2a;
252250
float_COLL const W3 = c3;
253251
float_COLL const W4 = c4 - W2;
@@ -261,7 +259,7 @@ namespace picongpu::particles::fusion
261259
{
262260
float_COLL const W1 = c3;
263261
float_COLL const W2 = (q1 - q3 * W1) / q4;
264-
float_COLL const W3 = 0.0_X;
262+
float_COLL const W3 = 0.0_COLL;
265263
float_COLL const W4 = c4 - W2;
266264
bool const ok = areWeightsValidWithCaps(W1, W2, W3, W4, c3, c4);
267265
return WeightResult{W1, W2, W3, W4, ok};
@@ -271,7 +269,7 @@ namespace picongpu::particles::fusion
271269
float_COLL const W2 = c4;
272270
float_COLL const W1 = (q1 - q4 * W2) / q3;
273271
float_COLL const W3 = c3 - W1;
274-
float_COLL const W4 = 0.0_X;
272+
float_COLL const W4 = 0.0_COLL;
275273
bool const ok = areWeightsValidWithCaps(W1, W2, W3, W4, c3, c4);
276274
return WeightResult{W1, W2, W3, W4, ok};
277275
}
@@ -334,9 +332,9 @@ namespace picongpu::particles::fusion
334332
IdGenerator& idGen,
335333
T_ParAccessor0 const& r1,
336334
T_ParAccessor1 const& r2,
337-
float_X& productWeighting,
338-
float3_X& mom1,
339-
float3_X& mom2,
335+
float_X const productWeighting,
336+
float3_X const& mom1,
337+
float3_X const& mom2,
340338
T_ParAccessor2& p1r1, // product 1 at pos 1
341339
T_ParAccessor2& p1r2, // product 1 at pos 2
342340
T_ParAccessor3& p2r1, // product 2 at pos 1
@@ -357,11 +355,10 @@ namespace picongpu::particles::fusion
357355
targetClone5.derive(worker, idGen, r2);
358356

359357

360-
static constexpr float_COLL tolerance
361-
= static_cast<float_COLL>(10) * std::numeric_limits<float_COLL>::epsilon();
358+
static constexpr float_COLL tolerance = 10.0_COLL * std::numeric_limits<float_COLL>::epsilon();
362359
// Charges must be non-negative
363360
static_assert(
364-
q1 >= 0.0_X && q2 >= 0.0_X && q3 >= 0.0_X && q4 >= 0.0_X,
361+
q1 >= 0.0_COLL && q2 >= 0.0_COLL && q3 >= 0.0_COLL && q4 >= 0.0_COLL,
365362
"All charges must be non-negative");
366363

367364
// Compute stoichiometric caps from species (can be fractional)

include/picongpu/particles/fusion/fieldSlots.hpp

Lines changed: 0 additions & 33 deletions
This file was deleted.

include/picongpu/particles/fusion/relativistic/FusionAlgorithm.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ namespace picongpu::particles::fusion::relativistic
312312

313313
// Convert energy from PIC units to keV
314314
constexpr float_COLL picEnergy_to_Joule = sim.unit.energy();
315-
constexpr float_COLL joule_to_eV = 1.0 / sim.si.get_eV();
316-
constexpr float_COLL eV_to_keV = 1e-3;
315+
constexpr float_COLL joule_to_eV = 1.0_COLL / sim.si.get_eV();
316+
constexpr float_COLL eV_to_keV = 1e-3_COLL;
317317
constexpr float_COLL convToKeV = picEnergy_to_Joule * joule_to_eV * eV_to_keV;
318318

319319
// Convert cross section from millibarns to PIC area units
320-
constexpr float_COLL millibarn_to_m2 = 1e-31; // 1 millibarn = 1e-31 m²
320+
constexpr float_COLL millibarn_to_m2 = 1e-31_COLL; // 1 millibarn = 1e-31 m²
321321
constexpr float_COLL picLength_to_m = sim.unit.length(); // [m/UNIT_LENGTH]
322-
constexpr float_COLL m2_to_picArea = 1.0 / (picLength_to_m * picLength_to_m);
322+
constexpr float_COLL m2_to_picArea = 1.0_COLL / (picLength_to_m * picLength_to_m);
323323
constexpr float_COLL millibarn_to_picArea = millibarn_to_m2 * m2_to_picArea;
324324

325325
float_X sigma_picArea = crossSection(fusionVar.E_r * convToKeV) * millibarn_to_picArea;
@@ -328,7 +328,7 @@ namespace picongpu::particles::fusion::relativistic
328328

329329
// print with probability 1e-8
330330
if constexpr(debugFusion)
331-
if(rng(worker) < 1e-8)
331+
if(rng(worker) < 1e-8_COLL)
332332
{
333333
// get pic velocity to m/s -> debug
334334
constexpr float_COLL picVelocity_to_m_per_s = sim.unit.length() / sim.unit.time();
@@ -376,7 +376,7 @@ namespace picongpu::particles::fusion::relativistic
376376
{
377377
// print Er
378378
if constexpr(debugFusion)
379-
if(worker.workerIdx() == 0 && rng(worker) < 1e-8)
379+
if(worker.workerIdx() == 0 && rng(worker) < 1e-8_COLL)
380380
{
381381
printf("Warning: Relative kinetic energy E_r is non-positive: %f\n", fusionVar.E_r);
382382
}

include/picongpu/simulation/stage/Fusion.x.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include "picongpu/defines.hpp"
2424
#include "picongpu/particles/filter/filter.hpp"
25-
#include "picongpu/particles/fusion/fieldSlots.hpp"
2625
#include "picongpu/particles/fusion/fusion.hpp"
2726
#include "picongpu/particles/param.hpp"
2827
#include "picongpu/particles/particleToGrid/ComputeFieldValue.hpp"

0 commit comments

Comments
 (0)