diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index 0c44121cba..4292144338 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -294,14 +294,18 @@ YAML format test inputs. - The fix to be tested must be specified in the ``post_commands:`` section with the fix-ID ``test``. This section may contain other commands and other fixes (e.g. an instance of fix nve for testing - thermostat or force manipulation fixes) + a thermostat or force manipulation fix) +- For fixes that can tally contributions to the global virial, the + line ``fix_modify test virial yes`` should be included in the + ``post_commands:`` section of the test input. - For thermostat fixes the target temperature should be ramped from an arbitrary value (e.g. 50K) to a pre-defined target temperature entered as ``${t_target}``. -- For fixes that may or may not do thermostatting depending on - the flags in use (e.g. fix rigid), the ``post_commands:`` section - should contain ``variable t_target delete`` to disable the target - temperature ramp check in case the thermostat is not enabled +- For fixes that have thermostatting support included, but do not + have it enabled in the input (e.g. fix rigid with default settings), + the ``post_commands:`` section should contain the line + ``variable t_target delete`` to disable the target temperature ramp + check to avoid false positives. Use custom linker for faster link times when ENABLE_TESTING is active ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/unittest/force-styles/test_fix_timestep.cpp b/unittest/force-styles/test_fix_timestep.cpp index d25085a5c6..cc20dae0ca 100644 --- a/unittest/force-styles/test_fix_timestep.cpp +++ b/unittest/force-styles/test_fix_timestep.cpp @@ -239,6 +239,15 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) } else { Fix *fix = lmp->modify->fix[ifix]; + // run_stress, if enabled + if (fix->thermo_virial) { + auto stress = fix->virial; + block = fmt::format("{:23.16e} {:23.16e} {:23.16e} " + "{:23.16e} {:23.16e} {:23.16e}", + stress[0], stress[1], stress[2], stress[3], stress[4], stress[5]); + writer.emit_block("run_stress", block); + } + // global scalar if (fix->scalar_flag) { double value = fix->compute_scalar(); @@ -338,8 +347,19 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; - stats.reset(); + 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, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar if (fix->scalar_flag) { double value = fix->compute_scalar(); @@ -402,6 +422,18 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 restart, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -453,6 +485,18 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 rmass, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -510,6 +554,18 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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; + } + stats.reset(); // global scalar @@ -561,6 +617,18 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 restart, respa: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -612,6 +680,18 @@ TEST(FixTimestep, plain) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 rmass, respa: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -701,6 +781,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -765,6 +857,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 restart, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -816,6 +920,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 rmass, verlet: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -873,6 +989,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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; + } + stats.reset(); // global scalar @@ -924,6 +1052,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 restart, respa: " << stats << std::endl; + } + stats.reset(); // global scalar @@ -975,6 +1115,18 @@ TEST(FixTimestep, omp) FAIL() << "ERROR: no fix defined with fix ID 'test'\n"; } else { Fix *fix = lmp->modify->fix[ifix]; + 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 rmass, respa: " << stats << std::endl; + } + stats.reset(); // global scalar diff --git a/unittest/force-styles/tests/fix-timestep-rattle_angle.yaml b/unittest/force-styles/tests/fix-timestep-rattle_angle.yaml index 4fcb01e297..788ca7c78d 100644 --- a/unittest/force-styles/tests/fix-timestep-rattle_angle.yaml +++ b/unittest/force-styles/tests/fix-timestep-rattle_angle.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 13:57:28 202 +date_generated: Sun Aug 9 16:30:21 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | fix move all nve fix test solvent rattle 1.0e-5 20 4 b 5 a 1 + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |- + -6.7489444076122581e+01 -3.6466857275816793e+01 -4.1453650662488030e+01 -3.0881715538687999e+01 -2.8271646386126275e+01 1.8512924155867125e-01 run_pos: ! |2 1 -2.7045559935221097e-01 2.4912159904412490e+00 -1.6695851634760922e-01 2 3.1004029578877490e-01 2.9612354630874571e+00 -8.5466363025011627e-01 diff --git a/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml b/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml index f466f8db95..09efa28256 100644 --- a/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml +++ b/unittest/force-styles/tests/fix-timestep-rattle_bond.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 13:57:18 202 +date_generated: Sun Aug 9 16:30:21 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | fix move all nve fix test solute rattle 1.0e-5 20 4 m 4.00794 + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |2- + 3.9891557115890999e+00 3.7983351717152480e+00 7.6152694943743228e+01 5.7163462651523300e-01 3.0839737670745507e+01 3.0066936263232019e+01 run_pos: ! |2 1 -2.6863205200662160e-01 2.4924200251053037e+00 -1.6940797171640173e-01 2 3.0314855494325726e-01 2.9555142432096928e+00 -8.4661597718762538e-01 diff --git a/unittest/force-styles/tests/fix-timestep-rigid-group.yaml b/unittest/force-styles/tests/fix-timestep-rigid-group.yaml index 156b5b4c24..a252c9ae16 100644 --- a/unittest/force-styles/tests/fix-timestep-rigid-group.yaml +++ b/unittest/force-styles/tests/fix-timestep-rigid-group.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:12:15 202 +date_generated: Sun Aug 9 16:30:21 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | variable t_target delete fix test all rigid group 2 solute solvent + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |- + -1.4245356937318927e+03 -1.4496493315649675e+03 -3.6144360984224963e+03 8.4840626828643849e+02 2.0318336761611764e+02 -6.0622397707969685e+02 global_scalar: 15.7115214231781 run_pos: ! |2 1 -2.7899546863891622e-01 2.4731857340328216e+00 -1.7290667740241872e-01 diff --git a/unittest/force-styles/tests/fix-timestep-rigid-molecule.yaml b/unittest/force-styles/tests/fix-timestep-rigid-molecule.yaml index 412ed1e17f..18ac7ea4e7 100644 --- a/unittest/force-styles/tests/fix-timestep-rigid-molecule.yaml +++ b/unittest/force-styles/tests/fix-timestep-rigid-molecule.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:12:15 202 +date_generated: Sun Aug 9 16:30:21 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | variable t_target delete fix test solvent rigid molecule + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |- + -4.9200116134790363e+01 -2.6907707565987732e+01 -6.0080860422282560e+00 -2.5620423972101747e+01 -1.3450224059984075e+01 -1.4947288487004844e+00 global_scalar: 18.3405601674144 run_pos: ! |2 1 -2.7993683669226832e-01 2.4726588069312840e+00 -1.7200860244148433e-01 diff --git a/unittest/force-styles/tests/fix-timestep-rigid-single.yaml b/unittest/force-styles/tests/fix-timestep-rigid-single.yaml index 0ddf281470..ab37c9ac6a 100644 --- a/unittest/force-styles/tests/fix-timestep-rigid-single.yaml +++ b/unittest/force-styles/tests/fix-timestep-rigid-single.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:12:16 202 +date_generated: Sun Aug 9 16:30:21 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | variable t_target delete fix test solute rigid single + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |- + -1.3754817466835852e+03 -1.4228425246165939e+03 -3.6087196201913630e+03 8.7407043149698166e+02 2.1665316519768876e+02 -6.0480791462031175e+02 global_scalar: 4.53142303857031 run_pos: ! |2 1 -2.7899546859693181e-01 2.4731857340428789e+00 -1.7290667720876129e-01 diff --git a/unittest/force-styles/tests/fix-timestep-shake_angle.yaml b/unittest/force-styles/tests/fix-timestep-shake_angle.yaml index 2ef5b314af..8add9728b3 100644 --- a/unittest/force-styles/tests/fix-timestep-shake_angle.yaml +++ b/unittest/force-styles/tests/fix-timestep-shake_angle.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:39:26 202 +date_generated: Sun Aug 9 16:30:22 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | fix move all nve fix test solvent shake 1.0e-5 20 4 b 5 a 1 + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |- + -6.7489461181454146e+01 -3.6466852749734755e+01 -4.1453635345326461e+01 -3.0881721833345594e+01 -2.8271651455044346e+01 1.8512237607314627e-01 run_pos: ! |2 1 -2.7045559935221097e-01 2.4912159904412490e+00 -1.6695851634760922e-01 2 3.1004029578877490e-01 2.9612354630874571e+00 -8.5466363025011627e-01 diff --git a/unittest/force-styles/tests/fix-timestep-shake_bond.yaml b/unittest/force-styles/tests/fix-timestep-shake_bond.yaml index a75b30e9c2..0fe61c0732 100644 --- a/unittest/force-styles/tests/fix-timestep-shake_bond.yaml +++ b/unittest/force-styles/tests/fix-timestep-shake_bond.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:37:51 202 +date_generated: Sun Aug 9 16:30:22 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -9,8 +9,11 @@ pre_commands: ! "" post_commands: ! | fix move all nve fix test solute shake 1.0e-5 20 4 m 4.00794 + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |2- + 4.1327164284089424e+00 4.1298776885725212e+00 7.7065049821613400e+01 7.3427739401911385e-01 3.1021321349896283e+01 3.0482918118325731e+01 run_pos: ! |2 1 -2.6863205200661111e-01 2.4924200251053290e+00 -1.6940797171639235e-01 2 3.0314855494326542e-01 2.9555142432097057e+00 -8.4661597718762593e-01 diff --git a/unittest/force-styles/tests/fix-timestep-wall-harmonic_const.yaml b/unittest/force-styles/tests/fix-timestep-wall-harmonic_const.yaml index 261ccc7b0c..36ed8a8a36 100644 --- a/unittest/force-styles/tests/fix-timestep-wall-harmonic_const.yaml +++ b/unittest/force-styles/tests/fix-timestep-wall-harmonic_const.yaml @@ -1,6 +1,6 @@ --- lammps_version: 21 Jul 2020 -date_generated: Sun Aug 9 07:21:00 202 +date_generated: Sun Aug 9 16:30:22 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -10,8 +10,11 @@ pre_commands: ! | post_commands: ! | fix move all nve fix test solute wall/harmonic ylo EDGE 100.0 0.0 5.0 yhi EDGE 100.0 0.0 5.0 + fix_modify test virial yes input_file: in.fourmol natoms: 29 +run_stress: ! |2- + 0.0000000000000000e+00 7.2422093200265749e+02 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 global_scalar: 42.6997744353244 global_vector: ! |- 2 0.0 161.92409617466126