예제 #1
0
def generate_lammps_input(calc,
                          parameters,
                          potential_obj,
                          structure_filename,
                          trajectory_filename,
                          add_thermo_keywords,
                          version_date='11 Aug 2017',
                          **kwargs):

    lammps_input_file = 'units          {0}\n'.format(
        potential_obj.default_units)
    lammps_input_file += 'boundary        p p p\n'
    lammps_input_file += 'box tilt large\n'
    lammps_input_file += 'atom_style      {0}\n'.format(
        potential_obj.atom_style)

    lammps_input_file += 'read_data       {}\n'.format(structure_filename)

    lammps_input_file += potential_obj.get_input_potential_lines()

    lammps_input_file += 'neighbor        0.3 bin\n'
    lammps_input_file += 'neigh_modify    every 1 delay 0 check no\n'

    thermo_keywords = ["step", "temp", "epair", "emol", "etotal", "press"]
    for kwd in add_thermo_keywords:
        if kwd not in thermo_keywords:
            thermo_keywords.append(kwd)
    lammps_input_file += 'thermo_style custom {}\n'.format(
        " ".join(thermo_keywords))

    if potential_obj.atom_style == 'charge':
        dump_variables = "element x y z fx fy fz q"
        dump_format = "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f %16.10f"
    else:
        dump_variables = "element x y z fx fy fz"
        dump_format = "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f"

    lammps_input_file += 'dump            aiida all custom 1 {0} {1}\n'.format(
        trajectory_filename, dump_variables)

    # TODO find exact version when changes were made
    if version_date <= convert_date_string('10 Feb 2015'):
        dump_mod_cmnd = "format"
    else:
        dump_mod_cmnd = "format line"

    lammps_input_file += 'dump_modify     aiida {0} "{1}"\n'.format(
        dump_mod_cmnd, dump_format)

    lammps_input_file += 'dump_modify     aiida sort id\n'
    lammps_input_file += 'dump_modify     aiida element {}\n'.format(' '.join(
        potential_obj.kind_elements))

    lammps_input_file += 'run             0\n'

    variables = parameters.get_attribute("output_variables", [])
    for var in variables:
        var_alias = var.replace("[", "_").replace("]", "_")
        lammps_input_file += 'variable {0} equal {1}\n'.format(var_alias, var)
        lammps_input_file += 'print "final_variable: {0} = ${{{0}}}"\n'.format(
            var_alias)

    lammps_input_file += 'variable final_energy equal etotal\n'
    lammps_input_file += 'print "final_energy: ${final_energy}"\n'

    return lammps_input_file
예제 #2
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):

        pdict = parameter_data.get_dict()
        version_date = convert_date_string(pdict.get("lammps_version", "11 Aug 2017"))
        lammps_input_file = ""

        lammps_input_file += "# Input written to comply with LAMMPS {}\n".format(
            version_date
        )

        # Configuration setup
        lammps_input_file += "\n# Atomic Configuration\n"
        lammps_input_file += "units           {0}\n".format(
            potential_data.default_units
        )
        lammps_input_file += "boundary        p p p\n"  # TODO allow non-periodic
        lammps_input_file += "box tilt large\n"
        lammps_input_file += "atom_style      {0}\n".format(potential_data.atom_style)
        lammps_input_file += "read_data       {}\n".format(structure_filename)

        # Potential specification
        lammps_input_file += "\n# Potential Setup\n"
        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        # Create groups

        groups = pdict.get("groups", {})
        if len(groups) > 0:
            lammps_input_file += "\n# Groups setup\n"

        for group in groups:  # TODO: Complete all group styles
            id = group.get("id")
            style = group.get("style")

            for bool_style in ["clear", "delete", "empty"]:
                if style.get(bool_style, False):
                    lammps_input_file += "group {0} {1}\n".format(id, bool_style)
                    break

            for attribute_style in ["id", "type", "molecule"]:
                if values := style.get(attribute_style, False):
                    str_vals = " ".join([str(i) for i in values])
                    lammps_input_file += "group {0} {1} {2}\n".format(
                        id, attribute_style, str_vals
                    )
                    break

            for attribute_style in ["include"]:
                if style.get(attribute_style, False):
                    lammps_input_file += "group {0} include molecule\n".format(id)
                    break

            for attribute_style in ["subtract", "union", "intersect"]:
                if style.get(attribute_style, False):
                    raise NotImplementedError()
예제 #3
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):

        parameter_data = parameter_data.get_dict()
        version_date = convert_date_string(
            parameter_data.get("lammps_version", "11 Aug 2017"))

        lammps_input_file = "units          {0}\n".format(
            potential_data.default_units)
        lammps_input_file += "boundary        p p p\n"
        lammps_input_file += "box tilt large\n"
        lammps_input_file += "atom_style      {0}\n".format(
            potential_data.atom_style)
        lammps_input_file += "read_data       {}\n".format(structure_filename)

        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        lammps_input_file += "fix             int all box/relax {} {} {}\n".format(
            parameter_data["relax"]["type"],
            parameter_data["relax"]["pressure"],
            join_keywords(parameter_data["relax"], ignore=["type",
                                                           "pressure"]),
        )

        # TODO find exact version when changes were made
        if version_date <= convert_date_string("11 Nov 2013"):
            lammps_input_file += "compute         stpa all stress/atom\n"
        else:
            lammps_input_file += "compute         stpa all stress/atom NULL\n"

        lammps_input_file += "compute         stgb all reduce sum c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]\n"
        lammps_input_file += (
            "variable        stress_pr equal -(c_stgb[1]+c_stgb[2]+c_stgb[3])/(3*vol)\n"
        )
        # lammps_input_file += "variable        stress_xx equal c_stgb[1]\n"
        # lammps_input_file += "variable        stress_yy equal c_stgb[2]\n"
        # lammps_input_file += "variable        stress_zz equal c_stgb[3]\n"
        # lammps_input_file += "variable        stress_xy equal c_stgb[4]\n"
        # lammps_input_file += "variable        stress_xz equal c_stgb[5]\n"
        # lammps_input_file += "variable        stress_yz equal c_stgb[6]\n"

        thermo_keywords = [
            "step",
            "temp",
            "press",
            "etotal",
            "v_stress_pr",
            # "c_stgb[1]",
            # "c_stgb[2]",
            # "c_stgb[3]",
            # "c_stgb[4]",
            # "c_stgb[5]",
            # "c_stgb[6]",
        ]
        for kwd in parameter_data.get("thermo_keywords", []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += "thermo_style custom {}\n".format(
            " ".join(thermo_keywords))

        if potential_data.atom_style == "charge":
            dump_variables = "element x y z  fx fy fz q c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]"
            dump_format = "%4s " + " ".join(["%16.10f"] * 13)
        else:
            dump_variables = "element x y z  fx fy fz c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]"
            dump_format = "%4s " + " ".join(["%16.10f"] * 12)

        dump_rate = parameter_data["minimize"].get("dump_rate", 1_000_000)

        lammps_input_file += "dump            aiida all custom {0} {1} {2}\n".format(
            dump_rate, trajectory_filename, dump_variables)

        # TODO find exact version when changes were made
        if version_date <= convert_date_string("10 Feb 2015"):
            dump_mod_cmnd = "format"
        else:
            dump_mod_cmnd = "format line"

        lammps_input_file += 'dump_modify     aiida {0} "{1}"\n'.format(
            dump_mod_cmnd, dump_format)

        lammps_input_file += "dump_modify     aiida sort id\n"
        lammps_input_file += "dump_modify     aiida element {}\n".format(
            " ".join(kind_symbols))
        lammps_input_file += "min_style       {}\n".format(
            parameter_data["minimize"]["style"])
        # lammps_input_file += 'min_style       cg\n'
        lammps_input_file += "minimize        {} {} {} {}\n".format(
            parameter_data["minimize"]["energy_tolerance"],
            parameter_data["minimize"]["force_tolerance"],
            parameter_data["minimize"]["max_iterations"],
            parameter_data["minimize"]["max_evaluations"],
        )

        variables = parameter_data.get("output_variables", [])
        for var in variables:
            var_alias = var.replace("[", "_").replace("]", "_")
            lammps_input_file += "variable {0} equal {1}\n".format(
                var_alias, var)
            lammps_input_file += 'print "final_variable: {0} = ${{{0}}}"\n'.format(
                var_alias)

        lammps_input_file += "variable final_energy equal etotal\n"
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        # lammps_input_file += 'print "final_variable: stress_pr = ${stress_pr}"\n'
        # lammps_input_file += 'print "final_cell: $(xlo) $(xhi) $(xy) $(ylo) $(yhi) $(xz) $(zlo) $(zhi) $(yz)"\n'
        # lammps_input_file += 'print "final_stress: ${stress_xx} ${stress_yy} ${stress_zz} ${stress_xy} ${stress_xz} ${stress_yz}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #4
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):

        version_date = convert_date_string(
            parameter_data.get_attribute("lammps_version", "11 Aug 2017"))

        lammps_input_file = "units          {0}\n".format(
            potential_data.default_units)
        lammps_input_file += "boundary        p p p\n"
        lammps_input_file += "box tilt large\n"
        lammps_input_file += "atom_style      {0}\n".format(
            potential_data.atom_style)

        lammps_input_file += "read_data       {}\n".format(structure_filename)

        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        lammps_input_file += "neighbor        0.3 bin\n"
        lammps_input_file += "neigh_modify    every 1 delay 0 check no\n"

        thermo_keywords = ["step", "temp", "epair", "emol", "etotal", "press"]
        for kwd in parameter_data.get_attribute("thermo_keywords", []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += "thermo_style custom {}\n".format(
            " ".join(thermo_keywords))

        if potential_data.atom_style == "charge":
            dump_variables = "element x y z fx fy fz q"
            dump_format = (
                "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f %16.10f"
            )
        else:
            dump_variables = "element x y z fx fy fz"
            dump_format = "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f"

        lammps_input_file += "dump            aiida all custom 1 {0} {1}\n".format(
            trajectory_filename, dump_variables)

        # TODO find exact version when changes were made
        if version_date <= convert_date_string("10 Feb 2015"):
            dump_mod_cmnd = "format"
        else:
            dump_mod_cmnd = "format line"

        lammps_input_file += 'dump_modify     aiida {0} "{1}"\n'.format(
            dump_mod_cmnd, dump_format)

        lammps_input_file += "dump_modify     aiida sort id\n"
        lammps_input_file += "dump_modify     aiida element {}\n".format(
            " ".join(kind_symbols))

        lammps_input_file += "run             0\n"

        variables = parameter_data.get_attribute("output_variables", [])
        for var in variables:
            var_alias = var.replace("[", "_").replace("]", "_")
            lammps_input_file += "variable {0} equal {1}\n".format(
                var_alias, var)
            lammps_input_file += 'print "final_variable: {0} = ${{{0}}}"\n'.format(
                var_alias)

        lammps_input_file += "variable final_energy equal etotal\n"
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #5
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):
        # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements

        pdict = parameter_data.get_dict()
        version_date = convert_date_string(
            pdict.get('lammps_version', '11 Aug 2017'))
        lammps_input_file = ''

        lammps_input_file += f'# Input written to comply with LAMMPS {version_date}\n'

        # Configuration setup
        lammps_input_file += '\n# Atomic Configuration\n'
        lammps_input_file += f'units           {potential_data.default_units}\n'
        lammps_input_file += 'boundary        p p p\n'  # TODO allow non-periodic
        lammps_input_file += 'box tilt large\n'
        lammps_input_file += f'atom_style      {potential_data.atom_style}\n'
        lammps_input_file += f'read_data       {structure_filename}\n'

        # Potential specification
        lammps_input_file += '\n# Potential Setup\n'
        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        # Modify pairwise neighbour list creation
        lammps_input_file += '\n# General Setup\n'
        if 'neighbor' in pdict:
            # neighbor skin_dist bin/nsq/multi
            lammps_input_file += f'neighbor {pdict["neighbor"][0]} {pdict["neighbor"][1]}\n'
        if 'neigh_modify' in pdict:
            # e.g. 'neigh_modify every 1 delay 0 check no\n'
            lammps_input_file += f'neigh_modify {join_keywords(pdict["neigh_modify"])}\n'
        # Define Timestep
        lammps_input_file += f'timestep        {pdict["timestep"]}\n'

        # Define computation/printing of thermodynamic info
        lammps_input_file += '\n# Thermodynamic Information Output\n'
        thermo_keywords = ['step', 'temp', 'epair', 'emol', 'etotal', 'press']
        for kwd in pdict.get('thermo_keywords', []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += f'thermo_style custom {" ".join(thermo_keywords)}\n'
        lammps_input_file += 'thermo          1000\n'  # TODO make variable?

        # Setup initial velocities of atoms
        if 'velocity' in pdict:
            lammps_input_file += '\n# Intial Atom Velocity\n'
        for vdict in pdict.get('velocity', []):
            lammps_input_file += f'velocity all {vdict["style"]} '
            lammps_input_file += f'{" ".join([str(a) for a in vdict["args"]])} '
            lammps_input_file += f'{join_keywords(vdict.get("keywords", {}))}\n'

        stage_names = []
        current_fixes = []
        current_dumps = []
        current_computes = []

        for stage_id, stage_dict in enumerate(pdict.get('stages')):

            stage_name = stage_dict.get('name')
            if stage_name in stage_names:
                raise ValueError(f'non-unique stage name: {stage_name}')
            stage_names.append(stage_name)

            lammps_input_file += f'\n# Stage {stage_id}: {stage_name}\n'

            # clear timestep
            # lammps_input_file += "reset_timestep  0\n"

            # Clear fixes, dumps and computes
            for fix in current_fixes:
                lammps_input_file += f'unfix {fix}\n'
            current_fixes = []
            for dump in current_dumps:
                lammps_input_file += f'undump {dump}\n'
            current_dumps = []
            for compute in current_computes:
                lammps_input_file += f'uncompute {compute}\n'
            current_computes = []

            # Define Computes
            for compute in stage_dict.get('computes', []):
                c_id = compute['id']
                c_style = compute['style']
                c_args = ' '.join([str(a) for a in compute.get('args', [])])
                lammps_input_file += f'compute         {c_id} all {c_style} {c_args}\n'
                current_computes.append(c_id)

            # Define Atom Level Outputs
            output_atom_dict = stage_dict.get('output_atom', {})
            if output_atom_dict.get('dump_rate', 0):
                atom_dump_cmnds, acomputes, afixes = atom_info_commands(
                    variables=output_atom_dict.get('variables', []),
                    ave_variables=output_atom_dict.get('ave_variables', []),
                    kind_symbols=kind_symbols,
                    atom_style=potential_data.atom_style,
                    dump_rate=output_atom_dict.get('dump_rate', 0),
                    average_rate=output_atom_dict.get('average_rate', 1),
                    filename='{}-{}'.format(stage_name, trajectory_filename),
                    version_date=version_date,
                    dump_name='atom_info',
                )
                if atom_dump_cmnds:
                    lammps_input_file += '\n'.join(atom_dump_cmnds) + '\n'
                    current_dumps.append('atom_info')
                current_computes.extend(acomputes)
                current_fixes.extend(afixes)

            # Define System Level Outputs
            output_sys_dict = stage_dict.get('output_system', {})
            if output_sys_dict.get('dump_rate', 0):
                sys_info_cmnds = sys_ave_commands(
                    variables=output_sys_dict.get('variables', []),
                    ave_variables=output_sys_dict.get('ave_variables', []),
                    dump_rate=output_sys_dict.get('dump_rate', 0),
                    filename='{}-{}'.format(stage_name, system_filename),
                    fix_name='sys_info',
                    average_rate=output_sys_dict.get('average_rate', 1),
                )
                if sys_info_cmnds:
                    lammps_input_file += '\n'.join(sys_info_cmnds) + '\n'
                    current_fixes.append('sys_info')

            # Define restart
            if stage_dict.get('restart_rate', 0):
                lammps_input_file += 'restart         '
                lammps_input_file += f'{stage_dict.get("restart_rate", 0)} '
                lammps_input_file += f'{"{}-{}".format(stage_name, restart_filename)}\n'
            else:
                lammps_input_file += 'restart         0\n'

            # Define time integration method
            lammps_input_file += 'fix             int all '
            lammps_input_file += f'{get_path(stage_dict, ["integration", "style"])} '
            _temp = join_keywords(
                get_path(
                    stage_dict,
                    ['integration', 'constraints'],
                    {},
                    raise_error=False,
                ))
            lammps_input_file += f'{_temp} '
            _temp = join_keywords(
                get_path(stage_dict, ['integration', 'keywords'], {},
                         raise_error=False))
            lammps_input_file += f'{_temp}\n'
            current_fixes.append('int')

            # Run
            lammps_input_file += f'run             {stage_dict.get("steps", 0)}\n'

            # check compute/fix/dump ids are unique
            if len(current_computes) != len(set(current_computes)):
                raise ValueError(
                    f'Stage {stage_name}: Non-unique compute ids; {current_computes}'
                )
            if len(current_fixes) != len(set(current_fixes)):
                raise ValueError(
                    f'Stage {stage_name}: Non-unique fix ids; {current_fixes}')
            if len(current_dumps) != len(set(current_dumps)):
                raise ValueError(
                    f'Stage {stage_name}: Non-unique dump ids; {current_dumps}'
                )

        lammps_input_file += '\n# Final Commands\n'
        # output final energy
        lammps_input_file += 'variable final_energy equal etotal\n'
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #6
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):
        # pylint: disable=too-many-locals, too-many-arguments¸ too-many-branches, too-many-statements, duplicate-code
        pdict = parameter_data.get_dict()
        version_date = convert_date_string(
            pdict.get('lammps_version', '11 Aug 2017'))

        # Geometry Setup
        lammps_input_file = f'units           {potential_data.default_units}\n'
        lammps_input_file += 'boundary        p p p\n'
        lammps_input_file += 'box tilt large\n'
        lammps_input_file += f'atom_style      {potential_data.atom_style}\n'
        lammps_input_file += f'read_data       {structure_filename}\n'

        # Potential Specification
        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        # Pairwise neighbour list creation
        if 'neighbor' in pdict:
            # neighbor skin_dist bin/nsq/multi
            lammps_input_file += f'neighbor {pdict["neighbor"][0]} {pdict["neighbor"][1]}\n'
        if 'neigh_modify' in pdict:
            # e.g. 'neigh_modify every 1 delay 0 check no\n'
            lammps_input_file += f'neigh_modify {join_keywords(pdict["neigh_modify"])}\n'
        # Define Timestep
        lammps_input_file += f'timestep        {pdict["timestep"]}\n'

        # Define computation/printing of thermodynamic info
        thermo_keywords = ['step', 'temp', 'epair', 'emol', 'etotal', 'press']
        for kwd in pdict.get('thermo_keywords', []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += f'thermo_style custom {" ".join(thermo_keywords)}\n'
        lammps_input_file += 'thermo          1000\n'

        # Define output of restart file
        restart = pdict.get('restart', False)
        if restart:
            lammps_input_file += f'restart        {restart} {restart_filename}\n'

        # Set the initial velocities of atoms, if a temperature is set
        initial_temp, _, _ = get_path(
            pdict,
            ['integration', 'constraints', 'temp'],
            default=[None, None, None],
            raise_error=False,
        )
        if initial_temp is not None:
            lammps_input_file += f'velocity        all create {initial_temp} '
            lammps_input_file += f'{pdict.get("rand_seed", np.random.randint(10000000))} '
            lammps_input_file += 'dist gaussian mom yes\n'
            lammps_input_file += f'velocity        all scale {initial_temp}\n'

        # Define Equilibration Stage
        lammps_input_file += 'fix             int all '
        lammps_input_file += f'{get_path(pdict, ["integration", "style"])} '
        _temp = join_keywords(
            get_path(
                pdict,
                ['integration', 'constraints'],
                {},
                raise_error=False,
            ))
        lammps_input_file += f'{_temp} '
        _temp = join_keywords(
            get_path(
                pdict,
                ['integration', 'keywords'],
                {},
                raise_error=False,
            ))
        lammps_input_file += f'{_temp}\n'

        lammps_input_file += f'run             {parameter_data.dict.equilibrium_steps}\n'
        lammps_input_file += 'reset_timestep  0\n'

        if potential_data.atom_style == 'charge':
            dump_variables = 'element x y z q'
            dump_format = '%4s  %16.10f %16.10f %16.10f %16.10f'
        else:
            dump_variables = 'element x y z'
            dump_format = '%4s  %16.10f %16.10f %16.10f'

        lammps_input_file += 'dump            aiida all custom '
        lammps_input_file += f'{parameter_data.dict.dump_rate} '
        lammps_input_file += f'{trajectory_filename} {dump_variables}\n'

        # TODO find exact version when changes were made
        if version_date <= convert_date_string('10 Feb 2015'):
            dump_mod_cmnd = 'format'
        else:
            dump_mod_cmnd = 'format line'

        lammps_input_file += f'dump_modify     aiida {dump_mod_cmnd} "{dump_format}"\n'
        lammps_input_file += 'dump_modify     aiida sort id\n'
        lammps_input_file += f'dump_modify     aiida element {" ".join(kind_symbols)}\n'

        variables = pdict.get('output_variables', [])
        if variables and 'step' not in variables:
            # always include 'step', so we can sync with the `dump` data
            # NOTE `dump` includes step 0, whereas `print` starts from step 1
            variables.append('step')
        var_aliases = []
        for var in variables:
            var_alias = var.replace('[', '_').replace(']', '_')
            var_aliases.append(var_alias)
            lammps_input_file += f'variable {var_alias} equal {var}\n'
        if variables:
            lammps_input_file += 'fix sys_info all print'
            lammps_input_file += f' {parameter_data.dict.dump_rate}'
            lammps_input_file += f' "{" ".join(["${{{0}}}".format(v) for v in var_aliases])}"'
            lammps_input_file += f' title "{" ".join(var_aliases)}"'
            lammps_input_file += f' file {system_filename} screen no\n'

        lammps_input_file += f'run             {parameter_data.dict.total_steps}\n'

        lammps_input_file += 'variable final_energy equal etotal\n'
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #7
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):

        pdict = parameter_data.get_dict()
        version_date = convert_date_string(pdict.get("lammps_version", "11 Aug 2017"))
        lammps_input_file = ""

        lammps_input_file += "# Input written to comply with LAMMPS {}\n".format(
            version_date
        )

        # Configuration setup
        lammps_input_file += "\n# Atomic Configuration\n"
        lammps_input_file += "units           {0}\n".format(
            potential_data.default_units
        )
        lammps_input_file += "boundary        p p p\n"  # TODO allow non-periodic
        lammps_input_file += "box tilt large\n"
        lammps_input_file += "atom_style      {0}\n".format(potential_data.atom_style)
        lammps_input_file += "read_data       {}\n".format(structure_filename)

        # Potential specification
        lammps_input_file += "\n# Potential Setup\n"
        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        # Modify pairwise neighbour list creation
        lammps_input_file += "\n# General Setup\n"
        if "neighbor" in pdict:
            # neighbor skin_dist bin/nsq/multi
            lammps_input_file += "neighbor {0} {1}\n".format(
                pdict["neighbor"][0], pdict["neighbor"][1]
            )
        if "neigh_modify" in pdict:
            # e.g. 'neigh_modify every 1 delay 0 check no\n'
            lammps_input_file += "neigh_modify {}\n".format(
                join_keywords(pdict["neigh_modify"])
            )
        # Define Timestep
        lammps_input_file += "timestep        {}\n".format(pdict["timestep"])

        # Define computation/printing of thermodynamic info
        lammps_input_file += "\n# Thermodynamic Information Output\n"
        thermo_keywords = ["step", "temp", "epair", "emol", "etotal", "press"]
        for kwd in pdict.get("thermo_keywords", []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += "thermo_style custom {}\n".format(
            " ".join(thermo_keywords)
        )
        lammps_input_file += "thermo          1000\n"  # TODO make variable?

        # Setup initial velocities of atoms
        if "velocity" in pdict:
            lammps_input_file += "\n# Intial Atom Velocity\n"
        for vdict in pdict.get("velocity", []):
            lammps_input_file += "velocity all {0} {1} {2}\n".format(
                vdict["style"],
                " ".join([str(a) for a in vdict["args"]]),
                join_keywords(vdict.get("keywords", {})),
            )

        stage_names = []
        current_fixes = []
        current_dumps = []
        current_computes = []

        for stage_id, stage_dict in enumerate(pdict.get("stages")):

            stage_name = stage_dict.get("name")
            if stage_name in stage_names:
                raise ValueError("non-unique stage name: {}".format(stage_name))
            stage_names.append(stage_name)

            lammps_input_file += "\n# Stage {}: {}\n".format(stage_id, stage_name)

            # clear timestep
            # lammps_input_file += "reset_timestep  0\n"

            # Clear fixes, dumps and computes
            for fix in current_fixes:
                lammps_input_file += "unfix {}\n".format(fix)
            current_fixes = []
            for dump in current_dumps:
                lammps_input_file += "undump {}\n".format(dump)
            current_dumps = []
            for compute in current_computes:
                lammps_input_file += "uncompute {}\n".format(compute)
            current_computes = []

            # Define Computes
            for compute in stage_dict.get("computes", []):
                c_id = compute["id"]
                c_style = compute["style"]
                c_args = " ".join([str(a) for a in compute.get("args", [])])
                lammps_input_file += "compute         {0} all {1} {2}\n".format(
                    c_id, c_style, c_args
                )
                current_computes.append(c_id)

            # Define Atom Level Outputs
            output_atom_dict = stage_dict.get("output_atom", {})
            if output_atom_dict.get("dump_rate", 0):
                atom_dump_cmnds, acomputes, afixes = atom_info_commands(
                    variables=output_atom_dict.get("variables", []),
                    ave_variables=output_atom_dict.get("ave_variables", []),
                    kind_symbols=kind_symbols,
                    atom_style=potential_data.atom_style,
                    dump_rate=output_atom_dict.get("dump_rate", 0),
                    average_rate=output_atom_dict.get("average_rate", 1),
                    filename="{}-{}".format(stage_name, trajectory_filename),
                    version_date=version_date,
                    dump_name="atom_info",
                )
                if atom_dump_cmnds:
                    lammps_input_file += "\n".join(atom_dump_cmnds) + "\n"
                    current_dumps.append("atom_info")
                current_computes.extend(acomputes)
                current_fixes.extend(afixes)

            # Define System Level Outputs
            output_sys_dict = stage_dict.get("output_system", {})
            if output_sys_dict.get("dump_rate", 0):
                sys_info_cmnds = sys_ave_commands(
                    variables=output_sys_dict.get("variables", []),
                    ave_variables=output_sys_dict.get("ave_variables", []),
                    dump_rate=output_sys_dict.get("dump_rate", 0),
                    filename="{}-{}".format(stage_name, system_filename),
                    fix_name="sys_info",
                    average_rate=output_sys_dict.get("average_rate", 1),
                )
                if sys_info_cmnds:
                    lammps_input_file += "\n".join(sys_info_cmnds) + "\n"
                    current_fixes.append("sys_info")

            # Define restart
            if stage_dict.get("restart_rate", 0):
                lammps_input_file += "restart         {0} {1}\n".format(
                    stage_dict.get("restart_rate", 0),
                    "{}-{}".format(stage_name, restart_filename),
                )
            else:
                lammps_input_file += "restart         0\n"

            # Define time integration method
            lammps_input_file += "fix             int all {0} {1} {2}\n".format(
                get_path(stage_dict, ["integration", "style"]),
                join_keywords(
                    get_path(
                        stage_dict,
                        ["integration", "constraints"],
                        {},
                        raise_error=False,
                    )
                ),
                join_keywords(
                    get_path(
                        stage_dict, ["integration", "keywords"], {}, raise_error=False
                    )
                ),
            )
            current_fixes.append("int")

            # Run
            lammps_input_file += "run             {}\n".format(
                stage_dict.get("steps", 0)
            )

            # check compute/fix/dump ids are unique
            if len(current_computes) != len(set(current_computes)):
                raise ValueError(
                    "Stage {}: Non-unique compute ids; {}".format(
                        stage_name, current_computes
                    )
                )
            if len(current_fixes) != len(set(current_fixes)):
                raise ValueError(
                    "Stage {}: Non-unique fix ids; {}".format(stage_name, current_fixes)
                )
            if len(current_dumps) != len(set(current_dumps)):
                raise ValueError(
                    "Stage {}: Non-unique dump ids; {}".format(
                        stage_name, current_dumps
                    )
                )

        lammps_input_file += "\n# Final Commands\n"
        # output final energy
        lammps_input_file += "variable final_energy equal etotal\n"
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #8
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):
        # pylint: disable=too-many-arguments, too-many-locals
        version_date = convert_date_string(
            parameter_data.get_attribute('lammps_version', '11 Aug 2017'))

        lammps_input_file = f'units          {potential_data.default_units}\n'
        lammps_input_file += 'boundary        p p p\n'
        lammps_input_file += 'box tilt large\n'
        lammps_input_file += f'atom_style      {potential_data.atom_style}\n'

        lammps_input_file += f'read_data       {structure_filename}\n'

        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        lammps_input_file += 'neighbor        0.3 bin\n'
        lammps_input_file += 'neigh_modify    every 1 delay 0 check no\n'

        thermo_keywords = ['step', 'temp', 'epair', 'emol', 'etotal', 'press']
        for kwd in parameter_data.get_attribute('thermo_keywords', []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += f'thermo_style custom {" ".join(thermo_keywords)}\n'

        if potential_data.atom_style == 'charge':
            dump_variables = 'element x y z fx fy fz q'
            dump_format = (
                '%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f %16.10f'
            )
        else:
            dump_variables = 'element x y z fx fy fz'
            dump_format = '%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f'

        lammps_input_file += 'dump            aiida all custom 1'
        lammps_input_file += f' {trajectory_filename} {dump_variables}\n'

        # TODO find exact version when changes were made
        if version_date <= convert_date_string('10 Feb 2015'):
            dump_mod_cmnd = 'format'
        else:
            dump_mod_cmnd = 'format line'

        lammps_input_file += f'dump_modify     aiida {dump_mod_cmnd} "{dump_format}"\n'

        lammps_input_file += 'dump_modify     aiida sort id\n'
        lammps_input_file += f'dump_modify     aiida element {" ".join(kind_symbols)}\n'

        lammps_input_file += 'run             0\n'

        variables = parameter_data.get_attribute('output_variables', [])
        for var in variables:
            var_alias = var.replace('[', '_').replace(']', '_')
            lammps_input_file += f'variable {var_alias} equal {var}\n'
            lammps_input_file += f'print "final_variable: {var_alias} = ${{{var_alias}}}"\n'

        lammps_input_file += 'variable final_energy equal etotal\n'
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #9
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):
        # pylint: disable=too-many-locals, too-many-arguments, too-many-statements

        parameter_data = parameter_data.get_dict()
        version_date = convert_date_string(
            parameter_data.get('lammps_version', '11 Aug 2017'))

        lammps_input_file = f'units          {potential_data.default_units}\n'
        lammps_input_file += 'boundary        p p p\n'
        lammps_input_file += 'box tilt large\n'
        lammps_input_file += f'atom_style      {potential_data.atom_style}\n'
        lammps_input_file += f'read_data       {structure_filename}\n'

        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        lammps_input_file += 'fix             int all box/relax'
        lammps_input_file += f' {parameter_data["relax"]["type"]}'
        lammps_input_file += f' {parameter_data["relax"]["pressure"]}'
        _temp = join_keywords(parameter_data['relax'],
                              ignore=['type', 'pressure'])
        lammps_input_file += f' {_temp}\n'

        # TODO find exact version when changes were made
        if version_date <= convert_date_string('11 Nov 2013'):
            lammps_input_file += 'compute         stpa all stress/atom\n'
        else:
            lammps_input_file += 'compute         stpa all stress/atom NULL\n'

        lammps_input_file += 'compute         stgb all reduce sum '
        lammps_input_file += 'c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]\n'
        lammps_input_file += (
            'variable        stress_pr equal -(c_stgb[1]+c_stgb[2]+c_stgb[3])/(3*vol)\n'
        )

        thermo_keywords = [
            'step',
            'temp',
            'press',
            'etotal',
            'v_stress_pr',
        ]
        for kwd in parameter_data.get('thermo_keywords', []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += f'thermo_style custom {" ".join(thermo_keywords)}\n'

        if potential_data.atom_style == 'charge':
            dump_variables = 'element x y z  fx fy fz q'
            dump_variables += ' c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]'
            dump_format = '%4s ' + ' '.join(['%16.10f'] * 13)
        else:
            dump_variables = 'element x y z  fx fy fz'
            dump_variables += ' c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]'
            dump_format = '%4s ' + ' '.join(['%16.10f'] * 12)

        lammps_input_file += 'dump            aiida all custom 1 '
        lammps_input_file += f'{trajectory_filename} {dump_variables}\n'

        # TODO find exact version when changes were made
        if version_date <= convert_date_string('10 Feb 2015'):
            dump_mod_cmnd = 'format'
        else:
            dump_mod_cmnd = 'format line'

        lammps_input_file += f'dump_modify     aiida {dump_mod_cmnd} "{dump_format}"\n'

        lammps_input_file += 'dump_modify     aiida sort id\n'
        lammps_input_file += f'dump_modify     aiida element {" ".join(kind_symbols)}\n'
        lammps_input_file += f'min_style       {parameter_data["minimize"]["style"]}\n'
        # lammps_input_file += 'min_style       cg\n'
        lammps_input_file += 'minimize        '
        lammps_input_file += f'{parameter_data["minimize"]["energy_tolerance"]} '
        lammps_input_file += f'{parameter_data["minimize"]["force_tolerance"]} '
        lammps_input_file += f'{parameter_data["minimize"]["max_iterations"]} '
        lammps_input_file += f'{parameter_data["minimize"]["max_evaluations"]}\n'

        variables = parameter_data.get('output_variables', [])
        for var in variables:
            var_alias = var.replace('[', '_').replace(']', '_')
            lammps_input_file += f'variable {var_alias} equal {var}\n'
            lammps_input_file += f'print "final_variable: {var_alias} = ${{{var_alias}}}"\n'

        lammps_input_file += 'variable final_energy equal etotal\n'
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #10
0
def generate_lammps_input(calc, parameters, potential_obj, structure_filename,
                          trajectory_filename, add_thermo_keywords,
                          version_date, **kwargs):

    parameters = parameters.get_dict()

    # lammps_date = convert_date_string(parameters.get("lammps_version", None))

    lammps_input_file = 'units          {0}\n'.format(
        potential_obj.default_units)
    lammps_input_file += 'boundary        p p p\n'
    lammps_input_file += 'box tilt large\n'
    lammps_input_file += 'atom_style      {0}\n'.format(
        potential_obj.atom_style)
    lammps_input_file += 'read_data       {}\n'.format(structure_filename)

    lammps_input_file += potential_obj.get_input_potential_lines()

    lammps_input_file += 'fix             int all box/relax {} {} {}\n'.format(
        parameters['relax']['type'], parameters['relax']['pressure'],
        join_keywords(parameters['relax'], ignore=['type', 'pressure']))

    # TODO find exact version when changes were made
    if version_date <= convert_date_string('11 Nov 2013'):
        lammps_input_file += 'compute         stpa all stress/atom\n'
    else:
        lammps_input_file += 'compute         stpa all stress/atom NULL\n'

        #  xx,       yy,        zz,       xy,       xz,       yz
    lammps_input_file += 'compute         stgb all reduce sum c_stpa[1] c_stpa[2] c_stpa[3] c_stpa[4] c_stpa[5] c_stpa[6]\n'
    lammps_input_file += 'variable        pr equal -(c_stgb[1]+c_stgb[2]+c_stgb[3])/(3*vol)\n'
    lammps_input_file += 'variable        stress_xx equal c_stgb[1]\n'
    lammps_input_file += 'variable        stress_yy equal c_stgb[2]\n'
    lammps_input_file += 'variable        stress_zz equal c_stgb[3]\n'
    lammps_input_file += 'variable        stress_xy equal c_stgb[4]\n'
    lammps_input_file += 'variable        stress_xz equal c_stgb[5]\n'
    lammps_input_file += 'variable        stress_yz equal c_stgb[6]\n'

    thermo_keywords = [
        "step", "temp", "press", "v_pr", "etotal", "c_stgb[1]", "c_stgb[2]",
        "c_stgb[3]", "c_stgb[4]", "c_stgb[5]", "c_stgb[6]"
    ]
    for kwd in add_thermo_keywords:
        if kwd not in thermo_keywords:
            thermo_keywords.append(kwd)
    lammps_input_file += 'thermo_style custom {}\n'.format(
        " ".join(thermo_keywords))

    if potential_obj.atom_style == 'charge':
        dump_variables = "element x y z  fx fy fz q"
        dump_format = "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f %16.10f"
    else:
        dump_variables = "element x y z  fx fy fz"
        dump_format = "%4s  %16.10f %16.10f %16.10f  %16.10f %16.10f %16.10f"

    lammps_input_file += 'dump            aiida all custom 1 {0} {1}\n'.format(
        trajectory_filename, dump_variables)

    # TODO find exact version when changes were made
    if version_date <= convert_date_string('10 Feb 2015'):
        dump_mod_cmnd = "format"
    else:
        dump_mod_cmnd = "format line"

    lammps_input_file += 'dump_modify     aiida {0} "{1}"\n'.format(
        dump_mod_cmnd, dump_format)

    lammps_input_file += 'dump_modify     aiida sort id\n'
    lammps_input_file += 'dump_modify     aiida element {}\n'.format(' '.join(
        potential_obj.kind_elements))
    lammps_input_file += 'min_style       {}\n'.format(
        parameters['minimize']['style'])
    # lammps_input_file += 'min_style       cg\n'
    lammps_input_file += 'minimize        {} {} {} {}\n'.format(
        parameters['minimize']['energy_tolerance'],
        parameters['minimize']['force_tolerance'],
        parameters['minimize']['max_iterations'],
        parameters['minimize']['max_evaluations'])

    variables = parameters.get("output_variables", [])
    for var in variables:
        var_alias = var.replace("[", "_").replace("]", "_")
        lammps_input_file += 'variable {0} equal {1}\n'.format(var_alias, var)
        lammps_input_file += 'print "final_variable: {0} = ${{{0}}}"\n'.format(
            var_alias)

    lammps_input_file += 'variable final_energy equal etotal\n'
    lammps_input_file += 'print "final_energy: ${final_energy}"\n'

    lammps_input_file += 'print "final_cell: $(xlo) $(xhi) $(xy) $(ylo) $(yhi) $(xz) $(zlo) $(zhi) $(yz)"\n'
    lammps_input_file += 'print "final_stress: ${stress_xx} ${stress_yy} ${stress_zz} ${stress_xy} ${stress_xz} ${stress_yz}"\n'

    return lammps_input_file
예제 #11
0
    def create_main_input_content(
        parameter_data,
        potential_data,
        kind_symbols,
        structure_filename,
        trajectory_filename,
        system_filename,
        restart_filename,
    ):

        pdict = parameter_data.get_dict()
        version_date = convert_date_string(
            pdict.get("lammps_version", "11 Aug 2017"))

        # Geometry Setup
        lammps_input_file = "units           {0}\n".format(
            potential_data.default_units)
        lammps_input_file += "boundary        p p p\n"
        lammps_input_file += "box tilt large\n"
        lammps_input_file += "atom_style      {0}\n".format(
            potential_data.atom_style)
        lammps_input_file += "read_data       {}\n".format(structure_filename)

        # Potential Specification
        lammps_input_file += potential_data.get_input_lines(kind_symbols)

        # Pairwise neighbour list creation
        if "neighbor" in pdict:
            # neighbor skin_dist bin/nsq/multi
            lammps_input_file += "neighbor {0} {1}\n".format(
                pdict["neighbor"][0], pdict["neighbor"][1])
        if "neigh_modify" in pdict:
            # e.g. 'neigh_modify every 1 delay 0 check no\n'
            lammps_input_file += "neigh_modify {}\n".format(
                join_keywords(pdict["neigh_modify"]))

        # Define Timestep
        lammps_input_file += "timestep        {}\n".format(pdict["timestep"])

        # Define computation/printing of thermodynamic info
        thermo_keywords = ["step", "temp", "epair", "emol", "etotal", "press"]
        for kwd in pdict.get("thermo_keywords", []):
            if kwd not in thermo_keywords:
                thermo_keywords.append(kwd)
        lammps_input_file += "thermo_style custom {}\n".format(
            " ".join(thermo_keywords))
        lammps_input_file += "thermo          1000\n"

        # Define output of restart file
        restart = pdict.get("restart", False)
        if restart:
            lammps_input_file += "restart        {0} {1}\n".format(
                restart, restart_filename)

        # Set the initial velocities of atoms, if a temperature is set
        initial_temp, _, _ = get_path(
            pdict,
            ["integration", "constraints", "temp"],
            default=[None, None, None],
            raise_error=False,
        )
        if initial_temp is not None:
            lammps_input_file += (
                "velocity        all create {0} {1} dist gaussian mom yes\n".
                format(initial_temp,
                       pdict.get("rand_seed", np.random.randint(10000000))))
            lammps_input_file += "velocity        all scale {}\n".format(
                initial_temp)

        # Define Equilibration Stage
        lammps_input_file += "fix             int all {0} {1} {2}\n".format(
            get_path(pdict, ["integration", "style"]),
            join_keywords(
                get_path(pdict, ["integration", "constraints"], {},
                         raise_error=False)),
            join_keywords(
                get_path(pdict, ["integration", "keywords"], {},
                         raise_error=False)),
        )

        lammps_input_file += "run             {}\n".format(
            parameter_data.dict.equilibrium_steps)
        lammps_input_file += "reset_timestep  0\n"

        if potential_data.atom_style == "charge":
            dump_variables = "element x y z q"
            dump_format = "%4s  %16.10f %16.10f %16.10f %16.10f"
        else:
            dump_variables = "element x y z"
            dump_format = "%4s  %16.10f %16.10f %16.10f"

        lammps_input_file += "dump            aiida all custom {0} {1} {2}\n".format(
            parameter_data.dict.dump_rate, trajectory_filename, dump_variables)

        # TODO find exact version when changes were made
        if version_date <= convert_date_string("10 Feb 2015"):
            dump_mod_cmnd = "format"
        else:
            dump_mod_cmnd = "format line"

        lammps_input_file += 'dump_modify     aiida {0} "{1}"\n'.format(
            dump_mod_cmnd, dump_format)
        lammps_input_file += "dump_modify     aiida sort id\n"
        lammps_input_file += "dump_modify     aiida element {}\n".format(
            " ".join(kind_symbols))

        variables = pdict.get("output_variables", [])
        if variables and "step" not in variables:
            # always include 'step', so we can sync with the `dump` data
            # NOTE `dump` includes step 0, whereas `print` starts from step 1
            variables.append("step")
        var_aliases = []
        for var in variables:
            var_alias = var.replace("[", "_").replace("]", "_")
            var_aliases.append(var_alias)
            lammps_input_file += "variable {0} equal {1}\n".format(
                var_alias, var)
        if variables:
            lammps_input_file += 'fix sys_info all print {0} "{1}" title "{2}" file {3} screen no\n'.format(
                parameter_data.dict.dump_rate,
                " ".join(["${{{0}}}".format(v) for v in var_aliases]),
                " ".join(var_aliases),
                system_filename,
            )

        lammps_input_file += "run             {}\n".format(
            parameter_data.dict.total_steps)

        lammps_input_file += "variable final_energy equal etotal\n"
        lammps_input_file += 'print "final_energy: ${final_energy}"\n'

        lammps_input_file += 'print "END_OF_COMP"\n'

        return lammps_input_file
예제 #12
0
    def prepare_for_submission(self, tempfolder):
        """Create the input files from the input nodes passed to this instance of the `CalcJob`.

        :param tempfolder: an `aiida.common.folders.Folder` to temporarily write files on disk
        :return: `aiida.common.CalcInfo` instance
        """
        # assert that the potential and structure have the same kind elements
        if [k.symbol for k in self.inputs.structure.kinds] != self.inputs.potential.kind_elements:
            raise ValidationError("the structure and potential are not compatible (different kind elements)")

        # Setup potential
        potential_txt = self.inputs.potential.get_potential_file()

        # Setup structure
        structure_txt, struct_transform = generate_lammps_structure(
            self.inputs.structure, self.inputs.potential.atom_style)

        with open(tempfolder.get_abs_path(self.options.cell_transform_filename), 'w+b') as handle:
            np.save(handle, struct_transform)

        if "parameters" in self.inputs:
            parameters = self.inputs.parameters
        else:
            parameters = Dict()
        pdict = parameters.get_dict()

        # Check lammps version date in parameters
        lammps_date = convert_date_string(
            pdict.get("lammps_version", '11 Aug 2017'))

        # Setup input parameters
        input_txt = self._generate_input_function(
            parameters=parameters,
            potential_obj=self.inputs.potential,
            structure_filename=self._INPUT_STRUCTURE,
            trajectory_filename=self.options.trajectory_name,
            info_filename=self.options.info_filename,
            restart_filename=self.options.restart_filename,
            add_thermo_keywords=pdict.get("thermo_keywords", []),
            version_date=lammps_date)

        input_filename = tempfolder.get_abs_path(self._INPUT_FILE_NAME)

        with open(input_filename, 'w') as infile:
            infile.write(input_txt)

        self.validate_parameters(parameters, self.inputs.potential)

        # prepare extra files if needed
        self.prepare_extra_files(tempfolder, self.inputs.potential)

        # =========================== dump to file =============================

        structure_filename = tempfolder.get_abs_path(self._INPUT_STRUCTURE)
        with open(structure_filename, 'w') as infile:
            infile.write(structure_txt)

        if potential_txt is not None:
            potential_filename = tempfolder.get_abs_path(
                self.inputs.potential.potential_filename)
            with open(potential_filename, 'w') as infile:
                infile.write(potential_txt)

        # ============================ calcinfo ================================

        codeinfo = CodeInfo()
        codeinfo.cmdline_params = self._cmdline_params
        codeinfo.code_uuid = self.inputs.code.uuid
        codeinfo.withmpi = False  # Set lammps openmpi environment properly
        codeinfo.stdout_name = self._stdout_name

        calcinfo = CalcInfo()
        calcinfo.uuid = self.uuid
        calcinfo.retrieve_list = self._retrieve_list + [
            self.options.output_filename,
            self.options.cell_transform_filename]
        calcinfo.retrieve_temporary_list = self._retrieve_temporary_list
        calcinfo.codes_info = [codeinfo]

        return calcinfo