Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from monty.serialization import dumpfn
from monty.json import jsanitize
from atomate.qchem.database import QChemCalcDb
from atomate.utils.utils import env_chk
from atomate.utils.utils import get_logger
__author__ = "Samuel Blau"
__copyright__ = "Copyright 2018, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Samuel Blau"
__email__ = "samblau1@gmail.com"
__status__ = "Alpha"
__date__ = "11/13/18"
logger = get_logger(__name__)
@explicit_serialize
class GatherGeometries(FiretaskBase):
"""
"""
required_params = ["prefix", "suffix"]
optional_params = ["db_file"]
def run_task(self, fw_spec):
data = []
for key in fw_spec:
if len(key) > len(self["prefix"])+len(self["suffix"]):
if key[0:len(self["prefix"])] == self["prefix"]:
to_add = copy.deepcopy(fw_spec[key])
def _get_images_by_linear_interp(self, nimages, ep0, ep1):
logger = get_logger(__name__)
sort_tol = self.get("sort_tol", 0.0)
try:
images = ep0.interpolate(ep1, nimages=nimages + 1, autosort_tol=sort_tol)
except Exception as e:
if "Unable to reliably match structures " in str(e):
logger.warning("Auto sorting is turned off because it is unable to match the "
"end-point structures!")
images = ep0.interpolate(ep1, nimages=nimages + 1, autosort_tol=0)
else:
raise e
return images
"""
This module defines the point defects workflow: structure optimization followed by transmuter fireworks.
"""
from fireworks import Workflow
from atomate.utils.utils import get_logger
from atomate.vasp.fireworks.core import OptimizeFW, TransmuterFW, StaticFW
from pymatgen.io.vasp.sets import MPRelaxSet, MPStaticSet
__author__ = 'Kiran Mathew'
__email__ = 'kmathew@lbl.gov'
logger = get_logger(__name__)
def get_wf_point_defects(structure, defect_transformations, defect_transformations_params,
charge_states=None, name="point_defects", vasp_input_set=None,
lepsilon=False, vasp_cmd="vasp", db_file=None, user_kpoints_settings=None,
tag=""):
"""
Returns a point defects workflow.
Firework 1 : structural relaxation
Firework 2 : static
Firework 3 - : Apply the defect transformations and run static calculation for each charge state.
import os
import yaml
import pymongo
from fireworks import LaunchPad
from pymongo import MongoClient
from atomate.utils.utils import get_logger
from atomate.vasp.database import VaspCalcDb
from atomate.vasp.drones import VaspDrone
logger =get_logger(__name__)
class PostRunInsertion():
"""
Inserts existing amorphous calculations into MongoDB
"""
def __init__(self):
with open("/global/homes/s/sivonxay/.conda/envs/knl_env/config/my_launchpad.yaml", "r") as f:
t = yaml.load(f)
client = MongoClient(t['host'])
db = client.fw_es_vasp
db.authenticate(t['username'], t['password'])
self.tasks = db.tasks
db_file = "/global/homes/s/sivonxay/.conda/envs/knl_env/config/db.json"
self.mmdb = VaspCalcDb.from_db_file(db_file, admin=True)
# coding: utf-8
from tqdm import tqdm
from atomate.utils.utils import get_database
from pymatgen import MPRester, Structure
from pymatgen.entries.computed_entries import ComputedEntry
from atomate.utils.utils import get_logger
from atomate.vasp.builders.base import AbstractBuilder
logger = get_logger(__name__)
__author__ = 'Anubhav Jain '
class MaterialsEhullBuilder(AbstractBuilder):
def __init__(self, materials_write, mapi_key=None, update_all=False):
"""
Starting with an existing materials collection, adds stability information and
The Materials Project ID.
Args:
materials_write: mongodb collection for materials (write access needed)
mapi_key: (str) Materials API key (if MAPI_KEY env. var. not set)
update_all: (bool) - if true, updates all docs. If false, only updates
docs w/o a stability key
"""
self._materials = materials_write
from atomate.common.firetasks.glue_tasks import get_calc_loc
from atomate.qchem.database import QChemCalcDb
from atomate.utils.utils import env_chk
from atomate.utils.utils import get_logger
from atomate.qchem.drones import QChemDrone
__author__ = "Samuel Blau"
__copyright__ = "Copyright 2018, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Samuel Blau"
__email__ = "samblau1@gmail.com"
__status__ = "Alpha"
__date__ = "4/25/18"
__credits__ = "Brandon Wood, Shyam Dwaraknath, Xiaohui Qu"
logger = get_logger(__name__)
@explicit_serialize
class QChemToDb(FiretaskBase):
"""
Enter a QChem run into the database. Uses current directory unless you
specify calc_dir or calc_loc.
Optional params:
calc_dir (str): path to dir (on current filesystem) that contains QChem
input and output files. Default: use current working directory.
calc_loc (str OR bool): if True will set most recent calc_loc. If str
search for the most recent calc_loc with the matching name
input_file (str): name of the QChem input file
output_file (str): name of the QChem output file
additional_fields (dict): dict of additional fields to add
from pymatgen.core import Structure
from pymatgen.io.vasp.sets import MPRelaxSet, MVLScanRelaxSet
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatgen.entries.computed_entries import ComputedStructureEntry
from pymatgen.analysis.defects.generators import VacancyGenerator, SubstitutionGenerator, \
InterstitialGenerator, VoronoiInterstitialGenerator, SimpleChargeGenerator
from fireworks import FiretaskBase, FWAction, explicit_serialize
from atomate.utils.utils import get_logger
from atomate.vasp.fireworks.core import TransmuterFW
from monty.serialization import dumpfn
from monty.json import MontyEncoder
logger = get_logger(__name__)
def optimize_structure_sc_scale(inp_struct, final_site_no):
"""
A function for finding optimal supercell transformation
by maximizing the nearest image distance with the number of
atoms remaining less than final_site_no
Args:
inp_struct: input pymatgen Structure object
final_site_no (float or int): maximum number of atoms
for final supercell
Returns:
3 x 1 array for supercell transformation
"""
if final_site_no <= len(inp_struct.sites):
add_tags,
add_additional_fields_to_taskdocs,
add_wf_metadata,
add_common_powerups,
)
from atomate.vasp.workflows.base.core import get_wf
from atomate.vasp.firetasks.parse_outputs import (
MagneticDeformationToDb,
MagneticOrderingsToDb,
)
from pymatgen.alchemy.materials import TransformedStructure
from atomate.utils.utils import get_logger
logger = get_logger(__name__)
from atomate.vasp.config import VASP_CMD, DB_FILE, ADD_WF_METADATA
from atomate.vasp.workflows.presets.scan import wf_scan_opt
from uuid import uuid4
from pymatgen.io.vasp.sets import MPRelaxSet
from pymatgen.core import Lattice, Structure
from pymatgen.analysis.magnetism.analyzer import (
CollinearMagneticStructureAnalyzer,
MagneticStructureEnumerator,
)
__author__ = "Matthew Horton"
__maintainer__ = "Matthew Horton"
__email__ = "mkhorton@lbl.gov"
__status__ = "Production"
# coding: utf-8
from tqdm import tqdm
from atomate.utils.utils import get_database
from pymatgen import Composition
from atomate.vasp.builders.base import AbstractBuilder
from atomate.utils.utils import get_logger
logger = get_logger(__name__)
__author__ = 'Anubhav Jain '
class FileMaterialsBuilder(AbstractBuilder):
def __init__(self, materials_write, data_file, delimiter=",", header_lines=0):
"""
Updates the database using a data file. Format of file must be:
, ,
Comment lines should *start* with '#'.
Args:
materials_write: mongodb collection for materials (write access needed)
data_file (str): path to data file
delimiter (str): delimiter for file parsing
from pymatgen.io.vasp.outputs import Chgcar
from pymatgen.apps.borg.hive import AbstractDrone
from pymatgen.command_line.bader_caller import bader_analysis_from_path
from atomate.utils.utils import get_uri
from atomate.utils.utils import get_logger
from atomate import __version__ as atomate_version
from atomate.vasp.config import STORE_VOLUMETRIC_DATA, STORE_ADDITIONAL_JSON
__author__ = 'Kiran Mathew, Shyue Ping Ong, Shyam Dwaraknath, Anubhav Jain'
__email__ = 'kmathew@lbl.gov'
__date__ = 'Mar 27, 2016'
__version__ = "0.1.0"
logger = get_logger(__name__)
bader_exe_exists = which("bader") or which("bader.exe")
class VaspDrone(AbstractDrone):
"""
pymatgen-db VaspToDbTaskDrone with updated schema and documents processing methods.
Please refer to matgendb.creator.VaspToDbTaskDrone documentation.
"""
__version__ = atomate_version # note: the version is inserted into the task doc
# Schema def of important keys and sub-keys; used in validation
schema = {
"root": {
"schema", "dir_name", "chemsys", "composition_reduced",