예제 #1
0
def generate_scf_input_params(structure, codename, pseudo_family):
    # The inputs
    inputs = PwCalculation.process().get_inputs_template()

    # The structure
    inputs.structure = structure

    inputs.code = Code.get_from_string(codename.value)
    inputs._options.resources = {"num_machines": 1}
    inputs._options.max_wallclock_seconds = 30 * 60

    # Kpoints
    KpointsData = DataFactory("array.kpoints")
    kpoints = KpointsData()
    kpoints_mesh = 2
    kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh])
    inputs.kpoints = kpoints

    # Calculation parameters
    parameters_dict = {
        "CONTROL": {"calculation": "scf",
                    "tstress": True,  #  Important that this stays to get stress
                    "tprnfor": True,},
        "SYSTEM": {"ecutwfc": 30.,
                   "ecutrho": 200.,},
        "ELECTRONS": {"conv_thr": 1.e-6,}
    }
    ParameterData = DataFactory("parameter")
    inputs.parameters = ParameterData(dict=parameters_dict)

    # Pseudopotentials
    inputs.pseudo = get_pseudos(structure, str(pseudo_family))

    return inputs
예제 #2
0
def eos(structure, codename, pseudo_family):
    Proc = PwCalculation.process()
    results = {}
    for s in (0.98, 0.99, 1.0, 1.02, 1.04):
        rescaled = rescale(structure, Float(s))
        inputs = generate_scf_input_params(rescaled, codename, pseudo_family)
        outputs = run(Proc, **inputs)
        res = outputs['output_parameters'].dict
        results[str(s)] = res

    return results
예제 #3
0
def run_si_scf(codename, pseudo_family):
    JobCalc = PwCalculation.process()
    inputs = JobCalc.get_inputs_template()

    inputs.code = Code.get_from_string(codename)
    # calc.label = "PW test"
    # calc.description = "My first AiiDA calculation of Silicon with Quantum ESPRESSO"
    inputs._options.resources = {"num_machines": 1}
    inputs._options.max_wallclock_seconds = 30 * 60

    # The structure
    alat = 5.4
    the_cell = [[alat / 2., alat / 2., 0], [alat / 2., 0, alat / 2.],
                [0, alat / 2., alat / 2.]]
    StructureData = DataFactory("structure")
    structure = StructureData(cell=the_cell)
    structure.append_atom(position=(0., 0., 0.), symbols="Si")
    structure.append_atom(position=(alat / 4., alat / 4., alat / 4.),
                          symbols="Si")
    inputs.structure = structure

    # Kpoints
    KpointsData = DataFactory("array.kpoints")
    kpoints = KpointsData()
    kpoints_mesh = 2
    kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh])
    inputs.kpoints = kpoints

    # Calculation parameters
    parameters_dict = {
        "CONTROL": {
            "calculation": "scf",
            "tstress": True,
            "tprnfor": True,
        },
        "SYSTEM": {
            "ecutwfc": 30.,
            "ecutrho": 200.,
        },
        "ELECTRONS": {
            "conv_thr": 1.e-6,
        }
    }
    ParameterData = DataFactory("parameter")
    inputs.parameters = ParameterData(dict=parameters_dict)

    # Pseudopotentials
    inputs.pseudo = get_pseudos(structure, pseudo_family)

    # calc.set_extra("element", "Si")
    # calc.submit()
    asyncd(JobCalc, **inputs)
예제 #4
0
def run_eos_wf(codename, pseudo_family, element):
	print "Workfunction node pk: {}".format(registry.current_calc_node)
	#Instantiate a JobCalc process and create basic structure
	JobCalc = PwCalculation.process()
	s0 = create_diamond_fcc(Str(element))
	eos=[]
	scale_facs = (0.98, 0.99, 1.0, 1.02, 1.04)
	for factor in  scale_facs:
		s = rescale(s0,Float(factor))
		inputs = generate_scf_input_params(
			s, str(codename), str(pseudo_family))
		print "Running a scf for {} with scale factor {}".format(
			element, factor)
	calc_results = run(JobCalc,**inputs)
	eos.append(get_info(calc_results))
	#Return information to plot the EOS
	ParameterData = DataFactory("parameter")
	return {'initial_structure': s0,'result': ParameterData(dict={'eos_data': eos})}
from aiida.orm.data.structure import StructureData
from aiida.workflows2.run import run
from aiida.workflows2.fragmented_wf import FragmentedWorkfunction, \
    ResultToContext, while_
from aiida.workflows2.wf import wf
from common_wf import generate_scf_input_params
from create_rescale import rescale, create_diamond_fcc
from aiida.orm.calculation.job.quantumespresso.pw import PwCalculation

GPa_to_eV_over_ang3 = 1./160.21766208


# Set up the factories
ParameterData = DataFactory("parameter")
KpointsData = DataFactory("array.kpoints")
PwProcess = PwCalculation.process()

def get_first_deriv(stress):
    """
    Return the energy first derivative from the stress
    """
    from numpy import trace
    # Get the pressure (GPa)
    p = trace(stress)/3.
    # Pressure is -dE/dV; moreover p in kbar, we need to convert
    # it to eV/angstrom^3 to be consisten
    dE = -p * GPa_to_eV_over_ang3
    return dE


def get_volume_energy_and_derivative(output_parameters):
예제 #6
0
# Set up kpoint
kpoints = KpointsData()
kpoints_mesh = 2
kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh])

# to retrieve the bands
# (the object settings is optional)
settings_dict = {'also_bands': True}
settings = ParameterData(dict=settings_dict)

# calc.label = "Test QE pw.x"
# calc.description = "Test calculation with the Quantum ESPRESSO pw.x code"
# Valid only for Slurm and PBS (using default values for the
# number_cpus_per_machine), change for SGE-like schedulers

JobCalc = PwCalculation.process()

# Inputs
inputs = JobCalc.get_inputs_template()
inputs.structure = s
inputs.parameters = parameters
inputs.kpoints = kpoints
inputs.code = test_and_get_code(codename,
                                expected_code_type='quantumespresso.pw')

# Calculation options
options = inputs._options
options.max_wallclock_seconds = 30 * 60  # 30 min
options.resources = {"num_machines": 1, "num_mpiprocs_per_machine": 8}
options.custom_scheduler_commands = u"#SBATCH --account=ch3"
if run_in_serial_mode:
예제 #7
0
from aiida.orm.code import Code
from aiida.orm.data.structure import StructureData
from aiida.workflows2.run import run, asyncd
from aiida.workflows2.fragmented_wf import (FragmentedWorkfunction,
                                            ResultToContext)
from common import generate_scf_input_params
from examples.workflows2.diamond_fcc import rescale
from aiida.orm.calculation.job.quantumespresso.pw import PwCalculation


# Set up the factories
ParameterData = DataFactory("parameter")
KpointsData = DataFactory("array.kpoints")


PwProcess = PwCalculation.process()


class EquationOfStates(FragmentedWorkfunction):
    @classmethod
    def _define(cls, spec):
        spec.input("structure", valid_type=StructureData)
        spec.input("start", valid_type=NumericType, default=Float(0.96))
        spec.input("delta", valid_type=NumericType, default=Float(0.02))
        spec.input("end", valid_type=NumericType, default=Float(1.04))
        spec.input("code", valid_type=SimpleData)
        spec.input("pseudo_family", valid_type=SimpleData)
        spec.outline(
            cls.run_pw,
            cls.plot_eos
        )
예제 #8
0
def run_scf(structure, codename, pseudo_family):
    JobCalc = PwCalculation.process()
    inputs = generate_scf_input_params(structure, codename, pseudo_family)
    return run(JobCalc, **inputs)
예제 #9
0
# This file is part of the AiiDA code.                                    #
#                                                                         #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
# For further information on the license, see the LICENSE.txt file        #
# For further information please visit http://www.aiida.net               #
###########################################################################

from aiida.work.workchain import WorkChain, while_, ToContext, Outputs
from aiida.orm.data.float import Float
from aiida.orm.data.str import Str
from aiida.orm.utils import DataFactory
from aiida.work.workfunctions import workfunction as wf
from aiida.work.launch import run, submit
from aiida.orm.calculation.job.quantumespresso.pw import PwCalculation

Proc = PwCalculation.process()


def generate_scf_input_params(**kwargs):
    pass


@wf
def rescale(structure, scale):
    the_ase = structure.get_ase()
    new_ase = the_ase.copy()
    new_ase.set_cell(the_ase.get_cell() * float(scale), scale_atoms=True)
    new_structure = DataFactory('structure')(ase=new_ase)
    return new_structure