Unverified Commit faac18ff authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add tester tool for timestep related fixes: integrators, thermostats, force...

add tester tool for timestep related fixes: integrators, thermostats, force manipulations, constraints
parent 0ce43efc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -114,3 +114,16 @@ foreach(TEST ${KSPACE_TESTS})
  add_test(NAME ${TNAME} COMMAND test_pair_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
  set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()

# tester for timestepping fixes
add_executable(test_fix_timestep test_fix_timestep.cpp)
target_link_libraries(test_fix_timestep PRIVATE lammps style_tests)

# tests for timestep related fixes (time integration, thermostat, force manipulation, constraints/restraints)
file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml)
foreach(TEST ${FIX_TIMESTEP_TESTS})
  string(REGEX REPLACE "^.*fix-timestep-(.*)\.yaml" "FixTimestep:\\1" TNAME ${TEST})
  add_test(NAME ${TNAME} COMMAND test_fix_timestep ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
  set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
+8 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@ public:
    stress_t run_stress;
    std::vector<coord_t> init_forces;
    std::vector<coord_t> run_forces;
    std::vector<coord_t> run_pos;
    std::vector<coord_t> restart_pos;
    std::vector<coord_t> run_vel;
    std::vector<coord_t> restart_vel;

    TestConfig() :
        lammps_version(""), date_generated(""), basename(""), epsilon(1.0e-14), input_file(""),
@@ -79,6 +83,10 @@ public:
        extract.clear();
        init_forces.clear();
        run_forces.clear();
        run_pos.clear();
        restart_pos.clear();
        run_vel.clear();
        restart_vel.clear();
    }
    virtual ~TestConfig(){};

+32 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ TestConfigReader::TestConfigReader(TestConfig &config) : YamlReader(), config(co
    consumers["run_stress"]     = &TestConfigReader::run_stress;
    consumers["init_forces"]    = &TestConfigReader::init_forces;
    consumers["run_forces"]     = &TestConfigReader::run_forces;
    consumers["run_pos"]        = &TestConfigReader::run_pos;
    consumers["run_vel"]        = &TestConfigReader::run_vel;

    consumers["pair_style"] = &TestConfigReader::pair_style;
    consumers["pair_coeff"] = &TestConfigReader::pair_coeff;
@@ -176,6 +178,36 @@ void TestConfigReader::run_forces(const yaml_event_t &event)
    }
}

void TestConfigReader::run_pos(const yaml_event_t &event)
{
    config.run_pos.clear();
    config.run_pos.resize(config.natoms + 1);
    std::stringstream data((char *)event.data.scalar.value);
    std::string line;

    while (std::getline(data, line, '\n')) {
        int tag;
        coord_t xyz;
        sscanf(line.c_str(), "%d %lg %lg %lg", &tag, &xyz.x, &xyz.y, &xyz.z);
        config.run_pos[tag] = xyz;
    }
}

void TestConfigReader::run_vel(const yaml_event_t &event)
{
    config.run_vel.clear();
    config.run_vel.resize(config.natoms + 1);
    std::stringstream data((char *)event.data.scalar.value);
    std::string line;

    while (std::getline(data, line, '\n')) {
        int tag;
        coord_t xyz;
        sscanf(line.c_str(), "%d %lg %lg %lg", &tag, &xyz.x, &xyz.y, &xyz.z);
        config.run_vel[tag] = xyz;
    }
}

void TestConfigReader::pair_style(const yaml_event_t &event)
{
    config.pair_style = (char *)event.data.scalar.value;
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ public:
    void run_stress(const yaml_event_t &event);
    void init_forces(const yaml_event_t &event);
    void run_forces(const yaml_event_t &event);
    void run_pos(const yaml_event_t &event);
    void run_vel(const yaml_event_t &event);
    void fix_style(const yaml_event_t &event);
    void pair_style(const yaml_event_t &event);
    void pair_coeff(const yaml_event_t &event);
    void bond_style(const yaml_event_t &event);
+628 −0

File added.

Preview size limit exceeded, changes collapsed.