matmethods.vasp package

Submodules

matmethods.vasp.config module

matmethods.vasp.database module

class matmethods.vasp.database.MMBoltztrapDb(host, port, database, collection, user, password)

Bases: matmethods.utils.database.MMDb

class matmethods.vasp.database.MMVaspDb(host=u'localhost', port=27017, database=u'vasp', collection=u'tasks', user=None, password=None)

Bases: matmethods.utils.database.MMDb

Class to help manage database insertions of Vasp drones

__init__(host=u'localhost', port=27017, database=u'vasp', collection=u'tasks', user=None, password=None)
build_indexes(indexes=None, background=True)

Build the indexes.

Args:
indexes (list): list of single field indexes to be built. background (bool): Run in the background or not.
TODO: make sure that the index building is sensible and check for
existing indexes.
get_band_structure(task_id, line_mode=False)
get_dos(task_id)
insert_gridfs(d, collection=u'fs', compress=True)

Insert the given document into GridFS.

Args:
d (dict): the document collection (string): the GridFS collection name compress (bool): Whether to compress the data or not
Returns:
file id, the type of compression used.
reset()

matmethods.vasp.drones module

class matmethods.vasp.drones.VaspDrone(runs=None, parse_dos=False, compress_dos=False, bandstructure_mode=False, compress_bs=False, additional_fields=None, use_full_uri=True)

Bases: pymatgen.apps.borg.hive.AbstractDrone

pymatgen-db VaspToDbTaskDrone with updated schema and documents processing methods. Please refer to matgendb.creator.VaspToDbTaskDrone documentation.

__init__(runs=None, parse_dos=False, compress_dos=False, bandstructure_mode=False, compress_bs=False, additional_fields=None, use_full_uri=True)
as_dict()
assimilate(path)

Parses vasp runs(vasprun.xml file) and insert the result into the db.

Args:
path (str): Path to the directory containing vasprun.xml file
Returns:
tuple of (task_id, task_doc dict)
check_keys(d)

Sanity check. Make sure all the important keys are set

filter_files(path, file_pattern=u'vasprun.xml')

Find the files that match the pattern in the given path and return them in an ordered dictionary. The searched for files are filtered by the run types defined in self.runs. e.g. [“relax1”, “relax2”]. Only 2 schemes of the file filtering is enabled: searching for run types in the list of files and in the filenames. Modify this method if more sophisticated filtering scheme is needed.

Args:
path (string): path to the folder file_pattern (string): files to be searched for
Returns:
OrderedDict of the names of the files to be processed further. The key is set from list of run types: self.runs
classmethod from_dict(d)
generate_doc(dir_name, vasprun_files, outcar_files)

Adapted from matgendb.creator.generate_doc

get_basic_processed_data(d)

return processed data such as vbm, cbm, gap etc.

get_task_doc(path)

Adapted from matgendb.creator Get the entire task doc from the vasprum.xml and the OUTCAR files in the path. Also adds some post-processed info.

Args:
path (str): Path to the directory containing vasprun.xml and OUTCAR files
Returns:
The dictionary to be inserted into the db
get_valid_paths(path)

Required by the AbstractDrone. Update this and use it to further filter the files to be assimilated.

post_process(dir_name, d)

Simple post-processing for various files other than the vasprun.xml and OUTCAR. Looks for files: Transformations.json and custodian.json. Modify this if other output files need to be processed.

Args:
dir_name:
The dir_name.
d:
Current doc generated.
process_outcar(dir_name, filename)

Process the outcar file

process_vasprun(dir_name, taskname, filename)

Adapted from matgendb.creator

Process a vasprun.xml file.

schema = {u'input': set([u'pseudo_potential', u'hubbards', u'xc_override', u'potcar_spec', u'is_hubbard', u'structure', u'is_lasph']), u'calcs_reversed': set([u'dir_name', u'run_type', u'task', u'input', u'formula_anonymous', u'nelements', u'vasp_version', u'nsites', u'composition_reduced', u'completed_at', u'formula_reduced_abc', u'composition_unit_cell', u'output', u'formula_pretty', u'has_vasp_completed', u'elements']), u'root': set([u'calcs_reversed', u'elements', u'input', u'composition_reduced', u'formula_pretty', u'nelements', u'nsites', u'chemsys', u'analysis', u'completed_at', u'state', u'formula_reduced_abc', u'run_stats', u'composition_unit_cell', u'dir_name', u'output', u'formula_anonymous', u'schema']), u'analysis': set([u'delta_volume', u'errors', u'max_force', u'delta_volume_percent', u'warnings']), u'output': set([u'is_gap_direct', u'density', u'is_metal', u'energy', u'bandgap', u'vbm', u'energy_per_atom', u'spacegroup', u'cbm', u'structure'])}
set_analysis(d, max_force_threshold=0.5, volume_change_threshold=0.2)

Adapted from matgendb.creator

set the ‘analysis’ key

set_input_data(d_calc, d)

set the ‘input’ key

set_output_data(d_calc, d)

set the ‘output’ key

set_state(d_calc, d)

set the ‘state’ key

matmethods.vasp.powerups module

matmethods.vasp.powerups.add_additional_fields_to_taskdocs(original_wf, update_dict=None)

For all VaspToDbTasks in a given workflow, add information to “additional_fields” to be placed in the task doc.

Args:
original_wf (Workflow) update_dict (Dict): dictionary to add additional_fields
matmethods.vasp.powerups.add_bandgap_check(original_wf, check_bandgap_params=None, fw_name_constraint=None)

Every FireWork that runs VASP has a CheckStability task afterward. This allows defusing jobs that are not stable. In practice, you might want to set the fw_name_constraint so that the stability is only checked at the beginning of the workflow

Args:
original_wf (Workflow) check_bandgap_params (dict): a kwargs style dict of params fw_name_constraint (str) - Only apply changes to FWs where fw_name contains this substring.
matmethods.vasp.powerups.add_common_powerups(wf, c)

Apply the common powerups such as add_namefile, use_scratch_dir etc. from the given config dict.

Args:
wf (Workflow) c (dict): Config dict
Returns:
Workflow
matmethods.vasp.powerups.add_modify_incar(original_wf, modify_incar_params=None, fw_name_constraint=None)

Every FireWork that runs VASP has a ModifyIncar task just beforehand. For example, allows you to modify the INCAR based on the Worker using env_chk or using hard-coded changes.

Args:
original_wf (Workflow) modify_incar_params (dict) - dict of parameters for ModifyIncar. fw_name_constraint (str) - Only apply changes to FWs where fw_name contains this substring.
matmethods.vasp.powerups.add_modify_incar_envchk(original_wf, fw_name_constraint=None)

If you set the “incar_update” parameter in the Worker env, the INCAR will update this parameter for all matching VASP runs

Args:
original_wf (Workflow) fw_name_constraint (str) - Only apply changes to FWs where fw_name contains this substring.
matmethods.vasp.powerups.add_namefile(original_wf, use_slug=True)

Every FireWork begins by writing an empty file with the name “FW–<fw.name>”. This makes it easy to figure out what jobs are in what launcher directories, e.g. “ls -l launch*/FW–*” from within a “block” dir.

Args:
original_wf (Workflow) use_slug (bool): whether to replace whitespace-type chars with a slug
matmethods.vasp.powerups.add_priority(original_wf, root_priority, child_priority=None)

Adds priority to a workflow

Args:

original_wf (Workflow): original WF root_priority (int): priority of first (root) job(s) child_priority(int): priority of all child jobs. Defaults to

root_priority
Returns:
(Workflow) priority-decorated workflow
matmethods.vasp.powerups.add_small_gap_multiply(original_wf, gap_cutoff, density_multiplier, fw_name_constraint=None)

In all FWs with specified name constraints, add a ‘small_gap_multiply’ parameter that multiplies the k-mesh density of compounds with gap < gap_cutoff by density multiplier. Note that this powerup only works on FireWorks with the appropriate WriteVasp* tasks that accept the small_gap_multiply argument...

Parameters:
  • original_wf
  • gap_cutoff
  • density_multiplier
  • fw_name_constraint
matmethods.vasp.powerups.add_stability_check(original_wf, check_stability_params=None, fw_name_constraint=None)

Every FireWork that runs VASP has a CheckStability task afterward. This allows defusing jobs that are not stable. In practice, you might want to set the fw_name_constraint so that the stability is only checked at the beginning of the workflow

Args:
original_wf (Workflow) check_stability_params (dict): a kwargs style dict of params fw_name_constraint (str) - Only apply changes to FWs where fw_name contains this substring.
matmethods.vasp.powerups.add_tags(original_wf, tags_list)
Adds tags to all Fireworks in the Workflow, WF metadata,
as well as additional_fields for the VaspDrone to track them later (e.g. all fireworks and vasp tasks related to a research project)
Args:
original_wf (Workflow) tags_list: list of tags parameters (list of strings)
matmethods.vasp.powerups.add_trackers(original_wf, tracked_files=None, nlines=25)

Every FireWork that runs VASP also tracks the OUTCAR, OSZICAR, etc using FWS Trackers.

Args:
original_wf (Workflow) tracked_files (list) : list of files to be tracked nlines (int): number of lines at the end of files to be tracked
matmethods.vasp.powerups.add_wf_metadata(original_wf, structure)

Adds structure metadata to a workflow

Args:
original_wf: (Workflow) structure: (Structure) the structure being run by this workflow

Returns:

matmethods.vasp.powerups.modify_to_soc(original_wf, nbands, structure=None, modify_incar_params=None, fw_name_constraint=None)

Takes a regular workflow and transforms its VASP fireworkers that are specified with fw_name_constraints to non-collinear calculations taking spin orbit coupling into account.

Args:
original_wf (Workflow) nbands (int): number of bands selected by the user (for now) structure (Structure) modify_incar_params ({}): a dictionary containing the setting for modyfining the INCAR (e.g. {“ICHARG”: 11}) fw_name_constraint (string): name of the fireworks to be modified (all if None is passed)
Returns:
modified Workflow with SOC
matmethods.vasp.powerups.remove_custodian(original_wf, fw_name_constraint=None)

Replaces all tasks with “RunVasp*” (e.g. RunVaspCustodian) to be RunVaspDirect.

Args:

original_wf (Workflow): original workflow fw_name_constraint (str): Only apply changes to FWs where fw_name

contains this substring.
matmethods.vasp.powerups.tag_fws(original_wf, tag, fw_name_constraint=None)

Tags VASP Fworker(s) of a Workflow; e.g. it can be used to run large-memory jobs on a separate queue

Args:
original_wf (Workflow): tag (string): user-defined tag to be added under fw.spec._fworker (e.g. “large memory”, “big”, etc) fw_name_constraint (string): name of the fireworks to be modified (all if None is passed)
Returns:
modified workflow with tagged Fworkers
matmethods.vasp.powerups.use_custodian(original_wf, fw_name_constraint=None, custodian_params=None)

Replaces all tasks with “RunVasp*” (e.g. RunVaspDirect) to be RunVaspCustodian. Thus, this powerup adds error correction into VASP runs if not originally present and/or modifies the correction behavior.

Args:

original_wf (Workflow): original workflow fw_name_constraint (str): Only apply changes to FWs where fw_name contains this substring.

For example, use custodian only for certain runs, or set job_type to “double_relaxation_run” only for structure optimization run, or set different handler_group for different runs.
custodian_params (dict): A dict of parameters for RunVaspCustodian. e.g., use it to set
a “scratch_dir” or “handler_group”.
matmethods.vasp.powerups.use_fake_vasp(original_wf, ref_dirs, params_to_check=None)

Replaces all tasks with “RunVasp” (e.g. RunVaspDirect) to be RunVaspFake. Thus, we do not actually run VASP but copy pre-determined inputs and outputs.

Args:
original_wf (Workflow) ref_dirs (dict): key=firework name, value=path to the reference vasp calculation directory params_to_check (list): optional list of incar parameters to check.
matmethods.vasp.powerups.use_scratch_dir(original_wf, scratch_dir)

For all RunVaspCustodian tasks, add the desired scratch dir.

Parameters:
  • original_wf
  • scratch_dir – The scratch dir to use. Supports env_chk

matmethods.vasp.submission_filter module

class matmethods.vasp.submission_filter.SubmissionFilter(is_valid=True, potcar_exists=True, max_natoms=200, is_ordered=True, not_in_MP=True, MAPI_KEY=None, require_bandstructure=False)

Bases: pymatgen.alchemy.filters.AbstractStructureFilter

NO_POTCARS = [u'Po', u'At', u'Rn', u'Fr', u'Ra', u'Am', u'Cm', u'Bk', u'Cf', u'Es', u'Fm', u'Md', u'No', u'Lr']
__init__(is_valid=True, potcar_exists=True, max_natoms=200, is_ordered=True, not_in_MP=True, MAPI_KEY=None, require_bandstructure=False)
as_dict()
classmethod from_dict(d)
test(structure)

matmethods.vasp.vasp_config module

matmethods.vasp.vasp_powerups module

Module contents