Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMarre committed May 5, 2023
1 parent 6f62eb1 commit 8176990
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 90 deletions.
12 changes: 6 additions & 6 deletions include/picongpu/particles/atomicPhysics2/SuperCellField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ namespace picongpu::particles::atomicPhysics2

// required by ISimulationData
//! == deviceToHost
HDINLINE void synchronize() override
HINLINE void synchronize() override
{
superCellField->deviceToHost();
}

// required by SimulationFieldHelper
HDINLINE void reset(uint32_t currentStep) override
HINLINE void reset(uint32_t currentStep) override
{
/// @todo figure out why exactly this way
superCellField->getHostBuffer().reset(true);
Expand All @@ -103,7 +103,7 @@ namespace picongpu::particles::atomicPhysics2

// required by SimulationHelperField
//! ==hostToDevice
HDINLINE void syncToDevice() override
HINLINE void syncToDevice() override
{
superCellField->hostToDevice();
}
Expand All @@ -112,17 +112,17 @@ namespace picongpu::particles::atomicPhysics2
*
* Note: dataBoxes are just "pointers"
*/
HDINLINE DataBoxType getDeviceDataBox()
HINLINE DataBoxType getDeviceDataBox()
{
return this->superCellField->getDeviceBuffer().getDataBox();
}

HDINLINE DeviceBufferType& getDeviceBuffer()
HINLINE DeviceBufferType& getDeviceBuffer()
{
return this->superCellField->getDeviceBuffer();
}

HDINLINE GridLayout<picongpu::simDim> getGridLayout()
HINLINE GridLayout<picongpu::simDim> getGridLayout()
{
return superCellField->getGridLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ namespace picongpu::particles::atomicPhysics2::electronDistribution
class HistogramInterface
{
//! check whether the given energy, [eV] is in the histogram energy range
virtual bool inRange(float_X const energy) const = 0;
HDINLINE virtual bool inRange(float_X const energy) const = 0;

//! get binIndex for a given energy [eV]
virtual uint32_t getBinIndex(float_X const energy) const = 0;
HDINLINE virtual uint32_t getBinIndex(float_X const energy) const = 0;

//! get the central Energy for a given binIndex, @return unit: eV
virtual float_X getBinEnergy(uint32_t const binIndex) const = 0;
HDINLINE virtual float_X getBinEnergy(uint32_t const binIndex) const = 0;

//! get energy width of bin, @return unit: eV
virtual float_X getBinWidth(uint32_t const binIndex) const = 0;
HDINLINE virtual float_X getBinWidth(uint32_t const binIndex) const = 0;

//! get weight of initially binned particles
virtual float_X getBinWeight0(uint32_t const binIndex) const = 0;
HDINLINE virtual float_X getBinWeight0(uint32_t const binIndex) const = 0;

//! get reserved/already used weight of bin
virtual float_X getBinDeltaWeight(uint32_t const binIndex) const = 0;
HDINLINE virtual float_X getBinDeltaWeight(uint32_t const binIndex) const = 0;

//! get deltaEnergy of Bin, @return unit: eV
virtual float_X getBinDeltaEnergy(uint32_t const binIndex) const = 0;
HDINLINE virtual float_X getBinDeltaEnergy(uint32_t const binIndex) const = 0;

/** bin the particle, add weight to w0 of the corresponding bin
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ namespace picongpu::particles::atomicPhysics2::kernel
T_Worker const& worker,
auto& particle)
{
if((particle[accepted_])
// already accepted transition
|| (particle[processClass_]
!= static_cast<uint8_t>(
picongpu::particles::atomicPhysics2::processClass::ProcessClass ::noChange))
// not a noChange transition
)
if(
// already accepted transition
(particle[accepted_])
||
// not a no-change transition
(particle[processClass_] != static_cast<uint8_t>(
picongpu::particles::atomicPhysics2::processClass::ProcessClass::noChange)))
{
return;
}

auto rngGenerator = rngFactory(worker, superCellFieldIdx);

Expand All @@ -118,9 +120,11 @@ namespace picongpu::particles::atomicPhysics2::kernel

// try to accept
if(probability >= rngGenerator())
{
particle[accepted_] = true;
});
worker.sync();
}
}
);
}
};
} // namespace picongpu::particles::atomicPhysics2::kernel
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,23 @@ namespace picongpu::particles::atomicPhysics2::kernel
forEachLocalIonBoxEntry(
[](T_Worker const& worker, auto& particle)
{
if(particle[accepted_])
return; // already accepted particle
if(
// already accepted particle
(particle[accepted_])
||
// not a no-change transition
!(particle[transitionIndex_] == static_cast<uint32_t>(0u)))
{
return;
}

if(!(particle[transitionIndex_] == static_cast<uint32_t>(0u)))
;
return; // not a no-change transition
particle[processClass_] = static_cast<uint8_t>(
picongpu::particles::atomicPhysics2::processClass::ProcessClass::noChange);

particle[processClass_]
== static_cast<uint8_t>(
picongpu::particles::atomicPhysics2::processClass::ProcessClass::noChange);
// transitionIndex and binIndex are not relevant for no-change transitions
// => no need to set them
});
worker.sync();
}
);
}
};
} // namespace picongpu::particles::atomicPhysics2::kernel
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ namespace picongpu::particles::atomicPhysics2::kernel
auto forEachAtomicState = pmacc::lockstep::makeForEach<T_numberAtomicStates, T_Worker>(worker);

forEachAtomicState(
[&worker, &rateCache, &startIndexDataBox, &numberTransitionsDataBox, &autonomousTransitionDataBox](
uint32_t const atomicStateCollectionIndex)
[
&worker,
&rateCache,
&startIndexDataBox,
&numberTransitionsDataBox,
&autonomousTransitionDataBox
](uint32_t const atomicStateCollectionIndex)
{
uint32_t const numberTransitionsDown
= numberTransitionsDataBox.numberOfTransitions(atomicStateCollectionIndex);
Expand All @@ -97,15 +102,21 @@ namespace picongpu::particles::atomicPhysics2::kernel

for(uint32_t i = static_cast<uint32_t>(0u); i < numberTransitionsDown; i++)
{
// no check for if processClass channel is active, since currently
// only one exist at all

rateCache.add(
atomicStateCollectionIndex,
-picongpu::particles::atomicPhysics2::rateCalculation::AutonomousTransitionRates::
template rateAutonomousIonization<T_AutonomousTransitionDataBox>(
offset + i, // transitionCollectionIndex
autonomousTransitionDataBox)); // 1/UNIT_TIME
// 1/UNIT_TIME
- picongpu::particles::atomicPhysics2::rateCalculation::AutonomousTransitionRates
::template rateAutonomousIonization<T_AutonomousTransitionDataBox>(
// transitionCollectionIndex
offset + i,
autonomousTransitionDataBox)
);
}
});
worker.sync();
}
);
}
};
} // namespace picongpu::particles::atomicPhysics2::kernel
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,20 @@ namespace picongpu::particles::atomicPhysics2::kernel
else
offset = startIndexDataBox.startIndexBlockTransitionsDown(atomicStateCollectionIndex);

// UNIT_LENGTH^3
constexpr float_X volumeScalingFactor
= pmacc::math::CT::volume<SuperCellSize>::type::value * picongpu::CELL_VOLUME; // UNIT_LENGTH^3
= pmacc::math::CT::volume<SuperCellSize>::type::value * picongpu::CELL_VOLUME;

for(uint32_t i = static_cast<uint32_t>(0u); i < numberTransitions; i++)
{
// collisional bound-bound de-/excitation
if constexpr((T_upward && T_electronicExcitation) || ((!T_upward) && T_electronicDeexcitation))
// collisional bound-bound de- or excitation
if constexpr(
// upward and electronic excitation channel is active
(T_upward && T_electronicExcitation)
||
// downward and electronic deexcitation channel is active
((!T_upward) && T_electronicDeexcitation))
{
rateCache.add(
worker,
atomicStateCollectionIndex,
Expand All @@ -153,19 +160,26 @@ namespace picongpu::particles::atomicPhysics2::kernel
template rateCollisionalBoundBoundTransition<
T_AtomicStateDataDataBox,
T_BoundBoundTransitionDataBox,
T_upward>(
T_upward
>(
histogram.getBinEnergy(binIndex),
histogram.getBinWidth(binIndex),
// 1/(UNIT_LENGTH^3*eV)
histogram.getBinWeight0(binIndex) / volumeScalingFactor
/ histogram.getBinWidth(binIndex), // 1/(UNIT_LENGTH^3*eV)
offset + i, // transitionCollectionIndex
/ histogram.getBinWidth(binIndex),
// transitionCollectionIndex
offset + i,
atomicStateDataDataBox,
boundBoundTransitionDataBox));
boundBoundTransitionDataBox)
);
}
}
});
}
);

// spontaneous radiative deexcitation
if constexpr((!T_upward) and T_spontaneousDeexcitation)
{
forEachAtomicState(
[&worker,
&rateCache,
Expand All @@ -183,17 +197,20 @@ namespace picongpu::particles::atomicPhysics2::kernel
{
rateCache.add(
atomicStateCollectionIndex,
-picongpu::particles::atomicPhysics2::rateCalculation:: // rate
BoundBoundTransitionRates<T_numberLevels>::
template rateSpontaneousRadiativeDeexcitation<
- picongpu::particles::atomicPhysics2::rateCalculation
::BoundBoundTransitionRates<T_numberLevels>
::template rateSpontaneousRadiativeDeexcitation<
T_AtomicStateDataDataBox,
T_BoundBoundTransitionDataBox>(
offset + i, // transitionCollectionIndex
T_BoundBoundTransitionDataBox
>(
// transitionCollectionIndex
offset + i,
atomicStateDataDataBox,
boundBoundTransitionDataBox));
}
});
worker.sync();
}
);
}
}
};
} // namespace picongpu::particles::atomicPhysics2::kernel
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,29 @@ namespace picongpu::particles::atomicPhysics2::kernel
for(uint32_t i = static_cast<uint32_t>(0u); i < numberTransitionsUp; i++)
{
if constexpr(T_electronicIonization)
{
rateCache.add(
worker,
atomicStateCollectionIndex,
-picongpu::particles::atomicPhysics2::rateCalculation:: // rate
BoundFreeTransitionRates<T_numberLevels>::template rateCollisionalIonizationTransition<
T_ChargeStateDataDataBox,
T_AtomicStateDataDataBox,
T_BoundFreeTransitionDataBox>(
histogram.getBinEnergy(binIndex),
histogram.getBinWidth(binIndex),
histogram.getBinWeight0(binIndex) / volumeScalingFactor
/ histogram.getBinWidth(binIndex), // 1/(UNIT_LENGTH^3*eV)
offset + i, // transitionCollectionIndex
chargeStateDataDataBox,
atomicStateDataDataBox,
boundFreeTransitionDataBox));
- picongpu::particles::atomicPhysics2::rateCalculation
::BoundFreeTransitionRates<T_numberLevels>
::template rateCollisionalIonizationTransition<
T_ChargeStateDataDataBox,
T_AtomicStateDataDataBox,
T_BoundFreeTransitionDataBox
>(
histogram.getBinEnergy(binIndex),
histogram.getBinWidth(binIndex),
// 1/(UNIT_LENGTH^3*eV)
histogram.getBinWeight0(binIndex) / volumeScalingFactor
/ histogram.getBinWidth(binIndex),
// transitionCollectionIndex
offset + i,
chargeStateDataDataBox,
atomicStateDataDataBox,
boundFreeTransitionDataBox)
);
}
}
});
worker.sync();
Expand Down
Loading

0 comments on commit 8176990

Please sign in to comment.