Beispiel #1
0
    def testSetRelaxed(self):
        crystal = self._crystal.copy()
        surface = Surface3D(crystal=self._crystal,
                            miller_indices=(0,0,1),
                            surface_cell=((1, 0), (0, 1)),
                            extra_atoms=Atoms('H', [[0.2, 0.3, 0.7]]),
                            )
        surface_parameters1 = surface.defaultParameters().copy(
                free_layers=2,
                bound_layers=1,
                vectors=((2, 0),(0, 2)),
                cell_size=50,
                )
        surface_parameters2 = surface_parameters1.copy(
                free_layers=2,
                bound_layers=1,
                vectors=((2, 0),(0, 3)),
                cell_size=50,
                )
        surface_atoms = surface.atoms(parameters=surface_parameters1)

        atoms = crystal.atoms()
        atoms.cell *= 1.1
        new_crystal = TestRelaxationSystem(crystal, atoms)
        surface = surface.setSubSystems([new_crystal])
        new_surface_atoms = surface.atoms(parameters=surface_parameters1)
        self.assertArraysEqual(new_surface_atoms.cell[:2, :2], surface_atoms.cell[:2,:2]*1.1)
        surface_atoms = new_surface_atoms.copy()
        surface_atoms.rattle(0.2)

        new_surface = TestRelaxationSystem(surface, surface_atoms)
        self.assertTrue(new_surface.isRelaxed())
        atoms = new_surface.atoms(parameters=surface_parameters2)
        positions = [[ -1.38723744e+00 ,-4.16171232e+00 ,-1.96185000e+00],
                     [  1.38723744e+00 ,-4.16171232e+00 ,-1.96185000e+00],
                     [ -1.38723744e+00 ,-1.38723744e+00 ,-1.96185000e+00],
                     [  1.38723744e+00 ,-1.38723744e+00 ,-1.96185000e+00],
                     [ -1.38723744e+00 , 1.38723744e+00 ,-1.96185000e+00],
                     [  1.38723744e+00 , 1.38723744e+00 ,-1.96185000e+00],
                     [ -1.33884498e+00 ,-3.15713093e+00 ,-1.32590857e+00],
                     [  1.27477993e+00 ,-2.97704110e+00 ,-9.18075533e-01],
                     [ -1.56884225e+00 ,-2.82460740e-01 ,-6.87795246e-01],
                     [  1.34208218e+00 , 1.35056409e-02 ,-1.26587464e+00],
                     [ -1.33884498e+00 , 2.39181883e+00 ,-1.32590857e+00],
                     [  1.27477993e+00 , 2.57190865e+00 ,-9.18075533e-01],
                     [ -2.88335142e+00 ,-2.75229036e+00 ,-2.30198715e-01],
                     [  7.51396037e-02 ,-2.89460262e+00 ,-5.83387500e-02],
                     [ -2.89481620e+00 , 3.70455637e-01 ,-2.69944495e-03],
                     [ -2.11542186e-01 , 1.64508982e-01 ,-2.44168730e-01],
                     [ -2.88335142e+00 , 2.79665940e+00 ,-2.30198715e-01],
                     [  7.51396037e-02 , 2.65434714e+00 ,-5.83387500e-02],
                     [ -1.27164335e+00 ,-3.80576182e+00 , 1.07759060e+00],
                     [  1.38199234e+00 ,-3.83766884e+00 , 1.58471945e+00],
                     [ -1.20674098e+00 ,-1.36300023e+00 , 1.10765779e+00],
                     [  1.56533343e+00 ,-8.23372891e-01 , 1.40756866e+00],
                     [ -1.27164335e+00 , 1.74318793e+00 , 1.07759060e+00],
                     [  1.38199234e+00 , 1.71128092e+00 , 1.58471945e+00]]
        exp_atoms = Atoms('C18H6', positions)
        self.assertAtomsEqual(exp_atoms, atoms)
Beispiel #2
0
    def testCalculate(self):
        crystal = SiAlpha
        atoms = crystal.atoms()
        atoms.cell *= 1.5
        store = atoms.copy()
        new_crystal = TestRelaxationSystem(crystal, atoms)
        atoms = new_crystal.atoms()

        self.assertArraysEqual(store.cell, atoms.cell)
    def testRelaxation(self):
        defect = Cross2DBDefect('Si', initial_state=AFM)
        defect_parameters = defect.defaultParameters().copy(
                                      free_layers=0,
                                      bound_layers=1,
                                      vectors=((2,0),(0,3)),
                                      cell_size=50,
                )
        surface_parameters = defect.surface().defaultParameters().copy(
                free_layers=0,
                bound_layers=1,
                vectors=((2, 0),(0, 2)),
                cell_size=50,
                )

        self.assertFalse(defect.isRelaxed())
        surface = defect.surface()
        crystal = surface.crystal()
        atoms = crystal.atoms()
        atoms.cell *= 1.1
        relaxation = atoms
        rcrystal = TestRelaxationSystem(crystal, relaxation)
        surface = surface.setSubSystems([rcrystal])
        atoms = surface.atoms(parameters=defect_parameters)
        atoms.rattle(0.2)
        rsurface = TestRelaxationSystem(surface, relaxation)

        atoms = surface.atoms(parameters=surface_parameters)
        defect = defect.setSubSystems([rsurface])
        self.assertTrue(defect.hasRelaxedSubsystems())
        self.assertTrue(defect.surface().isRelaxed())

        self.assertFalse(defect.isRelaxed())
        self.assertTrue(defect.hasRelaxedSubsystems())

        atoms3 = defect.atoms(parameters=defect_parameters)
        atoms3.rattle(0.1)
        relaxed_defect = TestRelaxationSystem(defect, atoms3)
        atoms4 = relaxed_defect.atoms(parameters=defect_parameters)

        expected = [[-7.85928, -4.43554, -4.23354],
                    [-5.23613, -4.43554, -4.23354],
                    [-3.63496, -4.43554, -4.23354],
                    [-1.0118 , -4.43554, -4.23354],
                    [0.58937 , -4.43554, -4.23354],
                    [3.21253 , -4.43554, -4.23354],
                    [4.8137  , -4.43554, -4.23354],
                    [7.43685 , -4.43554, -4.23354],
                    [-7.85928, -0.21122, -4.23354],
                    [-5.23613, -0.21122, -4.23354],
                    [-3.63496, -0.21122, -4.23354],
                    [-1.0118 , -0.21122, -4.23354],
                    [0.58937 , -0.21122, -4.23354],
                    [3.21253 , -0.21122, -4.23354],
                    [4.8137  , -0.21122, -4.23354],
                    [7.43685 , -0.21122, -4.23354],
                    [-7.85928, 4.01311 , -4.23354],
                    [-5.23613, 4.01311 , -4.23354],
                    [-3.63496, 4.01311 , -4.23354],
                    [-1.0118 , 4.01311 , -4.23354],
                    [0.58937 , 4.01311 , -4.23354],
                    [3.21253 , 4.01311 , -4.23354],
                    [4.8137  , 4.01311 , -4.23354],
                    [7.43685 , 4.01311 , -4.23354],
                    [-6.54771, -4.43554, -3.21618],
                    [-2.32338, -4.43554, -3.21618],
                    [1.90095 , -4.43554, -3.21618],
                    [6.12527 , -4.43554, -3.21618],
                    [-6.54771, -0.21122, -3.21618],
                    [-2.32338, -0.21122, -3.21618],
                    [1.90095 , -0.21122, -3.21618],
                    [6.12527 , -0.21122, -3.21618],
                    [-6.54771, 4.01311 , -3.21618],
                    [-2.32338, 4.01311 , -3.21618],
                    [1.90095 , 4.01311 , -3.21618],
                    [6.63777 , 4.52561 , -3.21618],
                    [-7.29651, -6.55515, -2.05506],
                    [-1.55147, -6.54168, -1.61686],
                    [1.10715 , -6.51755, -1.86665],
                    [6.78297 , -6.43342, -1.78799],
                    [-6.86063, -3.16873, -1.71815],
                    [-1.10581, -3.01911, -1.63938],
                    [1.02733 , -2.38001, -1.85321],
                    [6.84949 , -2.47845, -1.85632],
                    [-7.4285 , 1.94831 , -1.95512],
                    [-1.39382, 1.82262 , -1.89539],
                    [1.20774 , 1.77786 , -1.84043],
                    [7.03055 , 1.7402  , -1.84472],
                    [-6.69238, -6.46952, -0.41608],
                    [-2.28476, -6.49551, -0.26268],
                    [1.75533 , -6.51306, -0.36038],
                    [6.31916 , -6.5184 , -0.36382],
                    [-6.53179, -2.276  , -0.41151],
                    [-2.08706, -2.42085, -0.21367],
                    [6.4118  , -2.40545, -0.19604],
                    [-6.67709, 1.98315 , -0.1027 ],
                    [1.70574 , 1.82557 , -0.38133],
                    [6.21436 , 1.89324 , -0.25826]]

        self.assertArraysEqual(expected, atoms4.positions)
Beispiel #4
0
    def testRelaxation(self):
        surface = Si001
        surface_parameters1 = surface.defaultParameters().copy(
                free_layers=0,
                bound_layers=1,
                vectors=((2, 0),(0, 2)),
                cell_size=50,
                )
        surface_parameters2 = surface_parameters1.copy(
                free_layers=0,
                bound_layers=1,
                vectors=((2, 0),(0, 4)),
                cell_size=50,
                )
        atoms = surface.atoms(parameters=surface_parameters1)
        crystal = surface.crystal()
        atoms = crystal.atoms()
        atoms.cell *= 1.1
        relaxation = atoms
        rcrystal = TestRelaxationSystem(crystal, relaxation)
        atoms = surface.atoms(parameters=surface_parameters1)
        surface = surface.setSubSystems([rcrystal])
        self.assertTrue(surface.hasRelaxedSubsystems())
        self.assertFalse(surface.isRelaxed())

        atoms = surface.atoms(parameters=surface_parameters1)
        atoms.rattle(0.2)
        surface = TestRelaxationSystem(surface, atoms)

        atoms2 = surface.atoms(parameters=surface_parameters1)
        self.assertAtomsEqual(atoms, atoms2)
        atoms3 = surface.atoms(parameters=surface_parameters2)

        expected = [[-7.24595, -8.42647, -1.24756],
                    [-5.46077, -8.56878, -1.0757 ],
                    [-3.03309, -8.0782 , -1.02006],
                    [-1.52312, -8.28414, -1.26153],
                    [1.35335 , -8.84059, -1.283  ],
                    [2.95212 , -8.30096, -0.98309],
                    [5.51278 , -8.50887, -1.31307],
                    [6.99311 , -8.54078, -0.80594],
                    [-7.03773, -4.25198, -0.88783],
                    [-5.2313 , -4.27116, -1.06419],
                    [-2.59691, -4.07084, -1.11126],
                    [-1.20307, -4.31701, -1.11051],
                    [1.35997 , -4.60698, -1.36235],
                    [2.80029 , -4.42689, -0.95451],
                    [5.3543  , -4.50679, -0.72423],
                    [7.09192 , -4.21082, -1.30231],
                    [-7.24595, 0.02218 , -1.24756],
                    [-5.46077, -0.12013, -1.0757 ],
                    [-3.03309, 0.37046 , -1.02006],
                    [-1.52312, 0.16451 , -1.26153],
                    [1.35335 , -0.39193, -1.283  ],
                    [2.95212 , 0.14769 , -0.98309],
                    [5.51278 , -0.06022, -1.31307],
                    [6.99311 , -0.09213, -0.80594],
                    [-7.03773, 4.19667 , -0.88783],
                    [-5.2313 , 4.1775  , -1.06419],
                    [-2.59691, 4.37781 , -1.11126],
                    [-1.20307, 4.13164 , -1.11051],
                    [1.35997 , 3.84167 , -1.36235],
                    [2.80029 , 4.02176 , -0.95451],
                    [5.3543  , 3.94187 , -0.72423],
                    [7.09192 , 4.23783 , -1.30231],
                    [-8.44865, -8.44865, 0.0     ],
                    [-4.22433, -8.44865, 0.0     ],
                    [0.0     , -8.44865, 0.0     ],
                    [4.22433 , -8.44865, 0.0     ],
                    [-8.44865, -4.22433, 0.0     ],
                    [-4.22433, -4.22433, 0.0     ],
                    [0.0     , -4.22433, 0.0     ],
                    [4.22433 , -4.22433, 0.0     ],
                    [-8.44865, 0.0     , 0.0     ],
                    [-4.22433, 0.0     , 0.0     ],
                    [0.0     , 0.0     , 0.0     ],
                    [4.22433 , 0.0     , 0.0     ],
                    [-8.44865, 4.22433 , 0.0     ],
                    [-4.22433, 4.22433 , 0.0     ],
                    [0.0     , 4.22433 , 0.0     ],
                    [4.22433 , 4.22433 , 0.0     ],
                    [-7.83579, -6.43684, 1.53608 ],
                    [-4.93314, -6.44244, 1.45565 ],
                    [0.79398 , -6.14276, 1.21259 ],
                    [3.38423 , -6.41491, 1.0603  ],
                    [-7.68126, -1.79923, 0.82905 ],
                    [-4.83451, -2.09475, 1.2932  ],
                    [0.79292 , -2.50968, 1.30907 ],
                    [3.52119 , -1.81658, 1.24935 ],
                    [-7.83579, 2.01181 , 1.53608 ],
                    [-4.93314, 2.00621 , 1.45565 ],
                    [0.79398 , 2.30589 , 1.21259 ],
                    [3.38423 , 2.03374 , 1.0603  ],
                    [-7.68126, 6.64942 , 0.82905 ],
                    [-4.83451, 6.3539  , 1.2932  ],
                    [0.79292 , 5.93898 , 1.30907 ],
                    [3.52119 , 6.63207 , 1.24935 ],
                    [-8.22648, -6.35138, 2.54005 ],
                    [-4.40029, -6.32444, 3.41645 ],
                    [0.13219 , -6.27618, 2.91686 ],
                    [3.81993 , -6.10793, 3.07419 ],
                    [-8.21877, -2.05995, 2.92482 ],
                    [-4.44191, -2.39524, 2.83967 ],
                    [0.10212 , -2.27262, 2.89154 ],
                    [4.13447 , -1.73493, 2.95872 ],
                    [-8.22648, 2.09727 , 2.54005 ],
                    [-4.40029, 2.12421 , 3.41645 ],
                    [0.13219 , 2.17247 , 2.91686 ],
                    [3.81993 , 2.34073 , 3.07419 ],
                    [-8.21877, 6.3887  , 2.92482 ],
                    [-4.44191, 6.05342 , 2.83967 ],
                    [0.10212 , 6.17603 , 2.89154 ],
                    [4.13447 , 6.71373 , 2.95872 ]]


        self.assertArraysEqual(expected, atoms3.positions)