Skip to content
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

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2343dde
module added to GUI
jounaidr Nov 13, 2023
52a7a3e
export CONTROL file classes implemented
jounaidr Nov 15, 2023
f8ac94b
export CONTROL file classes implemented
jounaidr Nov 15, 2023
f14bdbc
add all props to control file exporter
jounaidr Nov 15, 2023
f92d0ae
CONTROL file formatting implemented
jounaidr Nov 16, 2023
3c9b386
timestepType removed and boolean timestepVariable implemented
jounaidr Nov 17, 2023
644ac20
add coul methods, precision and trajectory keyÂ
jounaidr Nov 24, 2023
a113e57
Merge branch 'disorderedmaterials:develop' into dl_poly_dev
jounaidr Nov 24, 2023
3d8a5de
all CONTROL file options implemented
jounaidr Nov 28, 2023
fe5919c
Merge branch 'dl_poly_dev' of https://github.com/jounaidr/dissolve in…
jounaidr Nov 28, 2023
d5a29ea
field file export implemented, params not working...
jounaidr Dec 6, 2023
08dd7cc
Merge branch 'disorderedmaterials:develop' into dl_poly_dev
jounaidr Dec 14, 2023
dff8c4e
field file fully implemented
jounaidr Dec 14, 2023
3288e7d
cleanup imports
jounaidr Dec 14, 2023
895c36c
vdw_mix_method and ensemble_method implemented in CONTROL file
jounaidr Dec 19, 2023
c2b5f31
minimisation options implemented
jounaidr Dec 20, 2023
93e9270
conditional esmemble_method/emsemble_thermostat_coupling
jounaidr Dec 20, 2023
297754c
add config file to dlpoly module
jounaidr Dec 20, 2023
585420b
add ./DLPOLY.Z execution to dlpoly module
jounaidr Dec 20, 2023
4d8de14
cleanup CONTROL option tool tips, attempt at hardcoding filenames (no…
jounaidr Jan 2, 2024
96117c1
comments
jounaidr Jan 5, 2024
20ca332
hardcode filenames and formats, fix parsing error
jounaidr Jan 5, 2024
d23e700
add filepath for DLPOLY execution to options (section needs to be fixed)
jounaidr Jan 9, 2024
c827715
initial test file added
jounaidr Jan 9, 2024
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
38 changes: 19 additions & 19 deletions CMakeLists.txt
Copy link
Member

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?

Original file line number Diff line number Diff line change
Expand Up @@ -272,26 +272,26 @@ else()
endif()

# Enable build of test suite?
option(BUILD_TESTS "Build test suite" OFF)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(examples)
add_subdirectory(tests)
endif(BUILD_TESTS)

if(BUILD_BENCHMARKS)
#option(BUILD_TESTS "Build test suite" OFF)
#if(BUILD_TESTS)
# enable_testing()
# add_subdirectory(examples)
# add_subdirectory(tests)
#endif(BUILD_TESTS)

#if(BUILD_BENCHMARKS)
# The conan package of goooglebenchmark segfaults - so lets use fetch content
include(FetchContent)
set(BENCHMARK_ENABLE_TESTING "OFF")
fetchcontent_declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.4
)

fetchcontent_makeavailable(googlebenchmark)
add_subdirectory(benchmark)
endif(BUILD_BENCHMARKS)
# include(FetchContent)
# set(BENCHMARK_ENABLE_TESTING "OFF")
# fetchcontent_declare(
# googlebenchmark
# GIT_REPOSITORY https://github.com/google/benchmark.git
# GIT_TAG v1.5.4
# )
#
# fetchcontent_makeavailable(googlebenchmark)
# add_subdirectory(benchmark)
#endif(BUILD_BENCHMARKS)

# Build CLI target executable
target_link_libraries(
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Copy link
Member

Choose a reason for hiding this comment

The 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.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
version = "1.4.0";
base_libs = pkgs:
with pkgs; [
gfortran
antlr4
antlr4.runtime.cpp
antlr4.runtime.cpp.dev
Expand Down Expand Up @@ -178,6 +179,7 @@
export __EGL_VENDOR_LIBRARY_FILENAMES=${pkgs.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.mesa.drivers]}:${pkgs.lib.makeSearchPathOutput "lib" "lib/vdpau" [pkgs.libvdpau]}:${pkgs.lib.makeLibraryPath [pkgs.libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export QT_PLUGIN_PATH="${qt-idaaas.packages.${system}.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
export FC=${pkgs.lib.makeSearchPathOutput "gfortran" "bin/gfortran" [pkgs.gfortran]}
'';


Expand Down Expand Up @@ -280,4 +282,4 @@
user-env = import ./nix/user-env.nix;
};
});
}
}
4 changes: 4 additions & 0 deletions src/io/export/CMakeLists.txt
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Up @@ -9,6 +9,8 @@ add_library(
species.cpp
trajectory.cpp
values.cpp
dlPolyControl.cpp
dlPolyField.cpp
coordinates.h
data1D.h
data2D.h
Expand All @@ -18,6 +20,8 @@ add_library(
species.h
trajectory.h
values.h
dlPolyControl.h
dlPolyField.h
)

target_include_directories(export PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
Expand Down
153 changes: 153 additions & 0 deletions src/io/export/dlPolyControl.cpp
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;
}
50 changes: 50 additions & 0 deletions src/io/export/dlPolyControl.h
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);

};


Loading
Loading