-
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
Dl poly dev #1726
base: develop
Are you sure you want to change the base?
Dl poly dev #1726
Changes from all commits
2343dde
52a7a3e
f8ac94b
f14bdbc
f92d0ae
3c9b386
644ac20
a113e57
3d8a5de
fe5919c
d5a29ea
08dd7cc
dff8c4e
3288e7d
895c36c
c2b5f31
93e9270
297754c
585420b
4d8de14
96117c1
20ca332
d23e700
c827715
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. I appreciate that you added this so you could compile DL_POLY within nix, but again this is outside of the Dissolve scope and shouldn't be included in this PR. |
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. Alphabetical file order within suffix sections. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// Copyright (c) 2023 Team Dissolve and contributors | ||
|
||
#include "io/export/dlPolyControl.h" | ||
#include "base/lineParser.h" | ||
#include "base/sysFunc.h" | ||
#include "classes/configuration.h" | ||
|
||
DlPolyControlExportFileFormat::DlPolyControlExportFileFormat(std::string_view filename, DlPolyControlExportFormat format) | ||
: FileAndFormat(formats_, filename, (int)format) | ||
{ | ||
formats_ = EnumOptions<DlPolyControlExportFileFormat::DlPolyControlExportFormat>( | ||
"ControlExportFileFormat", {{DlPolyControlExportFormat::DLPOLY, "dlpoly", "DL_POLY CONFIG File"}}); | ||
} | ||
|
||
|
||
// Export DlPolyControl as CONTROL file | ||
bool DlPolyControlExportFileFormat::exportDLPOLY(LineParser &parser, Configuration *cfg, bool capForces, double capForcesAt, std::optional<double> cutoffDistance, double padding, std::string ensemble, std::string ensembleMethod, double ensembleThermostatCoupling, bool timestepVariable, double fixedTimestep, std::optional<int> energyFrequency, int nSteps, std::optional<int> outputFrequency, bool randomVelocities, std::optional<int> trajectoryFrequency, std::string trajectoryKey, std::string coulMethod, double coulPrecision, std::string minimisationCriterion, double minimisationTolerance, double minimisationFrequency) | ||
{ | ||
if (!parser.writeLineF("title {} @ {}\n\n", cfg->name(), cfg->contentsVersion())) | ||
return false; | ||
if (!parser.writeLineF("io_file_config CONFIG\n")) | ||
return false; | ||
if (!parser.writeLineF("io_file_field FIELD\n")) | ||
return false; | ||
if (!parser.writeLineF("io_file_statis STATIS\n")) | ||
return false; | ||
if (!parser.writeLineF("io_file_revive REVIVE\n")) | ||
return false; | ||
if (!parser.writeLineF("io_file_revcon REVCON\n")) | ||
return false; | ||
if (!parser.writeLineF("temperature {} K\n", cfg->temperature())) | ||
return false; | ||
if (!parser.writeLineF("print_frequency {} steps\n", energyFrequency.value())) | ||
return false; | ||
if (!parser.writeLineF("stats_frequency {} steps\n", outputFrequency.value())) | ||
return false; | ||
if (!parser.writeLineF("cutoff {} nm\n", cutoffDistance.value())) | ||
return false; | ||
if (!parser.writeLineF("padding {} ang\n", padding)) | ||
return false; | ||
if (!parser.writeLineF("ensemble {}\n", ensemble)) | ||
return false; | ||
// Export ensemble_method and ensemble_thermostat_coupling for ensemble types other than NVE | ||
if (ensemble != "NVE"){ | ||
if (!parser.writeLineF("ensemble_method {}\n", ensembleMethod)) | ||
return false; | ||
if (!parser.writeLineF("ensemble_thermostat_coupling {} ps\n", ensembleThermostatCoupling)) | ||
return false; | ||
} | ||
// Export equilibration_force_cap if capForces is true | ||
if (capForces && !parser.writeLineF("equilibration_force_cap {} k_b.temp/ang\n", capForcesAt)) | ||
return false; | ||
if (!parser.writeLineF("time_run {} steps\n", nSteps)) | ||
return false; | ||
// Export timestep_variable as ON if timestepVariable is true | ||
if (timestepVariable && !parser.writeLineF("timestep_variable ON\n")) | ||
return false; | ||
if (!parser.writeLineF("timestep {} internal_t\n", fixedTimestep)) | ||
return false; | ||
// Export traj_calculate, traj_interval, traj_key if trajectoryFrequency is greater than 0 | ||
if (trajectoryFrequency.value_or(0) > 0) | ||
{ | ||
if (!parser.writeLineF("traj_calculate ON\n")) | ||
return false; | ||
if (!parser.writeLineF("traj_interval {}\n", trajectoryFrequency.value())) | ||
return false; | ||
if (!parser.writeLineF("traj_key {}\n", trajectoryKey)) | ||
return false; | ||
} | ||
if (!parser.writeLineF("coul_method {}\n", coulMethod)) | ||
return false; | ||
if (!parser.writeLineF("coul_precision {}\n", coulPrecision)) | ||
return false; | ||
|
||
// Note interaction is taken from the first atom only, not sure how to do this ... | ||
const auto sri = cfg->speciesPopulations()[0].first->atoms()[0].atomType()->interactionPotential().form(); | ||
std::string vdw_mix_method; | ||
|
||
// Export vdw_mix_method based on short range function type | ||
switch (sri) | ||
{ | ||
case (ShortRangeFunctions::Form::None): | ||
vdw_mix_method = "Off"; | ||
break; | ||
case (ShortRangeFunctions::Form::LennardJones): | ||
vdw_mix_method = "Lorentz-Berthelot"; | ||
break; | ||
case (ShortRangeFunctions::Form::LennardJonesGeometric): | ||
vdw_mix_method = "Hogervorst"; | ||
break; | ||
default: | ||
throw(std::runtime_error(fmt::format("Short-range type {} is not accounted for in PairPotential::setUp().\n", | ||
ShortRangeFunctions::forms().keyword(sri)))); | ||
} | ||
if (!parser.writeLineF("vdw_mix_method {}\n", vdw_mix_method)) | ||
return false; | ||
if (!parser.writeLineF("minimisation_criterion {}\n", minimisationCriterion)) | ||
return false; | ||
if (!parser.writeLineF("minimisation_tolerance {}\n", minimisationTolerance)) | ||
return false; | ||
if (!parser.writeLineF("minimisation_frequency {} steps\n", minimisationFrequency)) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
// Export DlPolyControl using current filename and format | ||
bool DlPolyControlExportFileFormat::exportData(Configuration *cfg, bool capForces, double capForcesAt, std::optional<double> cutoffDistance, double padding, std::string ensemble, std::string ensembleMethod, double ensembleThermostatCoupling, bool timestepVariable, double fixedTimestep, std::optional<int> energyFrequency, int nSteps, std::optional<int> outputFrequency, bool randomVelocities, std::optional<int> trajectoryFrequency, std::string trajectoryKey, std::string coulMethod, double coulPrecision, std::string minimisationCriterion, double minimisationTolerance, double minimisationFrequency) | ||
{ | ||
// Open the file | ||
LineParser parser; | ||
if (!parser.openOutput(filename_)) | ||
{ | ||
parser.closeFiles(); | ||
return false; | ||
} | ||
|
||
// Write data | ||
auto result = false; | ||
switch (formats_.enumerationByIndex(*formatIndex_)) | ||
{ | ||
case (DlPolyControlExportFormat::DLPOLY): | ||
result = exportDLPOLY(parser, | ||
cfg, | ||
capForces, | ||
capForcesAt, | ||
cutoffDistance, | ||
padding, | ||
ensemble, | ||
ensembleMethod, | ||
ensembleThermostatCoupling, | ||
timestepVariable, | ||
fixedTimestep, | ||
energyFrequency, | ||
nSteps, | ||
outputFrequency, | ||
randomVelocities, | ||
trajectoryFrequency, | ||
trajectoryKey, | ||
coulMethod, | ||
coulPrecision, | ||
minimisationCriterion, | ||
minimisationTolerance, | ||
minimisationFrequency); | ||
break; | ||
default: | ||
throw(std::runtime_error(fmt::format("DlPolyControl format '{}' export has not been implemented.\n", | ||
formats_.keywordByIndex(*formatIndex_)))); | ||
} | ||
|
||
return true; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// Copyright (c) 2023 Team Dissolve and contributors | ||
|
||
#pragma once | ||
|
||
#include "io/fileAndFormat.h" | ||
|
||
// Forward Declarations | ||
class Configuration; | ||
|
||
// Coordinate Export Formats | ||
class DlPolyControlExportFileFormat : public FileAndFormat | ||
{ | ||
public: | ||
// Available DlPolyControl formats | ||
enum class DlPolyControlExportFormat | ||
{ | ||
DLPOLY | ||
}; | ||
DlPolyControlExportFileFormat(std::string_view filename = "", DlPolyControlExportFormat format = DlPolyControlExportFormat::DLPOLY); | ||
~DlPolyControlExportFileFormat() override = default; | ||
|
||
/* | ||
* Formats | ||
*/ | ||
private: | ||
// Format enum options | ||
EnumOptions<DlPolyControlExportFileFormat::DlPolyControlExportFormat> formats_; | ||
|
||
/* | ||
* Filename / Basename | ||
*/ | ||
public: | ||
// Return whether the file must exist | ||
bool fileMustExist() const override { return false; } | ||
|
||
/* | ||
* Export Functions | ||
*/ | ||
private: | ||
// Export Configuration as DL_POLY CONTROL | ||
bool exportDLPOLY(LineParser &parser, Configuration *cfg, bool capForces, double capForcesAt, std::optional<double> cutoffDistance, double padding, std::string ensemble, std::string ensembleMethod, double ensembleThermostatCoupling, bool timestepVariable, double fixedTimestep, std::optional<int> energyFrequency, int nSteps, std::optional<int> outputFrequency, bool randomVelocities, std::optional<int> trajectoryFrequency, std::string trajectoryKey, std::string coulMethod, double coulPrecision, std::string minimisationCriterion, double minimisationTolerance, double minimisationFrequency); | ||
|
||
public: | ||
// Export Configuration using current filename and format | ||
bool exportData(Configuration *cfg, bool capForces, double capForcesAt, std::optional<double> cutoffDistance, double padding, std::string ensemble, std::string ensembleMethod, double ensembleThermostatCoupling, bool timestepVariable, double fixedTimestep, std::optional<int> energyFrequency, int nSteps, std::optional<int> outputFrequency, bool randomVelocities, std::optional<int> trajectoryFrequency, std::string trajectoryKey, std::string coulMethod, double coulPrecision, std::string minimisationCriterion, double minimisationTolerance, double minimisationFrequency); | ||
|
||
}; | ||
|
||
|
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.
If you need to hack the
CMakeLists.txt
to build on your local machine then make sure not to commit those changes since this will break the CI in various places. I'm not sure exactly why you had to comment these bits out since they are disabled by default, however?