예제 #1
0
    def generate_calculation_vasp(self,
                                  structure,
                                  parameters,
                                  type='optimize',
                                  pressure=0.0):
        # import pymatgen as mg
        from pymatgen.io import vasp as vaspio

        ParameterData = DataFactory('parameter')

        code = Code.get_from_string(parameters['code'])

        # Set calculation
        calc = code.new_calc(max_wallclock_seconds=3600,
                             resources=parameters['resources'])
        calc.set_withmpi(True)
        calc.label = 'VASP'

        # POSCAR
        calc.use_structure(structure)

        # INCAR
        incar = parameters['parameters']

        if type == 'optimize':
            vasp_input_optimize = dict(incar)
            vasp_input_optimize.update({
                'PREC': 'Accurate',
                'ISTART': 0,
                'IBRION': 2,
                'ISIF': 3,
                'NSW': 100,
                'LWAVE': '.FALSE.',
                'LCHARG': '.FALSE.',
                'EDIFF': 1e-08,
                'EDIFFG': -1e-08,
                'ADDGRID': '.TRUE.',
                'LREAL': '.FALSE.',
                'PSTRESS': pressure
            })  # unit: kb -> kB
            incar = vasp_input_optimize

        if type == 'optimize_constant_volume':
            vasp_input_optimize = dict(incar)
            vasp_input_optimize.update({
                'PREC': 'Accurate',
                'ISTART': 0,
                'IBRION': 2,
                'ISIF': 4,
                'NSW': 100,
                'LWAVE': '.FALSE.',
                'LCHARG': '.FALSE.',
                'EDIFF': 1e-08,
                'EDIFFG': -1e-08,
                'ADDGRID': '.TRUE.',
                'LREAL': '.FALSE.'
            })
            incar = vasp_input_optimize

        if type == 'forces':
            vasp_input_forces = dict(incar)
            vasp_input_forces.update({
                'PREC': 'Accurate',
                'ISYM': 0,
                'ISTART': 0,
                'IBRION': -1,
                'NSW': 1,
                'LWAVE': '.FALSE.',
                'LCHARG': '.FALSE.',
                'EDIFF': 1e-08,
                'ADDGRID': '.TRUE.',
                'LREAL': '.FALSE.'
            })
            incar = vasp_input_forces

        if type == 'born_charges':
            vasp_input_epsilon = dict(incar)
            vasp_input_epsilon.update({
                'PREC': 'Accurate',
                'LEPSILON': '.TRUE.',
                'ISTART': 0,
                'IBRION': 1,
                'NSW': 0,
                'LWAVE': '.FALSE.',
                'LCHARG': '.FALSE.',
                'EDIFF': 1e-08,
                'ADDGRID': '.TRUE.',
                'LREAL': '.FALSE.'
            })
            incar = vasp_input_epsilon

        # KPOINTS
        kpoints = parameters['kpoints']
        if 'kpoints_per_atom' in kpoints:
            kpoints = vaspio.Kpoints.automatic_density(
                structure.get_pymatgen_structure(),
                kpoints['kpoints_per_atom'])
#            num_kpoints = np.product(kpoints.kpts)
#            if num_kpoints < 4:
#                incar['ISMEAR'] = 0
#                incar['SIGMA'] = 0.05

        else:
            if not 'style' in kpoints:
                kpoints['style'] = 'Monkhorst'
            # supported_modes = Enum(("Gamma", "Monkhorst", "Automatic", "Line_mode", "Cartesian", "Reciprocal"))
            kpoints = vaspio.Kpoints(comment='aiida generated',
                                     style=kpoints['style'],
                                     kpts=(kpoints['points'], ),
                                     kpts_shift=kpoints['shift'])

        calc.use_kpoints(ParameterData(dict=kpoints.as_dict()))
        # update incar (just in case something changed with kpoints)
        incar = vaspio.Incar(incar)
        calc.use_incar(ParameterData(dict=incar.as_dict()))

        # POTCAR
        pseudo = parameters['pseudo']
        potcar = vaspio.Potcar(symbols=pseudo['symbols'],
                               functional=pseudo['functional'])
        calc.use_potcar(ParameterData(dict=potcar.as_dict()))

        # Parser settings
        settings = {'PARSER_INSTRUCTIONS': []}
        pinstr = settings['PARSER_INSTRUCTIONS']

        pinstr.append({
            'instr': 'array_data_parser',
            'type': 'data',
            'params': {}
        })
        pinstr.append({
            'instr': 'output_parameters',
            'type': 'data',
            'params': {}
        })

        # additional files to return
        settings.setdefault('ADDITIONAL_RETRIEVE_LIST', [
            'vasprun.xml',
        ])

        calc.use_settings(ParameterData(dict=settings))

        calc.store_all()

        return calc
예제 #2
0
            'ALGO': 38,
            'ISMEAR': 0,
            'SIGMA': 0.01,
            'GGA': 'PS'
        }

        es_settings = ParameterData(dict=incar_dict)

        from pymatgen.io import vasp as vaspio
        #kpoints
        #kpoints_pg = vaspio.Kpoints.monkhorst_automatic(
        #                         kpts=[2, 2, 2],
        #                         shift=[0.0, 0.0, 0.0])
        #kpoints = ParameterData(dict=kpoints_pg.as_dict())

        potcar = vaspio.Potcar(symbols=['Ga', 'N'], functional='PBE')

        settings_dict = {
            'code': 'vasp541mpi@boston',
            'parameters': incar_dict,
            'kpoints_per_atom': 1000,  # k-point density
            'pseudos': potcar.as_dict()
        }

        # pseudos = ParameterData(dict=potcar.as_dict())
        es_settings = ParameterData(dict=settings_dict)

    # QE SPECIFIC
    if False:
        parameters_dict = {
            'CONTROL': {
incar = vaspio.Incar(incar_dict)
calc.use_incar(ParameterData(dict=incar.as_dict()))

# KPOINTS
kpoints = kpoints_dict

kpoints = vaspio.Kpoints(comment='aiida generated',
                         style=kpoints['style'],
                         kpts=(kpoints['points'], ),
                         kpts_shift=kpoints['shift'])

calc.use_kpoints(ParameterData(dict=kpoints.as_dict()))

# POTCAR
pseudo = pseudo_dict
potcar = vaspio.Potcar(symbols=pseudo['symbols'],
                       functional=pseudo['functional'])
calc.use_potcar(ParameterData(dict=potcar.as_dict()))

# Define parsers to use
settings = {'PARSER_INSTRUCTIONS': []}
pinstr = settings['PARSER_INSTRUCTIONS']
pinstr += [{
    'instr': 'array_data_parser',
    'type': 'data',
    'params': {}
}, {
    'instr': 'output_parameters',
    'type': 'data',
    'params': {}
}, {
    'instr': 'dummy_error_parser',
    [0.5, 0.0, 0.5],
    [0.5, 0.5, 0.0]
])
lattice = mg.Lattice(lattice)

struct = mg.Structure(
    lattice,
    [Mn, Mn, Ga],
    # site coords
    [[0.00, 0.00, 0.00], [0.25, 0.25, 0.25], [0.50, 0.50, 0.50]]
)
poscar = vaspio.Poscar(struct, comment='cubic Mn2Ga')

# POTCAR
# Note: for this to work Pymatgen needs to have an access to VASP pseudopotential directory
potcar = vaspio.Potcar(symbols=['Mn_pv', 'Mn_pv', 'Ga_d'], functional='PBE')

# KPOINTS
kpoints = vaspio.Kpoints.monkhorst_automatic(
    kpts=(10, 10, 10), shift=(0.0, 0.0, 0.0)
)

# split the poscar for AiiDA serialization
poscar_parts = vplugin.disassemble_poscar(poscar)

# === Prepare Calculation
ParameterData = DataFactory('parameter')
StructureData = DataFactory('structure')

submit_test = True  # CAUTION: changing this will affect your database