def test_rotation(self):
        for make_atoms, calc in [ 
#            ( lambda a0,x : 
#              FaceCenteredCubic('He', size=[1,1,1],
#                                latticeconstant=3.5 if a0 is None else a0,
#                                directions=x),
#              LJCut(epsilon=10.2, sigma=2.28, cutoff=5.0, shift=True) ),
            ( lambda a0,x : FaceCenteredCubic('Au', size=[1,1,1],
                                              latticeconstant=a0, directions=x),
              EAM('Au-Grochola-JCP05.eam.alloy') ),
#            ( lambda a0,x : Diamond('Si', size=[1,1,1], latticeconstant=a0,
#                                    directions=x),
#              Kumagai() )
            #( lambda a0,x : FaceCenteredCubic('Au', size=[1,1,1],
            #                                  latticeconstant=a0, directions=x),
            #  EAM(potential='Au-Grochola-JCP05.eam.alloy') ),
            ]:

            a = make_atoms(None, [[1,0,0], [0,1,0], [0,0,1]])
            a.set_calculator(calc)
            FIRE(StrainFilter(a, mask=[1,1,1,0,0,0]), logfile=None) \
                .run(fmax=self.fmax)
            latticeconstant = np.mean(a.cell.diagonal())

            C6 = measure_triclinic_elastic_constants(a, delta=self.delta,
                                                     fmax=self.fmax)
            C11, C12, C44 = Voigt_6x6_to_cubic(C6)/GPa

            el = CubicElasticModuli(C11, C12, C44)

            C_m = measure_triclinic_elastic_constants(a, delta=self.delta,
                                                      fmax=self.fmax)/GPa
            self.assertArrayAlmostEqual(el.stiffness(), C_m, tol=0.01)

            for directions in [ [[1,0,0], [0,1,0], [0,0,1]],
                                [[0,1,0], [0,0,1], [1,0,0]],
                                [[1,1,0], [0,0,1], [1,-1,0]],
                                [[1,1,1], [-1,-1,2], [1,-1,0]] ]:
                a, b, c = directions

                directions = np.array([ np.array(x)/np.linalg.norm(x) 
                                        for x in directions ])
                a = make_atoms(latticeconstant, directions)
                a.set_calculator(calc)

                C = el.rotate(directions)
                C_check = el._rotate_explicit(directions)
                C_check2 = rotate_cubic_elastic_constants(C11, C12, C44,
                                                          directions)
                C_check3 = \
                    rotate_elastic_constants(cubic_to_Voigt_6x6(C11, C12, C44),
                                             directions)
                self.assertArrayAlmostEqual(C, C_check, tol=1e-6)
                self.assertArrayAlmostEqual(C, C_check2, tol=1e-6)
                self.assertArrayAlmostEqual(C, C_check3, tol=1e-6)

                C_m = measure_triclinic_elastic_constants(a, delta=self.delta,
                                                          fmax=self.fmax)/GPa

                self.assertArrayAlmostEqual(C, C_m, tol=1e-2)
Ejemplo n.º 2
0
 def test_measure_triclinic_relaxed(self):
     # compare to brute force method with relaxation
     C = measure_triclinic_elastic_constants(self.at0,
                                             delta=1e-2,
                                             optimizer=FIRE,
                                             fmax=self.fmax)
     self.assertArrayAlmostEqual(C / units.GPa,
                                 self.C_ref_relaxed,
                                 tol=0.2)
Ejemplo n.º 3
0
if hasattr(params, 'relax_bulk') and params.relax_bulk:
    print('Minimising bulk unit cell...')
    opt = FIRE(StrainFilter(a, mask=[1, 1, 1, 0, 0, 0]))
    opt.run(fmax=params.bulk_fmax)

a0 = a.cell[0, 0]
print('Lattice constant %.3f A\n' % a0)

a.set_calculator(params.calc)

# ******* Find elastic constants *******

# Get 6x6 matrix of elastic constants C_ij
C = measure_triclinic_elastic_constants(a,
                                        optimizer=FIRE,
                                        fmax=params.bulk_fmax)
print('Elastic constants (GPa):')
print((C / units.GPa).round(0))
print('')

E = youngs_modulus(C, params.cleavage_plane)
print('Young\'s modulus %.1f GPa' % (E / units.GPa))
nu = poisson_ratio(C, params.cleavage_plane, params.crack_direction)
print('Poisson ratio % .3f\n' % nu)

# **** Setup crack slab unit cell ******

directions = [
    params.crack_direction, params.cleavage_plane, params.crack_front
]
Ejemplo n.º 4
0
a.set_calculator(params.calc)

if hasattr(params, 'relax_bulk') and params.relax_bulk:
    print('Minimising bulk unit cell...')
    opt = FIRE(StrainFilter(a, mask=[1, 1, 1, 0, 0, 0]))
    opt.run(fmax=params.bulk_fmax)
    
a0 = a.cell[0, 0]
print('Lattice constant %.3f A\n' % a0)

a.set_calculator(params.calc)

# ******* Find elastic constants *******

# Get 6x6 matrix of elastic constants C_ij
C = measure_triclinic_elastic_constants(a, optimizer=FIRE,
                                        fmax=params.bulk_fmax)
print('Elastic constants (GPa):')
print((C / units.GPa).round(0))
print('')

E = youngs_modulus(C, params.cleavage_plane)
print('Young\'s modulus %.1f GPa' % (E / units.GPa))
nu = poisson_ratio(C, params.cleavage_plane, params.crack_direction)
print('Poisson ratio % .3f\n' % nu)

# **** Setup crack slab unit cell ******

directions = [params.crack_direction,
              params.cleavage_plane,
              params.crack_front]
print_crack_system(directions)
Ejemplo n.º 5
0
 def test_measure_triclinic_relaxed(self):
     # compare to brute force method with relaxation            
     C = measure_triclinic_elastic_constants(self.at0, delta=1e-2, optimizer=FIRE,
                                             fmax=self.fmax)
     self.assertArrayAlmostEqual(C/units.GPa, self.C_ref_relaxed, tol=0.2)