set metal units and add option to do verbose execution to EIM potential tester
This commit is contained in:
@ -12,15 +12,20 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "MANYBODY/pair_eim.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||
bool verbose = false;
|
||||
|
||||
class EIMPotentialFileReaderTest : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
@ -33,9 +38,10 @@ protected:
|
||||
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
::testing::internal::GetCapturedStdout();
|
||||
lmp->input->one("units metal");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int npair = nelements * (nelements + 1) / 2;
|
||||
setfl.ielement = new int[nelements];
|
||||
@ -85,17 +91,17 @@ protected:
|
||||
delete[] setfl.rs;
|
||||
delete[] setfl.tp;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, global_line)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
reader.get_global(&setfl);
|
||||
ASSERT_DOUBLE_EQ(setfl.division, 2.0);
|
||||
@ -105,9 +111,9 @@ TEST_F(EIMPotentialFileReaderTest, global_line)
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_sequential)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
reader.get_element(&setfl, 0, "Li");
|
||||
ASSERT_EQ(setfl.ielement[0], 3);
|
||||
@ -130,9 +136,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_sequential)
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, element_line_random)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
reader.get_element(&setfl, 0, "Id");
|
||||
ASSERT_EQ(setfl.ielement[0], 53);
|
||||
@ -146,9 +152,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_random)
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_line)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
reader.get_pair(&setfl, 0, "Li", "Li");
|
||||
ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], 6.0490e+00);
|
||||
@ -169,9 +175,9 @@ TEST_F(EIMPotentialFileReaderTest, pair_line)
|
||||
|
||||
TEST_F(EIMPotentialFileReaderTest, pair_identical)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
EIMPotentialFileReader reader(lmp, "ffield.eim");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
reader.get_pair(&setfl, 0, "Li", "Na");
|
||||
reader.get_pair(&setfl, 1, "Na", "Li");
|
||||
@ -195,5 +201,6 @@ int main(int argc, char **argv)
|
||||
{
|
||||
MPI_Init(&argc, &argv);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user