Example #1
0
 def test_weights(self):
     cb = CalcBox(name="testbox",
                  pos=(0., 0., 0.),
                  cutoff=2.0,
                  dim=(100.0, 100.0, 100.0),
                  inner_dim=(50.0, 50.0, 50.0))
     # test all three axis
     test_positions = np.column_stack(
         (np.linspace(-55.0, 55.0, 100), np.zeros(100), np.zeros(100)))
     test_positions = np.append(test_positions,
                                np.column_stack(
                                    (np.zeros(100),
                                     np.linspace(-55.0, 55.0,
                                                 100), np.zeros(100))),
                                axis=0)
     test_positions = np.append(test_positions,
                                np.column_stack(
                                    (np.zeros(100), np.zeros(100),
                                     np.linspace(-55.0, 55.0, 100))),
                                axis=0)
     # and all 8 corners too
     a = 37.5
     test_positions = np.append(test_positions,
                                np.array(
                                    ((-a, -a, -a), (-a, -a, a), (-a, a, -a),
                                     (-a, a, -a), (a, -a, -a), (a, -a, a),
                                     (a, a, -a), (a, a, a))),
                                axis=0)
     correct_weights = np.loadtxt("weight_test.csv", delimiter=",")
     for i in range(len(test_positions)):
         w = cb.get_weight(test_positions[i])
         self.assertEqual(correct_weights[i], w)
Example #2
0
 def test_weights(self):
     cb = CalcBox(name="testbox", pos=(0., 0., 0.),
                  cutoff=2.0,
                  dim=(100.0, 100.0, 100.0),
                  inner_dim=(50.0, 50.0, 50.0))
     # test all three axis
     test_positions = np.column_stack((np.linspace(-55.0, 55.0, 100),
                                       np.zeros(100),
                                       np.zeros(100)))
     test_positions = np.append(test_positions, np.column_stack(
                             (np.zeros(100),
                              np.linspace(-55.0, 55.0, 100),
                              np.zeros(100))), axis=0)
     test_positions = np.append(test_positions, np.column_stack(
                             (np.zeros(100),
                              np.zeros(100),
                              np.linspace(-55.0, 55.0, 100))),
                              axis=0)
     # and all 8 corners too
     a = 37.5
     test_positions = np.append(test_positions, np.array((
                             (-a, -a, -a),
                             (-a, -a, a),
                             (-a, a, -a),
                             (-a, a, -a),
                             (a, -a, -a),
                             (a, -a, a),
                             (a, a, -a),
                             (a, a, a))),
                             axis=0)
     correct_weights = np.loadtxt("weight_test.csv", delimiter=",")
     for i in range(len(test_positions)):
         w = cb.get_weight(test_positions[i])
         self.assertEqual(correct_weights[i], w)
Example #3
0
 def test_calcbox_all(self):
     cb = CalcBox(name="testbox",
                  pos=(0., 0., 0.),
                  dim=(self._edge + 5, self._edge + 5, self._edge + 5))
     sa, srmap, sw = cb.select_atoms(self._atoms)
     ra = self._atoms
     self.assertEqual(ra, sa)
Example #4
0
 def test_calcbox_subset(self):
     cb = CalcBox(name="testbox", pos=(0., 0., 0.),
                  cutoff=0.0,
                  dim=(50.0, 50.0, 50.0))
     sa, srmap, sw = cb.select_atoms(self._atoms)
     correct_ids = set([307, 215, 405, 280, 281, 410, 155, 156, 285, 286,
         415, 160, 289, 290, 419, 165, 294, 455, 430, 432, 305, 306, 435,
         180, 414, 310, 439, 312, 185, 186, 315, 188, 190, 181, 193, 343,
         161, 457, 330, 311, 332, 205, 462, 335, 337, 210, 340, 213, 313,
         218, 314, 465, 444, 338, 437, 440, 318, 319, 460])
     self.assertEqual(set(Mixer.get_atom_ids(sa)), correct_ids)
Example #5
0
 def test_calcbox_subset(self):
     cb = CalcBox(name="testbox",
                  pos=(0., 0., 0.),
                  cutoff=0.0,
                  dim=(50.0, 50.0, 50.0))
     sa, srmap, sw = cb.select_atoms(self._atoms)
     correct_ids = set([
         307, 215, 405, 280, 281, 410, 155, 156, 285, 286, 415, 160, 289,
         290, 419, 165, 294, 455, 430, 432, 305, 306, 435, 180, 414, 310,
         439, 312, 185, 186, 315, 188, 190, 181, 193, 343, 161, 457, 330,
         311, 332, 205, 462, 335, 337, 210, 340, 213, 313, 218, 314, 465,
         444, 338, 437, 440, 318, 319, 460
     ])
     self.assertEqual(set(Mixer.get_atom_ids(sa)), correct_ids)
Example #6
0
 def test_calcbox_moving_ch4(self):
     cb = CalcBox(name="testbox",
                  pos=(0., 0., 0.),
                  cutoff=2.0,
                  dim=(55.0, 55.0, 55.0),
                  debug=0)
     ch4 = [0, 1, 2, 3]  # these are atoms indexes and ids
     z = np.linspace(-self._edge / 2.0 - 25, self._edge / 2.0 + 25, 100)
     x = np.zeros_like(z)
     y = np.zeros_like(z)
     pos = np.column_stack((x, y, z))
     for i in range(len(pos)):
         self._set_molecule_pos(self._atoms, ch4, pos[i])
         sa, srmap, sw = cb.select_atoms(self._atoms)
         s_ids = set(Mixer.get_atom_ids(sa))
         all_ids = set(Mixer.get_atom_ids(self._atoms))
         inside_ids = s_ids.intersection(set(ch4))
         if not (len(inside_ids) == 0 or len(inside_ids) == 4):
             print("CH4 pos: %s" % pos[i])
             print("CH4 in selection: %s" % inside_ids)
Example #7
0
 def test_calcbox_moving_ch4(self):
     cb = CalcBox(name="testbox", pos=(0., 0., 0.),
                  cutoff=2.0,
                  dim=(55.0, 55.0, 55.0),
                  debug=0)
     ch4 = [0, 1, 2, 3] # these are atoms indexes and ids
     z = np.linspace(-self._edge/2.0 - 25, self._edge/2.0 + 25, 100)
     x = np.zeros_like(z)
     y = np.zeros_like(z)
     pos = np.column_stack((x, y, z))
     for i in range(len(pos)):
         self._set_molecule_pos(self._atoms,
                                ch4,
                                pos[i])
         sa, srmap, sw = cb.select_atoms(self._atoms)
         s_ids = set(Mixer.get_atom_ids(sa))
         all_ids = set(Mixer.get_atom_ids(self._atoms))
         inside_ids = s_ids.intersection(set(ch4))
         if not (len(inside_ids) == 0 or len(inside_ids) == 4):
             print("CH4 pos: %s" % pos[i])
             print("CH4 in selection: %s" % inside_ids)
Example #8
0
 def test_calcbox_all(self):
     cb = CalcBox(name="testbox", pos=(0., 0., 0.),
                  dim=(self._edge + 5, self._edge + 5, self._edge + 5))
     sa, srmap, sw = cb.select_atoms(self._atoms)
     ra = self._atoms
     self.assertEqual(ra, sa)
Example #9
0
Mixer.set_atom_ids(atoms)  # this one is important!

calc_gpaw = GPAW(nbands=bands, txt="mixer_box_gpaw.log")
calc_reaxff_full = ReaxFF(ff_file_path=get_datafile("ffield.reax.new"),
                          implementation="C")
calc_reaxff_qbox = ReaxFF(ff_file_path=get_datafile("ffield.reax.new"),
                          implementation="C")

# debug disabled for non-master nodes, this is so on purpose!
debug = 0
if rank == 0:
    debug = set_debug

filter_full_sys = CalcBox(name="full_sys",
                          pos=(0, 0, 0),
                          dim=cell,
                          cutoff=cutoff,
                          pbc=(1, 1, 1),
                          debug=debug)
filter_qbox = CalcBox(name="qbox",
                      pos=qbox_pos,
                      dim=q_cell,
                      cutoff=cutoff,
                      inner_dim=(q_cell[0] - transition_buffer * 2.0,
                                 q_cell[1] - transition_buffer * 2.0,
                                 q_cell[2] - transition_buffer * 2.0),
                      debug=debug)

# full system classical is taken as positive
forces_full_system = ForceCalculation("force_full",
                                      selector=filter_full_sys,
                                      calculator=calc_reaxff_full,