-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: more control of averaging potentials #1970
base: develop
Are you sure you want to change the base?
Changes from 3 commits
1ad2d1b
bae42c4
2e107e9
2be06a0
57a0c5a
ca5bb3e
6f84266
88e0bbb
8e345d2
b2d20d7
677a2a2
dd10495
b1bd16b
87e8029
b5467b8
fb0068a
7f6629e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||
|
||||||
#include "classes/scatteringMatrix.h" | ||||||
#include "generator/generator.h" | ||||||
#include "math/averaging.h" | ||||||
#include "module/groups.h" | ||||||
#include "module/module.h" | ||||||
#include <tuple> | ||||||
|
@@ -35,6 +36,12 @@ class EPSRManagerModule : public Module | |||||
}; | ||||||
// Potential scalings | ||||||
std::string potentialScalings_; | ||||||
// Number of historical partial sets to combine into final partials | ||||||
std::optional<int> averagingLength_; | ||||||
// Weighting scheme to use when averaging partials | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Averaging::AveragingScheme averagingScheme_{Averaging::LinearAveraging}; | ||||||
// Vector of averaged potentials over multiple iterations | ||||||
std::vector<std::map<std::string, EPData>> averagedPotentialsStore; | ||||||
|
||||||
/* | ||||||
* Functions | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,26 @@ Module::ExecutionResult EPSRManagerModule::process(ModuleContext &moduleContext) | |
for (auto &&[key, epData] : potentials) | ||
epData.ep /= epData.count; | ||
|
||
std::map<std::string, EPData> averagedPotentials = potentials; | ||
|
||
averagedPotentialsStore.emplace_back(potentials); | ||
// Check if ran the right amount of iterations before averaging | ||
if (averagedPotentialsStore.size() > averagingLength_) | ||
{ | ||
averagedPotentialsStore.pop_back(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't account for cases where the user changes the averaging length and we need to remove more than one. This curation of data is also handled for us if we move to using the proper |
||
|
||
// Average the potentials and replace the map with the new averaged | ||
for (const auto &pots : averagedPotentialsStore) | ||
{ | ||
Danbr4d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (auto &&[key, epData] : pots) | ||
{ | ||
averagedPotentials[key].ep += epData.ep; | ||
averagedPotentials[key].ep /= averagingLength_.value(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Careful - the value of |
||
} | ||
} | ||
potentials = averagedPotentials; | ||
Danbr4d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Apply potential scalings | ||
auto scalings = DissolveSys::splitString(potentialScalings_, ","); | ||
for (const auto &scaling : scalings) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.