### Install MLIPX from PyPI using pip Source: https://github.com/basf/mlipx/blob/main/docs/source/installation.rst Installs the MLIPX package using pip. This command is the basic installation step. Optional extras can be added to install specific MLIP packages. ```console (.venv) $ pip install mlipx ``` -------------------------------- ### Get MLIPX package information Source: https://github.com/basf/mlipx/blob/main/docs/source/installation.rst Retrieves an overview of the MLIPX package, listing the MLIP models it is compatible with. This command helps users understand the available models for use with MLIPX. ```console (.venv) $ mlipx info ``` -------------------------------- ### Install MLIPX from source using uv Source: https://github.com/basf/mlipx/blob/main/docs/source/installation.rst Installs and sets up the MLIPX package for development from its source code repository. This involves cloning the repository, synchronizing dependencies with uv, and activating the virtual environment. ```console (.venv) $ git clone https://github.com/basf/mlipx (.venv) $ cd mlipx (.venv) $ uv sync (.venv) $ source .venv/bin/activate ``` -------------------------------- ### MLIPx CLI: Evaluate and Compare Models Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart.rst This snippet demonstrates how to use the MLIPx command-line interface to evaluate multiple MLIP models on a dataset and compare the results. It requires the MLIPx library to be installed and models to be accessible. The output includes metrics and comparison data. ```console (.venv) $ mlipx recipes metrics --models mace-mpa-0,sevennet,orb-v2 --datapath ../data DODH_adsorption_dft.xyz --repro (.venv) $ mlipx compare --glob "*CompareCalculatorResults" ``` -------------------------------- ### Install MLIPX with MLIP package extras Source: https://github.com/basf/mlipx/blob/main/docs/source/installation.rst Installs MLIPX with specific MLIP package extras. These commands allow users to install MLIPX along with their preferred MLIP packages, such as mace or orb, for enhanced functionality. ```console (.venv) $ pip install mlipx[mace] (.venv) $ pip install mlipx[orb] ``` -------------------------------- ### Switch MLIP package extras with uv sync Source: https://github.com/basf/mlipx/blob/main/docs/source/installation.rst Allows users to switch between different MLIP package extras after installing MLIPX from source. The 'uv sync' command with the '--extra' flag enables easy management of optional dependencies. ```console (.venv) $ uv sync --extra mattersim (.venv) $ uv sync --extra sevenn ``` -------------------------------- ### Initialize Project with Git and DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Commands to create a new project directory and initialize it with Git and DVC for version control and data management. ```console (.venv) $ mkdir my_project (.venv) $ cd my_project (.venv) $ git init (.venv) $ dvc init ``` -------------------------------- ### List MLIPX Steps and Compare Results Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Commands to list available workflow steps using zntrack and compare calculator results using mlipx. Requires a running ZnDraw server. ```console (.venv) $ zntrack list (.venv) $ mlipx compare mace-mp_CompareCalculatorResults ``` -------------------------------- ### Add MLIPX Metrics Recipe Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Command to generate a main.py file that defines the workflow for computing metrics using MLIPX. ```console (.venv) $ mlipx recipes metrics --datapath data.xyz ``` -------------------------------- ### Install ZnDraw Package Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zndraw.rst Installs the ZnDraw package using pip. This is the primary method to get the visualization tool. ```bash pip install zndraw ``` -------------------------------- ### Run MLIPX Energy-Volume Curve Calculation and Comparison Source: https://github.com/basf/mlipx/blob/main/docs/source/index.rst This example demonstrates how to use the mlipx command-line interface to compute energy-volume curves (ev) for a specified material ID using multiple MLIP models. It then shows how to compare the results globbing for 'EnergyVolumeCurve' files. This requires the mlipx library to be installed and configured. ```console (.venv) $ mlipx recipes ev --models mace-mpa-0,sevennet,orb-v2 --material-ids=mp-1143 --repro (.venv) $ mlipx compare --glob "*EnergyVolumeCurve" ``` -------------------------------- ### Evaluate Multiple Models with MLIPX Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Command to evaluate multiple specified models against reference data and automatically reproduce the results using DVC. ```console (.venv) $ mlipx recipes metrics --datapath data.xyz --models mace-mpa-0,sevennet,orb-v2,chgnet --repro ``` -------------------------------- ### Import Reference Data with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Command to import a remote XYZ dataset and add it to the DVC versioned repository. Assumes the data can be read by ase.io.read. ```console (.venv) $ dvc import-url https://github.com/zincware/ips-mace/releases/download/v0.1.0/mptraj_slice.xyz data.xyz ``` -------------------------------- ### Python Plugin Recipe Example Source: https://github.com/basf/mlipx/blob/main/docs/source/authors.rst Demonstrates how to create a new recipe plugin for mlipx. This involves defining a Python file with a command decorated by `app.command()` and registering it in the `pyproject.toml` under the `mlipx.recipes` entry point. The recipe will then be accessible via the mlipx CLI. ```python from mlipx.recipes import app @app.command() def my_recipe(): # Your recipe code here ``` ```toml [project.entry-points."mlipx.recipes"] yourpackage = "yourpackage.recipes" ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/basf/mlipx/blob/main/docs/source/authors.rst Installs the pre-commit hooks for the mlipx project. These hooks must pass before a pull request can be merged, ensuring code quality and consistency. This command is executed within the project's virtual environment. ```console (.venv) $ pre-commit install ``` -------------------------------- ### Copy Local Reference Data with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Commands to copy a local data file and add it to the DVC versioned repository. Use this if you have your own data file. ```bash (.venv) $ cp /path/to/your/data.xyz data.xyz (.venv) $ dvc add data.xyz ``` -------------------------------- ### Get MLIPX Recipe Help Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/recipes.rst Displays help information for the MLIPX recipes command. This is useful for understanding available subcommands and options for managing recipes. ```console (.venv) $ mlipx recipes --help ``` -------------------------------- ### Complete ZnTrack Workflow Example in a Single File Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zntrack.rst This Python script provides a self-contained example of a ZnTrack workflow. It includes the definitions for the BuildMolecule and PackBox Nodes, project initialization, graph definition, and the main execution block. This script can be saved as a single file (e.g., main.py) and used to run the workflow. ```python import zntrack import ase.io import rdkit2ase import pathlib class BuildMolecule(zntrack.Node): smiles: str = zntrack.params() frames: list[ase.Atoms] = zntrack.outs() def run(self): self.frames = [rdkit2ase.smiles2atoms(self.smiles)] class PackBox(zntrack.Node): data: list[list[ase.Atoms]] = zntrack.deps() counts: list[int] = zntrack.params() density: float = zntrack.params() frames_path: pathlib.Path = zntrack.outs_path(zntrack.nwd / 'frames.xyz') def run(self): box = rdkit2ase.pack(self.data, counts=self.counts, density=self.density) ase.io.write(self.frames_path, box) if __name__ == "__main__": project = zntrack.Project() with project: water = BuildMolecule(smiles="O") ethanol = BuildMolecule(smiles="CCO") box = PackBox(data=[water.frames, ethanol.frames], counts=[50, 50], density=800) project.build() ``` -------------------------------- ### Install MLFlow for mlipx Integration Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/metrics.rst Installs the MLFlow library, which is required for mlipx to log metrics to MLFlow. Ensure pip is available. ```bash pip install mlflow ``` -------------------------------- ### Install mlipx Python Package Source: https://github.com/basf/mlipx/blob/main/README.md Installs the mlipx Python library using pip. This package is lightweight and does not include MLIP code; users may need to install additional dependencies manually if ImportErrors occur. ```bash pip install mlipx ``` -------------------------------- ### Install Paraffin Package Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/distributed.rst Installs the paraffin package from PyPI using pip. This is the primary method for obtaining the necessary tools for distributed evaluation. ```bash pip install paraffin ``` -------------------------------- ### View Metrics with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/metrics.rst Displays the metrics associated with Data Version Control (DVC) for the current project. Requires DVC to be installed and initialized. ```bash dvc metrics show ``` -------------------------------- ### Install MLIPX and RDKit2ASE Packages Source: https://github.com/basf/mlipx/blob/main/docs/source/notebooks/structure_relaxation.ipynb Installs the MLIPX and RDKit2ASE Python packages if they are not already present. This ensures the necessary libraries are available for running the subsequent code. ```python # Only install the packages if they are not already installed !pip show mlipx > /dev/null 2>&1 || pip install mlipx !pip show rdkit2ase > /dev/null 2>&1 || pip install rdkit2ase ``` -------------------------------- ### CLI: Display Model Information Source: https://context7.com/basf/mlipx/llms.txt Retrieves and displays information about installed MLIPs, available computational nodes, and the current environment configuration. This command is essential for understanding the available resources and models. ```bash mlipx info ``` -------------------------------- ### Define MLIPX Calculator Model in Python Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/cli.rst Python code defining a generic ASE calculator for a MACE model using mlipx. The 'device' set to 'auto' will use a GPU if available. ```python import mlipx mace_mp = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", device="auto", kwargs={ "model": "medium", }, ) MODELS = {"mace-mp": mace_mp} ``` -------------------------------- ### Initialize Git and DVC Repository Source: https://github.com/basf/mlipx/blob/main/docs/source/notebooks/structure_relaxation.ipynb Initializes a Git and DVC repository within a temporary directory. This is a standard setup for tracking experiments and data in mlipx projects. ```shell !git init !dvc init --quiet !mkdir src !touch src/__init__.py ``` -------------------------------- ### Upload MLIPX Recipe Results (MLflow) Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/recipes.rst Uploads MLIPX recipe results to a parameter and metric tracking service like MLflow. This command requires a running MLflow server and the 'zntrack' package to be installed. Other tracking services may also be supported. ```console (.venv) $ zntrack mlflow-sync --help ``` -------------------------------- ### Load Trajectory Files with MLIPX Source: https://context7.com/basf/mlipx/llms.txt Provides an entry point for loading atomic structures from various file formats into MLIPX workflows. It supports loading full trajectories or sampled frames based on start, stop, and step parameters. The output is a list of ase.Atoms objects. ```python import mlipx project = mlipx.Project() with project: # Load full trajectory traj = mlipx.LoadDataFile( path="/path/to/trajectory.xyz", start=0, stop=None, step=1 ) # Load every 10th frame sampled = mlipx.LoadDataFile( path="/path/to/large_trajectory.h5md", start=100, stop=1000, step=10 ) project.repro() # Access frames all_frames = traj.frames # list of ase.Atoms sampled_frames = sampled.frames print(f"Loaded {len(all_frames)} structures") ``` -------------------------------- ### Run NEB Calculations with MLIPX CLI Source: https://github.com/basf/mlipx/blob/main/README.md This snippet demonstrates how to run Nudged Elastic Band (NEB) calculations using the MLIPX command-line interface. It specifies the models to use, the data path for the start and end structures, and enables reproducibility. It also includes a command to compare the results of multiple NEB calculations. ```bash mlipx recipes neb --models mace-mpa-0,sevennet,orb-v2 --datapath ../data/neb_end_p.xyz --repro mlipx compare --glob "*NEBs" ``` -------------------------------- ### Python Main Script for Molecular Dynamics Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/md.rst This Python script, main.py, is used within the molecular dynamics simulation recipe. It likely orchestrates the simulation setup and execution, potentially interacting with model definitions and simulation parameters. It serves as the entry point for running the molecular dynamics tests. ```Python from mlipx.nodes.md.configs import LangevinConfig from mlipx.nodes.md.observers import MaximumForceObserver from mlipx.nodes.md.modifiers import TemperatureRampModifier from mlipx.nodes.md import MolecularDynamics # Example usage (assuming model is defined elsewhere) # model = ... # config = LangevinConfig(dt=0.001, temperature=300) # observer = MaximumForceObserver(max_force=10.0) # modifier = TemperatureRampModifier(start_temp=300, end_temp=500, duration=1000) # md_node = MolecularDynamics(model=model, config=config, observers=[observer], modifiers=[modifier]) # In a real scenario, this script would likely call md_node.run() or similar ``` -------------------------------- ### Initialize mlipx Project with Git and DVC Source: https://github.com/basf/mlipx/blob/main/README.md Sets up a new project directory for running experiments using mlipx. This involves initializing Git for version control and DVC for data versioning, with a recommendation to use `dvc add` for data files. ```bash mkdir exp cd exp git init && dvc init ``` ```bash cp /your/data/file.xyz . dvc add file.xyz ``` -------------------------------- ### Initialize MLIPX Recipe Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/recipes.rst Initializes a new MLIPX recipe for molecular dynamics. This command creates a directory structure and essential files for a new recipe. Ensure you are in the desired project directory before running. ```console (.venv) $ mkdir molecular_dynamics (.venv) $ cd molecular_dynamics (.venv) $ mlipx recipes md --initialize ``` -------------------------------- ### Build and Track MLIPX Recipe Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/recipes.rst Builds and executes an MLIPX recipe, followed by tracking the results with DVC. This involves running the main script and then using 'dvc repro' to manage data versioning and reproducibility. ```console (.venv) $ python main.py (.venv) $ dvc repro ``` -------------------------------- ### Python API for MLIPX Project Initialization and Structure Optimization Source: https://github.com/basf/mlipx/blob/main/README.md This Python snippet shows how to initialize an MLIPX project and define a GenericASECalculator using the MACE model. It then demonstrates how to perform a structure optimization using this calculator and load data from a file. The snippet concludes by showing how to reproduce the project state and access the optimization results. ```python import mlipx # Initialize the project project = mlipx.Project() # Define an MLIP mace_mp = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", device="auto", kwargs={ "model": "medium", }, ) # Use the MLIP in a structure optimization with project: data = mlipx.LoadDataFile(path="/your/data/file.xyz") relax = mlipx.StructureOptimization( data=data.frames, data_id=-1, model=mace_mp, fmax=0.1 ) # Reproduce the project state project.repro() # Access the results print(relax.frames) # >>> [ase.Atoms(...), ...] ``` -------------------------------- ### Set up MLIPx Recipe for Evaluation Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/python.rst Sets up the MLIPx recipe to compute metrics for an MLIP. It involves loading reference data, applying a calculator to new data, evaluating calculator results, and comparing them against the reference. ```python project = mlipx.Project() with project.group("reference"): data = mlipx.LoadDataFile(path=mptraj) ref_evaluation = mlipx.EvaluateCalculatorResults(data=data.frames) with project.group("mace-mp"): updated_data = mlipx.ApplyCalculator(data=data.frames, model=mace_mp) evaluation = mlipx.EvaluateCalculatorResults(data=updated_data.frames) mlipx.CompareCalculatorResults(data=evaluation, reference=ref_evaluation) project.repro() ``` -------------------------------- ### List MLIPx Steps Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/python.rst Lists the available steps in the MLIPx workflow. This command helps in understanding the structure and components of the defined workflow. ```console (.venv) $ zntrack list ``` -------------------------------- ### Generate Phase Diagram using MLIPX CLI Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/phase_diagram.rst This snippet demonstrates the command-line usage of MLIPX for generating phase diagrams. It shows how to instantiate a test directory for creating diagrams. No specific input/output is detailed beyond directory creation. ```bash # Command to instantiate a test directory for phase diagram generation. # Specific arguments or expected output are not detailed in the provided text. ``` -------------------------------- ### Create and Build a ZnTrack Project Graph Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zntrack.rst This Python script demonstrates how to initialize a ZnTrack Project, define nodes for building molecules and packing them into a box, and then build the project graph. It shows the instantiation of BuildMolecule and PackBox nodes and their connection within the project context. ```python project = zntrack.Project() with project: water = BuildMolecule(smiles="O") ethanol = BuildMolecule(smiles="CCO") box = PackBox(data=[water.frames, ethanol.frames], counts=[50, 50], density=800) project.build() ``` -------------------------------- ### Run Energy-Volume Curve Recipe with CLI Source: https://context7.com/basf/mlipx/llms.txt A command-line interface command to run common MLIP evaluation workflows, specifically the Energy-Volume curve. It allows specifying multiple models, material IDs, and automatically reproduces the calculation. Results can then be compared using the 'mlipx compare' command. ```bash # Initialize new project directory mkdir my_mlip_test cd my_mlip_test git init && dvc init # Run E-V curve for silicon with multiple models mlipx recipes ev \ --models mace-mpa-0,sevennet,orb-v2 \ --material-ids mp-149 \ --repro # Compare results in ZnDraw mlipx compare --glob "*EnergyVolumeCurve" ``` -------------------------------- ### Generate Plots for Homonuclear Diatomics (Python) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/homonuclear_diatomics.rst This Python snippet generates plots for MLIP performance on homonuclear diatomics. It uses the 'get_plots' function from 'mlipx.doc_utils', requiring a glob pattern and a path to the model data. The output is a dictionary of plots, with an example of showing the 'Li-Li bond (adjusted)' plot. ```python from mlipx.doc_utils import get_plots plots = get_plots("*HomonuclearDiatomics", "../../mlipx-hub/diatomics/LiCl/") plots["Li-Li bond (adjusted)"].show() ``` -------------------------------- ### Run mlipx comparison command Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/energy_and_forces.rst This command-line interface (CLI) snippet demonstrates how to initiate a comparison of calculator results using the mlipx tool. It utilizes glob patterns to specify which calculator results to compare, typically those related to formation energy evaluations. ```console (.venv) $ mlipx compare --glob "*CompareCalculatorResults" ``` -------------------------------- ### Main script for DODH adsorption metrics Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/energy_and_forces.rst This Python script, likely the entry point for the DODH adsorption metrics calculation, orchestrates the workflow. It imports and utilizes various mlipx nodes to perform calculations and comparisons, as detailed in the project's documentation. ```python from pathlib import Path from mlipx.nodes import ( ApplyCalculator, EvaluateCalculatorResults, CompareCalculatorResults, CalculateFormationEnergy, CompareFormationEnergy ) def main(): """Main function to orchestrate the formation energy comparison. """ # Create a directory for the output if it doesn't exist output_dir = Path("./output") output_dir.mkdir(exist_ok=True) # Define paths to data and models # In a real scenario, these would be more dynamic or passed as arguments data_path = Path("./data/reference_data.json") model_path = Path("./models.py") # Assuming models.py is in the same directory # --- Step 1: Calculate Formation Energy for Reference Data --- # This node calculates the formation energy for each structure in the reference dataset. calculate_formation_energy_ref = CalculateFormationEnergy( input=data_path, output=output_dir / "reference_formation_energy.json", name="CalculateFormationEnergy_Reference" ) calculate_formation_energy_ref.run() # --- Step 2: Evaluate Calculator Results for Reference Data --- # This node evaluates the results from a calculator (e.g., DFT) against the reference formation energies. evaluate_calculator_results_ref = EvaluateCalculatorResults( input=calculate_formation_energy_ref.output, output=output_dir / "reference_evaluated_results.json", name="EvaluateCalculatorResults_Reference" ) evaluate_calculator_results_ref.run() # --- Step 3: Apply and Evaluate Different Models --- # This section would typically loop through different models (e.g., MLIPs) and compare their predictions. # For demonstration, we'll simulate applying one model. # Assuming a model defined in models.py, e.g., 'MyMLModel' # from models import MyMLModel # Uncomment and adapt if models.py is structured this way # --- Model 1 Example (Conceptual) --- # Apply the calculator (e.g., MLIP) to the reference data structures apply_calculator_model1 = ApplyCalculator( input=data_path, # Replace 'your_model_instance' with the actual model loading/instantiation logic # calculator=your_model_instance, calculator="models.MyMLModel", # Example using string reference output=output_dir / "model1_applied_results.json", name="ApplyCalculator_Model1" ) apply_calculator_model1.run() # Calculate formation energy using the applied model's predictions calculate_formation_energy_model1 = CalculateFormationEnergy( input=apply_calculator_model1.output, output=output_dir / "model1_formation_energy.json", name="CalculateFormationEnergy_Model1" ) calculate_formation_energy_model1.run() # Evaluate the results from Model 1 evaluate_calculator_results_model1 = EvaluateCalculatorResults( input=calculate_formation_energy_model1.output, output=output_dir / "model1_evaluated_results.json", name="EvaluateCalculatorResults_Model1" ) evaluate_calculator_results_model1.run() # --- Step 4: Compare Model Results with Reference --- # Compare the results of Model 1 against the reference evaluation. compare_calculator_results_model1 = CompareCalculatorResults( input=[evaluate_calculator_results_ref.output, evaluate_calculator_results_model1.output], output=output_dir / "comparison_model1.json", name="CompareCalculatorResults_Model1" ) compare_calculator_results_model1.run() # --- Conceptual loop for multiple models (N) --- # for i in range(2, N + 1): # # Apply, CalculateFormationEnergy, EvaluateCalculatorResults for model i # # ... # # CompareCalculatorResults for model i # compare_calculator_results_model_i = CompareCalculatorResults( # input=[evaluate_calculator_results_ref.output, evaluate_calculator_results_model_i.output], # output=output_dir / f"comparison_model{i}.json", # name=f"CompareCalculatorResults_Model{i}" # ) # compare_calculator_results_model_i.run() # --- Final Comparison (Optional: Compare Formation Energies Directly) --- # This node can directly compare formation energies if needed, potentially across multiple models. # compare_formation_energy = CompareFormationEnergy( # input=[ # calculate_formation_energy_ref.output, # calculate_formation_energy_model1.output, # # Add outputs from other models here # ], # output=output_dir / "comparison_formation_energy.json", # name="CompareFormationEnergy_All" # ) # compare_formation_energy.run() print("Energy and Force Evaluation process completed.") if __name__ == "__main__": main() ``` -------------------------------- ### Load ASE-Compatible Calculators with GenericASECalculator Source: https://context7.com/basf/mlipx/llms.txt Initializes an ASE-compatible calculator for use within mlipx workflows. Supports loading calculators from specified modules and class names, with options for device selection and keyword arguments. It also includes a check for calculator availability. ```python import mlipx # Initialize a MACE-MP calculator mace_calculator = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", device="auto", # auto-detect cuda/cpu kwargs={ "model": "medium", "default_dtype": "float32" } ) # Initialize a Lennard-Jones calculator for testing lj_calculator = mlipx.GenericASECalculator( module="ase.calculators.lj", class_name="LennardJones", kwargs={"epsilon": 1.0, "sigma": 1.0} ) # Check if dependencies are available if mace_calculator.available: calc = mace_calculator.get_calculator() # Use calc with ASE Atoms objects else: print("MACE not installed") ``` -------------------------------- ### Submit and Manage Paraffin Evaluation Jobs Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/distributed.rst Commands for interacting with the paraffin package to manage distributed evaluations. 'paraffin submit' queues evaluation stages, and 'paraffin worker' starts worker processes to execute queued tasks. Workers can be configured with concurrency and specific queue targeting. ```bash paraffin submit ``` ```bash paraffin worker --concurrency 5 ``` ```bash paraffin worker --queue BQueue ``` -------------------------------- ### Set Custom ZnDraw Server and Run Comparison Source: https://context7.com/basf/mlipx/llms.txt Sets a custom URL for the ZnDraw server and then runs a comparison, likely for energy-volume curves, using a glob pattern to match relevant files. ```bash export ZNDRAW_URL=http://localhost:1234 mlipx compare --glob "*EnergyVolumeCurve" --browser ``` -------------------------------- ### Initialize Git and DVC Repositories Source: https://github.com/basf/mlipx/blob/main/docs/source/notebooks/combine.ipynb Initializes a Git repository and a DVC (Data Version Control) repository in the current directory. This is a fundamental step for experiment tracking and data management within the MLIPX framework. It uses shell commands executed within a Python environment. ```python import os import tempfile temp_dir = tempfile.TemporaryDirectory() os.chdir(temp_dir.name) !git init !dvc init --quiet ``` -------------------------------- ### Run MLIPx Workflow Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/python.rst Executes the MLIPx workflow defined in the main.py file. This command triggers the computation of metrics for the MLIP against the reference DFT data. ```console (.venv) $ python main.py ``` -------------------------------- ### CLI: Run NEB Calculation with Endpoint Structures Source: https://context7.com/basf/mlipx/llms.txt Sets up and executes a nudged elastic band (NEB) calculation using specified MLIP models and endpoint structures from a data file. The `--repro` flag ensures reproducibility. ```bash mlipx recipes neb \ --models mace-mpa-0,sevennet \ --datapath ../data/neb_endpoints.xyz \ --repro ``` -------------------------------- ### Run Vibrational Analysis and Compare Results (Console) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/vibrational_analysis.rst This snippet shows the console commands to execute a vibrational analysis workflow using mlipx. It involves running a main script, reproducing data with dvc, and comparing analysis results. ```console (.venv) $ python main.py (.venv) $ dvc repro (.venv) $ mlipx compare --glob "*VibrationalAnalysis" ``` -------------------------------- ### Copy and Add Local Data File with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/data.rst Demonstrates the command-line steps to copy a local data file (e.g., trajectory file) to the current directory and then add it to DVC for version control. ```console (.venv) $ cp /path/to/data.xyz . (.venv) $ dvc add data.xyz ``` -------------------------------- ### Configure MLIPX Project Workflow Source: https://github.com/basf/mlipx/blob/main/docs/source/notebooks/combine.ipynb Sets up a computational workflow using the MLIPX library. This involves defining project groups for different stages: initializing structures from SMILES, optimizing structures, running molecular dynamics simulations, and calculating homonuclear diatomics. It utilizes various MLIPX nodes and configurations like ASE calculators and Langevin thermostats. ```python import mlipx project = mlipx.Project() emt = mlipx.GenericASECalculator( module="ase.calculators.emt", class_name="EMT", ) with project.group("initialize"): confs = mlipx.Smiles2Conformers(smiles="CCCC", num_confs=1) with project.group("structure-optimization"): struct_optim = mlipx.StructureOptimization( data=confs.frames, data_id=-1, optimizer="LBFGS", model=emt ) thermostat = mlipx.LangevinConfig( timestep=0.5, temperature=300, friction=0.001, ) with project.group("molecular-dynamics"): md = mlipx.MolecularDynamics( data=struct_optim.frames, data_id=-1, model=emt, thermostat=thermostat, steps=1000, ) with project.group("homonuclear-diatomics"): ev = mlipx.HomonuclearDiatomics( data=confs.frames, model=emt, n_points=100, min_distance=0.75, max_distance=2.0, elements=[], ) project.repro() ``` -------------------------------- ### Vibrational Analysis Models Configuration (Python) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/vibrational_analysis.rst This Python code snippet defines the models used for vibrational analysis, typically found in a models.py file. It illustrates how to import and potentially configure different analysis models. ```python from mlipx.nodes import Energetics, VibrationalAnalysis # Define your models here # Example: Using VibrationalAnalysis node models = [ VibrationalAnalysis( # ... configuration options ... ) # Add other nodes like Energetics if needed ] ``` -------------------------------- ### Run NEB Calculation for Transition State Search Source: https://context7.com/basf/mlipx/llms.txt Calculates minimum energy pathways and transition states between reactant and product configurations using the NEB method. It requires initial and final structures, a calculator, and specifies relaxation parameters. Outputs include the NEB path, energy barrier, and trajectory frames. ```python import mlipx project = mlipx.Project() calculator = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", kwargs={"model": "medium"} ) with project: # Load initial and final structures data = mlipx.LoadDataFile(path="/path/to/neb_endpoints.xyz") # Interpolate between endpoints interpolated = mlipx.NEBinterpolate( data=data.frames, n_images=7, mic=False, add_constraints=True ) # Run NEB calculation neb = mlipx.NEBs( data=interpolated.frames, model=calculator, relax=True, optimizer="FIRE", fmax=0.09, n_steps=500 ) project.repro() # Access results neb_path = neb.frames energy_barrier = max(neb.results["potential_energy"]) trajectory = neb.trajectory_frames figures = neb.figures["NEB_path"] print(f"Activation energy: {energy_barrier:.3f} eV") ``` -------------------------------- ### Generate Conformers and Build Simulation Box from SMILES Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/data.rst Demonstrates generating multiple conformers for a molecule from its SMILES string and then building a simulation box with a specified density and number of molecules using mlipx. Requires Packmol and rdkit2ase. ```python import mlipx project = mlipx.Project() with project.group("initialize"): confs = mlipx.Smiles2Conformers(smiles="CCO", num_confs=10) data = mlipx.BuildBox(data=[confs.frames], counts=[10], density=789) ``` -------------------------------- ### Visualize Atomic Structures via CLI Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zndraw.rst Demonstrates how to use the ZnDraw command-line interface to visualize atomic structures from files or ZnTrack nodes. It supports ASE-compatible file formats and H5MD, as well as ZnTrack nodes with specific attributes. ```bash zndraw file.xyz # any ASE supported file format + H5MD ``` ```bash zndraw --remote . Node.frames # any ZnTrack node that has an attribute `list[ase.Atoms]` ``` -------------------------------- ### CLI: Relax Multiple Molecules from SMILES Source: https://context7.com/basf/mlipx/llms.txt Performs structure relaxation workflows for multiple molecules specified by SMILES strings using different MLIP models. The `--repro` flag ensures reproducibility. ```bash mlipx recipes relax \ --models mace-mpa-0,sevennet \ --smiles "CCO,C1=CC=CC=C1" \ --repro ``` -------------------------------- ### Configure Vibrational Analysis System Parameter (Python) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/vibrational_analysis.rst This Python code demonstrates how to configure the 'system' parameter within the VibrationalAnalysis node in the main.py script. This is crucial for specifying the type of molecular system to be analyzed. ```python from mlipx.nodes import VibrationalAnalysis # ... other setup code ... # Set the system parameter based on your SMILES list system_type = "molecule" # or other relevant type VibrationalAnalysis( # ... other parameters ... system=system_type ) # ... rest of the script ... ``` -------------------------------- ### Download Reference Data using zntrack Source: https://github.com/basf/mlipx/blob/main/docs/source/quickstart/python.rst Downloads reference dataset using zntrack.add function. This function takes a URL and a local path, fetching the data and saving it to the specified location within the project. ```python import mlipx import zntrack mptraj = zntrack.add( url="https://github.com/zincware/ips-mace/releases/download/v0.1.0/mptraj_slice.xyz", path="data.xyz", ) ``` -------------------------------- ### Python: Compare Multiple Structure Optimization Runs Source: https://context7.com/basf/mlipx/llms.txt Loads multiple structure optimization runs from a project using zntrack and compares them using mlipx. This allows for statistical analysis of model agreement and uncertainty, with results including frames and comparison figures. ```python import mlipx import zntrack # Load multiple optimization runs project = mlipx.Project() node1 = zntrack.from_rev("mace_StructureOptimization", rev="main") node2 = zntrack.from_rev("sevennet_StructureOptimization", rev="main") node3 = zntrack.from_rev("orb_StructureOptimization", rev="main") # Compare optimizations comparison = mlipx.StructureOptimization.compare(node1, node2, node3) # Access comparison results all_frames = comparison["frames"] energy_comparison_fig = comparison["figures"]["energy_vs_steps"] adjusted_energy_fig = comparison["figures"]["adjusted_energy_vs_steps"] ``` -------------------------------- ### CLI: Compare NEB Paths Source: https://context7.com/basf/mlipx/llms.txt Compares NEB calculation results based on a glob pattern, likely to analyze reaction pathways computed with different models or settings. It can also be used to visualize transition states. ```bash mlipx compare --glob "*NEBs" mlipx compare --glob "*NEBs" --token my_custom_token ``` -------------------------------- ### Connect to ZnDraw Instance with Python Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zndraw.rst Shows how to connect to a running ZnDraw instance from within a Python script using the ZnDraw library. It allows for real-time modification of ASE Atom objects, which are reflected in the GUI. Requires a running ZnDraw instance and potentially a token. ```python from zndraw import ZnDraw vis = ZnDraw(url="http://localhost:1234", token="") print(vis[0]) >>> ase.Atoms(...) vis.append(ase.Atoms(...)) ``` -------------------------------- ### View Plots with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/metrics.rst Renders and displays the plots generated and tracked by Data Version Control (DVC). This command requires DVC to be set up. ```bash dvc plots show ``` -------------------------------- ### Python: Compare Energy-Volume Curves and Save Figure Source: https://context7.com/basf/mlipx/llms.txt Compares energy-volume curves from different MLIP models, retrieves comparison results including figures, and saves the energy-volume curve comparison figure as a JSON file. ```python import mlipx import zntrack from plotly import io as pio # Compare E-V curves ev1 = zntrack.from_rev("mace_EnergyVolumeCurve") ev2 = zntrack.from_rev("sevennet_EnergyVolumeCurve") ev_comparison = mlipx.EnergyVolumeCurve.compare(ev1, ev2) # Save figures pio.write_json( ev_comparison["figures"]["energy-volume-curve"], "ev_comparison.json" ) ``` -------------------------------- ### Run MD Simulations with MolecularDynamics Node Source: https://context7.com/basf/mlipx/llms.txt Performs molecular dynamics simulations with temperature control using the Langevin thermostat. This node requires an ASE-compatible calculator, thermostat configuration (timestep, temperature, friction), and the number of simulation steps. It outputs trajectory frames and plots. ```python import mlipx from mlipx.nodes.molecular_dynamics import LangevinConfig project = mlipx.Project() calculator = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", kwargs={"model": "medium"} ) with project: data = mlipx.LoadDataFile(path="/path/to/initial_structure.xyz") # Configure Langevin thermostat thermostat = LangevinConfig( timestep=1.0, # fs temperature=300.0, # K friction=0.01 # 1/fs ) # Run MD simulation md_run = mlipx.MolecularDynamics( data=data.frames, data_id=-1, model=calculator, thermostat=thermostat, steps=1000 ) project.repro() ``` -------------------------------- ### CLI: Relax from Custom Data File Source: https://context7.com/basf/mlipx/llms.txt Executes structure relaxation for a molecule defined in a custom data file (e.g., XYZ format) using a specified MLIP model. The `--repro` flag ensures reproducibility. ```bash mlipx recipes relax \ --models orb-v2 \ --datapath my_structure.xyz \ --repro ``` -------------------------------- ### Structure Optimization with StructureOptimization Node Source: https://context7.com/basf/mlipx/llms.txt Performs structure relaxation to find local energy minima using any MLIP calculator. This node takes ASE-compatible calculators, optimization parameters like `fmax` and `steps`, and outputs optimized structures and plots of energy/fmax convergence. ```python import mlipx from ase.optimize import LBFGS # Setup project and calculator project = mlipx.Project() mace_mp = mlipx.GenericASECalculator( module="mace.calculators", class_name="mace_mp", device="cuda", kwargs={"model": "medium"} ) # Load structure data with project: data = mlipx.LoadDataFile(path="/path/to/structure.xyz") # Optimize the last structure in the file relax = mlipx.StructureOptimization( data=data.frames, data_id=-1, model=mace_mp, optimizer="LBFGS", fmax=0.05, # convergence criterion steps=100_000_000 ) # Run optimization project.repro() # Access results optimized_structures = relax.frames energy_vs_steps = relax.figures["energy_vs_steps"] fmax_vs_steps = relax.figures["fmax_vs_steps"] print(f"Final energy: {optimized_structures[-1].get_potential_energy()} eV") ``` -------------------------------- ### Import Remote Data File with DVC Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/data.rst Illustrates the command-line usage of DVC to import a data file from a remote URL into the local file system, making it available for the workflow. ```console (.venv) $ dvc import-url https://url/to/your/data.xyz data.xyz ``` -------------------------------- ### Compare Metrics with mlipx compare Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/metrics.rst Compares results from the same Node or experiment using ZnDraw visualization. Each Node defines its own comparison method. ```bash mlipx compare mace-mpa-0_StructureOptimization orb-v2_0_StructureOptimization ``` -------------------------------- ### Fetch Structures from Materials Project API Source: https://context7.com/basf/mlipx/llms.txt Queries the Materials Project database to retrieve crystalline structures. It allows searching by material IDs or chemical formulas and specifies criteria like the number of sites. The retrieved structures are returned as a list of ase.Atoms objects. ```python import mlipx import os # Set API key os.environ["MP_API_KEY"] = "your_materials_project_api_key" project = mlipx.Project() with project: # Search by material IDs mp_structures = mlipx.MPRester( search_kwargs={ "material_ids": ["mp-1143", "mp-149", "mp-30"] } ) # Search by formula silicon_structures = mlipx.MPRester( search_kwargs={ "formula": "Si", "num_sites": (1, 10) } ) project.repro() # Access structures frames = mp_structures.frames print(f"Retrieved {len(frames)} structures") for atoms in frames: print(f"{atoms.get_chemical_formula()}: {len(atoms)} atoms") ``` -------------------------------- ### Build a Simulation Box from SMILES Strings with rdkit2ase Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/zntrack.rst This Python script demonstrates how to use the rdkit2ase library to convert SMILES strings into atomic structures and then pack them into a simulation box with specified density and counts. It utilizes rdkit2ase.smiles2atoms for structure creation and rdkit2ase.pack for box packing. ```python import rdkit2ase water = rdkit2ase.smiles2atoms('O') ethanol = rdkit2ase.smiles2atoms('CCO') box = rdkit2ase.pack([[water], [ethanol]], counts=[50, 50], density=800) print(box) >>> ase.Atoms(...) ``` -------------------------------- ### Set ZnDraw Visualizer URL Source: https://github.com/basf/mlipx/blob/main/README.md Configures the default visualizer path for ZnDraw by setting the ZNDRAW_URL environment variable. This is used to direct visualization outputs to a specific local instance. ```bash export ZNDRAW_URL=http://localhost:1234 ``` -------------------------------- ### Compare Energy-Volume Curves using mlipx Source: https://github.com/basf/mlipx/blob/main/README.md Compares the results of energy-volume curve computations. The `--glob` option filters results based on a pattern, likely targeting specific experiment outputs. ```bash mlipx compare --glob "*EnergyVolumeCurve" ``` -------------------------------- ### Optimize Structure with mlipx and Multiple Models Source: https://github.com/basf/mlipx/blob/main/README.md Performs structure optimization for molecular structures defined by SMILES strings, comparing the performance of different MLIP models (mace-mpa-0, sevennet, orb-v2). The `--repro` flag enables reproducible runs. ```bash mlipx recipes relax --models mace-mpa-0,sevennet,orb-v2 --smiles "CCO,C1=CC2=C(C=C1O)C(=CN2)CCN" --repro ``` -------------------------------- ### Models configuration for Structure Relaxation (Python) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/relax.rst Defines the models used for structure relaxation. This file should contain the model implementations that the recipe will evaluate. ```Python # Example placeholder for models.py class MyRelaxationModel: def predict(self, structure): # Your model's prediction logic here print("Predicting relaxation for structure...") return structure # Placeholder return # Instantiate your model(s) # model = MyRelaxationModel() print("Models file loaded.") ``` -------------------------------- ### Main Script for Adsorption Energy Calculation (Python) Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/adsorption.rst The main Python script to execute the adsorption energy calculation. It utilizes mlipx library components to set up and run the simulation. This script is intended to be run within the mlipx framework. ```Python from ase.build import fcc111 from ase.calculators.emt import EMT from ase.constraints import FixAtoms from ase.optimize import QuasiNewton from ase.visualize import view from mlipx.nodes.optimization import Optimize from mlipx.nodes.slab_building import BuildASEslab from mlipx.nodes.smiles2conformers import Smiles2Conformers from mlipx.nodes.relaxation import RelaxAdsorptionConfigs def main(): # 1. Build slab slab = fcc111("Cu", size=(2, 2, 3), vacuum=10.0) slab.calc = EMT() # Fix the bottom layer constraint = FixAtoms(mask=slab.get_tags() == 1) slab.set_constraint(constraint) # 2. Build ASE slab node slab_node = BuildASEslab( atoms=slab, distance=2.0, smile="CCO", # metal="Cu", # facet="fcc111", # size=(2, 2, 3), # vacuum=10.0, # center=True, ) slab_atoms = slab_node.get_atoms() # 3. Generate conformers smiles2conformers_node = Smiles2Conformers(atoms=slab_atoms, smile="CCO") smiles2conformers_node.get_conformers() # 4. Relax adsorption configurations relax_node = RelaxAdsorptionConfigs(atoms=slab_atoms, smile="CCO") relax_node.get_relaxed_configs() # 5. Optimize the system optimize_node = Optimize(atoms=slab_atoms) optimize_node.get_optimized_atoms() # 6. Visualize the relaxed system view(slab_atoms) if __name__ == "__main__": main() ``` -------------------------------- ### Define MLIPX Models in Python Source: https://github.com/basf/mlipx/blob/main/docs/source/glossary.rst This snippet shows the expected structure for defining machine learning models within the MLIPX project. It requires importing the NodeWithCalculator class and defining a dictionary named MODELS, mapping string names to NodeWithCalculator instances. ```python from mlipx.abc import NodeWithCalculator MODELS: dict[str, NodeWithCalculator] = { ... } ``` -------------------------------- ### Upload MLIPX Recipe Results (Git & DVC) Source: https://github.com/basf/mlipx/blob/main/docs/source/concept/recipes.rst Uploads completed MLIPX recipe results to remote storage using Git and DVC. This involves staging changes, committing them, and pushing to both Git and DVC remotes. Git and DVC remotes must be pre-configured. ```console (.venv) $ git add . (.venv) $ git commit -m "Finished molecular dynamics test" (.venv) $ git push (.venv) $ dvc push ``` -------------------------------- ### Main script for Pourbaix Diagram Generation Source: https://github.com/basf/mlipx/blob/main/docs/source/recipes/pourbaix_diagram.rst This Python script, main.py, is used in conjunction with mlipx to generate Pourbaix diagrams. It likely orchestrates the process using the PourbaixDiagram node. ```Python from mlipx.nodes import PourbaixDiagram def main(): # Example usage of PourbaixDiagram node # This is a placeholder and would be replaced with actual node configuration pd = PourbaixDiagram() pd.run() if __name__ == "__main__": main() ```