### Install Basic atomate2 with Pip Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install the core functionality of atomate2 using pip. This is the simplest way to get started. ```bash pip install atomate2 ``` -------------------------------- ### Clone and Install atomate2 from Source Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Clone the atomate2 repository from GitHub and install it from the local source code. ```bash git clone https://github.com/materialsproject/atomate2 cd atomate2 pip install . ``` -------------------------------- ### Install Documentation Build Requirements Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install the dependencies required to build the atomate2 documentation using Sphinx. ```bash pip install . --group docs ``` -------------------------------- ### Install atomate2 with optional dependencies Source: https://context7.com/materialsproject/atomate2/llms.txt Install the base atomate2 package or with additional support for phonons, LOBSTER, force fields, or OpenMM. A full strict install is available for reproducible testing. ```bash pip install atomate2 ``` ```bash pip install "atomate2[phonons]" ``` ```bash pip install "atomate2[lobster]" ``` ```bash pip install "atomate2[forcefields-demo]" ``` ```bash pip install "atomate2[openmm]" ``` ```bash pip install "atomate2[strict]" ``` -------------------------------- ### Developer Install from Source Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Perform a developer installation of atomate2 from source using the editable flag. ```bash pip install -e . ``` -------------------------------- ### Install Atomate2 with OpenMM from Source Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/openmm_tutorial.ipynb Sets up a conda environment and installs Atomate2 with classical MD dependencies from GitHub source. ```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]' ``` -------------------------------- ### Install Atomate2 from Source with OpenMM Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Clone the Atomate2 repository and install it from source with OpenMM support, suitable for frequent updates. ```bash >>> git clone https://github.com/materialsproject/atomate2 >>> cd atomate2 >>> pip install -e '.[openmm]' ``` -------------------------------- ### Install atomate2 with Optional Dependencies Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/install.md Install atomate2 with optional dependency sets for specialized capabilities like phonons, Lobster, or force fields. Choose the set that matches your needs. ```bash pip install atomate2[phonons] ``` ```bash pip install atomate2[lobster] ``` ```bash pip install atomate2[forcefields] ``` -------------------------------- ### Install Test Requirements Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install the necessary dependencies to run unit tests for atomate2 from the source folder. ```bash pip install . --group tests ``` -------------------------------- ### Mock VASP Setup Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/phonon_workflow.ipynb Imports necessary libraries and defines reference paths for mocking VASP calculations. This is used for testing purposes when direct VASP execution is not feasible. ```python import warnings from mock_vasp import TEST_DIR, mock_vasp ref_paths = { "phonon static 1/1": "Si_phonons_3/phonon_static_1_1", "static": "Si_phonons_3/static", "tight relax 1": "Si_phonons_3/tight_relax_1", "tight relax 2": "Si_phonons_3/tight_relax_2", "dielectric": "Si_phonons_3/dielectric", } ``` -------------------------------- ### Install Atomate2 with OpenMM from Conda Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Set up a conda environment and install Atomate2 with OpenMM support using pip. ```bash >>> conda create -n atomate2 python=3.11 >>> conda activate atomate2 >>> pip install "atomate2[openmm]" ``` -------------------------------- ### Install Fireworks Dependencies from Source Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install optional Fireworks dependencies when installing atomate2 from a local source clone. ```bash pip install .[fireworks] ``` -------------------------------- ### Install atomate2 with AMSET Dependencies Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install atomate2 with specific dependencies needed for running AMSET calculations. ```bash pip install atomate2[amset] ``` -------------------------------- ### Mock VASP Setup for QHA Tutorial Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/qha_workflow.ipynb This code block is necessary for running the tutorial in a Jupyter notebook as it mocks the VASP executable. It defines a dictionary mapping various VASP calculation types to their corresponding test directory paths. ```python import warnings from mock_vasp import TEST_DIR, mock_vasp ref_paths = { "phonon static 1/1": "Si_qha_2/phonon_static_1_1", "static": "Si_qha_2/static", "tight relax 1 EOS equilibrium relaxation": "Si_qha_2/tight_relax_1", "tight relax 2 EOS equilibrium relaxation": "Si_qha_2/tight_relax_2", "tight relax 1 deformation 0": "Si_qha_2/tight_relax_1_d0", "tight relax 1 deformation 1": "Si_qha_2/tight_relax_1_d1", "tight relax 1 deformation 2": "Si_qha_2/tight_relax_1_d2", "tight relax 1 deformation 3": "Si_qha_2/tight_relax_1_d3", "tight relax 1 deformation 4": "Si_qha_2/tight_relax_1_d4", "tight relax 1 deformation 5": "Si_qha_2/tight_relax_1_d5", "tight relax 2 deformation 0": "Si_qha_2/tight_relax_2_d0", "tight relax 2 deformation 1": "Si_qha_2/tight_relax_2_d1", "tight relax 2 deformation 2": "Si_qha_2/tight_relax_2_d2", "tight relax 2 deformation 3": "Si_qha_2/tight_relax_2_d3", "tight relax 2 deformation 4": "Si_qha_2/tight_relax_2_d4", "tight relax 2 deformation 5": "Si_qha_2/tight_relax_2_d5", "dft phonon static eos deformation 1": "Si_qha_2/" "dft_phonon_static_eos_deformation_1", "dft phonon static eos deformation 2": "Si_qha_2/" "dft_phonon_static_eos_deformation_2", "dft phonon static eos deformation 3": "Si_qha_2/" "dft_phonon_static_eos_deformation_3", "dft phonon static eos deformation 4": "Si_qha_2/" "dft_phonon_static_eos_deformation_4", "dft phonon static eos deformation 5": "Si_qha_2/" "dft_phonon_static_eos_deformation_5", "dft phonon static eos deformation 6": "Si_qha_2/" "dft_phonon_static_eos_deformation_6", "dft phonon static eos deformation 7": "Si_qha_2/" "dft_phonon_static_eos_deformation_7", "dft phonon static 1/1 eos deformation 1": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_1", "dft phonon static 1/1 eos deformation 2": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_2", "dft phonon static 1/1 eos deformation 3": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_3", "dft phonon static 1/1 eos deformation 4": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_4", "dft phonon static 1/1 eos deformation 5": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_5", "dft phonon static 1/1 eos deformation 6": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_6", "dft phonon static 1/1 eos deformation 7": "Si_qha_2/" "dft_phonon_static_1_1_eos_deformation_7", } ``` -------------------------------- ### Install Atomate2 with TorchSim Support Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/torchsim_tutorial.ipynb Set up a conda environment and install atomate2 with TorchSim and optional MACE model support. ```bash >>> conda create -n atomate2-torchsim python=3.11 >>> conda activate atomate2-torchsim >>> pip install atomate2 >>> pip install torch-sim # For MACE models (optional but recommended) >>> pip install mace-torch ``` -------------------------------- ### Grid Engine Job Submission Script Example Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/install.md An example job submission script for a Grid Engine scheduler, including resource requests and module loading. ```bash #!/bin/bash -l #$ -N relax_si #$ -P my_project #$ -l h_rt=1:00:00 #$ -l mem=4G #$ -pe mpi 16 #$ -cwd # ensure you load the modules to run VASP, e.g., module load vasp conda activate atomate2 python relax.py ``` -------------------------------- ### Install atomate2 with Fireworks Dependencies Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install atomate2 along with optional dependencies required for using it with Fireworks. ```bash pip install atomate2[fireworks] ``` -------------------------------- ### Mock FHI-aims Setup Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/phonon_workflow_aims.ipynb Imports necessary modules and defines reference paths for mocking FHI-aims calculations. This is required for running the workflow in an environment where FHI-aims is not directly accessible. ```python import warnings from mock_aims import TEST_DIR, mock_aims ref_paths = { "Relaxation calculation": "phonon-relax-si", "phonon static aims 1/1": "phonon-disp-si", "SCF Calculation": "phonon-energy-si", "phonon static aims anharmonicity quant. 1/1": "anharm-si-full", } ``` -------------------------------- ### Test OpenMM Installation Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/openmm_tutorial.ipynb Verifies the OpenMM installation by running its test suite. Ensure CUDA is configured if GPU testing is intended. ```bash >>> python -m openmm.testInstallation ``` -------------------------------- ### Create Private LigParGen Docker Image Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md This Dockerfile sets up an Ubuntu environment with Miniconda, RDKit, OpenBabel, and LigParGen. It installs necessary dependencies and clones the LigParGen repository. Ensure BOSS is installed in the same directory as the Dockerfile. ```bash FROM ubuntu:20.04 LABEL org.opencontainers.image.version="20.04" LABEL org.opencontainers.image.ref.name="ubuntu" ARG LAUNCHPAD_BUILD_ARCH ARG RELEASE RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install -y \ libc6:i386 \ libncurses5:i386 \ libstdc++6:i386 \ zlib1g:i386 \ gcc-multilib \ g++-multilib \ binutils \ git \ curl \ libxrender1 \ csh && \ apt-get clean RUN curl -L -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && \ rm Miniconda3-latest-Linux-x86_64.sh && \ /opt/conda/bin/conda init RUN /opt/conda/bin/conda create -n ligpargen -y python=3.7 && \ /opt/conda/bin/conda install -n ligpargen -y -c rdkit rdkit && \ /opt/conda/bin/conda install -n ligpargen -y -c conda-forge openbabel ENV PATH="/opt/conda/envs/ligpargen/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" RUN git clone https://github.com/Isra3l/ligpargen.git /opt/ligpargen && \ cd /opt/ligpargen && \ /opt/conda/envs/ligpargen/bin/pip install -e . COPY ./boss /opt/BOSSdir RUN chmod +x /opt/BOSSdir/* ENV BOSSdir="/opt/BOSSdir" WORKDIR /opt/output RUN echo "source activate ligpargen" > ~/.bashrc SHELL ["/bin/bash", "-c"] CMD ["/bin/bash"] ``` -------------------------------- ### Full Elastic Workflow Test Example Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/vasp_tests.md A complete pytest example for testing the ElasticMaker workflow. It includes setting up mock VASP, generating the flow, updating k-point settings, running the flow locally, and validating the elastic tensor output. ```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, ) ``` -------------------------------- ### Task Document 'calcs_reversed' Example Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/docs_schemas_emmet.md Illustrates the 'calcs_reversed' key within a task document, showing the structure for storing calculation inputs and outputs in reverse order. This is useful for analyzing multi-step calculations. ```json "calcs_reversed": [ { "dir_name": "/scratch/gpfs/.../job_2024-05-19-21-13-15-058677-64911", "vasp_version": "6.4.2", "has_vasp_completed": "successful", "input": { "incar": {...}, "kpoints": {...}, "nkpoints": 20, "potcar": ["PAW_PBE"], "potcar_spec": [ ... ], "potcar_type": ["PAW_PBE"], "parameters": {...}, "lattice_rec": {...}, "structure": {...}, "is_hubbard": false, "hubbards": {} }, "output": { "energy": -11.48288783, "energy_per_atom": -5.741443915, "structure": { .... }, "efermi": 5.96853235, "is_metal": false, "bandgap": 0.45999999999999996, "cbm": 6.2225, "vbm": 5.7625, "is_gap_direct": false, "direct_gap": 2.5146000000000006, "transition": "(0.000,0.000,0.000)-(0.429,0.429,-0.000)", "mag_density": -1.2698159551931228e-7, "epsilon_static": null, "epsilon_static_wolfe": null, "epsilon_ionic": null, "frequency_dependent_dielectric": { "real": null, "imaginary": null, "energy": null }, "ionic_steps": [ ... ], "force_constants": null, "normalmode_frequencies": null, "normalmode_eigenvals": null, "normalmode_eigenvecs": null, "elph_displaced_structures": { "temperatures": null, "structures": null }, "dos_properties": {...}, "run_stats": { "average_memory": 0, "max_memory": 241584, "elapsed_time": 18.833, "system_time": 1.114, "user_time": 16.166, "total_time": 17.28, "cores": 40 } }, "completed_at": "2024-05-19 17:13:34.897366", "task_name": "standard", "output_file_paths": { "chgcar": "CHGCAR", "aeccar0": "AECCAR0", "aeccar1": "AECCAR1", "aeccar2": "AECCAR2" }, "bader": null, "ddec6": null, "run_type": "PBESol", "task_type": "Structure Optimization", "calc_type": "PBESol Structure Optimization" }, ] ``` -------------------------------- ### Start Phonon Workflow with PhononMaker Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/vasp.md Initiates the default VASP phonon workflow. It's recommended to symmetrize the structure beforehand to ensure accurate symmetry detection and minimize calculations. Adjust convergence parameters if necessary for your specific case. ```python from atomate2.vasp.flows.phonons import PhononMaker from pymatgen.core.structure import Structure 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]], ) phonon_flow = PhononMaker(min_length=15.0, store_force_constants=False).make( structure=structure ) ``` -------------------------------- ### BasePhononMaker Flow Maker Example Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/key_concepts_overview.md Demonstrates a Flow Maker for phonon calculations. The `make` function is adjusted to return a `Flow` object, enabling complex workflows with dynamic job creation. ```python @dataclass class BasePhononMaker(Maker, ABC): """ Maker to calculate harmonic phonons with a DFT/force field code and Phonopy. [...] """ name: str = "phonon" [...] # noqa E501 def make(...) -> Flow: ``` -------------------------------- ### Execute a Flow Locally in Python Source: https://context7.com/materialsproject/atomate2/llms.txt Demonstrates how to instantiate a custom Maker, generate a flow from a structure, and execute it locally using jobflow's run_locally function. Ensure pymatgen and jobflow are installed. ```python from jobflow import run_locally from pymatgen.core import Structure # Assuming MyRelaxThenStaticMaker is defined as above # and MyStaticMaker is a valid Maker subclass si = Structure.from_file("Si.cif") flow = MyRelaxThenStaticMaker().make(si) run_locally(flow, create_folders=True) ``` -------------------------------- ### Start Quasi-harmonic Workflow with QhaMaker Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/vasp.md Computes thermodynamic properties using the quasi-harmonic approximation. This workflow includes structural relaxation, optimizations at various volumes, phonon runs, and equation of state fitting. It's recommended to symmetrize the input structure. ```python from atomate2.vasp.flows.qha import QhaMaker from pymatgen.core.structure import Structure 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]], ) qha_flow = QhaMaker( linear_strain=(-0.10, 0.10), number_of_frames=10, ).make(structure=structure) ``` -------------------------------- ### Initialize Job Store and Load Structure Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/qha_workflow.ipynb Sets up the job store and loads the crystal structure for the QHA workflow. Ensure TEST_DIR is correctly defined. ```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") ``` -------------------------------- ### Initialize JobStore, Structure, and LOBSTER workflow maker Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/lobster_workflow.ipynb Sets up the JobStore, loads a structure, and initializes the VaspLobsterMaker for the workflow. Ensure warnings are filtered. ```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") ``` -------------------------------- ### Initialize and run PhononMaker with default settings Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/force_fields/phonon_workflow.ipynb Initializes the PhononMaker with default force field settings and runs the phonon calculation locally. ```python from jobflow import run_locally from atomate2.forcefields.flows.phonons import PhononMaker warnings.filterwarnings("ignore") flow = PhononMaker( min_length=3.0, born_maker=None, use_symmetrized_structure="conventional", create_thermal_displacements=False, store_force_constants=False, prefer_90_degrees=False, generate_frequencies_eigenvectors_kwargs={"tstep": 100}, ).make(si_structure) run_locally(flow, create_folders=True, raise_immediately=True, root_dir=tmp_dir) ``` -------------------------------- ### Build Documentation Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Build the atomate2 documentation into the 'docs_build' directory using sphinx-build. ```bash sphinx-build docs docs_build ``` -------------------------------- ### Initialize and Process with ElectrolyteBuilder Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Set up MongoDB stores for solvation and calculation documents, initialize the ElectrolyteBuilder, and process all items to update simulation targets. This enables high-throughput analysis. ```python solvation_docs = MongoStore(**mongo_info, collection_name="solvation_docs") calculation_docs = MongoStore(**mongo_info, collection_name="calculation_docs") builder = ElectrolyteBuilder(md_docs, md_blob_store, solvation_docs, calculation_docs) builder.connect() items = builder.get_items() processed_docs = builder.process_items(items) builder.update_targets(processed_docs) ``` -------------------------------- ### Verify TorchSim Installation Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/torchsim_tutorial.ipynb Check if TorchSim and atomate2 are installed correctly by importing necessary modules and printing a success message. ```python import torch_sim as ts from atomate2.torchsim.core import TorchSimStaticMaker print("Installation successful!") ``` -------------------------------- ### Set Up and Run VASP Workflows with Parallelization Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/materials_project_workflows.ipynb Sets up VASP workflows using atomate2, applies custom parallelization settings (NCORE, KPAR, NSIM), and prepares for local execution with mock VASP. Imports jobflow, maggma, mock_vasp, monty, and atomate2 modules. ```python from jobflow import Flow, JobStore, run_locally from maggma.stores import MemoryStore from mock_vasp import TEST_DIR from monty.serialization import dumpfn from atomate2.vasp.flows.mp import ( MPGGADoubleRelaxStaticMaker, MPMetaGGADoubleRelaxStaticMaker, ) from atomate2.vasp.powerups import update_user_incar_settings jobs = [] for mp_id, structure in structures.items(): pbe_job = MPGGADoubleRelaxStaticMaker().make(structure) pbe_job.append_name(f" {mp_id}") pbe_job.update_metadata({"mp_id": mp_id}) r2scan_job = MPMetaGGADoubleRelaxStaticMaker().make(structure) r2scan_job.append_name(f" {mp_id}") pbe_job.update_metadata({"mp_id": mp_id}) jobs.extend([pbe_job, r2scan_job]) all_jobs = Flow(jobs) all_jobs = update_user_incar_settings(all_jobs, {"NCORE": 1, "KPAR": 8, "NSIM": 8}) ``` ```python test_data_dir = TEST_DIR / "vasp" / "mp_phase_diagram_tutorial" ref_paths = { k: test_data_dir / v for k, v in { "MP GGA static mp-12957": "MP_GGA_static_mp-12957.json.lzma", "MP GGA relax 2 mp-18937": "MP_GGA_relax_2_mp-18937.json.lzma", "MP GGA relax 1 mp-18937": "MP_GGA_relax_1_mp-18937.json.lzma", "MP pre-relax 1 mp-146": "MP_pre-relax_1_mp-146.json.lzma", "MP meta-GGA relax 2 mp-146": "MP_meta-GGA_relax_2_mp-146.json.lzma", "MP pre-relax 1 mp-541404": "MP_pre-relax_1_mp-541404.json.lzma", "MP meta-GGA static mp-146": "MP_meta-GGA_static_mp-146.json.lzma", "MP GGA static mp-146": "MP_GGA_static_mp-146.json.lzma", "MP meta-GGA static mp-12957": "MP_meta-GGA_static_mp-12957.json.lzma", "MP meta-GGA static mp-541404": "MP_meta-GGA_static_mp-541404.json.lzma", "MP meta-GGA relax 2 mp-541404": "MP_meta-GGA_relax_2_mp-541404.json.lzma", "MP GGA relax 2 mp-146": "MP_GGA_relax_2_mp-146.json.lzma", "MP meta-GGA relax 2 mp-12957": "MP_meta-GGA_relax_2_mp-12957.json.lzma", "MP pre-relax 1 mp-12957": "MP_pre-relax_1_mp-12957.json.lzma", "MP GGA relax 1 mp-12957": "MP_GGA_relax_1_mp-12957.json.lzma", "MP GGA static mp-541404": "MP_GGA_static_mp-541404.json.lzma", "MP GGA relax 1 mp-146": "MP_GGA_relax_1_mp-146.json.lzma", "MP GGA static mp-18937": "MP_GGA_static_mp-18937.json.lzma", "MP GGA relax 2 mp-12957": "MP_GGA_relax_2_mp-12957.json.lzma", "MP pre-relax 1 mp-18937": "MP_pre-relax_1_mp-18937.json.lzma", "MP meta-GGA relax 2 mp-18937": "MP_meta-GGA_relax_2_mp-18937.json.lzma", "MP GGA relax 1 mp-541404": "MP_GGA_relax_1_mp-541404.json.lzma", "MP meta-GGA static mp-18937": "MP_meta-GGA_static_mp-18937.json.lzma", "MP GGA relax 2 mp-541404": "MP_GGA_relax_2_mp-541404.json.lzma", }.items() } job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()}) with mock_vasp(ref_paths) as vasp: responses = run_locally( all_jobs, store=job_store, create_folders=True, ensure_success=True, ) ``` -------------------------------- ### Initialize Phonon Workflow Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/phonon_workflow.ipynb Loads necessary classes and structures for the phonon workflow. Initializes a JobStore with MemoryStores and loads a silicon structure. ```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") ``` -------------------------------- ### Import necessary libraries Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/force_fields/phonon_workflow.ipynb Imports required for setting up temporary directories and file paths for the tutorial. ```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" ``` -------------------------------- ### Install Developer Requirements and Pre-commit Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/dev_install.md Install developer requirements, including pre-commit hooks for code linting and style checks, when contributing to the source code. ```bash pip install -e . --group dev pre-commit install ``` -------------------------------- ### Initialize JobStore and Load Structure Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/phonon_workflow_aims.ipynb Initializes the JobStore and loads the structure for the phonon calculation. It also sets the FHI-aims species directory. Ensure pymatgen settings are correctly configured. ```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" ``` -------------------------------- ### Install Emmet MD Builders Branch Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Install a specific development branch of Emmet's MD builders using pip. This is a prerequisite for using the latest analysis tools. ```bash pip install git+https://github.com/orionarcher/emmet@md_builders ``` -------------------------------- ### Emmet Query Examples Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Provides examples of common Emmet queries for filtering simulation jobs based on completion date or specific UUIDs. These queries help in selecting relevant data for analysis. ```python # query jobs from a specific day april_16 = {"completed_at": {"$regex": "^2024-04-16"}} may = {"completed_at": {"$regex": "^2024-05"}} # query a particular set of jobs job_uuids = [ "3d7b4db4-85e5-48a5-9585-07b37910720f", "4202b18f-f156-4705-8ca6-ac2a08093174", "187d9466-c359-4013-9e25-8b4ece6e3ecf", ] my_specific_jobs = {"uuid": {"$in": job_uuids}} ``` -------------------------------- ### Load VASP Tutorial Tasks Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/materials_project_workflows.ipynb Loads task data from a JSON file for VASP phase diagram tutorial. Requires mock_vasp and monty libraries. ```python from mock_vasp import TEST_DIR, mock_vasp from monty.serialization import loadfn tasks = loadfn( TEST_DIR / "vasp" / "mp_phase_diagram_tutorial" / "MP-example-V-O-phase-diagram.json.gz" ) structures = { mp_id: task_block["PBEsol Structure Optimization"].input.structure for mp_id, task_block in tasks.items() } ``` -------------------------------- ### Create atomate2 Directory Scaffold Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/install.md Run this command to create the initial directory structure for atomate2, including a config subdirectory. ```bash mkdir -p atomate2/config ``` -------------------------------- ### Configure Phonon Displacement Maker Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/qha_workflow.ipynb Sets up the `PhononDisplacementMaker` for static energy calculations within the QHA workflow, configuring VASP parameters. ```python phonon_displacement_maker = PhononDisplacementMaker( run_vasp_kwargs={"handlers": ()}, input_set_generator=StaticSetGenerator( user_incar_settings={ "GGA": "PE", "IBRION": -1, "ISPIN": 1, "ISMEAR": 0, "ISIF": 3, "ENCUT": 700, "EDIFF": 1e-7, "LAECHG": False, "LREAL": False, "ALGO": "Normal", "NSW": 0, "LCHARG": False, "LWAVE": False, "LVTOT": False, "LORBIT": None, "LOPTICS": False, "SIGMA": 0.05, "ISYM": 0, "KSPACING": 0.1, "NPAR": 4, }, auto_ispin=False, ), ) phonon_displacement_maker.name = "dft phonon static" ``` -------------------------------- ### Update Custodian Handlers for VASP Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/vasp.md Modify the custodian handlers for a VASP job by specifying them in `run_vasp_kwargs`. This example sets only the `VaspErrorHandler`. ```python from atomate2.vasp.jobs.core import StaticMaker from custodian.vasp.handlers import VaspErrorHandler maker = StaticMaker(run_vasp_kwargs={"handlers": [VaspErrorHandler]}) ``` -------------------------------- ### Set MAGMOM for VASP Calculations Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/vasp.md Specify magnetic moments for elements using a dictionary in `user_incar_settings`. This example sets MAGMOM for In, Ga, and As. ```python from pymatgen.io.vasp.sets import MPRelaxSet vis = MPRelaxSet(user_incar_settings={"MAGMOM": {"In": 0.5, "Ga": 0.5, "As": -0.5}}) ``` -------------------------------- ### Generate Interchange Object using create_mol_spec Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/openmm_tutorial.ipynb Functionally identical to the previous example, this demonstrates using `create_mol_spec` to prepare molecule specifications before passing them to `generate_interchange`. ```python from atomate2.openff.utils import create_mol_spec mols_specs = [create_mol_spec(**mol_spec_dict) for mol_spec_dict in mol_specs_dicts] generate_interchange(mols_specs, 1.3) ``` -------------------------------- ### Set up Emmet Database Stores Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/codes/openmm.md Configure MongoDB and S3 stores for Emmet to access simulation data. Ensure connection details and bucket names are correctly specified. ```python from maggma.stores import MongoStore, S3Store mongo_info = { "username": "USERNAME", "password": "PASSWORD", "database": "DATABASE", "host": "mongodb05.nersc.gov", } s3_info = { "bucket": "BUCKET", "s3_profile": "PROFILE", "endpoint_url": "https://next-gen-minio.materialsproject.org", } md_docs = 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( **s3_info, index=md_blob_index, key="blob_uuid", ) ``` -------------------------------- ### Plot Free Energy-Volume Curves Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/qha_workflow.ipynb Uses matplotlib to plot the free energy-volume curves for different temperatures based on the retrieved data. Requires matplotlib to be installed. ```python import matplotlib.pyplot as plt for temp, energy_list in zip( result["output"]["temperatures"], result["output"]["helmholtz_volume"], strict=False, ): # Create the plot plt.plot( result["output"]["volumes"], energy_list, marker="o", label=temp, ) # Add labels and title plt.xlabel("Volume") plt.ylabel("Free Energy") # Show the plot plt.show() ``` -------------------------------- ### LobsterMaker Job Maker Example Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/key_concepts_overview.md Illustrates a Job Maker for LOBSTER calculations. The `@job` decorator transforms the `make` function into a job creator, returning a `LobsterTaskDocument`. ```python @dataclass class LobsterMaker(Maker): """ LOBSTER job maker. [...] """ name: str = "lobster" [...] # noqa E501 @job(output_schema=LobsterTaskDocument, data=[CompleteCohp, LobsterCompleteDos]) def make( self, wavefunction_dir: str | Path = None, basis_dict: dict | None = None, ) -> LobsterTaskDocument: """ Run a LOBSTER calculation. [...] """ ``` -------------------------------- ### Configure Phonon Displacement Maker Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/grueneisen_workflow.ipynb Sets up a PhononDisplacementMaker for static VASP calculations, specifying INCAR settings for phonon calculations. ```python phonon_displacement_maker = PhononDisplacementMaker( name="dft phonon static", run_vasp_kwargs={"handlers": ()}, input_set_generator=StaticSetGenerator( user_incar_settings={ "GGA": "PE", "IBRION": -1, "ISPIN": 1, "ISMEAR": 0, "ISIF": 3, "ENCUT": 700, "EDIFF": 1e-7, "LAECHG": False, "LREAL": False, "ALGO": "Normal", "NSW": 0, "LCHARG": False, "LWAVE": False, "LVTOT": False, "LORBIT": None, "LOPTICS": False, "SIGMA": 0.05, "ISYM": 0, "KSPACING": 0.1, "NPAR": 4, }, auto_ispin=False, ), ) ``` -------------------------------- ### Generate ABINIT Reference Files (Implicit Structure) Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/abinit_tests.md Run the `atm dev abinit-generate-reference` command without arguments to generate reference files using an `initial_structure.json` in the current directory. ```bash atm dev abinit-generate-reference ``` -------------------------------- ### Submit atomate2 flow with jobflow-remote Source: https://github.com/materialsproject/atomate2/blob/main/docs/user/jobflow-remote.md Use this snippet to submit a constructed atomate2 flow using jobflow-remote. Ensure jobflow-remote is installed and configure your worker, resources, and project details. ```python from atomate2.vasp.flows.core import RelaxBandStructureMaker from atomate2.vasp.powerups import add_metadata_to_flow from jobflow_remote import submit_flow from pymatgen.core import Structure resources = {"nodes": 1, "partition": "micro", "time": "00:55:00", "ntasks": 48} # construct a rock salt MgO structure mgo_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]], ) # make a band structure flow to optimise the structure and obtain the band structure bandstructure_flow = RelaxBandStructureMaker().make(mgo_structure) # (Optional) add metadata to the flow task document. # Could be useful to filter specific results from the database. # For e.g., adding material project ID for the compound, use following lines bandstructure_flow = add_metadata_to_flow( flow=bandstructure_flow, additional_fields={"mp_id": "mp-190"}, ) submit_flow( bandstructure_flow, worker="my_worker", resources=resources, project="my_project" ) ``` -------------------------------- ### Generate Interchange Object with Simple Molecules Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/openmm_tutorial.ipynb Creates an OpenFF Interchange object from specified molecule specifications (SMILES, count, name). This is the starting point for classical MD workflows. ```python from atomate2.openff.core import generate_interchange mol_specs_dicts = [ {"smiles": "O", "count": 200, "name": "water"}, {"smiles": "CCO", "count": 10, "name": "ethanol"}, {"smiles": "C1=C(C=C(C(=C1O)O)O)C(=O)O", "count": 1, "name": "gallic_acid"}, ] gallic_interchange_job = generate_interchange(mol_specs_dicts, 1.3) ``` -------------------------------- ### Create ABINIT Maker Template Source: https://github.com/materialsproject/atomate2/blob/main/docs/dev/abinit_tests.md Use the `atm dev abinit-script-maker` command to generate a template `create_maker.py` script for testing ABINIT makers. ```bash python create_maker.py ``` -------------------------------- ### Setup LAMMPS Force Field File Source: https://github.com/materialsproject/atomate2/blob/main/tutorials/lammps_workflow.ipynb This code snippet prepares a LAMMPS force field file by decompressing a gzipped file. Ensure your `atomate2.yaml` is configured with `LAMMPS_CMD` or `LAMMPS_MPICMD`. ```python import gzip from importlib.resources import files as import_resource_file from pathlib import Path from jobflow import run_locally from pymatgen.core import Structure from pymatgen.io.lammps.generators import LammpsInputFile from atomate2.lammps.flows.core import MeltQuenchThermalizeMaker from atomate2.lammps.jobs.core import CustomLammpsMaker, LammpsNPTMaker, LammpsNVTMaker original_force_field_file = ( Path(import_resource_file("atomate2")).resolve() / ".." / ".." / "tests/test_data/lammps/Si.tersoff.gz" ) force_field_file = ( original_force_field_file.parent / original_force_field_file.name.split(".gz")[0] ) with ( gzip.open(original_force_field_file, "rb") as f_in, open(force_field_file, "wb") as f_out, ): f_out.write(f_in.read()) ```