Skip to content

Commit

Permalink
fix averaging bug with average over count
Browse files Browse the repository at this point in the history
  • Loading branch information
Danbr4d committed Dec 19, 2024
1 parent 204fa25 commit 2706f40
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/modules/epsrManager/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ Module::ExecutionResult EPSRManagerModule::process(ModuleContext &moduleContext)
Messenger::print("Potentials: No averaging of potentials will be performed.\n");

auto &moduleData = moduleContext.dissolve().processingModuleData();

// Potential Set
PotentialSet potentials;
// Does a PotentialSet already exist for this Configuration?
auto originalPotentialsObject =
moduleData.realiseIf<PotentialSet>(fmt::format("PotentialSet"), name_, GenericItem::InRestartFileFlag);
// Loop over target data
for (auto *module : target_)
{
auto *epsrModule = dynamic_cast<EPSRModule *>(module);
auto eps = epsrModule->empiricalPotentials();
potentials.reset();

for (auto &&[at1, at2, ep] : eps)
{
Expand All @@ -56,12 +54,19 @@ Module::ExecutionResult EPSRManagerModule::process(ModuleContext &moduleContext)
}
}
}
// Does a PotentialSet already exist for this Configuration?
auto originalPotentialsObject =
moduleData.realiseIf<PotentialSet>(fmt::format("PotentialSet"), name_, GenericItem::InRestartFileFlag);
// Set restart equal to changes
originalPotentialsObject.first = potentials;
// Average the Potentials
if (averagingLength_)
Averaging::average<PotentialSet>(moduleContext.dissolve().processingModuleData(), "PotentialSet", name(),
averagingLength_.value(), averagingScheme_);

for (auto &&[key, epData] : potentials.potentialMap())
epData.ep /= potentials.potentialMap()[key].count;

// Apply potential scalings
auto scalings = DissolveSys::splitString(potentialScalings_, ",");
for (const auto &scaling : scalings)
Expand Down

0 comments on commit 2706f40

Please sign in to comment.