Skip to content

Commit fe11c3f

Browse files
fix: termination of ALP pulse-time loop
The pulse-time loop in ALPStrategy used an absolute difference and hardcoded absolute epsilon (std::fabs(time - pulseTime) > 1e-6) as its termination guard, which does not brake if the time increment is not a whole fraction of pulseTime (or very close). Replace with a scaled epsilon (coverageTimeStep * 1e-4) and changed termination guard.
1 parent 937d716 commit fe11c3f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

include/viennaps/process/psALPStrategy.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class ALPStrategy final : public ProcessStrategy<NumericType, D> {
162162

163163
double time = 0.;
164164
unsigned pulseIteration = 0;
165-
while (std::fabs(time - pulseTime) > 1e-6) {
165+
const double coverageTimeStep = context.atomicLayerParams.coverageTimeStep;
166+
while (time < pulseTime - coverageTimeStep * 1e-4) {
166167
#ifdef VIENNATOOLS_PYTHON_BUILD
167168
// Check for user interruption
168169
if (PyErr_CheckSignals() != 0)
@@ -178,7 +179,7 @@ class ALPStrategy final : public ProcessStrategy<NumericType, D> {
178179

179180
outputIntermediateResults(context, fluxes, pulseIteration);
180181

181-
time += context.atomicLayerParams.coverageTimeStep;
182+
time += coverageTimeStep;
182183
pulseIteration++;
183184

184185
if (Logger::hasInfo()) {

0 commit comments

Comments
 (0)