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
6 changes: 6 additions & 0 deletions src/raspakit/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,7 @@ Archive<std::ofstream> &operator<<(Archive<std::ofstream> &archive, const Compon
archive << c.partialReinsertionFixedAtoms;
archive << c.identityChanges;
archive << c.gibbsIdentityChanges;
archive << c.identitySwitches;

archive << c.initialNumberOfMolecules;

Expand Down Expand Up @@ -2239,6 +2240,11 @@ Archive<std::ifstream> &operator>>(Archive<std::ifstream> &archive, Component &c
archive >> c.partialReinsertionFixedAtoms;
archive >> c.identityChanges;
archive >> c.gibbsIdentityChanges;
// 'identitySwitches' was added in version 2; older restart files do not contain it.
if (versionNumber >= 2)
{
archive >> c.identitySwitches;
}

archive >> c.initialNumberOfMolecules;

Expand Down
3 changes: 2 additions & 1 deletion src/raspakit/component.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export struct Component
std::optional<double> fugacityCoefficient = std::nullopt,
bool thermodynamicIntegration = false, std::vector<double4> blockingPockets = {}) noexcept(false);

std::uint64_t versionNumber{1}; ///< Version number for serialization.
std::uint64_t versionNumber{2}; ///< Version number for serialization.

Type type{0}; ///< Type of the component (Adsorbate or Cation).

Expand Down Expand Up @@ -236,6 +236,7 @@ export struct Component
mutable std::map<std::vector<std::size_t>, std::vector<CBMC::GrowStep>> growthPlanCache{};
std::vector<std::size_t> identityChanges{};
std::vector<std::size_t> gibbsIdentityChanges{};
std::vector<std::size_t> identitySwitches{}; ///< Partner components for the canonical identity-switch move.

std::size_t initialNumberOfMolecules{0}; ///< Initial number of molecules in the component.

Expand Down
26 changes: 26 additions & 0 deletions src/raspakit/input_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,15 @@ void InputReader::parseMolecularSimulations(const nlohmann::basic_json<nlohmann:
}
}

if (item.contains("IdentitySwitchProbability") && item["IdentitySwitchProbability"].is_number_float())
{
double identity_switch_CBMC_probability = item["IdentitySwitchProbability"].get<double>();
for (std::size_t i = 0; i < move_probabilities.size(); ++i)
{
move_probabilities[i].setProbability(Move::Types::IdentitySwitchCBMC, identity_switch_CBMC_probability);
}
}

if (item.contains("SwapConventionalProbability") && item["SwapConventionalProbability"].is_number_float())
{
double swapProbability = item["SwapConventionalProbability"].get<double>();
Expand Down Expand Up @@ -1200,6 +1209,21 @@ void InputReader::parseMolecularSimulations(const nlohmann::basic_json<nlohmann:
}
}

if (item.contains("IdentitySwitches") && item["IdentitySwitches"].is_array())
{
std::vector<std::size_t> identity_switches = item["IdentitySwitches"].get<std::vector<std::size_t>>();
if (std::ranges::contains(identity_switches, componentId))
{
throw std::runtime_error(
std::format("[Input reader]: component '{}' (id {}) cannot list itself in 'IdentitySwitches'\n",
jsonComponentName, componentId));
}
for (std::size_t i = 0; i != jsonNumberOfSystems; ++i)
{
jsonComponents[i][componentId].identitySwitches = identity_switches;
}
}

if (item.contains("GibbsIdentityChanges") && item["GibbsIdentityChanges"].is_array())
{
std::vector<std::size_t> gibbs_identity_changes = item["GibbsIdentityChanges"].get<std::vector<std::size_t>>();
Expand Down Expand Up @@ -3376,6 +3400,7 @@ const std::set<std::string, InputReader::InsensitiveCompare> InputReader::compon
"ReinsertionProbability",
"PartialReinsertionProbability",
"IdentityChangeProbability",
"IdentitySwitchProbability",
"SwapConventionalProbability",
"SwapProbability",
"PairSwapConventionalProbability",
Expand Down Expand Up @@ -3409,6 +3434,7 @@ const std::set<std::string, InputReader::InsensitiveCompare> InputReader::compon
"IdealGasRosenbluthWeight",
"MolFraction",
"IdentityChanges",
"IdentitySwitches",
"GibbsIdentityChanges",
"ThermodynamicIntegration",
"LambdaBinIndex",
Expand Down
Loading
Loading