Skip to content
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
4 changes: 3 additions & 1 deletion include/viennaps/models/psSingleParticleALD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ template <typename NumericType>
class SingleParticleALDSurfaceModel : public SurfaceModel<NumericType> {
using SurfaceModel<NumericType>::coverages;

const NumericType dt_;
NumericType dt_;
const NumericType gpc_;
const NumericType s0_;

Expand All @@ -37,6 +37,8 @@ class SingleParticleALDSurfaceModel : public SurfaceModel<NumericType> {
coverages->insertNextScalarData(cov, "Coverage");
}

void setTimeStep(NumericType dt) override { dt_ = dt; }

SmartPointer<std::vector<NumericType>>
calculateVelocities(SmartPointer<viennals::PointData<NumericType>> rates,
const std::vector<Vec3D<NumericType>> &coordinates,
Expand Down
10 changes: 8 additions & 2 deletions include/viennaps/process/psALPStrategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,19 @@ class ALPStrategy final : public ProcessStrategy<NumericType, D> {

double time = 0.;
unsigned pulseIteration = 0;
while (std::fabs(time - pulseTime) > 1e-6) {
const double coverageTimeStep =
context.atomicLayerParams.coverageTimeStep;
while (time < pulseTime - coverageTimeStep * 1e-4) {
#ifdef VIENNATOOLS_PYTHON_BUILD
// Check for user interruption
if (PyErr_CheckSignals() != 0)
return ProcessResult::USER_INTERRUPTED;
#endif

// Clamp last step to land exactly on pulseTime
double dt = std::min(coverageTimeStep, pulseTime - time);
context.model->getSurfaceModel()->setTimeStep(dt);

// Calculate fluxes
auto fluxes = SmartPointer<viennals::PointData<NumericType>>::New();
PROCESS_CHECK(fluxEngine_->calculateFluxes(context, fluxes));
Expand All @@ -178,7 +184,7 @@ class ALPStrategy final : public ProcessStrategy<NumericType, D> {

outputIntermediateResults(context, fluxes, pulseIteration);

time += context.atomicLayerParams.coverageTimeStep;
time += dt;
pulseIteration++;

if (Logger::hasInfo()) {
Expand Down
2 changes: 2 additions & 0 deletions include/viennaps/process/psSurfaceModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ template <typename NumericType> class SurfaceModel {
// if no surface data get initialized here, they won't be used at all
}

virtual void setTimeStep(NumericType dt) {}

virtual SmartPointer<std::vector<NumericType>>
calculateVelocities(SmartPointer<viennals::PointData<NumericType>> fluxes,
const std::vector<Vec3D<NumericType>> &coordinates,
Expand Down
Loading