Unverified Commit 70f37d66 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

update for handling r-RESPA properly

parent 3993f539
Loading
Loading
Loading
Loading
+349 −339
Original line number Diff line number Diff line
@@ -296,7 +296,6 @@ TEST(FixTimestep, plain)

    ::testing::internal::CaptureStdout();
    LAMMPS *lmp        = init_lammps(argc, argv, test_config);

    std::string output = ::testing::internal::GetCapturedStdout();
    if (verbose) std::cout << output;

@@ -318,8 +317,9 @@ TEST(FixTimestep, plain)

    double epsilon = test_config.epsilon;

    auto x   = lmp->atom->x;
    auto tag = lmp->atom->tag;
    auto x   = lmp->atom->x;
    auto v   = lmp->atom->v;
    ErrorStats stats;
    stats.reset();
    const std::vector<coord_t> &x_ref = test_config.run_pos;
@@ -331,7 +331,6 @@ TEST(FixTimestep, plain)
    }
    if (print_stats) std::cerr << "run_pos, normal run, verlet: " << stats << std::endl;

    auto v                            = lmp->atom->v;
    const std::vector<coord_t> &v_ref = test_config.run_vel;
    stats.reset();
    ASSERT_EQ(nlocal + 1, v_ref.size());
@@ -396,8 +395,9 @@ TEST(FixTimestep, plain)
    restart_lammps(lmp, test_config, false, false);
    if (!verbose) ::testing::internal::GetCapturedStdout();

    x   = lmp->atom->x;
    tag = lmp->atom->tag;
    x   = lmp->atom->x;
    v   = lmp->atom->v;
    stats.reset();
    ASSERT_EQ(nlocal + 1, x_ref.size());
    for (int i = 0; i < nlocal; ++i) {
@@ -407,7 +407,6 @@ TEST(FixTimestep, plain)
    }
    if (print_stats) std::cerr << "run_pos, restart, verlet: " << stats << std::endl;

    v = lmp->atom->v;
    stats.reset();
    ASSERT_EQ(nlocal + 1, v_ref.size());
    for (int i = 0; i < nlocal; ++i) {
@@ -518,6 +517,10 @@ TEST(FixTimestep, plain)
            std::cerr << "global_data, rmass, verlet: " << stats << std::endl;
    }

    // rigid fixes need work to test properly with r-RESPA
    ifix = lmp->modify->find_fix("test");
    if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid")) {

        if (!verbose) ::testing::internal::CaptureStdout();
        cleanup_lammps(lmp, test_config);
        if (!verbose) ::testing::internal::GetCapturedStdout();
@@ -527,11 +530,12 @@ TEST(FixTimestep, plain)
        output = ::testing::internal::GetCapturedStdout();
        if (verbose) std::cout << output;

    // lower required precision by one order of magnitude to accommodate respa
    epsilon *= 10.0;
        // lower required precision by two orders of magnitude to accommodate respa
        epsilon *= 100.0;

    x   = lmp->atom->x;
        tag = lmp->atom->tag;
        x   = lmp->atom->x;
        v   = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, x_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -541,7 +545,6 @@ TEST(FixTimestep, plain)
        }
        if (print_stats) std::cerr << "run_pos, normal run, respa: " << stats << std::endl;

    v = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, v_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -559,13 +562,14 @@ TEST(FixTimestep, plain)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
            if (print_stats) std::cerr << "run_stress normal run, respa: " << stats << std::endl;
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats)
                    std::cerr << "run_stress normal run, respa: " << stats << std::endl;
            }

            stats.reset();
@@ -573,7 +577,7 @@ TEST(FixTimestep, plain)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -583,18 +587,19 @@ TEST(FixTimestep, plain)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
            std::cerr << "global_data, normal run, verlet: " << stats << std::endl;
                std::cerr << "global_data, normal run, respa: " << stats << std::endl;
        }

        if (!verbose) ::testing::internal::CaptureStdout();
        restart_lammps(lmp, test_config, false, true);
        if (!verbose) ::testing::internal::GetCapturedStdout();

    x   = lmp->atom->x;
        tag = lmp->atom->tag;
        x   = lmp->atom->x;
        v   = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, x_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -604,7 +609,6 @@ TEST(FixTimestep, plain)
        }
        if (print_stats) std::cerr << "run_pos, restart, respa: " << stats << std::endl;

    v = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, v_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -622,12 +626,12 @@ TEST(FixTimestep, plain)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats) std::cerr << "run_stress restart, respa: " << stats << std::endl;
            }

@@ -636,7 +640,7 @@ TEST(FixTimestep, plain)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -646,7 +650,7 @@ TEST(FixTimestep, plain)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
                std::cerr << "global_data, restart, respa: " << stats << std::endl;
@@ -685,12 +689,12 @@ TEST(FixTimestep, plain)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats) std::cerr << "run_stress rmass, respa: " << stats << std::endl;
            }

@@ -699,7 +703,7 @@ TEST(FixTimestep, plain)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -709,11 +713,12 @@ TEST(FixTimestep, plain)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
                std::cerr << "global_data, rmass, respa: " << stats << std::endl;
        }
    }

    if (!verbose) ::testing::internal::CaptureStdout();
    cleanup_lammps(lmp, test_config);
@@ -753,8 +758,9 @@ TEST(FixTimestep, omp)

    double epsilon = test_config.epsilon;

    auto x   = lmp->atom->x;
    auto tag = lmp->atom->tag;
    auto x   = lmp->atom->x;
    auto v   = lmp->atom->v;
    ErrorStats stats;
    stats.reset();
    const std::vector<coord_t> &x_ref = test_config.run_pos;
@@ -766,7 +772,6 @@ TEST(FixTimestep, omp)
    }
    if (print_stats) std::cerr << "run_pos, normal run, verlet: " << stats << std::endl;

    auto v                            = lmp->atom->v;
    const std::vector<coord_t> &v_ref = test_config.run_vel;
    stats.reset();
    ASSERT_EQ(nlocal + 1, v_ref.size());
@@ -795,7 +800,6 @@ TEST(FixTimestep, omp)
        }

        stats.reset();

        // global scalar
        if (fix->scalar_flag) {
            double value = fix->compute_scalar();
@@ -832,8 +836,9 @@ TEST(FixTimestep, omp)
    restart_lammps(lmp, test_config, false, false);
    if (!verbose) ::testing::internal::GetCapturedStdout();

    x   = lmp->atom->x;
    tag = lmp->atom->tag;
    x   = lmp->atom->x;
    v   = lmp->atom->v;
    stats.reset();
    ASSERT_EQ(nlocal + 1, x_ref.size());
    for (int i = 0; i < nlocal; ++i) {
@@ -843,7 +848,6 @@ TEST(FixTimestep, omp)
    }
    if (print_stats) std::cerr << "run_pos, restart, verlet: " << stats << std::endl;

    v = lmp->atom->v;
    stats.reset();
    ASSERT_EQ(nlocal + 1, v_ref.size());
    for (int i = 0; i < nlocal; ++i) {
@@ -954,6 +958,10 @@ TEST(FixTimestep, omp)
            std::cerr << "global_data, rmass, verlet: " << stats << std::endl;
    }

    // rigid fixes need work to test properly with r-RESPA
    ifix = lmp->modify->find_fix("test");
    if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid")) {

        if (!verbose) ::testing::internal::CaptureStdout();
        cleanup_lammps(lmp, test_config);
        if (!verbose) ::testing::internal::GetCapturedStdout();
@@ -963,11 +971,12 @@ TEST(FixTimestep, omp)
        output = ::testing::internal::GetCapturedStdout();
        if (verbose) std::cout << output;

    // lower required precision by one order of magnitude to accommodate respa
    epsilon *= 10.0;
        // lower required precision by two orders of magnitude to accommodate respa
        epsilon *= 100.0;

    x   = lmp->atom->x;
        tag = lmp->atom->tag;
        x   = lmp->atom->x;
        v   = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, x_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -977,7 +986,6 @@ TEST(FixTimestep, omp)
        }
        if (print_stats) std::cerr << "run_pos, normal run, respa: " << stats << std::endl;

    v = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, v_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -995,13 +1003,14 @@ TEST(FixTimestep, omp)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
            if (print_stats) std::cerr << "run_stress normal run, respa: " << stats << std::endl;
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats)
                    std::cerr << "run_stress normal run, respa: " << stats << std::endl;
            }

            stats.reset();
@@ -1009,7 +1018,7 @@ TEST(FixTimestep, omp)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -1019,18 +1028,19 @@ TEST(FixTimestep, omp)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
            std::cerr << "global_data, normal run, verlet: " << stats << std::endl;
                std::cerr << "global_data, normal run, respa: " << stats << std::endl;
        }

        if (!verbose) ::testing::internal::CaptureStdout();
        restart_lammps(lmp, test_config, false, true);
        if (!verbose) ::testing::internal::GetCapturedStdout();

    x   = lmp->atom->x;
        tag = lmp->atom->tag;
        x   = lmp->atom->x;
        v   = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, x_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -1040,7 +1050,6 @@ TEST(FixTimestep, omp)
        }
        if (print_stats) std::cerr << "run_pos, restart, respa: " << stats << std::endl;

    v = lmp->atom->v;
        stats.reset();
        ASSERT_EQ(nlocal + 1, v_ref.size());
        for (int i = 0; i < nlocal; ++i) {
@@ -1058,12 +1067,12 @@ TEST(FixTimestep, omp)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats) std::cerr << "run_stress restart, respa: " << stats << std::endl;
            }

@@ -1072,7 +1081,7 @@ TEST(FixTimestep, omp)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -1082,7 +1091,7 @@ TEST(FixTimestep, omp)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
                std::cerr << "global_data, restart, respa: " << stats << std::endl;
@@ -1121,12 +1130,12 @@ TEST(FixTimestep, omp)
            if (fix->thermo_virial) {
                stats.reset();
                auto stress = fix->virial;
            EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
            EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
                EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
                if (print_stats) std::cerr << "run_stress rmass, respa: " << stats << std::endl;
            }

@@ -1135,7 +1144,7 @@ TEST(FixTimestep, omp)
            // global scalar
            if (fix->scalar_flag) {
                double value = fix->compute_scalar();
            EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, epsilon);
                EXPECT_FP_LE_WITH_EPS(test_config.global_scalar, value, 10 * epsilon);
            }

            // global vector
@@ -1145,11 +1154,12 @@ TEST(FixTimestep, omp)

                for (int i = 0; i < num; ++i)
                    EXPECT_FP_LE_WITH_EPS(test_config.global_vector[i], fix->compute_vector(i),
                                      epsilon);
                                          10 * epsilon);
            }
            if (print_stats && stats.has_data())
                std::cerr << "global_data, rmass, respa: " << stats << std::endl;
        }
    }

    if (!verbose) ::testing::internal::CaptureStdout();
    cleanup_lammps(lmp, test_config);