Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
efb74ef
setup edges for test
RobBuchananCompPhys Jul 25, 2025
3db24d9
tests - edges
RobBuchananCompPhys Jul 25, 2025
c48b332
generate cells
RobBuchananCompPhys Jul 29, 2025
4bf0a06
reformat file
RobBuchananCompPhys Jul 29, 2025
2840d23
initialise potential map from DissolveNode
RobBuchananCompPhys Jul 30, 2025
1ba52c7
static graph pair potentials
RobBuchananCompPhys Jul 30, 2025
90d343a
fix signature
RobBuchananCompPhys Jul 30, 2025
6eec3a4
clang format
RobBuchananCompPhys Jul 30, 2025
b66543d
add atom type in atomic species node
RobBuchananCompPhys Jul 31, 2025
e24e09e
fix dissolve header
RobBuchananCompPhys Aug 5, 2025
3a56100
fix description
RobBuchananCompPhys Aug 5, 2025
55ffc60
fix description 2
RobBuchananCompPhys Aug 5, 2025
c7ed373
fix description 3
RobBuchananCompPhys Aug 5, 2025
3e51c4c
move atomTypes method to local configuration
RobBuchananCompPhys Aug 5, 2025
2469cf4
changes
RobBuchananCompPhys Aug 5, 2025
5abac8c
feat:Display enum parameters (#2210)
rprospero Aug 4, 2025
d8d9c0c
refactor
RobBuchananCompPhys Aug 20, 2025
e4363b2
refactor 2
RobBuchananCompPhys Aug 20, 2025
d4ad352
remove unused code
RobBuchananCompPhys Aug 28, 2025
8e20d12
non static member
RobBuchananCompPhys Aug 28, 2025
0fc33ec
atom types from atomTypeIndexMap
RobBuchananCompPhys Aug 28, 2025
de77ef9
atom types from atomTypeIndexMap 2
RobBuchananCompPhys Aug 28, 2025
ffb5be7
use internal dissolve node pair potentials
RobBuchananCompPhys Aug 28, 2025
7e4985a
non const pair potentials
RobBuchananCompPhys Aug 29, 2025
eb45612
making a start on dissolve node pair potentials
RobBuchananCompPhys Aug 29, 2025
e95097d
find dissolve node to generate kernel
RobBuchananCompPhys Aug 29, 2025
c60a079
initialise potential map from atom type pairs
RobBuchananCompPhys Sep 3, 2025
1c45600
dissolve node getter
RobBuchananCompPhys Sep 3, 2025
3bfa19e
remove unused parameter
RobBuchananCompPhys Sep 3, 2025
9641cf6
potential map constructor
RobBuchananCompPhys Sep 4, 2025
8df92cf
refactor potential map xtor
RobBuchananCompPhys Sep 4, 2025
65d34fb
move update cells call into prepareEnergyCalculation
RobBuchananCompPhys Sep 4, 2025
124309d
get atom type vector
RobBuchananCompPhys Sep 4, 2025
5b47b39
private
RobBuchananCompPhys Sep 4, 2025
4337662
if else pair potential storage
RobBuchananCompPhys Sep 4, 2025
da4ceb0
dissolve graph getter; store pairPotential
RobBuchananCompPhys Sep 4, 2025
5ebaec2
set pair potential - default deteled assignment operator
RobBuchananCompPhys Sep 4, 2025
97b5b1f
shared pair potential ptr
RobBuchananCompPhys Sep 4, 2025
8111cc9
update pair potentials
RobBuchananCompPhys Sep 4, 2025
62ad067
dissolveGraph getter part 2
RobBuchananCompPhys Sep 4, 2025
4b95b22
restrict md to atomic species
RobBuchananCompPhys Sep 4, 2025
1405a5f
debugging - potential matrix is zero matrix
RobBuchananCompPhys Sep 5, 2025
8f6d7b5
copy potentialMap as value
RobBuchananCompPhys Sep 9, 2025
7b8c00e
pair potential delta
RobBuchananCompPhys Sep 11, 2025
37ddbd9
tabulate pair potential
RobBuchananCompPhys Sep 11, 2025
92636d8
not a pointer
RobBuchananCompPhys Sep 12, 2025
a57ffd7
use message member func
RobBuchananCompPhys Sep 12, 2025
e5e2d5d
incremental progress
RobBuchananCompPhys Sep 12, 2025
4c329b6
initialise unweightedGR
RobBuchananCompPhys Sep 12, 2025
a41a9ad
check if initialise method can be called conditionally
RobBuchananCompPhys Sep 16, 2025
ae755fd
tougher checks on optional emplacement
RobBuchananCompPhys Sep 16, 2025
df8f267
default file path for reference FQ
RobBuchananCompPhys Sep 16, 2025
90a98b2
refactor partial set average initialiser
RobBuchananCompPhys Sep 16, 2025
a608c44
temporarily append full dissolve path to referenceFQ filename
RobBuchananCompPhys Sep 16, 2025
9206dba
add Ar36 isotope
RobBuchananCompPhys Sep 17, 2025
3d20d08
Small fixes.
trisyoungs Sep 17, 2025
7bef8b1
echo on
RobBuchananCompPhys Sep 18, 2025
13b0b3b
dave partial set to file
RobBuchananCompPhys Sep 18, 2025
778ed50
average sq
RobBuchananCompPhys Sep 18, 2025
8786cc9
update outfile path
RobBuchananCompPhys Sep 18, 2025
325653a
ignore nodes output
RobBuchananCompPhys Sep 18, 2025
c3f4625
fix wrong function call
RobBuchananCompPhys Sep 19, 2025
2a26bda
run clang format on src/nodes
RobBuchananCompPhys Sep 23, 2025
ff3089f
no need for cast
RobBuchananCompPhys Sep 23, 2025
c297394
add forward declarations comment
RobBuchananCompPhys Sep 23, 2025
18f78c1
dont save sq by default
RobBuchananCompPhys Sep 23, 2025
e75cdf3
error report filename
RobBuchananCompPhys Sep 23, 2025
da28ce3
revert to one line return for energy
RobBuchananCompPhys Sep 23, 2025
b18b09f
no optional for function arg
RobBuchananCompPhys Sep 23, 2025
db2839b
update log string
RobBuchananCompPhys Sep 23, 2025
ca097cf
private helper functions - sq
RobBuchananCompPhys Sep 24, 2025
a9f2428
no optional check
RobBuchananCompPhys Sep 24, 2025
aa7ab3f
no ignore
RobBuchananCompPhys Sep 24, 2025
1c620f6
more clang format
RobBuchananCompPhys Sep 25, 2025
6057cff
no need for lambda
RobBuchananCompPhys Sep 25, 2025
cf21abf
back to normal data1d import
RobBuchananCompPhys Sep 25, 2025
8fd9abb
remove unused filename
RobBuchananCompPhys Sep 26, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/_build_and_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ jobs:
publishBenchmarks: ${{ inputs.publishBenchmarks }}
msvcVersion: ${{ inputs.msvcVersion }}
osxTargetDeploymentVersion: ${{ inputs.osxTargetDeploymentVersion }}

2 changes: 1 addition & 1 deletion develop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ catch
{
# Move freetype if error on rename
$fromFreetype = "freetype-$freetypeVersion"
$moveFreetype = (JoinPath -Path $dependencies -ChildPath $freetypeRepo)
$moveFreetype = (Join-Path -Path $dependencies -ChildPath $freetypeRepo)
if (-not (TestPath $moveFreetype))
{
New-Item -Path $moveFreetype -ItemType Directory | Out-Null
Expand Down
42 changes: 41 additions & 1 deletion src/classes/partialSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "items/serialisers.h"
#include "math/mathFunc.h"
#include "templates/algorithms.h"
#include <filesystem>

// Initialise
void PartialSet::initialise(const KeyedVector<const Species *, int> &speciesPopulations, bool half)
Expand Down Expand Up @@ -47,6 +48,41 @@ void PartialSet::initialise(const KeyedVector<const Species *, int> &speciesPopu
unboundTotal_.clear();
}

// Initialise from supplied real species populations
void PartialSet::initialise(const KeyedVector<const Species *, double> &realSpeciesPopulations, bool half)
{
// Take integer species populations and convert to real
realSpeciesPopulations_.clear();
for (const auto &[species, population] : realSpeciesPopulations)
realSpeciesPopulations_[species] = double(population);

half_ = half;

partials_.clear(half_);
boundPartials_.clear(half_);
unboundPartials_.clear(half_);

// Create data for partials and set tags
dissolve::for_each_pair(
ParallelPolicies::seq, atomTypeFractions(),
[&](int indexI, const auto &popI, int indexJ, const auto &popJ)
{
DoubleKeyedMapKey key(popI.first->name(), popJ.first->name());
partials_.get(key).setTag(std::format("{}-{}//Full", popI.first->name(), popJ.first->name()));
boundPartials_.get(key).setTag(std::format("{}-{}//Bound", popI.first->name(), popJ.first->name()));
unboundPartials_.get(key).setTag(std::format("{}-{}//Unbound", popI.first->name(), popJ.first->name()));
},
half_);

// Set up arrays for totals
total_.setTag("Total");
boundTotal_.setTag("BoundTotal");
unboundTotal_.setTag("UnboundTotal");
total_.clear();
boundTotal_.clear();
unboundTotal_.clear();
}

// Initialise based on supplied PartialSet
void PartialSet::initialise(const PartialSet &partialSet)
{
Expand Down Expand Up @@ -248,7 +284,11 @@ bool PartialSet::save(std::string_view prefix, std::string_view tag, std::string
std::string filename{std::format("{}-{}-{}-{}.{}", prefix, tag, popI.first->name(), popJ.first->name(), suffix)};
Messenger::printVerbose("Writing partial file '{}'...\n", filename);

parser.openOutput(filename, true);
auto cwd = std::filesystem::current_path();
auto path = cwd.parent_path().parent_path() / "tests" / "nodes" / "output" / filename;
auto fullPath = path.string();

parser.openOutput(fullPath, true);
if (!parser.isFileGoodForWriting())
return Messenger::error("Couldn't open file '{}' for writing.\n", filename);

Expand Down
2 changes: 2 additions & 0 deletions src/classes/partialSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PartialSet
public:
// Initialise from supplied species populations
void initialise(const KeyedVector<const Species *, int> &speciesPopulations, bool half = true);
// Initialise from supplied real species populations
void initialise(const KeyedVector<const Species *, double> &realSpeciesPopulations, bool half = true);
// Initialise based on supplied PartialSet, templating all data
void initialise(const PartialSet &partialSet);
// Reset partial arrays
Expand Down
76 changes: 76 additions & 0 deletions src/classes/potentialMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@
#include "classes/pairPotential.h"
#include "classes/species.h"

PotentialMap::PotentialMap(const std::vector<const AtomType *> &atomTypes,
const DoubleKeyedMap<std::shared_ptr<PairPotential>> &pairPotentials, double pairPotentialRange)
{
// Create PairPotential matrix
nTypes_ = atomTypes.size();
potentialMatrix_.initialise(nTypes_, nTypes_);

dissolve::for_each_pair(
ParallelPolicies::seq, atomTypes,
[&](int i, const auto &atI, int j, const auto &atJ)
{
auto pp = pairPotentials.get({atI->name(), atJ->name()}).get();

// Store PairPotential pointer
if (i == j)
{
Messenger::print("Linking self-interaction PairPotential for '{}' (index {},{} in matrix).\n", atI->name(), i,
j);
potentialMatrix_[{i, j}] = pp;
}
else
{
Messenger::print("Linking PairPotential between '{}' and '{}' (indices {},{} and {},{} in matrix).\n",
atI->name(), atJ->name(), i, j, j, i);
potentialMatrix_[{i, j}] = pp;
potentialMatrix_[{j, i}] = pp;
}
});

// Store potential range
range_ = pairPotentialRange;
}

// Clear all data
void PotentialMap::clear() { potentialMatrix_.clear(); }

Expand Down Expand Up @@ -60,6 +93,49 @@ bool PotentialMap::initialise(const std::vector<std::shared_ptr<AtomType>> &mast
return true;
}

bool PotentialMap::initialise(const std::vector<const AtomType *> &masterAtomTypes,
const std::vector<PairPotential::Definition> &pairPotentials, double pairPotentialRange)
{
// Clear old data first
clear();

// Create PairPotential matrix
nTypes_ = masterAtomTypes.size();
potentialMatrix_.initialise(nTypes_, nTypes_);

// Loop over defined PairPotentials
int indexI, indexJ;
for (auto &&[at1, at2, pp] : pairPotentials)
{
indexI = at1->index();
indexJ = at2->index();
if (indexI == -1)
return Messenger::error("Couldn't find AtomType '{}' in typeIndex.\n", at1->name());
if (indexJ == -1)
return Messenger::error("Couldn't find AtomType '{}' in typeIndex.\n", at1->name());

// Store PairPotential pointer
if (indexI == indexJ)
{
Messenger::print("Linking self-interaction PairPotential for '{}' (index {},{} in matrix).\n", at1->name(), indexI,
indexJ);
potentialMatrix_[{indexI, indexI}] = pp.get();
}
else
{
Messenger::print("Linking PairPotential between '{}' and '{}' (indices {},{} and {},{} in matrix).\n", at1->name(),
at2->name(), indexI, indexJ, indexJ, indexI);
potentialMatrix_[{indexI, indexJ}] = pp.get();
potentialMatrix_[{indexJ, indexI}] = pp.get();
}
}

// Store potential range
range_ = pairPotentialRange;

return true;
}

// Return PairPotential range
double PotentialMap::range() const { return range_; }

Expand Down
5 changes: 5 additions & 0 deletions src/classes/potentialMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "classes/pairPotential.h"
#include "templates/array2D.h"
#include "templates/doubleKeyedMap.h"

// Forward Declarations
class Atom;
Expand All @@ -16,6 +17,8 @@ class PotentialMap
{
public:
PotentialMap() = default;
PotentialMap(const std::vector<const AtomType *> &atomTypes,
const DoubleKeyedMap<std::shared_ptr<PairPotential>> &pairPotentials, double pairPotentialRange);
~PotentialMap() = default;
// Clear all data
void clear();
Expand All @@ -35,6 +38,8 @@ class PotentialMap
// Initialise map
bool initialise(const std::vector<std::shared_ptr<AtomType>> &masterAtomTypes,
const std::vector<PairPotential::Definition> &pairPotentials, double pairPotentialRange);
bool initialise(const std::vector<const AtomType *> &atomTypes,
const std::vector<PairPotential::Definition> &pairPotentials, double pairPotentialRange);
// Return PairPotential range
double range() const;

Expand Down
4 changes: 4 additions & 0 deletions src/classes/species.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Species : public Serialisable<const CoreData &>
std::vector<SpeciesAtom> atoms_;
// Version of the atom selection
VersionCounter atomSelectionVersion_;
// Atom types for the species
std::vector<std::shared_ptr<AtomType>> atomTypes_;

private:
// Recursively add atoms along any path from the specified one, ignoring the bond(s) provided
Expand All @@ -68,6 +70,8 @@ class Species : public Serialisable<const CoreData &>
public:
// Add a new atom to the Species, returning its index
int addAtom(Elements::Element Z, Vector3 r, double q = 0.0, std::shared_ptr<AtomType> atomType = nullptr);
// Add new atom type to atom types
const std::shared_ptr<AtomType> addAtomType(Elements::Element Z);
// Remove the specified atom from the species
void removeAtom(int index);
// Remove set of atom indices
Expand Down
17 changes: 17 additions & 0 deletions src/classes/species_atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ int Species::addAtom(Elements::Element Z, Vector3 r, double q, std::shared_ptr<A
return i.index();
}

// Add new atom type to atom types
const std::shared_ptr<AtomType> Species::addAtomType(Elements::Element Z)
{
auto newAtomType = std::make_shared<AtomType>();
atomTypes_.push_back(newAtomType);

// Create a suitable unique name
newAtomType->setName(DissolveSys::uniqueName(Elements::symbol(Z), atomTypes_,
[&](const auto &at) { return newAtomType == at ? "" : at->name(); }));

// Set data
newAtomType->setZ(Z);
newAtomType->setIndex(atomTypes_.size() - 1);

return newAtomType;
}

// Remove the specified atom from the species
void Species::removeAtom(int index)
{
Expand Down
1 change: 1 addition & 0 deletions src/io/import/data1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "keywords/optionalDouble.h"
#include "math/data1D.h"
#include "math/filters.h"
#include <filesystem>

Data1DImportFileFormat::Data1DImportFileFormat(std::string_view filename, Data1DImportFileFormat::Data1DImportFormat format,
int xColumn, int yColumn, int errorColumn)
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "classes/potentialMap.h"
#include "math/vector3.h"
#include "templates/optionalRef.h"
#include <memory>
Expand All @@ -13,7 +14,6 @@ class Box;
class CellArray;
class Configuration;
class Molecule;
class PotentialMap;

// Kernel Base
class KernelBase
Expand All @@ -28,7 +28,7 @@ class KernelBase

protected:
// Potential map to use
const PotentialMap &potentialMap_;
const PotentialMap potentialMap_;
// Squared cutoff distance to use in calculation
double cutoffDistanceSquared_;
// Periodic Box
Expand Down
3 changes: 3 additions & 0 deletions src/kernels/energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,6 @@ EnergyResult EnergyKernel::totalEnergy(const Molecule &mol, Flags<EnergyCalculat
flags.isSet(ExcludeGeometry) ? 0.0 : totalGeometryEnergy(mol),
flags.isSet(ExcludeExtended) ? 0.0 : extendedEnergy(mol)};
}

// Return potential map
const PotentialMap &EnergyKernel::potentialMap() const { return potentialMap_; }
2 changes: 2 additions & 0 deletions src/kernels/energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,6 @@ class EnergyKernel : public GeometryKernel
EnergyResult totalEnergy(const Atom &i) const;
// Return total energy of supplied molecule with the world
EnergyResult totalEnergy(const Molecule &mol, Flags<EnergyCalculationFlags> flags = {}) const;
// Return potential map
const PotentialMap &potentialMap() const;
};
2 changes: 2 additions & 0 deletions src/main/dissolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ class Dissolve : public Serialisable<>
PairPotential *addPairPotential(const std::shared_ptr<AtomType> &at1, const std::shared_ptr<AtomType> &at2);
// Return PairPotentials list
const std::vector<PairPotential::Definition> &pairPotentials() const;
std::vector<PairPotential::Definition> &pairPotentials();
// Return nth PairPotential in list
PairPotential *pairPotential(int n);
// Return specified PairPotential (if defined)
PairPotential *pairPotential(const AtomType *at1, const AtomType *at2) const;
PairPotential *pairPotential(std::string_view at1Name, std::string_view at2Name) const;
// Return map for PairPotentials
const PotentialMap &potentialMap() const;
PotentialMap &potentialMap();
// Update all pair potentials
bool updatePairPotentials(std::optional<bool> useCombinationRulesHint = {});
// Clear additional potentials
Expand Down
3 changes: 3 additions & 0 deletions src/main/pairPotentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ PairPotential *Dissolve::addPairPotential(const std::shared_ptr<AtomType> &at1,
// Return first PairPotential in list
const std::vector<PairPotential::Definition> &Dissolve::pairPotentials() const { return pairPotentials_; }

std::vector<PairPotential::Definition> &Dissolve::pairPotentials() { return pairPotentials_; }

// Return nth PairPotential in list
PairPotential *Dissolve::pairPotential(int n) { return std::get<2>(pairPotentials_[n]).get(); }

Expand Down Expand Up @@ -95,6 +97,7 @@ PairPotential *Dissolve::pairPotential(std::string_view at1Name, std::string_vie

// Return map for PairPotentials
const PotentialMap &Dissolve::potentialMap() const { return potentialMap_; }
PotentialMap &Dissolve::potentialMap() { return potentialMap_; }

// Update all pair potentials
bool Dissolve::updatePairPotentials(std::optional<bool> useCombinationRulesHint)
Expand Down
7 changes: 5 additions & 2 deletions src/math/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#pragma once

#include "base/serialiser.h"
#include <functional>
#include <memory>
#include <optional>
#include <vector>

// Data History
Expand All @@ -16,7 +18,7 @@ template <class T> class History

public:
// Update history with supplied data and return current average
T average(const T &currentData, int averagingLength)
T average(const T &currentData, int averagingLength, std::function<T()> initialiser = {})
{
// Push the current data onto the history stack
history_.emplace_back(std::make_unique<T>(currentData));
Expand All @@ -26,7 +28,8 @@ template <class T> class History
history_.erase(history_.begin());

// Perform averaging of the datasets that we have
T averaged;
T averaged = initialiser ? initialiser() : T();

auto weight = 1.0 / history_.size();
for (auto &data : history_)
averaged += *data * weight;
Expand Down
1 change: 1 addition & 0 deletions src/nodes/atomicMC/atomicMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AtomicMCNode::AtomicMCNode(Graph *parentGraph) : Node(parentGraph)
addOption<Number>("TargetAcceptanceRate", "Target acceptance rate for Monte Carlo moves", targetAcceptanceRate_);
addOption<Number>("StepSizeMax", "Maximum allowed value for step size, in Angstroms", stepSizeMax_);
addOption<Number>("StepSizeMin", "Minimum allowed value for step size, in Angstroms", stepSizeMin_);
addOutput<Configuration *>("Configuration", "Output configuration", targetConfiguration_);
}

std::string_view AtomicMCNode::type() const { return "AtomicMC"; }
Expand Down
5 changes: 3 additions & 2 deletions src/nodes/atomicMC/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "main/dissolve.h"
#include "math/mathFunc.h"
#include "nodes/atomicMC/atomicMC.h"
#include "nodes/dissolve.h"

// Run main processing
NodeConstants::ProcessResult AtomicMCNode::process()
Expand All @@ -30,8 +31,8 @@ NodeConstants::ProcessResult AtomicMCNode::process()
message("Target acceptance rate is {}.\n", targetAcceptanceRate);
message("\n");

auto kernel =
KernelProducer::energyKernel(targetConfiguration_, dissolve().potentialMap(), dissolve().pairPotentialRange());
// Prepare for energy calculation, generate kernel
auto kernel = dissolveGraph()->prepareEnergyCalculation(targetConfiguration_);

auto nAttempts = 0, nAccepted = 0;
bool accept;
Expand Down
Loading
Loading