1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
|
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "fmt/format.h"
#include "info.h"
#include "input.h"
#include "lammps.h"
#include "lmppython.h"
#include "modify.h"
#include "output.h"
#include "utils.h"
#include "variable.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstdlib>
#include <mpi.h>
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::MatchesRegex;
using ::testing::StrEq;
class KimCommandsTest : public LAMMPSTest {
protected:
Variable *variable;
void SetUp() override
{
testbinary = "KimCommandsTest";
LAMMPSTest::SetUp();
variable = lmp->input->variable;
}
};
TEST_F(KimCommandsTest, kim)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal kim command.*", command("kim"););
TEST_FAILURE(".*ERROR: Unknown kim subcommand.*", command("kim unknown"););
TEST_FAILURE(".*kim_init.*has been renamed to.*", command("kim_init"););
TEST_FAILURE(".*kim_interactions.*has been renamed to.*", command("kim_interactions"););
TEST_FAILURE(".*kim_param.*has been renamed to.*", command("kim_param"););
TEST_FAILURE(".*kim_property.*has been renamed to.*", command("kim_property"););
TEST_FAILURE(".*kim_query.*has been renamed to.*", command("kim_query"););
}
TEST_F(KimCommandsTest, kim_init)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*", command("kim init"););
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*",
command("kim init LennardJones_Ar real si"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style lj not supported by KIM models.*",
command("kim init LennardJones_Ar lj"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style micro not supported by KIM models.*",
command("kim init LennardJones_Ar micro"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style nano not supported by KIM models.*",
command("kim init LennardJones_Ar nano"););
TEST_FAILURE(".*ERROR: Unknown unit_style.*", command("kim init LennardJones_Ar new_style"););
TEST_FAILURE(".*ERROR: KIM Model name not found.*", command("kim init Unknown_Model real"););
TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model, required units = metal.*",
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real"););
// TEST_FAILURE(".*ERROR: KIM Model does not support the requested unit system.*",
// command("kim init ex_model_Ar_P_Morse real"););
BEGIN_HIDE_OUTPUT();
command("kim init LennardJones_Ar real");
END_HIDE_OUTPUT();
int ifix = lmp->modify->find_fix("KIM_MODEL_STORE");
ASSERT_GE(ifix, 0);
}
TEST_F(KimCommandsTest, kim_interactions)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*", command("kim interactions"););
BEGIN_HIDE_OUTPUT();
command("kim init LennardJones_Ar real");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Must use 'kim interactions' command "
"after simulation box is defined.*",
command("kim interactions Ar"););
BEGIN_HIDE_OUTPUT();
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
command("kim interactions Ar Ar"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("lattice fcc 4.4300");
command("region box block 0 20 0 20 0 20");
command("create_box 4 box");
command("create_atoms 4 box");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
command("kim interactions Ar Ar"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Must use 'kim init' before 'kim interactions'.*",
command("kim interactions Ar"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: fixed_types cannot be used with a KIM Portable Model.*",
command("kim interactions fixed_types"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("pair_style kim LennardJones_Ar");
command("region box block 0 1 0 1 0 1");
command("create_box 4 box");
command("pair_coeff * * Ar Ar Ar Ar");
END_HIDE_OUTPUT();
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
command("lattice fcc 4.920");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Species 'Ar' is not supported by this KIM Simulator Model.*",
command("kim interactions Ar"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
command("lattice fcc 4.08");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Au");
END_HIDE_OUTPUT();
// ASSERT_EQ(lmp->output->var_kim_periodic, 1);
// TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model.*",
// command("kim interactions Au"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
END_HIDE_OUTPUT();
int ifix = lmp->modify->find_fix("KIM_MODEL_STORE");
ASSERT_GE(ifix, 0);
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
command("run 1");
command("kim interactions Ar");
command("run 1");
END_HIDE_OUTPUT();
}
TEST_F(KimCommandsTest, kim_param)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim param' command.*", command("kim param"););
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim param' command.\n"
"'kim param get/set' is mandatory.*",
command("kim param unknown shift 1 shift"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: 'kim param' can only be used with a KIM Portable Model.*",
command("kim param get shift 1 shift"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal 'kim param get' command.\nTo get the new "
"parameter values, pair style must be assigned.\nMust use 'kim"
" interactions' or 'pair_style kim' before 'kim param get'.*",
command("kim param get shift 1 shift"););
TEST_FAILURE(".*ERROR: Illegal 'kim param set' command.\nTo set the new "
"parameter values, pair style must be assigned.\nMust use 'kim"
" interactions' or 'pair_style kim' before 'kim param set'.*",
command("kim param set shift 1 2"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal index '0' for "
"'shift' parameter with the extent of '1'.*",
command("kim param get shift 0 shift"););
TEST_FAILURE(".*ERROR: Illegal index '2' for "
"'shift' parameter with the extent of '1'.*",
command("kim param get shift 2 shift"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1.' in index_range.*",
command("kim param get shift 1. shift"););
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for 'shift' "
"parameter with the extent of '1'.*",
command("kim param get shift 1:2 shift"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1-2' in index_range.*",
command("kim param get shift 1-2 shift"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param "
"get' command.\nThe LAMMPS '3' variable names or "
"'s1 split' is mandatory.*",
command("kim param get sigmas 1:3 s1 s2"););
TEST_FAILURE(".*ERROR: Wrong argument in 'kim param get' command.\nThis "
"Model does not have the requested 'unknown' parameter.*",
command("kim param get unknown 1 unknown"););
BEGIN_HIDE_OUTPUT();
command("kim param get shift 1 shift");
END_HIDE_OUTPUT();
ASSERT_FALSE(variable->find("shift") == -1);
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
TEST_FAILURE(".*ERROR: Illegal index '2' for "
"'shift' parameter with the extent of '1'.*",
command("kim param set shift 2 2"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1.' in index_range.*",
command("kim param set shift 1. shift"););
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for "
"'shift' parameter with the extent of '1'.*",
command("kim param set shift 1:2 2"););
TEST_FAILURE(".*ERROR: Wrong number of variable values for pair coefficients.*",
command("kim param set sigmas 1:3 0.5523570 0.4989030"););
TEST_FAILURE(".*ERROR: Wrong argument for pair coefficients.\nThis "
"Model does not have the requested '0.4989030' parameter.*",
command("kim param set sigmas 1:1 0.5523570 0.4989030"););
BEGIN_HIDE_OUTPUT();
command("variable new_shift equal 2");
command("kim param set shift 1 ${new_shift}");
command("kim param get shift 1 shift");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 list"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 list"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 split"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 split"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 explicit"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 explicit"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
"command.\nThe LAMMPS '3' variable names or 'cutoffs "
"split/list' is mandatory.*",
command("kim param get cutoffs 1:3 cutoffs"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
"command.\nThe LAMMPS '3' variable names or 'cutoffs_1 "
"split' is mandatory.*",
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2"););
BEGIN_HIDE_OUTPUT();
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
BEGIN_HIDE_OUTPUT();
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3 explicit");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
BEGIN_HIDE_OUTPUT();
command("kim param get cutoffs 1:3 cutoffs split");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
BEGIN_HIDE_OUTPUT();
command("kim param get cutoffs 1:3 cutoffs list");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.20943 2.10252 5.666115"));
BEGIN_HIDE_OUTPUT();
command("kim param set cutoffs 1 2.21 cutoffs 2 2.11");
command("kim param get cutoffs 1:2 cutoffs list");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.21 2.11"));
BEGIN_HIDE_OUTPUT();
command("kim param set cutoffs 1:3 2.3 2.2 5.7");
command("kim param get cutoffs 1:3 cutoffs list");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.3 2.2 5.7"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("mass 1 39.95");
command("pair_style kim LennardJones612_UniversalShifted__MO_959249795837_003");
command("pair_coeff * * Ar");
END_HIDE_OUTPUT();
BEGIN_HIDE_OUTPUT();
command("kim param get shift 1 shift");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
BEGIN_HIDE_OUTPUT();
command("variable new_shift equal 2");
command("kim param set shift 1 ${new_shift}");
command("kim param get shift 1 shift");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
}
TEST_F(KimCommandsTest, kim_property)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
if (!LAMMPS::is_installed_pkg("PYTHON")) GTEST_SKIP();
if (!lmp->python->has_minimum_version(3, 6)) {
TEST_FAILURE(".*ERROR: Invalid Python version.\n"
"The kim-property Python package requires Python "
"3 >= 3.6 support.*",
command("kim property"););
} else {
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property"););
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property create"););
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim property' command."
"\n'kim property create/destroy/modify/remove/dump' "
"is mandatory.*",
command("kim property unknown 1 atomic-mass"););
}
#if defined(KIM_EXTRA_UNITTESTS)
TEST_FAILURE(".*ERROR: Invalid 'kim property create' command.*",
command("kim property create 1"););
TEST_FAILURE(".*ERROR: Invalid 'kim property destroy' command.*",
command("kim property destroy 1 cohesive-potential-energy-cubic-crystal"););
TEST_FAILURE(".*ERROR: Invalid 'kim property modify' command.*",
command("kim property modify 1 key short-name"););
TEST_FAILURE(".*ERROR: There is no property instance to modify the content.*",
command("kim property modify 1 key short-name source-value 1 fcc"););
TEST_FAILURE(".*ERROR: Invalid 'kim property remove' command.*",
command("kim property remove 1 key"););
TEST_FAILURE(".*ERROR: There is no property instance to remove the content.*",
command("kim property remove 1 key short-name"););
TEST_FAILURE(".*ERROR: There is no property instance to dump the content.*",
command("kim property dump results.edn"););
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
command("kim property create 1 cohesive-potential-energy-cubic-crystal");
command("kim property modify 1 key short-name source-value 1 fcc");
command("kim property destroy 1");
END_HIDE_OUTPUT();
#endif
}
TEST_F(KimCommandsTest, kim_query)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.*", command("kim query"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'split' "
"must be followed by the name of the query function.*",
command("kim query a0 split"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'list' "
"must be followed by the name of the query function.*",
command("kim query a0 list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'index' "
"must be followed by the name of the query function.*",
command("kim query a0 index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
"can not be used after 'split'.*",
command("kim query a0 split list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
"can not be used after 'split'.*",
command("kim query a0 split index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
"can not be used after 'list'.*",
command("kim query a0 list split"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
"can not be used after 'list'.*",
command("kim query a0 list index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
"can not be used after 'index'.*",
command("kim query a0 index list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
"can not be used after 'index'.*",
command("kim query a0 index split"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `crystal` "
"to 'kim query' is wrong. The query format is the "
"keyword=\\[value\\], where value is always an array of one "
"or more comma-separated items.*",
command("kim query a0 get_lattice_constant_cubic "
"crystal"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=fcc` to 'kim query' is wrong. The query format is the "
"keyword=\\[value\\], where value is always an array of one "
"or more comma-separated items.*",
command("kim query a0 get_lattice_constant_cubic "
"crystal=fcc"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=\\[fcc` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command("kim query a0 get_lattice_constant_cubic "
"crystal=[fcc"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=fcc\\]` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command("kim query a0 get_lattice_constant_cubic "
"crystal=fcc]"););
std::string squery = "kim query a0 get_lattice_constant_cubic "
"crystal=[\"fcc\"] species=\"Al\",\"Ni\" units=[\"angstrom\"]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\"Al\",\"Ni\"` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni, units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni,` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al,Ni, units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\\[Al,Ni,` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni], units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,\"Ni\"], "
"units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,\"Ni\"\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=\"Al\",Ni], "
"units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\"Al\",Ni\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[\"Al\"]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[Al]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
command(squery););
#if defined(KIM_EXTRA_UNITTESTS)
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim query latconst_1 get_lattice_constant_cubic "
"crystal=[fcc] species=[Al] units=[angstrom] "
"model=[EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
command("kim query latconst_1 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
"units=[angstrom]");
command("kim query latconst_2 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
"units=[angstrom] "
"model=[LennardJones612_UniversalShifted__MO_959249795837_003]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("3.328125931322575"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
command("kim query latconst split get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
"units=[angstrom]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("3.234055244384789"));
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("5.167650199630013"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim query latconst index get_lattice_constant_hexagonal "
"crystal=[hcp] species=[Zr] units=[angstrom] "
"model=[EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789"));
BEGIN_HIDE_OUTPUT();
command("variable latconst delete");
command("clear");
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
command("kim query latconst list get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
"units=[angstrom]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789 5.167650199630013"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
command("kim query alpha get_linear_thermal_expansion_coefficient_cubic "
"crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] "
"temperature_units=[K]");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("alpha"), StrEq("1.654960564704273e-05"));
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim query model_list list get_available_models species=[Al]");
END_HIDE_OUTPUT();
std::string model_list = variable->retrieve("model_list");
auto n = model_list.find("EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005");
ASSERT_TRUE(n != std::string::npos);
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim query model_name index get_available_models species=[Al]");
command("variable model_name delete");
END_HIDE_OUTPUT();
BEGIN_HIDE_OUTPUT();
command("clear");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[eam,meam]");
command("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[\"eam\",\"meam\"]");
command("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[eam,\"meam\"]");
command("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[\"eam\",meam]");
command("variable model_name delete");
END_HIDE_OUTPUT();
#endif
}
} // namespace LAMMPS_NS
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. "
"Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;
}
}
}
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
int rv = RUN_ALL_TESTS();
MPI_Finalize();
return rv;
}
|