### Setup developer environment Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Install developer requirements and initialize pre-commit hooks for code linting. ```bash pip install -e . --group dev pre-commit install ``` -------------------------------- ### Install atomate2 from source Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Clone the repository and install the package locally. ```bash git clone https://github.com/materialsproject/atomate2 cd atomate2 pip install . ``` -------------------------------- ### Blob Storage Tutorial Setup Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Code snippet demonstrating the setup for using Blob Storage within atomate2 tutorials. This involves importing necessary modules. ```python from atomate2.utils.blob import BlobStore # Example of initializing BlobStore (specific parameters not shown) # blob_store = BlobStore() ``` -------------------------------- ### Install source dependencies and developer mode Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Install optional dependencies or perform an editable developer installation. ```bash pip install .[fireworks] ``` ```bash pip install -e . ``` -------------------------------- ### Install atomate2 via pip Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Basic installation of atomate2 using pip. ```bash pip install atomate2 ``` -------------------------------- ### OpenMM Installation from Source Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Instructions for installing Atomate2 from source with OpenMM support. This typically involves cloning the repository and using pip. ```bash git clone https://github.com/materialsproject/atomate2.git cd atomate2 pip install -e "[openmm]" ``` -------------------------------- ### Install Atomate2 from Source with OpenMM Source: https://materialsproject.github.io/atomate2/user/codes/openmm.html Clone the Atomate2 repository and install it from source using pip for regular updates. ```bash git clone https://github.com/materialsproject/atomate2 cd atomate2 pip install -e '.[openmm]' ``` -------------------------------- ### Full Elastic Workflow Test Example Source: https://materialsproject.github.io/atomate2/dev/vasp_tests.html This example demonstrates a complete test for an elastic workflow. It includes setting up reference paths, configuring `fake_run_vasp` arguments, generating the flow with updated k-point settings, running it locally, and asserting the output against expected values. ```python def test_elastic(mock_vasp, clean_dir): import numpy as np from jobflow import run_locally from atomate2.common.schemas.elastic import ElasticDocument from atomate2.vasp.flows.elastic import ElasticMaker from atomate2.vasp.powerups import update_user_kpoints_settings # mapping from job name to directory containing test files ref_paths = { "elastic relax 1/6": "Si_elastic/elastic_relax_1_6", "elastic relax 2/6": "Si_elastic/elastic_relax_2_6", "elastic relax 3/6": "Si_elastic/elastic_relax_3_6", "elastic relax 4/6": "Si_elastic/elastic_relax_4_6", "elastic relax 5/6": "Si_elastic/elastic_relax_5_6", "elastic relax 6/6": "Si_elastic/elastic_relax_6_6", "tight relax 1": "Si_elastic/tight_relax_1", "tight relax 2": "Si_elastic/tight_relax_2", } # settings passed to fake_run_vasp; adjust these to check for certain INCAR settings fake_run_vasp_kwargs = { "elastic relax 1/6": {"incar_settings": ["NSW", "ISMEAR"]}, "elastic relax 2/6": {"incar_settings": ["NSW", "ISMEAR"]}, "elastic relax 3/6": {"incar_settings": ["NSW", "ISMEAR"]}, "elastic relax 4/6": {"incar_settings": ["NSW", "ISMEAR"]}, "elastic relax 5/6": {"incar_settings": ["NSW", "ISMEAR"]}, "elastic relax 6/6": {"incar_settings": ["NSW", "ISMEAR"]}, "tight relax 1": {"incar_settings": ["NSW", "ISMEAR"]}, "tight relax 2": {"incar_settings": ["NSW", "ISMEAR"]}, } # automatically use fake VASP and write POTCAR.spec during the test mock_vasp(ref_paths, fake_run_vasp_kwargs) # generate flow si_structure = Structure( lattice=[[0, 2.73, 2.73], [2.73, 0, 2.73], [2.73, 2.73, 0]], species=["Si", "Si"], coords=[[0, 0, 0], [0.25, 0.25, 0.25]], ) # generate the flow and reduce the k-point mesh for the relaxation jobs flow = ElasticMaker().make(si_structure) flow = update_user_kpoints_settings( flow, {"grid_density": 100}, name_filter="relax" ) # run the flow and ensure that it finished running successfully responses = run_locally(flow, create_folders=True, ensure_success=True) # validate workflow outputs elastic_output = responses[flow.jobs[-1].uuid][1].output assert isinstance(elastic_output, ElasticDocument) assert np.allclose( elastic_output.elastic_tensor.ieee_format, [ [155.7923, 54.8871, 54.8871, 0.0, 0.0, 0.0], [54.8871, 155.7923, 54.8871, 0.0, 0.0, 0.0], [54.8871, 54.8871, 155.7923, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 31.5356, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 31.5356, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 31.5356], ], atol=1e-3, ) ``` -------------------------------- ### Get Default Strain States Source: https://materialsproject.github.io/atomate2/reference/atomate2.common.flows.gruneisen.BaseGruneisenMaker.html Retrieves a list of default strain states to be applied for elastic property calculations. This simplifies the setup of elastic calculations. ```python from atomate2.common.analysis.elastic import get_default_strain_states get_default_strain_states( "num_deformations" ) ``` -------------------------------- ### LOBSTER Workflow Tutorial Setup Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Code snippet for setting up the LOBSTER workflow tutorial, likely involving VASP calculations for DFT. ```python from atomate2.vasp.flows.lobster import LobsterMaker # Example of initializing LobsterMaker (specific parameters not shown) # lobster_maker = LobsterMaker() ``` -------------------------------- ### Get Supercell from PRV Calc Job Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.schemas.calculation.html Constructs a supercell from a primitive cell calculation. Useful when starting with a primitive structure and needing a larger supercell. ```python from atomate2.common.jobs.defect import get_supercell_from_prv_calc supercell = get_supercell_from_prv_calc(prv_calc_dir='path/to/prv/calc') ``` -------------------------------- ### Build documentation Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Install documentation dependencies and generate the site using sphinx. ```bash pip install . --group docs ``` ```bash sphinx-build docs docs_build ``` -------------------------------- ### Initialize workflow environment Source: https://materialsproject.github.io/atomate2/tutorials/phonon_workflow_aims.html Sets up the job store and loads the structure required for the phonon workflow. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from pymatgen.core import SETTINGS, Structure from atomate2.aims.flows.phonons import PhononMaker warnings.filterwarnings("ignore") job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si_diamond.cif") SETTINGS["AIMS_SPECIES_DIR"] = TEST_DIR / "../aims/species_dir/tight" ``` -------------------------------- ### Initialize JobStore and structure Source: https://materialsproject.github.io/atomate2/tutorials/blob_storage.html Setup the JobStore with an additional memory store for blob data and load a silicon structure. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from mock_vasp import TEST_DIR, mock_vasp from monty.json import MontyDecoder from pymatgen.core import Structure from pymatgen.io.vasp import Chgcar from atomate2.vasp.flows.core import StaticMaker job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si.cif") ref_paths = {"static": "Si_band_structure/static"} ``` -------------------------------- ### Get Z-file Utility Source: https://materialsproject.github.io/atomate2/reference/atomate2.vasp.flows.defect.html A utility function to get the Z-file. This is part of `atomate2.common.files`. ```python from atomate2.common.files import get_zfile get_zfile( "directory", "filename" ) ``` -------------------------------- ### VASP Code Examples Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Examples related to VASP calculations within atomate2. ```python from atomate2.vasp.flows.core import VaspMaker # Example usage of VaspMaker (specific code not provided in source) # maker = VaspMaker() # flow = maker.make_flow() ``` -------------------------------- ### OpenMM Tutorial Example Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html A basic code structure for the OpenMM tutorial within atomate2. This would involve setting up molecular dynamics simulations. ```python from atomate2.openmm.flows.core import OpenMMMaker # Example of initializing OpenMMMaker (specific parameters not shown) # openmm_maker = OpenMMMaker() ``` -------------------------------- ### Quasi-harmonic Workflow Tutorial (VASP) Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Code snippet for setting up a quasi-harmonic workflow tutorial using VASP. ```python from atomate2.vasp.flows.qha import CommonQhaMaker # Example of initializing CommonQhaMaker for VASP (specific parameters not shown) # qha_maker = CommonQhaMaker() ``` -------------------------------- ### Install mpi4py Source: https://materialsproject.github.io/atomate2/user/codes/openmm.html Install the MPI library required for distributing simulations across multiple GPUs. ```bash conda install mpi4py ``` -------------------------------- ### Initialize FileClient Source: https://materialsproject.github.io/atomate2/_modules/atomate2/utils/file_client.html Instantiate the FileClient with optional paths for SSH keys and configuration files. ```python def __init__( self, key_filename: str | Path = "~/.ssh/id_rsa", config_filename: str | Path = "~/.ssh/config", verbose: bool = False, ) -> None: self.key_filename = key_filename self.config_filename = config_filename self.connections: dict[str, dict[str, Any]] = {} self.verbose = verbose ``` -------------------------------- ### Install atomate2 with optional components Source: https://materialsproject.github.io/atomate2/dev/dev_install.html Install atomate2 with specific dependency sets for fireworks or AMSET functionality. ```bash pip install atomate2[fireworks] ``` ```bash pip install atomate2[amset] # Install requirements for running AMSET calculations ``` -------------------------------- ### Get Zipped File Utility Source: https://materialsproject.github.io/atomate2/_modules/atomate2/cp2k/drones.html A utility function to get a file from a zip archive. This is part of `atomate2.common.files`. ```python from atomate2.common.files import get_zfile get_zfile( "/path/to/archive.zip", "file_inside.txt" ) ``` -------------------------------- ### Initializing Job Store and Structure Source: https://materialsproject.github.io/atomate2/tutorials/grueneisen_workflow.html Sets up the job store and loads the silicon structure for the workflow. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from pymatgen.core import Structure from atomate2.vasp.flows.gruneisen import GruneisenMaker, PhononMaker warnings.filterwarnings("ignore") job_store = JobStore( MemoryStore(), additional_stores={"data": MemoryStore()}, ) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si_diamond.cif") ``` -------------------------------- ### Install optional atomate2 dependencies Source: https://materialsproject.github.io/atomate2/user/install.html Commands to install specialized capabilities for phonons, Lobster, or force field workflows. ```bash pip install atomate2[phonons] pip install atomate2[lobster] pip install atomate2[forcefields] ``` -------------------------------- ### Initialize Stores via Python Source: https://materialsproject.github.io/atomate2/user/codes/openmm.html Programmatically create and pass MongoStore and S3Store instances to run_locally. ```python from jobflow import run_locally, JobStore from maggma.stores import MongoStore, S3Store mongo_info = { "username": "USERNAME", "password": "PASSWORD", "database": "DATABASE", "host": "mongodb05.nersc.gov", } md_doc_store = MongoStore(**mongo_info, collection_name="atomate2_docs") md_blob_index = MongoStore( **mongo_info, collection_name="atomate2_blobs_index", key="blob_uuid", ) md_blob_store = S3Store( index=md_blob_index, bucket="BUCKET", s3_profile="PROFILE", endpoint_url="https://next-gen-minio.materialsproject.org", key="blob_uuid", ) # run our previous flow with the new stores run_locally( Flow([elyte_interchange_job, production_flow]), store=JobStore(md_doc_store, additional_stores={"data": md_blob_store}), ensure_success=True, ) ``` -------------------------------- ### Execute a LOBSTER workflow Source: https://materialsproject.github.io/atomate2/user/codes/vasp.html Example demonstrating how to initialize a structure, create a LOBSTER workflow, update INCAR settings, and run the job locally. ```python from jobflow import SETTINGS from jobflow import run_locally from pymatgen.core.structure import Structure from atomate2.vasp.flows.lobster import VaspLobsterMaker from atomate2.vasp.powerups import update_user_incar_settings structure = Structure( lattice=[[0, 2.13, 2.13], [2.13, 0, 2.13], [2.13, 2.13, 0]], species=["Mg", "O"], coords=[[0, 0, 0], [0.5, 0.5, 0.5]], ) lobster = VaspLobsterMaker().make(structure) # update the incar lobster = update_user_incar_settings(lobster, {"NPAR": 4}) # run the job run_locally(lobster, create_folders=True, store=SETTINGS.JOB_STORE) ``` -------------------------------- ### Install Atomate2 with OpenMM from Conda Source: https://materialsproject.github.io/atomate2/user/codes/openmm.html Use these commands to set up a conda environment and install Atomate2 with OpenMM support. ```bash conda create -n atomate2 python=3.11 conda activate atomate2 pip install "atomate2[openmm]" ``` -------------------------------- ### Get Inserted Structures Job for Electrodes Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.schemas.task.InputSummary.html Gets inserted structures for electrode calculations. This job is part of `atomate2.common.jobs.electrode`. ```python from atomate2.common.jobs.electrode import get_inserted_structures inserted_structures = get_inserted_structures( structure=structure, element=element, max_sites=max_sites, name="get_inserted_structures" ) ``` -------------------------------- ### Phonon Workflow Tutorial (Force Fields) Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Code snippet for setting up a phonon workflow tutorial using force fields. ```python from atomate2.common.flows.phonons import BasePhononMaker # Example of initializing BasePhononMaker for force fields (specific parameters not shown) # phonon_maker = BasePhononMaker() ``` -------------------------------- ### Get Relaxed Job Summaries Job for Electrodes Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.schemas.task.InputSummary.html Gets summaries of relaxed jobs for electrode calculations. This job is in `atomate2.common.jobs.electrode`. ```python from atomate2.common.jobs.electrode import get_relaxed_job_summaries relaxed_job_summaries = get_relaxed_job_summaries( structure=structure, name="get_relaxed_job_summaries" ) ``` -------------------------------- ### Create Task Document from Directory Source: https://materialsproject.github.io/atomate2/_modules/atomate2/cp2k/schemas/task.html Factory method to initialize a Cp2kTaskDoc by parsing CP2K output files within a directory. ```python @classmethod def from_directory( cls, dir_name: Union[Path, str], volumetric_files: tuple[str, ...] = _VOLUMETRIC_FILES, store_additional_json: bool = SETTINGS.CP2K_STORE_ADDITIONAL_JSON, additional_fields: dict[str, Any] = None, **cp2k_calculation_kwargs, ) -> Self: """Create a task document from a directory containing CP2K files. Parameters ---------- dir_name The path to the folder containing the calculation outputs. store_additional_json Whether to store additional JSON files found in the calculation directory. volumetric_files Volumetric files to search for. additional_fields dictionary of additional fields to add to output document. **cp2k_calculation_kwargs Additional parsing options that will be passed to the :obj:`.Calculation.from_cp2k_files` function. Returns ------- Cp2kTaskDoc A task document for the calculation. """ logger.info(f"Getting task doc in: {dir_name}") additional_fields = additional_fields or {} dir_name = Path(dir_name) task_files = _find_cp2k_files(dir_name, volumetric_files=volumetric_files) if len(task_files) == 0: raise FileNotFoundError(f"No CP2K files found in {dir_name}") calcs_reversed = [] all_cp2k_objects = [] for task_name, files in task_files.items(): calc_doc, cp2k_objects = Calculation.from_cp2k_files( dir_name, task_name, **files, **cp2k_calculation_kwargs ) calcs_reversed.append(calc_doc) all_cp2k_objects.append(cp2k_objects) analysis = AnalysisSummary.from_cp2k_calc_docs(calcs_reversed) transformations, icsd_id, tags, author = parse_transformations(dir_name) if tags: tags.extend(additional_fields.get("tags", [])) else: tags = additional_fields.get("tags") custodian = parse_custodian(dir_name) orig_inputs = _parse_orig_inputs(dir_name) additional_json = None if store_additional_json: additional_json = parse_additional_json(dir_name) dir_name = get_uri(dir_name) # convert to full uri path # only store objects from last calculation # TODO: make this an option cp2k_objects = all_cp2k_objects[-1] included_objects = None if cp2k_objects: included_objects = list(cp2k_objects) if isinstance(calcs_reversed[0].output.structure, Structure): attr = "from_structure" dat = { "structure": calcs_reversed[0].output.structure, "meta_structure": calcs_reversed[0].output.structure, "include_structure": True, } elif isinstance(calcs_reversed[0].output.structure, Molecule): attr = "from_molecule" dat = { "structure": calcs_reversed[0].output.structure, "meta_structure": calcs_reversed[0].output.structure, "molecule": calcs_reversed[0].output.structure, "include_molecule": True, } doc = getattr(cls, attr)(**dat) data = { "structure": calcs_reversed[0].output.structure, "meta_structure": calcs_reversed[0].output.structure, "dir_name": dir_name, "calcs_reversed": calcs_reversed, "analysis": analysis, "transformations": transformations, "custodian": custodian, "orig_inputs": orig_inputs, "additional_json": additional_json, ``` -------------------------------- ### Get Inserted Structures Job Source: https://materialsproject.github.io/atomate2/_modules/atomate2/vasp/flows/lobster.html Gets structures corresponding to inserted electrodes. Useful for analyzing the structural changes during insertion. ```python from atomate2.common.jobs.electrode import get_inserted_structures inserted_structures = get_inserted_structures(task_doc=task_document) ``` -------------------------------- ### Phonon Workflow Tutorial (VASP) Source: https://materialsproject.github.io/atomate2/reference/atomate2.cp2k.jobs.base.BaseCp2kMaker.html Code snippet for setting up a phonon workflow tutorial using VASP. ```python from atomate2.vasp.flows.phonons import PhononMaker # Example of initializing PhononMaker for VASP (specific parameters not shown) # phonon_maker = PhononMaker() ``` -------------------------------- ### Initialize JobStore and Load Structure Source: https://materialsproject.github.io/atomate2/tutorials/qha_workflow.html Sets up the local job storage and loads the input structure for the workflow. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from pymatgen.core import Structure from atomate2.vasp.flows.qha import QhaMaker job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si_diamond.cif") ``` -------------------------------- ### Implement MPMorphMDMaker make method Source: https://materialsproject.github.io/atomate2/_modules/atomate2/common/flows/mpmorph.html Workflow construction method that chains equilibrium volume, production MD, and quenching steps. ```python def make( self, structure: Structure, prev_dir: str | Path | None = None, ) -> Flow: """ Create an MPMorph equilibration workflow. Converegence and quench steps are optional, and may be used to equilibrate the cell volume (useful for high temperature production runs of structures extracted from Materials Project) and to quench the structure from high to low temperature (e.g. amorphous structures), respectively. Parameters ---------- structure : .Structure A pymatgen structure object. prev_dir : str or Path or None A previous VASP calculation directory to copy output files from. Returns ------- Flow A flow containing series of molecular dynamics run (and relax+static). """ flow_jobs = [] if self.equilibrium_volume_maker is not None: convergence_flow = self.equilibrium_volume_maker.make( structure, prev_dir=prev_dir ) flow_jobs.append(convergence_flow) # convergence_flow only outputs a structure structure = convergence_flow.output["structure"] self.production_md_maker.name = self.name + " production run" production_run = self.production_md_maker.make(structure, prev_dir=prev_dir) flow_jobs.append(production_run) if self.quench_maker: quench_flow = self.quench_maker.make( production_run.output.structure, ``` -------------------------------- ### Get Min Energy Summary Job Source: https://materialsproject.github.io/atomate2/reference/atomate2.common.jobs.electrode.TYPE_CHECKING.html Gets a summary of the minimum energy structure from calculation documents. Useful for relaxation studies. ```python from atomate2.common.jobs.electrode import get_min_energy_summary get_min_energy_summary( "calc_docs" ) ``` -------------------------------- ### Initialize JobStore and Load Structure for Phonon Workflow Source: https://materialsproject.github.io/atomate2/tutorials/phonon_workflow.html Initializes a JobStore with a MemoryStore and loads the silicon structure. This setup is necessary before creating the phonon flow. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from pymatgen.core import Structure from atomate2.vasp.flows.phonons import PhononMaker warnings.filterwarnings("ignore") job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si.cif") ``` -------------------------------- ### Test OpenMM Installation Source: https://materialsproject.github.io/atomate2/tutorials/openmm_tutorial.html Run this command to verify that the OpenMM installation is successful. Ensure CUDA tests pass if GPU acceleration is intended. ```bash python -m openmm.testInstallation ``` -------------------------------- ### Initialize test environment Source: https://materialsproject.github.io/atomate2/tutorials/force_fields/phonon_workflow.html Sets up a temporary directory and defines paths for test data. ```python import tempfile import warnings from pathlib import Path tmp_dir = tempfile.mkdtemp() TEST_ROOT = Path().cwd().parent.parent / "tests" TEST_DIR = TEST_ROOT / "test_data" ``` -------------------------------- ### Get Computed Entries Source: https://materialsproject.github.io/atomate2/reference/atomate2.common.flows.gruneisen.BaseGruneisenMaker.html Retrieves computed entries from a database, often used in electrode insertion workflows to get relevant calculation results. ```python from atomate2.common.jobs.electrode import get_computed_entries get_computed_entries( "query", "additional_criteria" ) ``` -------------------------------- ### Initialize workflow components Source: https://materialsproject.github.io/atomate2/tutorials/lobster_workflow.html Sets up the job store and loads the structure for the VASP LOBSTER workflow. ```python from jobflow import JobStore, run_locally from maggma.stores import MemoryStore from pymatgen.core import Structure from atomate2.vasp.flows.lobster import LobsterMaker, VaspLobsterMaker from atomate2.vasp.powerups import update_user_incar_settings warnings.filterwarnings("ignore") job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) si_structure = Structure.from_file(TEST_DIR / "structures" / "Si.cif") ``` -------------------------------- ### Install Atomate2 from Source with OpenMM Source: https://materialsproject.github.io/atomate2/tutorials/openmm_tutorial.html Use these commands to set up a conda environment and install Atomate2 from its GitHub repository, including classical MD dependencies. ```bash conda create -n atomate2 python=3.11 conda activate atomate2 pip install 'git+https://github.com/orionarcher/atomate2.git#egg=atomate2[classical_md]' conda install -c conda-forge --file .github/classical_md_requirements.txt ``` ```bash git clone https://github.com/orionarcher/atomate2.git cd atomate2 git branch openff git checkout openff git pull origin openff pip install -e '.[classical_md]' ```