Unverified Commit 6d725c9b authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2287 from akohlmey/lattice-region-tester

Add unittest tool for lattice and region (/w create_box/create_atoms)
parents 1c274773 ba793f2e
Loading
Loading
Loading
Loading
+13 −17
Original line number Original line Diff line number Diff line
@@ -260,12 +260,8 @@ of Aidan Thompson), with its 8 atom unit cell.
   variable b equal  $a*sqrt(3.0)
   variable b equal  $a*sqrt(3.0)
   variable c equal  $a*sqrt(8.0/3.0)
   variable c equal  $a*sqrt(8.0/3.0)


   variable 1_3 equal 1.0/3.0
   variable third equal 1.0/3.0
   variable 2_3 equal 2.0/3.0
   variable five6 equal 5.0/6.0
   variable 1_6 equal 1.0/6.0
   variable 5_6 equal 5.0/6.0
   variable 1_12 equal 1.0/12.0
   variable 5_12 equal 5.0/12.0


   lattice custom    1.0     &
   lattice custom    1.0     &
           a1      $a       0.0     0.0     &
           a1      $a       0.0     0.0     &
@@ -273,12 +269,12 @@ of Aidan Thompson), with its 8 atom unit cell.
           a3      0.0      0.0     $c      &
           a3      0.0      0.0     $c      &
           basis   0.0      0.0     0.0     &
           basis   0.0      0.0     0.0     &
           basis   0.5      0.5     0.0     &
           basis   0.5      0.5     0.0     &
           basis   ${1_3}  0.0     0.5     &
           basis   ${third} 0.0     0.5     &
           basis   ${5_6}  0.5     0.5     &
           basis   ${five6} 0.5     0.5     &
           basis   0.0      0.0     0.625   &
           basis   0.0      0.0     0.625   &
           basis   0.5      0.5     0.625   &
           basis   0.5      0.5     0.625   &
           basis   ${1_3}  0.0     0.125   &
           basis   ${third} 0.0     0.125   &
           basis   ${5_6}  0.5     0.125
           basis   ${five6} 0.5     0.125


   region myreg block 0 1 0 1 0 1
   region myreg block 0 1 0 1 0 1
   create_box      2 myreg
   create_box      2 myreg
+14 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,20 @@ void CreateAtoms::command(int narg, char **arg)
    error->all(FLERR,"Cannot create_atoms after "
    error->all(FLERR,"Cannot create_atoms after "
               "reading restart file with per-atom info");
               "reading restart file with per-atom info");


  // check for compatible lattice

  int latsty = domain->lattice->style;
  if (domain->dimension == 2) {
    if (latsty == Lattice::SC || latsty == Lattice::BCC
        || latsty == Lattice::FCC || latsty == Lattice::HCP
        || latsty == Lattice::DIAMOND)
      error->all(FLERR,"Lattice style incompatible with simulation dimension");
  } else {
    if (latsty == Lattice::SQ ||latsty == Lattice::SQ2
        || latsty == Lattice::HEX)
      error->all(FLERR,"Lattice style incompatible with simulation dimension");
  }

  // parse arguments
  // parse arguments


  if (narg < 2) error->all(FLERR,"Illegal create_atoms command");
  if (narg < 2) error->all(FLERR,"Illegal create_atoms command");
+0 −2
Original line number Original line Diff line number Diff line
@@ -28,8 +28,6 @@ using namespace LAMMPS_NS;


#define BIG 1.0e30
#define BIG 1.0e30


enum{NONE,SC,BCC,FCC,HCP,DIAMOND,SQ,SQ2,HEX,CUSTOM};

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */


Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ namespace LAMMPS_NS {


class Lattice : protected Pointers {
class Lattice : protected Pointers {
 public:
 public:
  enum{NONE,SC,BCC,FCC,HCP,DIAMOND,SQ,SQ2,HEX,CUSTOM};

  int style;                           // NONE,SC,FCC,etc
  int style;                           // NONE,SC,FCC,etc
  double xlattice,ylattice,zlattice;   // lattice scale factors in 3 dims
  double xlattice,ylattice,zlattice;   // lattice scale factors in 3 dims
  double a1[3],a2[3],a3[3];            // edge vectors of unit cell
  double a1[3],a2[3],a3[3];            // edge vectors of unit cell
+4 −0
Original line number Original line Diff line number Diff line
@@ -3,6 +3,10 @@ add_executable(test_simple_commands test_simple_commands.cpp)
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest)
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME SimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME SimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})


add_executable(test_lattice_region test_lattice_region.cpp)
target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME LatticeRegion COMMAND test_lattice_region WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_executable(test_kim_commands test_kim_commands.cpp)
add_executable(test_kim_commands test_kim_commands.cpp)
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock GTest::GTest)
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME KimCommands COMMAND test_kim_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME KimCommands COMMAND test_kim_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Loading