Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
**custodian_params),
VaspSlabDBInsertTask(struct_type="slab_cell",
loc=new_folder, cwd=cwd, shift=slab.shift,
surface_area=slab.surface_area,
vsize=slabs.min_vac_size,
ssize=slabs.min_slab_size,
miller_index=miller_index,
**vaspdbinsert_parameters)],
name=new_folder)
FWs.append(fw)
return FWAction(additions=FWs)
@explicit_serialize
class RunCustodianTask(FireTaskBase):
"""
Runs Custodian.
"""
required_params = ["dir", "jobs", "cwd"]
optional_params = ["custodian_params", "handlers", "max_errors"]
def run_task(self, fw_spec):
"""
Required Parameters:
dir (str path): directory containing the vasp inputs
jobs (VaspJob): Contains the cmd needed to run vasp
Optional Parameters:
custodian_params (dict **kwargs): Contains the job and the
scratch directory for a custodian run
drone = VaspToDbTaskDrone(host=self["host"], port=self["port"],
user=self["user"],
password=self["password"],
database=self["database"],
use_full_uri=False,
additional_fields=additional_fields,
collection=self["collection"])
drone.assimilate(cwd+loc)
# print loc
# print self["collection"]
# print additional_fields['vsize']
# print additional_fields['miller_index']
@explicit_serialize
class WriteUCVaspInputs(FireTaskBase):
"""
Writes VASP inputs for an oriented unit cell
"""
required_params = ["oriented_ucell", "folder", "cwd"]
optional_params = ["angle_tolerance", "user_incar_settings",
"k_product", "potcar_functional", "symprec"]
def run_task(self, fw_spec):
"""
Required Parameters:
oriented_unit_cell (Structure): Generated with surface.py
folder (str path): Location where vasp inputs
are to be written
Optional Parameters:
# update all the specs of the workflow with their nested values
# return a FWAction(additons=wf) where wf includes a new AutoOptimizeTask with initialized = true
wf_dict["fws"][0]["spec"]["_tasks"].append(AutoOptimizeTask(initialized = True, inputs = input_keys,
outputs = output_keys, dimensions=dim_keys,
workflow=wf))
wf = Workflow.from_dict(wf_dict)
return FWAction(additions=wf)
@explicit_serialize
class OptimizeTaskFromVector(FireTaskBase):
required_params = ['input', 'output', 'dimensions']
optional_params = []
_fw_name = "OptimizeTaskFromVector"
def __init__(self):
self._tw_port = 27017
self._tw_host = 'localhost'
self._tw_mongo = MongoClient(self._tw_host, self._tw_port)
self._tw_db = self._tw_mongo.turboworks
self._tw_collection = self._tw_db.turboworks2
def run_task(self, fw_spec):
x = self['input']
from mpworks.firetasks.raman_functions import verify_raman
from mpworks.workflows.wf_settings import QA_VASP, QA_DB, MOVE_TO_GARDEN_PROD, MOVE_TO_GARDEN_DEV
from mpworks.workflows.wf_utils import last_relax, get_loc, move_to_garden
from pymatgen import Composition
from pymatgen.io.vasp.inputs import Incar, Poscar, Potcar, Kpoints
from pymatgen.matproj.snl import StructureNL
__author__ = 'Anubhav Jain'
__copyright__ = 'Copyright 2013, The Materials Project'
__version__ = '0.1'
__maintainer__ = 'Anubhav Jain'
__email__ = 'ajain@lbl.gov'
__date__ = 'Mar 15, 2013'
class VaspWriterTask(FireTaskBase, FWSerializable):
"""
Write VASP input files based on the fw_spec
"""
_fw_name = "Vasp Writer Task"
def run_task(self, fw_spec):
fw_spec['vasp']['incar'].write_file('INCAR')
fw_spec['vasp']['poscar'].write_file('POSCAR')
fw_spec['vasp']['potcar'].write_file('POTCAR')
fw_spec['vasp']['kpoints'].write_file('KPOINTS')
class VaspCopyTask(FireTaskBase, FWSerializable):
"""
Copy the VASP run directory in 'prev_vasp_dir' to the current dir
if mpid:
additional_fields["material_id"] = mpid
drone = VaspToDbTaskDrone(use_full_uri=False,
additional_fields=additional_fields,
**vaspdbinsert_parameters)
drone.assimilate(os.path.join(cwd, folder))
if struct_type != "isolated_atom":
# Now we update the surface properties collection
post_process_updater = UpdateRepositoriesAndDBs(vaspdbinsert_parameters)
post_process_updater.insert_surface_property_entry(mpid)
post_process_updater.insert_wulff_entry(mpid)
@explicit_serialize
class WriteUCVaspInputs(FireTaskBase):
"""
Writes VASP inputs for an oriented unit cell
"""
required_params = ["oriented_ucell", "folder", "cwd", "potcar_functional"]
optional_params = ["user_incar_settings", "oxides", "limit_sites",
"k_product", "gpu", "debug"]
def run_task(self, fw_spec):
"""
Required Parameters:
oriented_unit_cell (Structure): Generated with surface.py
folder (str path): Location where vasp inputs
are to be written
cwd (str): Current working directory
k = [int(round(2.5*k)) if int(round(2.5*k))%2
else int(round(2.5*k))+1 for k in kpoints['kpoints'][0]]
kpoints['kpoints'] = [k]
return FWAction()
class SetupElastConstTask(FireTaskBase, FWSerializable):
_fw_name = "Setup Elastic Constant Task"
def run_task(self, fw_spec):
incar = Incar.from_file(zpath("INCAR"))
incar.update({"ISIF": 2})
incar.write_file("INCAR")
return FWAction()
class SetupDeformedStructTask(FireTaskBase, FWSerializable):
_fw_name = "Setup Deformed Struct Task"
def run_task(self, fw_spec):
# Read structure from previous relaxation
relaxed_struct = fw_spec['output']['crystal']
# Generate deformed structures
d_struct_set = DeformedStructureSet(relaxed_struct, ns=0.06)
wf=[]
for i, d_struct in enumerate(d_struct_set.def_structs):
fws=[]
connections={}
f = Composition(d_struct.formula).alphabetical_formula
snl = StructureNL(d_struct, 'Joseph Montoya ',
projects=["Elasticity"])
tasks = [AddSNLTask()]
snl_priority = fw_spec.get('priority', 1)
from os.path import expandvars, expanduser
import shutil
import traceback
from fireworks.core.firework import FireTaskBase
from fireworks.utilities.fw_serializers import FWSerializable
__author__ = 'Anubhav Jain, David Waroquiers'
__copyright__ = 'Copyright 2013, The Materials Project'
__version__ = '0.1'
__maintainer__ = 'Anubhav Jain'
__email__ = 'ajain@lbl.gov'
__date__ = 'Aug 29, 2013'
# TODO: write some unit tests - this is really an untested FireTask
class TransferTask(FireTaskBase, FWSerializable):
_fw_name = "Transfer Task"
def __init__(self, parameters):
"""
:param parameters: (dict) parameters.
"""
self.update(parameters)
self.fn_list = {
"move": shutil.move,
"mv": shutil.move,
"copy": shutil.copy,
"cp": shutil.copy,
"copy2": shutil.copy2,
"copytree": shutil.copytree,
"copyfile": shutil.copyfile,
from custodian.custodian import Custodian
from custodian.vasp.jobs import VaspJob
from matgendb.creator import VaspToDbTaskDrone
from pymatgen.core.surface import SlabGenerator
from monty.json import MontyDecoder
from pymatgen.io.vaspio_metal_slabs import MPSlabVaspInputSet
from matgendb import QueryEngine
"""
Firework tasks
"""
@explicit_serialize
class VaspSlabDBInsertTask(FireTaskBase):
"""
Inserts a single vasp calculation in a folder into a
DB. Also inserts useful information pertaining
to slabs and oriented unit cells.
"""
required_params = ["host", "port", "user", "password",
"database", "collection", "struct_type", "loc",
"cwd", "miller_index"]
optional_params = ["surface_area", "shift", "vsize", "ssize"]
def run_task(self, fw_spec):
"""
Required Parameters: