示例#1
0
    def _get_potential_data(pkey):
        """return data to create a potential,
        and accompanying structure data and expected output data to test it with
        """
        if pkey == "eam":
            pair_style = "eam"
            with io.open(os.path.join(TEST_DIR, "input_files",
                                      "Fe_mm.eam.fs")) as handle:
                potential_dict = {
                    "type": "fs",
                    "file_contents": handle.readlines(),
                    "element_names": ["Fe"],
                }
            structure = get_structure_data("Fe")
            output_dict = {"initial_energy": -8.2441284, "energy": -8.2448702}

        elif pkey == "lennard-jones":

            structure = get_structure_data("Ar")

            # Example LJ parameters for Argon. These may not be accurate at all
            pair_style = "lennard_jones"
            potential_dict = {
                "1  1": "0.01029   3.4    3.5",
                # '2  2':   '1.0      1.0    2.5',
                # '1  2':   '1.0      1.0    2.5'
            }

            output_dict = {
                "initial_energy": 0.0,
                "energy": 0.0,  # TODO should LJ energy be 0?
            }

        elif pkey == "tersoff":

            structure = get_structure_data("GaN")

            potential_dict = {
                "Ga Ga Ga":
                "1.0 0.007874 1.846 1.918000 0.75000 -0.301300 1.0 1.0 1.44970 410.132 2.87 0.15 1.60916 535.199",
                "N  N  N":
                "1.0 0.766120 0.000 0.178493 0.20172 -0.045238 1.0 1.0 2.38426 423.769 2.20 0.20 3.55779 1044.77",
                "Ga Ga N":
                "1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 0.0 0.00000 0.00000 2.90 0.20 0.00000 0.00000",
                "Ga N  N":
                "1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 1.0 2.63906 3864.27 2.90 0.20 2.93516 6136.44",
                "N  Ga Ga":
                "1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 1.0 2.63906 3864.27 2.90 0.20 2.93516 6136.44",
                "N  Ga N ":
                "1.0 0.766120 0.000 0.178493 0.20172 -0.045238 1.0 0.0 0.00000 0.00000 2.20 0.20 0.00000 0.00000",
                "N  N  Ga":
                "1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 0.0 0.00000 0.00000 2.90 0.20 0.00000 0.00000",
                "Ga N  Ga":
                "1.0 0.007874 1.846 1.918000 0.75000 -0.301300 1.0 0.0 0.00000 0.00000 2.87 0.15 0.00000 0.00000",
            }

            pair_style = "tersoff"

            output_dict = {"initial_energy": -18.109886, "energy": -18.110852}

        elif pkey == "reaxff":

            from aiida_lammps.common.reaxff_convert import (
                filter_by_species,
                read_lammps_format,
            )

            pair_style = "reaxff"
            with io.open(
                    os.path.join(TEST_DIR, "input_files",
                                 "FeCrOSCH.reaxff")) as handle:
                potential_dict = read_lammps_format(
                    handle.read().splitlines(), tolerances={"hbonddist": 7.0})
                potential_dict = filter_by_species(potential_dict,
                                                   ["Fe core", "S core"])
                for n in ["anglemin", "angleprod", "hbondmin", "torsionprod"]:
                    potential_dict["global"].pop(n)
                potential_dict["control"] = {"safezone": 1.6}
                # potential_dict = {
                #     "file_contents": handle.readlines(),
                #     "control": {"safezone": 1.6},
                #     "global": {"hbonddist": 7.0},
                # }

            structure = get_structure_data("pyrite")

            output_dict = {
                "initial_energy": -1027.9739,
                "energy": -1030.3543,
                "units": "real",
            }

        else:
            raise ValueError("Unknown potential key: {}".format(pkey))

        return potential_data(pair_style, potential_dict, structure,
                              output_dict)
示例#2
0
    def _get_potential_data(pkey):
        """return data to create a potential,
        and accompanying structure data and expected output data to test it with
        """
        if pkey == 'eam':
            pair_style = 'eam'
            filename = os.path.join(
                TEST_DIR,
                'input_files',
                'potentials',
                'Fe_mm.eam.fs',
            )
            with io.open(filename) as handle:
                potential_dict = {
                    'type': 'fs',
                    'file_contents': handle.readlines(),
                    'element_names': ['Fe'],
                }
            structure = get_structure_data('Fe')
            output_dict = {'initial_energy': -8.2441284, 'energy': -8.2448702}

        elif pkey == 'lennard-jones':

            structure = get_structure_data('Ar')

            # Example LJ parameters for Argon. These may not be accurate at all
            pair_style = 'lennard_jones'
            potential_dict = {
                '1  1': '0.01029   3.4    3.5',
            }

            output_dict = {
                'initial_energy': 0.0,
                'energy': 0.0,  # TODO should LJ energy be 0?
            }

        elif pkey == 'tersoff':

            structure = get_structure_data('GaN')

            potential_dict = {
                'Ga Ga Ga':
                '1.0 0.007874 1.846 1.918000 0.75000 -0.301300 '+\
                    '1.0 1.0 1.44970 410.132 2.87 0.15 1.60916 535.199',
                'N  N  N':
                '1.0 0.766120 0.000 0.178493 0.20172 -0.045238 '+\
                    '1.0 1.0 2.38426 423.769 2.20 0.20 3.55779 1044.77',
                'Ga Ga N':
                '1.0 0.001632 0.000 65.20700 2.82100 -0.518000 '+\
                    '1.0 0.0 0.00000 0.00000 2.90 0.20 0.00000 0.00000',
                'Ga N  N':
                '1.0 0.001632 0.000 65.20700 2.82100 -0.518000 '+\
                    '1.0 1.0 2.63906 3864.27 2.90 0.20 2.93516 6136.44',
                'N  Ga Ga':
                '1.0 0.001632 0.000 65.20700 2.82100 -0.518000 '+\
                    '1.0 1.0 2.63906 3864.27 2.90 0.20 2.93516 6136.44',
                'N  Ga N ':
                '1.0 0.766120 0.000 0.178493 0.20172 -0.045238 '+\
                    '1.0 0.0 0.00000 0.00000 2.20 0.20 0.00000 0.00000',
                'N  N  Ga':
                '1.0 0.001632 0.000 65.20700 2.82100 -0.518000 '+\
                    '1.0 0.0 0.00000 0.00000 2.90 0.20 0.00000 0.00000',
                'Ga N  Ga':
                '1.0 0.007874 1.846 1.918000 0.75000 -0.301300 '+\
                    '1.0 0.0 0.00000 0.00000 2.87 0.15 0.00000 0.00000',
            }

            pair_style = 'tersoff'

            output_dict = {'initial_energy': -18.109886, 'energy': -18.110852}

        elif pkey == 'reaxff':

            pair_style = 'reaxff'
            filename = os.path.join(
                TEST_DIR,
                'input_files',
                'potentials',
                'FeCrOSCH.reaxff',
            )
            with io.open(filename) as handle:
                potential_dict = read_lammps_format(
                    handle.read().splitlines(),
                    tolerances={'hbonddist': 7.0},
                )
                potential_dict = filter_by_species(
                    potential_dict,
                    ['Fe core', 'S core'],
                )
                for name in [
                        'anglemin', 'angleprod', 'hbondmin', 'torsionprod'
                ]:
                    potential_dict['global'].pop(name)
                potential_dict['control'] = {'safezone': 1.6}

            structure = get_structure_data('pyrite')

            output_dict = {
                'initial_energy': -1027.9739,
                'energy': -1030.3543,
                'units': 'real',
            }

        else:
            raise ValueError(f'Unknown potential key: {pkey}')

        return PotentialData(
            pair_style,
            potential_dict,
            structure,
            output_dict,
        )
示例#3
0
def test_round_trip_lammps_format2(file_regression):
    """Check that one can write the reaxff potential in the second format"""
    data = read_lammps_format(lammps_file2.splitlines())
    output = write_lammps_format(data)
    file_regression.check(output)
示例#4
0
def test_read_lammps_format2(data_regression):
    """Check that the reaxff potential is compatible with the second lammps format"""
    output = read_lammps_format(lammps_file2.splitlines())
    data_regression.check(output)
示例#5
0
def test_round_trip_lammps_format2(file_regression):
    data = read_lammps_format(lammps_file2.splitlines())
    output = write_lammps_format(data)
    file_regression.check(output)
示例#6
0
def test_read_lammps_format2(data_regression):
    output = read_lammps_format(lammps_file2.splitlines())
    data_regression.check(output)