Skip to content

Commit

Permalink
more mtd
Browse files Browse the repository at this point in the history
Signed-off-by: Conrad Hübler <[email protected]>
  • Loading branch information
conradhuebler committed Jun 8, 2024
1 parent 37fabfb commit 93916d8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
url = https://github.com/conradhuebler/ripser
[submodule "external/xtb"]
path = external/xtb
url = https://github.com/conradhuebler/xtb
url = https://github.com/grimme-lab/xtb
[submodule "external/tblite"]
path = external/tblite
url = https://github.com/tblite/tblite
Expand Down
39 changes: 17 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmt/include
${PROJECT_SOURCE_DIR}/external/eigen-3.4.0
${PROJECT_SOURCE_DIR}/external/cpp-d4/include
${PROJECT_SOURCE_DIR}/external/)
if(Plumed)
include(${PROJECT_SOURCE_DIR}/external/plumed2/src/lib/Plumed.cmake)
endif()


include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} )

Expand Down Expand Up @@ -98,22 +96,22 @@ if (OPENMP_FOUND)
endif()

IF(CMAKE_COMPILER_IS_GNUCXX)
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -pedantic \
# -Wextra -Wcast-align -Wcast-qual -Wchar-subscripts \
# -Wcomment -Wdisabled-optimization \
# -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security\
# -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch\
# -Wunsafe-loop-optimizations -Wno-missing-braces\
# -Wmissing-field-initializers -Wmissing-format-attribute \
# -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses\
# -Wpointer-arith -Wno-redundant-decls -Wsequence-point\
# -Wsign-compare -Wstack-protector -Wstrict-aliasing\
# -Wstrict-aliasing=2 -Wswitch -Wsuggest-override\
# -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code\
# -Wunused -Wunused-function -Wunused-label -Wunused-parameter\
# -Wunused-value -Wunused-variable -Wvariadic-macros\
# -Wvolatile-register-var -Wwrite-strings -Wdeprecated-declarations\
# -Wno-error=unused-local-typedefs -Wno-error=enum-compare -Wno-narrowing -Werror=return-type -Wno-sign-compare -g")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -pedantic \
-Wextra -Wcast-align -Wcast-qual -Wchar-subscripts \
-Wcomment -Wdisabled-optimization \
-Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security\
-Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch\
-Wunsafe-loop-optimizations -Wno-missing-braces\
-Wmissing-field-initializers -Wmissing-format-attribute \
-Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses\
-Wpointer-arith -Wno-redundant-decls -Wsequence-point\
-Wsign-compare -Wstack-protector -Wstrict-aliasing\
-Wstrict-aliasing=2 -Wswitch -Wsuggest-override\
-Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code\
-Wunused -Wunused-function -Wunused-label -Wunused-parameter\
-Wunused-value -Wunused-variable -Wvariadic-macros\
-Wvolatile-register-var -Wwrite-strings -Wdeprecated-declarations\
-Wno-error=unused-local-typedefs -Wno-error=enum-compare -Wno-narrowing -Werror=return-type -Wno-sign-compare -g")
set (GCC ON)
if(WIN32) # Check if we are on Windows
else()
Expand Down Expand Up @@ -344,10 +342,7 @@ if(USE_D4)
endif()

if(USE_Plumed)
# target_link_libraries(curcuma_core ${Plumed_LIBRARIES})
# target_link_libraries(curcuma_core ${PLUMED_LOAD})
target_link_libraries(curcuma_core ${PROJECT_SOURCE_DIR}/external/plumed2/src/lib/libplumed.so)
#link_directories(${PROJECT_SOURCE_DIR}/external/plumed2/src/lib/libplumedKernel)
endif()

target_link_libraries(curcuma_core pthread fmt::fmt-header-only )
Expand Down
24 changes: 21 additions & 3 deletions src/capabilities/simplemd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ void SimpleMD::LoadControlJson()
m_writeXYZ = Json2KeyWord<bool>(m_defaults, "writeXYZ");
m_writeinit = Json2KeyWord<bool>(m_defaults, "writeinit");
m_mtd = Json2KeyWord<bool>(m_defaults, "mtd");
m_mtd_dT = Json2KeyWord<int>(m_defaults, "mtd_dT");
if (m_mtd_dT < 0) {
m_eval_mtd = true;
} else {
m_eval_mtd = false;
}
m_initfile = Json2KeyWord<std::string>(m_defaults, "initfile");
m_norestart = Json2KeyWord<bool>(m_defaults, "norestart");
m_dt2 = m_dT * m_dT;
Expand All @@ -109,7 +115,7 @@ void SimpleMD::LoadControlJson()
this->Rattle(grad);
};
m_rattle_tolerance = Json2KeyWord<double>(m_defaults, "rattle_tolerance");
m_coupling = m_dT;
// m_coupling = m_dT;
m_rattle = Json2KeyWord<int>(m_defaults, "rattle");
std::cout << "Using rattle to constrain bonds!" << std::endl;
} else {
Expand Down Expand Up @@ -586,6 +592,7 @@ void SimpleMD::start()
fmt::print(fg(fmt::color::green) | fmt::emphasis::bold, "\nUsing Berendson Thermostat\nJ. Chem. Phys. 81, 3684 (1984) - DOI: 10.1063/1.448118\n\n");
ThermostatFunction = std::bind(&SimpleMD::Berendson, this);
} else {
ThermostatFunction = std::bind(&SimpleMD::None, this);
std::cout << "No Thermostat applied\n"
<< std::endl;
}
Expand Down Expand Up @@ -701,8 +708,15 @@ void SimpleMD::start()
plumed_cmd(plumedmain, "setVirial", &m_virial[0]);

plumed_cmd(plumedmain, "setMasses", &m_mass[0]);
plumed_cmd(plumedmain, "prepareCalc", NULL);
plumed_cmd(plumedmain, "performCalc", NULL);
if (m_eval_mtd) {
plumed_cmd(plumedmain, "prepareCalc", NULL);
plumed_cmd(plumedmain, "performCalc", NULL);
} else {
if (std::abs(m_T0 - m_aver_Temp) < m_mtd_dT && m_step > 10) {
m_eval_mtd = true;
std::cout << "Starting with MetaDynamics ..." << std::endl;
}
}
}
#endif

Expand Down Expand Up @@ -1397,6 +1411,10 @@ bool SimpleMD::WriteGeometry()
return result;
}

void SimpleMD::None()
{
}

void SimpleMD::Berendson()
{
double lambda = sqrt(1 + (m_dT * (m_T0 - m_T)) / (m_T * m_coupling));
Expand Down
8 changes: 6 additions & 2 deletions src/capabilities/simplemd.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static json CurcumaMDJson{
{ "seed", 1 },
{ "cleanenergy", false },
{ "wall", "none" }, // can be spheric or rect
{ "wall_type", "logfermi" }, // can be logfermi or harmonic
{ "wall_type", "harmonic" }, // can be logfermi or harmonic
{ "wall_spheric_radius", 0 },
{ "wall_xl", 0 },
{ "wall_yl", 0 },
Expand All @@ -85,7 +85,8 @@ static json CurcumaMDJson{
{ "wall_temp", 298.15 },
{ "wall_beta", 6 },
{ "mtd", false },
{ "plumed", "plumed.dat" }
{ "plumed", "plumed.dat" },
{ "mtd_dT", -1 }
};

class SimpleMD : public CurcumaMethod {
Expand Down Expand Up @@ -156,6 +157,7 @@ class SimpleMD : public CurcumaMethod {
double EKin();
void Berendson();
void CSVR();
void None();

void InitialiseWalls();

Expand Down Expand Up @@ -214,6 +216,8 @@ class SimpleMD : public CurcumaMethod {
bool m_dipole = false;
bool m_clean_energy = false;
bool m_mtd = false;
bool m_eval_mtd = true;
int m_mtd_dT = -1;
int m_seed = -1;
int m_time_step = 0;
int m_dof = 0;
Expand Down

0 comments on commit 93916d8

Please sign in to comment.