Example #1
0
    def test_elastic_constants_lammpslib(self):
        """Test the get_elastic_constants() function using lammpslib.

        If lammps crashes, check "lammps.log" file in the tests directory
        See lammps and ASE documentation on how to make lammpslib work
        """
        print("WARNING: In case lammps crashes no error message is printed: ",
              "check 'lammps.log' file in test folder")
        target_values = np.array([
            3.14339177996466,  # alat
            523.0266819809012,  # C11
            202.1786296941397,  # C12
            160.88179872237012
        ])  # C44 for eam4

        pot_name = "w_eam4.fs"

        lammps = LAMMPSlib(
            lmpcmds=["pair_style eam/fs",
                     "pair_coeff * * %s W" % pot_name],
            atom_types={'W': 1},
            keep_alive=True,
            log_file="lammps.log")

        obtained_values = sd.get_elastic_constants(calculator=lammps,
                                                   delta=1.0e-3)

        os.remove("lammps.log")

        self.assertArrayAlmostEqual(obtained_values, target_values, tol=1e-4)
Example #2
0
    def test_elastic_constants_EAM(self):
        """Test the get_elastic_constants() function using matscipy EAM calculator."""
        target_values = np.array([
            3.14339177996466,  # alat
            523.0266819809012,  # C11
            202.1786296941397,  # C12
            160.88179872237012
        ])  # C44 for eam4

        pot_name = "w_eam4.fs"
        calc_EAM = EAM(pot_name)
        obtained_values = sd.get_elastic_constants(calculator=calc_EAM,
                                                   delta=1.0e-3)

        self.assertArrayAlmostEqual(obtained_values, target_values, tol=1e-4)