Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor AU units #5133

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions docs/source/usage/workflows/ionization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ To include charge-state-only simulations in your simulations you must:
float_X,
7, // number charge states
Nitrogen, // name you may reference this by later, remember to prepend the namespace and append _t!
14.53413 * UNITCONV_eV_to_AU,
29.60125 * UNITCONV_eV_to_AU,
47.4453 * UNITCONV_eV_to_AU,
77.4735 * UNITCONV_eV_to_AU,
97.89013 * UNITCONV_eV_to_AU,
552.06731 * UNITCONV_eV_to_AU,
667.04609 * UNITCONV_eV_to_AU);
sim.si.conv().eV2auEnergy(14.53413),
sim.si.conv().eV2auEnergy(29.60125),
sim.si.conv().eV2auEnergy(47.4453),
sim.si.conv().eV2auEnergy(77.4735),
sim.si.conv().eV2auEnergy(97.89013),
sim.si.conv().eV2auEnergy(552.06731),
sim.si.conv().eV2auEnergy(667.04609));
}; // namespace picongpu::ionization::energies::AU

.. note::
Expand Down
1 change: 0 additions & 1 deletion include/picongpu/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ namespace picongpu
#include "picongpu/param/speciesConstants.param"
#include "picongpu/param/simulation.param"
#include "picongpu/unitless/simulation.unitless"
#include "picongpu/unitless/physicalConstants.unitless"
// clang-format on
325 changes: 165 additions & 160 deletions include/picongpu/param/ionizationEnergies.param

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/picongpu/param/ionizer.param
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ namespace picongpu
*/
constexpr float_X CUTOFF_MAX_ENERGY_KEV = 50.0;
/** cutoff energy for electron "temperature" calculation in SI units*/
constexpr float_X CUTOFF_MAX_ENERGY = CUTOFF_MAX_ENERGY_KEV * sim.si.conv.ev2Joule(1.0e3);
constexpr float_X CUTOFF_MAX_ENERGY = sim.si.conv().eV2Joule(CUTOFF_MAX_ENERGY_KEV * 1.0e3);

/** lower ion density cutoff
*
Expand Down
21 changes: 0 additions & 21 deletions include/picongpu/param/physicalConstants.param
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,5 @@ namespace picongpu
constexpr float_64 ELECTRON_MASS_SI = 9.1093837139e-31;
//! unit: C, 2022 CODATA value, https://physics.nist.gov/cgi-bin/cuu/Value?e
constexpr float_64 ELECTRON_CHARGE_SI = -1.602176634e-19;

/* atomic unit for energy:
* 2 Rydberg = 27.21 eV --> converted to Joule
*/
constexpr float_64 ATOMIC_UNIT_ENERGY = 4.36e-18;

/* atomic unit for electric field in V/m:
* field strength between electron and core in ground state hydrogen
*/
constexpr float_64 ATOMIC_UNIT_EFIELD = 5.14e11;

/* atomic unit for time in s:
* 150 attoseconds (classical electron orbit time in hydrogen) / 2 PI
*/
constexpr float_64 ATOMIC_UNIT_TIME = 2.4189e-17;

} // namespace SI

/* 1 atomic unit of energy is equal to 1 Hartree or 2 Rydberg
* which is twice the ground state binding energy of atomic hydrogen */
constexpr float_64 UNITCONV_AU_to_eV = 27.21139;
constexpr float_64 UNITCONV_eV_to_AU = (1.0 / UNITCONV_AU_to_eV);
} // namespace picongpu
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ namespace picongpu::particles::atomicPhysics
//}

// unit conversion factor for eV
constexpr float_X eV = static_cast<float_X>(
picongpu::sim.unit.mass() * picongpu::sim.si.getSpeedOfLight() * picongpu::sim.si.getSpeedOfLight()
* sim.si.conv.joule2ev(1.0));
constexpr float_X eV = static_cast<float_X>(sim.si.conv().joule2eV(
picongpu::sim.unit.mass() * picongpu::sim.si.getSpeedOfLight() * picongpu::sim.si.getSpeedOfLight()));

// eV
return energy * eV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ namespace picongpu::particles::atomicPhysics::initElectrons
// sim.unit.mass()/sim.unit.mass() = unitless
float_64 const mE_mI = static_cast<float_64>(massElectron / massIon);
// kg * m^2/s^2 * keV/J * 1e3 = J/J * eV = eV
float_64 const mc2_Ion = static_cast<float_64>(massIon) * sim.unit.mass()
* pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u) * sim.si.conv.joule2ev(1.0);
float_64 const mc2_Ion = static_cast<float_64>(massIon)
* sim.si.conv().joule2eV(sim.unit.mass() * pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u));

// eV / eV + sim.unit.mass() / sim.unit.mass() = unitless
float_64 const A_E = deltaEnergy / mc2_Ion + mE_mI;
Expand Down Expand Up @@ -247,8 +247,8 @@ namespace picongpu::particles::atomicPhysics::initElectrons
// sim.unit.mass()/sim.unit.mass() = unitless
float_64 const mI_mE = static_cast<float_64>(massIon / massElectron);
// kg * m^2/s^2 * keV/J * 1e3 = J/J * eV = eV
float_64 const mc2_Electron = static_cast<float_64>(massElectron) * sim.unit.mass()
* pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u) * sim.si.conv.joule2ev(1.0);
float_64 const mc2_Electron = static_cast<float_64>(massElectron)
* sim.si.conv().joule2eV(sim.unit.mass() * pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u));

float_64 const A_I = deltaEnergy / mc2_Electron + mI_mE;
float_64 const gammaStarIon_IonSystem = (A_I * (A_I + 2.) + (mI_mE * mI_mE)) / ((A_I + 1.) * 2. * mI_mE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ namespace picongpu::particles::atomicPhysics::ionizationPotentialDepression
T_LocalZStarBox const localZStarBox)
{
// eV/(sim.unit.mass() * sim.unit.length()^2 / sim.unit.time()^2)
constexpr float_X eV = static_cast<float_X>(
picongpu::sim.unit.mass() * pmacc::math::cPow(picongpu::sim.unit.length(), 2u)
/ pmacc::math::cPow(picongpu::sim.unit.time(), 2u) * sim.si.conv.joule2ev(1.0));
constexpr float_X eV = sim.pic.get_eV();

// eV/(sim.unit.mass() * sim.unit.length()^2 / sim.unit.time()^2) * unitless * sim.unit.charge()^2
// / ( unitless * sim.unit.charge()^2 * sim.unit.time()^2 / (sim.unit.length()^3 * sim.unit.mass()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ namespace picongpu::particles::atomicPhysics::ionizationPotentialDepression::ker
localZStar = localSumChargeNumberSquared / localSumChargeNumber;

// eV/(sim.unit.mass() * sim.unit.length()^2 / sim.unit.time()^2)
constexpr float_X eV = static_cast<float_X>(
picongpu::sim.unit.mass() * pmacc::math::cPow(picongpu::sim.unit.length(), 2u)
/ pmacc::math::cPow(picongpu::sim.unit.time(), 2u) * sim.si.conv.joule2ev(1.0));
constexpr float_X eV
= static_cast<float_X>(picongpu::sim.si.conv().joule2eV(picongpu::sim.unit.energy()));

// eV/(sim.unit.mass() * sim.unit.length()^2 / sim.unit.time()^2) * sim.unit.mass() *
// sim.unit.length()^2 / sim.unit.time()^2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ namespace picongpu::particles::atomicPhysics::kernel
// = Nm/J * eV = J/J * eV = eV, ~ 511e3 eV
float_X const mcSquaredElectron = static_cast<float_X>(
static_cast<float_64>(picongpu::traits::frame::getMass<typename T_Electron::FrameType>())
* sim.unit.mass() * pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u)
* sim.si.conv.joule2ev(1.0));
* sim.si.conv().joule2eV(
sim.unit.mass() * pmacc::math::cPow(picongpu::sim.si.getSpeedOfLight(), 2u)));
// eV, not weighted

// distribute energy change as mean by weight on all electrons in bin
Expand All @@ -133,16 +133,15 @@ namespace picongpu::particles::atomicPhysics::kernel
picongpu::sim.si.getSpeedOfLight() * sim.unit.time() / sim.unit.length());
// usually ~1, internal units

constexpr float_X conversionEnergy
= static_cast<float_X>(sim.si.conv.ev2Joule(1.0) / sim.unit.energy());
constexpr float_X conversionEnergy = static_cast<float_X>(picongpu::sim.pic.get_eV());
// J/(eV) * sim.unit.energy()/J = J/J * sim.unit.energy()/(eV)

constexpr float_X scalingFactor = 1._X / c_internal * conversionEnergy;

// sqrt(E' * (E' + 2* m*c^2)) / c
float_X const newElectronMomentum
= math::sqrt(newEnergyElectron * (newEnergyElectron + 2 * mcSquaredElectron)) * scalingFactor;
// AU = ATOMIC_UNIT_ENERGY
// AU = sim.atomicUnit.energy()
// sqrt(eV * (eV + eV))/(sim.unit.length()/sim.unit.time()) * (sim.unit.energy()/eV)
// = sqrt((eV)^2)/(eV) * sim.unit.time()/sim.unit.length() * sim.unit.energy()
// = sim.unit.mass() * sim.unit.length()^2/sim.unit.time()^2 * sim.unit.time()/sim.unit.length()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ namespace picongpu::particles::atomicPhysics::rateCalculation
8. * pmacc::math::cPow(picongpu::PI * sim.si.getBohrRadius(), u8(2u))
/ (1.e-22)); // [1e6b], ~ 2211,01 * 1e6b
// 1e6b
constexpr float_X constantPart
= scalingConstant * static_cast<float_X>(pmacc::math::cPow(sim.si.getRydbergEnergy(), u8(2u)));
constexpr float_X constantPart = scalingConstant
* static_cast<float_X>(pmacc::math::cPow(sim.si.conv().joule2eV(sim.si.getRydbergEnergy()), u8(2u)));
// [1e6b * (eV)^2]

// 1e6b*(eV)^2 / (eV)^2 * unitless * (eV)/(eV) * unitless = 1e6b
Expand Down Expand Up @@ -390,7 +390,7 @@ namespace picongpu::particles::atomicPhysics::rateCalculation

// J/(eV) / (Js) * s/sim.unit.time() = J/J * s/s * 1/(eV * sim.unit.time())
constexpr float_X scalingConstantPhotonFrequency
= static_cast<float_X>(sim.si.conv.ev2Joule(1.0) / (2 * pi * hbar_SI) * picongpu::sim.unit.time());
= static_cast<float_X>(picongpu::sim.si.get_eV() / (2 * pi * hbar_SI) * picongpu::sim.unit.time());

/// @attention actual SI frequency, NOT angular frequency
// 1/sim.unit.time()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace picongpu::particles::atomicPhysics::rateCalculation
{
constexpr float_64 C = 2.3; // a fitting factor well suited for Z >= 2, unitless
constexpr float_64 a0 = sim.si.getBohrRadius(); // m
constexpr float_64 E_R = sim.si.getRydbergEnergy(); // eV
constexpr float_64 E_R = sim.si.conv().joule2eV(sim.si.getRydbergEnergy()); // eV
constexpr float_64 scalingConstant
= C * picongpu::PI * pmacc::math::cPow(a0, 2u) / 1e-22 * pmacc::math::cPow(E_R, 2u);
// 10^6*b * eV^2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace picongpu::particles::atomicPhysics::rateCalculation
chargeStateDataBox);
// unitless
float_X const effectivePrincipalQuantumNumber
= screenedCharge / math::sqrt(2._X * ionizationEnergy * picongpu::UNITCONV_eV_to_AU);
float_X const eFieldNorm_AU = eFieldNorm / ATOMIC_UNIT_EFIELD;
= screenedCharge / math::sqrt(2._X * sim.si.conv().eV2auEnergy(ionizationEnergy));
float_X const eFieldNorm_AU = sim.pic.conv().eField2auEField(eFieldNorm);
float_X const screenedChargeCubed = pmacc::math::cPow(screenedCharge, 3u);
float_X const dBase = 4.0_X * math::exp(1._X) * screenedChargeCubed
/ (eFieldNorm_AU * pmacc::math::cPow(effectivePrincipalQuantumNumber, 4u));
Expand All @@ -103,7 +103,7 @@ namespace picongpu::particles::atomicPhysics::rateCalculation
constexpr float_X pi = pmacc::math::Pi<float_X>::value;
float_X const nEffCubed = pmacc::math::cPow(effectivePrincipalQuantumNumber, 3u);

// 1/ATOMIC_UNIT_TIME
// 1/sim.atomicUnit.time()
float_X rateADK_AU = eFieldNorm_AU * pmacc::math::cPow(dFromADK, 2u) / (8._X * pi * screenedCharge)
* math::exp(-2._X * screenedChargeCubed / (3._X * nEffCubed * eFieldNorm_AU));

Expand All @@ -112,7 +112,7 @@ namespace picongpu::particles::atomicPhysics::rateCalculation
u32(T_ADKLaserPolarization) == u32(atomicPhysics::enums::ADKLaserPolarization::linearPolarization))
rateADK_AU *= math::sqrt(3._X * nEffCubed * eFieldNorm_AU / (pi * screenedChargeCubed));

return rateADK_AU / ATOMIC_UNIT_TIME;
return rateADK_AU / sim.atomicUnit.time();
}
};
} // namespace picongpu::particles::atomicPhysics::rateCalculation
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace picongpu::particles2::atomicPhysics::rateCalculation
constexpr float_64 c_SI = picongpu::sim.si.getSpeedOfLight(); // [m/s]
constexpr float_64 m_e_SI = picongpu::sim.si.getElectronMass(); // [kg]

constexpr float_64 electronRestMassEnergy = m_e_SI * c_SI * c_SI / sim.si.conv.ev2Joule(1.0);
constexpr float_64 electronRestMassEnergy = m_e_SI * c_SI * c_SI / picongpu::sim.si.get_eV();
// kg * (m^2)/(s^2) * 1/(J/eV) = Nm * eV/J = J/J * eV
// [eV] ~ 5.11e5

Expand Down
2 changes: 1 addition & 1 deletion include/picongpu/particles/boundary/Thermal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace picongpu
static constexpr char const* name = "reflectThermalIfOutside";

HINLINE ReflectThermalIfOutside()
: energy((m_parameters.temperature * sim.si.conv.ev2Joule(1.0e3)) / sim.unit.energy())
: energy((m_parameters.temperature * sim.si.conv().eV2Joule(1.0e3)) / sim.unit.energy())
{
}

Expand Down
2 changes: 1 addition & 1 deletion include/picongpu/particles/debyeLength/Estimate.kernel
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace picongpu
using Frame = typename T_ElectronBox::FrameType;
auto const mass = static_cast<double>(picongpu::traits::frame::getMass<Frame>());
auto const kT = (momentumVariance[0] + momentumVariance[1] + momentumVariance[2]) / (3.0 * mass);
auto const temperatureKeV = kT * sim.unit.energy() / sim.si.conv.ev2Joule(1.0e3);
auto const temperatureKeV = kT * sim.unit.energy() / sim.si.conv().eV2Joule(1.0e3);
auto const electronCharge = picongpu::traits::frame::getCharge<Frame>();
auto const debyeLength
= sqrt(sim.pic.getEps0() * kT / (electronDensity * electronCharge * electronCharge));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace picongpu
/** convert kinetic energy in J to "temperature" in eV by assuming an ideal electron gas
* E_kin = 3/2 k*T
*/
constexpr float_64 convKinEnergyToTemperature = sim.si.conv.joule2ev(1.0) * float_64(2. / 3.);
constexpr float_64 convKinEnergyToTemperature = sim.si.conv().joule2eV(1.0) * float_64(2. / 3.);
/** electron "temperature" in electron volts */
float_64 const temperature = avgKinEnergy * convKinEnergyToTemperature;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace picongpu

constexpr float_X pi = pmacc::math::Pi<float_X>::value;
/* electric field in atomic units - only absolute value */
float_X const eInAU = pmacc::math::l2norm(eField) / ATOMIC_UNIT_EFIELD;
float_X const eInAU = sim.pic.conv().eField2auEField(pmacc::math::l2norm(eField));

/* the charge that attracts the electron that is to be ionized:
* equals `protonNumber - #allInnerElectrons`
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace picongpu
}

/* simulation time step in atomic units */
auto const timeStepAU = float_X(sim.pic.getDt() / ATOMIC_UNIT_TIME);
auto const timeStepAU = sim.pic.conv().time2auTime(sim.pic.getDt());
/* ionization probability
*
* probability = rate * time step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace picongpu
/* critical field strength in atomic units */
float_X const critField = iEnergy * iEnergy / (float_X(4.0) * effectiveCharge);
/* ionization condition */
if(pmacc::math::l2norm(eField) / ATOMIC_UNIT_EFIELD >= critField)
if(sim.pic.conv().eField2auEField(pmacc::math::l2norm(eField)) >= critField)
{
/* return ionization energy and number of macro electrons to produce */
return IonizerReturn{iEnergy, 1u};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace picongpu
float_X critField = iEnergy * iEnergy / (float_X(4.0) * ZEff);

/* ionization condition */
if(pmacc::math::l2norm(eField) / ATOMIC_UNIT_EFIELD >= critField)
if(sim.pic.conv().eField2auEField(pmacc::math::l2norm(eField)) >= critField)
{
/* return ionization energy and number of macro electrons to produce */
return IonizerReturn{iEnergy, 1u};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace picongpu
= (math::sqrt(float_X(2.)) - float_X(1.)) * math::pow(iEnergy, float_X(3. / 2.));

/* ionization condition */
if(pmacc::math::l2norm(eField) / ATOMIC_UNIT_EFIELD >= critField)
if(sim.pic.conv().eField2auEField(pmacc::math::l2norm(eField)) >= critField)
{
/* return ionization energy number of electrons to produce */
return IonizerReturn{iEnergy, 1u};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ namespace picongpu
* ionization current. */
if(retValue.ionizationEnergy != 0.0_X)
{
auto ionizationEnergy = weighting * retValue.ionizationEnergy * SI::ATOMIC_UNIT_ENERGY
/ sim.unit.energy(); // convert to PIConGPU units
auto ionizationEnergy = sim.pic.conv().auEnergy2Joule(weighting * retValue.ionizationEnergy);
/* calculate ionization current at particle position */
float3_X jIonizationPar = JIonizationCalc{}(ionizationEnergy, eField);
/* assign ionization current to grid points */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace picongpu

constexpr float_X pi = pmacc::math::Pi<float_X>::value;
/* electric field in atomic units - only absolute value */
float_X eInAU = pmacc::math::l2norm(eField) / ATOMIC_UNIT_EFIELD;
float_X eInAU = sim.pic.conv().eField2auEField(pmacc::math::l2norm(eField));

/* factor two avoid calculation math::pow(2,5./4.); */
const float_X twoToFiveQuarters = 2.3784142300054;
Expand All @@ -89,7 +89,7 @@ namespace picongpu
* math::sqrt(float_X(1.) / charExpArg) * math::exp(-float_X(2. / 3.) * charExpArg);

/* simulation time step in atomic units */
const auto timeStepAU = float_X(sim.pic.getDt() / ATOMIC_UNIT_TIME);
const auto timeStepAU = sim.pic.conv().time2auTime(sim.pic.getDt());
/* ionization probability
*
* probability = rate * time step
Expand Down
Loading