Merge pull request #4467 from evoyiatzis/patch-2

extend fix adapt to treat improper angles
This commit is contained in:
Axel Kohlmeyer
2025-04-02 12:18:40 -04:00
committed by GitHub
43 changed files with 416 additions and 20 deletions

View File

@ -720,3 +720,44 @@ TEST(ImproperStyle, numdiff)
cleanup_lammps(lmp, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout();
}
TEST(ImproperStyle, extract)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = nullptr;
try {
lmp = init_lammps(args, test_config, true);
} catch (std::exception &e) {
if (!verbose) ::testing::internal::GetCapturedStdout();
FAIL() << e.what();
}
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
for (auto prerequisite : test_config.prerequisites) {
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
}
GTEST_SKIP();
}
auto *improper = lmp->force->improper;
void *ptr = nullptr;
int dim = 0;
for (auto extract : test_config.extract) {
ptr = improper->extract(extract.first.c_str(), dim);
EXPECT_NE(ptr, nullptr);
EXPECT_EQ(dim, extract.second);
}
ptr = improper->extract("does_not_exist", dim);
EXPECT_EQ(ptr, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout();
}

View File

@ -14,7 +14,9 @@ improper_coeff: ! |
1 75.0 169
2 45.0 10
* aa 75 42 31 125.4 130.01 115.06
extract: ! ""
extract: ! |
k 1
chi0 1
natoms: 29
init_energy: 1375.7372366975192
init_stress: ! |-

View File

@ -13,7 +13,9 @@ improper_style: cossq
improper_coeff: ! |
1 75.0 120.2
2 45.0 59.5
extract: ! ""
extract: ! |
k 1
chi0 1
natoms: 29
init_energy: 47.901206451962224
init_stress: ! |-

View File

@ -13,7 +13,10 @@ improper_style: cvff
improper_coeff: ! |
1 75.0 -1 5
2 45.0 +1 2
extract: ! ""
extract: ! |
k 1
d 1
n 1
natoms: 29
init_energy: 89.33266688553577
init_stress: ! |2-

View File

@ -13,7 +13,9 @@ improper_style: distance
improper_coeff: ! |
1 75.0 120.2
2 45.0 59.5
extract: ! ""
extract: ! |
k2 1
k4 1
natoms: 29
init_energy: 0.0747454910197192
init_stress: ! |-

View File

@ -13,7 +13,9 @@ improper_style: distharm
improper_coeff: ! |
1 75.0 5.5
2 45.0 6.2
extract: ! ""
extract: ! |
k 1
d0 1
natoms: 29
init_energy: 3973.601605432119
init_stress: ! |2-

View File

@ -13,7 +13,11 @@ improper_style: fourier
improper_coeff: ! |
1 75.0 0.9 0.2 0.3 1
2 45.0 0.5 0.1 0.8 0
extract: ! ""
extract: ! |
k 1
C0 1
C1 1
C2 1
natoms: 29
init_energy: 376.7915390602297
init_stress: ! |2-

View File

@ -13,7 +13,9 @@ improper_style: harmonic
improper_coeff: ! |
1 75.0 120.2
2 45.0 59.5
extract: ! ""
extract: ! |
k 1
chi0 1
natoms: 29
init_energy: 369.34096479618404
init_stress: ! |2-

View File

@ -13,7 +13,9 @@ improper_style: inversion/harmonic
improper_coeff: ! |
1 75.0 0.1
2 45.0 1.0
extract: ! ""
extract: ! |
k 1
w0 1
natoms: 29
init_energy: 0.35230115027159387
init_stress: ! |-

View File

@ -13,7 +13,9 @@ improper_style: ring
improper_coeff: ! |
1 75.0 120.2
2 45.0 59.5
extract: ! ""
extract: ! |
k 1
theta0 1
natoms: 29
init_energy: 31535.23771704055
init_stress: ! |-

View File

@ -13,7 +13,8 @@ improper_style: sqdistharm
improper_coeff: ! |
1 75.0 5.5
2 45.0 6.2
extract: ! ""
extract: ! |
k 1
natoms: 29
init_energy: 3997.62616072489
init_stress: ! |2-

View File

@ -13,7 +13,9 @@ improper_style: umbrella
improper_coeff: ! |
1 75.0 120.2
2 45.0 59.5
extract: ! ""
extract: ! |
k 1
w0 1
natoms: 29
init_energy: 120.51735030260785
init_stress: ! |2-