Exemple #1
0
    def test_rotation(self):
        Cs = [
             np.array([
             [165.7, 63.9, 63.9, 0, 0, 0],
             [63.9, 165.7, 63.9, 0, 0, 0],
             [63.9, 63.9, 165.7, 0, 0, 0],
             [0, 0, 0, 79.6, 0, 0],
             [0, 0, 0, 0, 79.6, 0],
             [0, 0, 0, 0, 0, 79.6],
             ])
             ]
        l = [np.array([1, 0, 0]), np.array([1, 1, 0])]
        EM = [
              {'E': np.array([130, 130, 130]),
              'nu': np.array([0.28, 0.28, 0.28]),
              'G': np.array([79.6, 79.6, 79.6])},
              {'E': np.array([169, 169, 130]),
              'nu': np.array([0.36, 0.28, 0.064]),
              'G': np.array([79.6, 79.6, 50.9])}
              ]
        for C in Cs:
            for i, directions in enumerate(l):
                directions = directions/np.linalg.norm(directions)

                E, nu, Gm, B, K = elastic_moduli(C, l=directions)

                nu_v = np.array([nu[1, 2], nu[2, 0], nu[0, 1]])
                G = np.array([Gm[1, 2], Gm[2, 0], Gm[0, 1]])

                self.assertArrayAlmostEqual(E, EM[i]['E'], tol=1e0)
                self.assertArrayAlmostEqual(nu_v, EM[i]['nu'], tol=1e-2)
                self.assertArrayAlmostEqual(G, EM[i]['G'], tol=1e-1)
Exemple #2
0
    def test_rotation(self):
        Cs = [
            np.array([
                [165.7, 63.9, 63.9, 0, 0, 0],
                [63.9, 165.7, 63.9, 0, 0, 0],
                [63.9, 63.9, 165.7, 0, 0, 0],
                [0, 0, 0, 79.6, 0, 0],
                [0, 0, 0, 0, 79.6, 0],
                [0, 0, 0, 0, 0, 79.6],
            ])
        ]
        l = [np.array([1, 0, 0]), np.array([1, 1, 0])]
        EM = [{
            'E': np.array([130, 130, 130]),
            'nu': np.array([0.28, 0.28, 0.28]),
            'G': np.array([79.6, 79.6, 79.6])
        }, {
            'E': np.array([169, 169, 130]),
            'nu': np.array([0.36, 0.28, 0.064]),
            'G': np.array([79.6, 79.6, 50.9])
        }]
        for C in Cs:
            for i, directions in enumerate(l):
                directions = directions / np.linalg.norm(directions)

                E, nu, Gm, B, K = elastic_moduli(C, l=directions)

                nu_v = np.array([nu[1, 2], nu[2, 0], nu[0, 1]])
                G = np.array([Gm[1, 2], Gm[2, 0], Gm[0, 1]])

                self.assertArrayAlmostEqual(E, EM[i]['E'], tol=1e0)
                self.assertArrayAlmostEqual(nu_v, EM[i]['nu'], tol=1e-2)
                self.assertArrayAlmostEqual(G, EM[i]['G'], tol=1e-1)
 def get_elastic_moduli(C, verbosity=0):
     E, nu, G, B, K = el.elastic_moduli(C)
     if verbosity > 1:
         np.set_printoptions(precision=4)
         print("Young\'s modulus E = \n {}".format(E / units.GPa))
         print("Poisson\'s ratio \\nu = \n {}".format(nu))
         print("Shear modulus G = \n {}".format(G / units.GPa))
         print("Bulk modulus B = \n {}".format(B / units.GPa))
         print("Bulk modulus tensor K = \n {}".format(K / units.GPa))
         np.set_printoptions(precision=8)
     return E / units.GPa, nu, G / units.GPa, B / units.GPa, K / units.GPa
                           relax_pos=True,
                           relax_cell=True,
                           tol=1.0e-4,
                           traj_file=None)
    a0 = bulk_at.get_cell_lengths_and_angles()[0] * np.sqrt(2.0)
    bulk_at = bulk("Si", "diamond", a0)

    from matscipy import elasticity
    from ase.optimize import BFGS

    bulk_at.set_calculator(model.calculator)
    opt = BFGS
    b = elasticity.fit_elastic_constants(bulk_at,
                                         symmetry='cubic',
                                         optimizer=opt)
    bulk_modulus = elasticity.elastic_moduli(b[0])[3]

try:
    with open("../model-{}-test-phonon_diamond-properties.json".format(
            model.name)) as f:
        j = json.load(f)

    f0 = j["phonon_diamond_frequencies"]
    bf0 = j["phonon_diamond_band_frequencies"]
    band_distances = j["phonon_diamond_band_distances"]
    weights = j["phonon_diamond_weights"]
except:
    phonon_properties = phonons(model,
                                bulk_at,
                                supercell=supercell,
                                dx=dx,