Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5cc92e5
initial work
lucafedeli88 May 4, 2022
fc3334d
fixed bugs and added species
lucafedeli88 May 5, 2022
d744b7a
update documentation
lucafedeli88 May 5, 2022
d768660
delete unused file
lucafedeli88 May 18, 2022
2e5d076
Add properties for neutron, hydrogen isotopes, helium isotopes
RemiLehe May 31, 2022
029f3e1
Update code to be more consistent
RemiLehe May 31, 2022
8ce861d
Correct typo
RemiLehe May 31, 2022
f716fea
Parse deuterium-tritium fusion
RemiLehe May 31, 2022
9763ad3
Start putting in place the files for deuterium-tritium
RemiLehe May 31, 2022
ea3217e
Update documentation
RemiLehe May 31, 2022
c5d067c
Prepare structures for deuterium tritium
RemiLehe May 31, 2022
9549830
Fix typo
RemiLehe May 31, 2022
c0309bd
Merge branch 'more_data' into dt_fusion
RemiLehe Jun 1, 2022
78be34e
Fix compilation
RemiLehe Jun 1, 2022
d6639d6
Add neutron
RemiLehe Jun 2, 2022
24a743d
Merge branch 'development' into improve_SpeciesPhysicalProperties
RemiLehe Jun 2, 2022
c096d29
Merge branch 'development' into improve_SpeciesPhysicalProperties
RemiLehe Jun 2, 2022
08cd304
Add correct formula for the cross-section
RemiLehe Jun 3, 2022
139eebf
Correct compilation error
RemiLehe Jun 3, 2022
c6e7c92
Fix nuclear fusion
RemiLehe Jun 3, 2022
6ab97ec
Reset benchmarks
RemiLehe Jun 3, 2022
6f7e7c0
Prepare creation functor for 2-product fusion
RemiLehe Jun 3, 2022
ff08305
First implementation of momentum initialization
RemiLehe Jun 3, 2022
428a179
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2022
fa01fdd
Use utility function for fusion
RemiLehe Jun 7, 2022
88fcaf5
Minor modification of variable names
RemiLehe Jun 7, 2022
0a59ecd
Merge branch 'dt_fusion' of github.com:RemiLehe/WarpX into dt_fusion
RemiLehe Jun 7, 2022
821356d
Fix GPU compilation
RemiLehe Jun 7, 2022
ad24117
Fix single precision compilation
RemiLehe Jun 7, 2022
ca278c6
Update types
RemiLehe Jun 8, 2022
2cdd394
Use util function in P-B fusion
RemiLehe Jun 8, 2022
3bc13d4
Correct compilation errors
RemiLehe Jun 8, 2022
eb91623
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 8, 2022
d82bb73
Correct errors
RemiLehe Jun 8, 2022
2a5cc53
Merge branch 'dt_fusion' of github.com:RemiLehe/WarpX into dt_fusion
RemiLehe Jun 8, 2022
323950d
Update values of mass and charge
RemiLehe Jun 9, 2022
61b0769
Correct compilation error
RemiLehe Jun 9, 2022
bbf95b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 9, 2022
70c5fe6
Correct compilation error
RemiLehe Jun 9, 2022
65409f4
Correct compilation error
RemiLehe Jun 9, 2022
c82c8e7
Correct compilation error
RemiLehe Jun 9, 2022
9510dee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 9, 2022
2a41771
Reset benchmark
RemiLehe Jun 9, 2022
24d1fc7
Use helium particle in proton-boron, to avoid resetting benchmark
RemiLehe Jun 9, 2022
73c8d9d
Fixed proton-boron test
RemiLehe Jun 10, 2022
5c31035
Revert "Fixed proton-boron test"
RemiLehe Jun 21, 2022
72fb317
Merge branch 'development' into improve_SpeciesPhysicalProperties
RemiLehe Jun 21, 2022
542d2cb
Incorporate Neil's recommendations
RemiLehe Jul 5, 2022
c9a8661
Merge branch 'development' into improve_SpeciesPhysicalProperties
RemiLehe Jul 5, 2022
b228c29
Reset benchmarks
RemiLehe Jul 5, 2022
00e5d09
Merge branch 'improve_SpeciesPhysicalProperties' into dt_fusion
RemiLehe Jul 5, 2022
dd1ca83
Merge branch 'development' into dt_fusion
RemiLehe Jul 5, 2022
665451f
Correct compilation errors
RemiLehe Jul 5, 2022
284f370
Add new deuterium tritium automated test
RemiLehe Jul 11, 2022
c3cff64
Correct formula of cross-section
RemiLehe Jul 11, 2022
67d0ff1
Correct cross-section
RemiLehe Jul 11, 2022
8137f01
Improve analysis script
RemiLehe Jul 11, 2022
637ea1b
Add test of energy conservation
RemiLehe Jul 11, 2022
a163b8a
Merge branch 'development' into dt_fusion
RemiLehe Jul 11, 2022
b11812d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 11, 2022
eb76522
Add test of conservation of momentum
RemiLehe Jul 11, 2022
a61aef3
Progress in analysis script
RemiLehe Jul 11, 2022
5b6585d
Merge branch 'dt_fusion' of github.com:RemiLehe/WarpX into dt_fusion
RemiLehe Jul 11, 2022
d1bd322
Fix error in the initial energy of the deuterium particles
RemiLehe Jul 12, 2022
e29d5ab
Add check of isotropy
RemiLehe Jul 12, 2022
a117150
Clean up the test script
RemiLehe Jul 12, 2022
e787250
Rewrite p_sq formula in a way to avoids machine-precision negative nu…
RemiLehe Jul 12, 2022
b45e99d
Add checksum
RemiLehe Jul 12, 2022
471e263
Clean up code
RemiLehe Jul 12, 2022
0629a95
Merge branch 'development' into dt_fusion
RemiLehe Jul 13, 2022
1b847d4
Merge branch 'development' into dt_fusion
RemiLehe Jul 13, 2022
44fd734
Merge branch 'development' into dt_fusion
RemiLehe Jul 13, 2022
d931ef7
Merge branch 'dt_fusion' of github.com:RemiLehe/WarpX into dt_fusion
RemiLehe Jul 13, 2022
e6efe57
Apply suggestions from code review
RemiLehe Jul 13, 2022
fec693e
Update PR according to comments
RemiLehe Jul 13, 2022
f11f72e
Update benchmark
RemiLehe Jul 14, 2022
c2846d8
Address additional comments
RemiLehe Jul 14, 2022
c103462
Numerical Literals
ax3l Jul 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include "Particles/MultiParticleContainer.H"

enum struct CollisionType { ProtonBoronFusion, Undefined };
enum struct CollisionType { DeuteriumTritiumFusion, ProtonBoronFusion, Undefined };

enum struct NuclearFusionType { ProtonBoron, Undefined };
enum struct NuclearFusionType { DeuteriumTritium, ProtonBoron, Undefined };

namespace BinaryCollisionUtils{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ namespace BinaryCollisionUtils{
auto& species1 = mypc->GetParticleContainerFromName(species_names[0]);
auto& species2 = mypc->GetParticleContainerFromName(species_names[1]);

if ((species1.AmIA<PhysicalSpecies::hydrogen>() && species2.AmIA<PhysicalSpecies::boron11>())
if ((species1.AmIA<PhysicalSpecies::hydrogen2>() && species2.AmIA<PhysicalSpecies::hydrogen3>())
||
(species1.AmIA<PhysicalSpecies::hydrogen3>() && species2.AmIA<PhysicalSpecies::hydrogen2>())
)
{
return NuclearFusionType::DeuteriumTritium;
}
else if ((species1.AmIA<PhysicalSpecies::hydrogen>() && species2.AmIA<PhysicalSpecies::boron11>())
||
(species1.AmIA<PhysicalSpecies::boron11>() && species2.AmIA<PhysicalSpecies::hydrogen>())
)
Expand Down Expand Up @@ -56,6 +63,8 @@ namespace BinaryCollisionUtils{

CollisionType nuclear_fusion_type_to_collision_type (const NuclearFusionType fusion_type)
{
if (fusion_type == NuclearFusionType::DeuteriumTritium)
return CollisionType::DeuteriumTritiumFusion;
if (fusion_type == NuclearFusionType::ProtonBoron)
return CollisionType::ProtonBoronFusion;
amrex::Abort("Invalid nuclear fusion type");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Copyright 2022 Remi Lehe
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/

#ifndef DEUTERIUM_TRITIUM_FUSION_CROSS_SECTION_H
#define DEUTERIUM_TRITIUM_FUSION_CROSS_SECTION_H

#include "Utils/WarpXConst.H"

#include <AMReX_REAL.H>

#include <cmath>

/**
* \brief Computes the total deuterium-tritium fusion cross section.
*
* @param[in] E_kin_star the kinetic energy of the deuterium-tritium pair in its center of mass frame,
* in SI units.
* @return The total cross section in SI units (square meters).
*/
AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::ParticleReal DeuteriumTritiumFusionCrossSection (const amrex::ParticleReal& E_kin_star)
{
using namespace amrex::literals;

// Convert cross section to SI units: barn to square meter
constexpr auto barn_to_sqm = 1.e-28_prt;
return 0.*barn_to_sqm;
}

#endif // DEUTERIUM_TRITIUM_TRITIUM_FUSION_CROSS_SECTION_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Copyright 2022 Remi Lehe
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/

#ifndef DEUTERIUM_TRITIUM_FUSION_INITIALIZE_MOMENTUM_H
#define DEUTERIUM_TRITIUM_FUSION_INITIALIZE_MOMENTUM_H

#include "Particles/WarpXParticleContainer.H"
#include "Utils/ParticleUtils.H"
#include "Utils/WarpXConst.H"

#include <AMReX_DenseBins.H>
#include <AMReX_Random.H>
#include <AMReX_REAL.H>

#include <cmath>
#include <limits>

namespace {
// Define shortcuts for frequently-used type names
using SoaData_type = WarpXParticleContainer::ParticleTileType::ParticleTileDataType;
using ParticleType = WarpXParticleContainer::ParticleType;
using ParticleBins = amrex::DenseBins<ParticleType>;
using index_type = ParticleBins::index_type;

/**
* \brief This function initializes the momentum of the particles produced from
* deuterium-tritium fusion.
*
* @param[in] soa_1 struct of array data of the first colliding species (can be either deuterium
* or tritium)
* @param[in] soa_2 struct of array data of the second colliding species (can be either deuterium
* or tritium)
* @param[out] ...
* @param[in] idx_1 index of first colliding macroparticle
* @param[in] idx_2 index of second colliding macroparticle
* @param[in]...
* @param[in] m1 mass of first colliding species
* @param[in] m2 mass of second colliding species
* @param[in] engine the random engine
*/
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void DeuteriumTritiumFusionInitializeMomentum (
const SoaData_type& soa_1, const SoaData_type& soa_2,
SoaData_type& soa_alpha,
const index_type& idx_1, const index_type& idx_2,
const index_type& idx_alpha_start,
const amrex::ParticleReal& m1, const amrex::ParticleReal& m2,
const amrex::RandomEngine& engine)
{
// General notations in this function:
// x_sq denotes the square of x
// x_star denotes the value of x in the proton+boron center of mass frame
// x_Bestar denotes the value of x in the Beryllium rest frame

using namespace amrex::literals;
}

}

#endif // DEUTERIUM_TRITIUM_FUSION_INITIALIZE_MOMENTUM_H
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ public:
amrex::Vector<std::string> product_species_name;
pp_collision_name.getarr("product_species", product_species_name);

if (m_fusion_type == NuclearFusionType::DeuteriumTritium)
{
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
product_species_name.size() == 2,
"ERROR: Deuterium-tritium must contain exactly two product species");
auto& product_species1 = mypc->GetParticleContainerFromName(product_species_name[0]);
auto& product_species2 = mypc->GetParticleContainerFromName(product_species_name[1]);
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
(product_species.AmIA<PhysicalSpecies::helium4>() && product_species.AmIA<PhysicalSpecies::neutron>())
||
(product_species.AmIA<PhysicalSpecies::neutron>() && product_species.AmIA<PhysicalSpecies::helium4>()),
"ERROR: Product species of deuterium-tritium fusion must be of type neutron and helium4");
}
if (m_fusion_type == NuclearFusionType::ProtonBoron)
{
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef SINGLE_NUCLEAR_FUSION_EVENT_H_
#define SINGLE_NUCLEAR_FUSION_EVENT_H_

#include "DeuteriumTritiumFusionCrossSection.H"
#include "ProtonBoronFusionCrossSection.H"

#include "Particles/Collision/BinaryCollision/BinaryCollisionUtils.H"
Expand Down Expand Up @@ -111,7 +112,11 @@ void SingleNuclearFusionEvent (const amrex::ParticleReal& u1x, const amrex::Part

// Compute fusion cross section as a function of kinetic energy in the center of mass frame
auto fusion_cross_section = amrex::ParticleReal(0.);
if (fusion_type == NuclearFusionType::ProtonBoron)
if (fusion_type == NuclearFusionType::DeuteriumTritium)
{
fusion_cross_section = DeuteriumTritiumFusionCrossSection(E_kin_star);
}
else if (fusion_type == NuclearFusionType::ProtonBoron)
{
fusion_cross_section = ProtonBoronFusionCrossSection(E_kin_star);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "BinaryCollisionUtils.H"

#include "Particles/Collision/BinaryCollision/NuclearFusion/DeuteriumTritiumFusionInitializeMomentum.H"
#include "Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H"
#include "Particles/ParticleCreation/SmartCopy.H"
#include "Particles/MultiParticleContainer.H"
Expand Down Expand Up @@ -208,6 +209,10 @@ public:

// Initialize the product particles' momentum, using a function depending on the
// specific collision type
if (t_collision_type == CollisionType::DeuteriumTritiumFusion)
{
// TODO DeuteriumTritiumFusionInitializeMomentum
}
if (t_collision_type == CollisionType::ProtonBoronFusion)
{
const index_type product_start_index = products_np_data[0] + 2*p_offsets[i]*
Expand Down
47 changes: 42 additions & 5 deletions Source/Particles/SpeciesPhysicalProperties.H
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#include <map>
#include <string>

enum struct PhysicalSpecies{unspecified=0, electron, positron, photon, hydrogen, helium, boron,
boron10, boron11, carbon, nitrogen, oxygen, argon, copper, xenon};
enum struct PhysicalSpecies{unspecified=0, electron, positron, photon, neutron,
hydrogen, hydrogen2, hydrogen3, helium, helium3, helium4, boron, boron10,
boron11, carbon, nitrogen, oxygen, argon, copper, xenon};

namespace species
{
Expand All @@ -33,12 +34,20 @@ namespace species
return PhysicalSpecies::positron;
if( species=="photon" )
return PhysicalSpecies::photon;
if( species=="hydrogen" )
return PhysicalSpecies::hydrogen;
if( species=="proton" )
if( species=="neutron" )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: #3090

return PhysicalSpecies::neutron;
if( (species=="hydrogen") || (species=="proton") )
return PhysicalSpecies::hydrogen;
if( (species=="hydrogen2") || (species=="deuterium") )
return PhysicalSpecies::hydrogen2;
if (species=="hydrogen3") || (species=="tritium") )
return PhysicalSpecies::hydrogen3;
if( species=="helium" )
return PhysicalSpecies::helium;
if( species=="helium3" )
return PhysicalSpecies::helium3;
if( species=="helium4" )
return PhysicalSpecies::helium4;
if( species=="alpha" )
return PhysicalSpecies::helium;
if( species=="boron" )
Expand Down Expand Up @@ -75,10 +84,20 @@ namespace species
return PhysConst::q_e;
case PhysicalSpecies::photon:
return 0.;
case PhysicalSpecies::neutron:
return 0.;
case PhysicalSpecies::hydrogen:
return PhysConst::q_e;
case PhysicalSpecies::hydrogen2:
return PhysConst::q_e;
case PhysicalSpecies::hydrogen3:
return PhysConst::q_e;
case PhysicalSpecies::helium:
return PhysConst::q_e * amrex::Real(2.0);
case PhysicalSpecies::helium3:
return PhysConst::q_e * amrex::Real(2.0);
case PhysicalSpecies::helium4:
return PhysConst::q_e * amrex::Real(2.0);
case PhysicalSpecies::boron:
return PhysConst::q_e * amrex::Real(5.0);
case PhysicalSpecies::boron10:
Expand Down Expand Up @@ -115,10 +134,20 @@ namespace species
return PhysConst::m_e;
case PhysicalSpecies::photon:
return 0.;
case PhysicalSpecies::neutron:
return PhysConst::m_p * amrex::Real(1.0013784193052508);
case PhysicalSpecies::hydrogen:
return PhysConst::m_p;
case PhysicalSpecies::hydrogen2:
return PhysConst::m_p * amrex::Real(1.99901);
case PhysicalSpecies::hydrogen3:
return PhysConst::m_p * amrex::Real(2.99372);
case PhysicalSpecies::helium:
return PhysConst::m_p * amrex::Real(3.97369);
case PhysicalSpecies::helium3:
return PhysConst::m_p * amrex::Real(2.99369);
case PhysicalSpecies::helium4:
return PhysConst::m_p * amrex::Real(3.97314);
case PhysicalSpecies::boron:
return PhysConst::m_p * amrex::Real(10.7319);
case PhysicalSpecies::boron10:
Expand Down Expand Up @@ -157,8 +186,16 @@ namespace species
return "photon";
case PhysicalSpecies::hydrogen:
return "hydrogen";
case PhysicalSpecies::hydrogen2:
return "hydrogen2";
case PhysicalSpecies::hydrogen3:
return "hydrogen3";
case PhysicalSpecies::helium:
return "helium";
case PhysicalSpecies::helium3:
return "helium3";
case PhysicalSpecies::helium4:
return "helium4";
case PhysicalSpecies::boron:
return "boron";
case PhysicalSpecies::boron10:
Expand Down