### Install janus-core with additional features Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs janus-core with additional optional features enabled. This example demonstrates installing the DFTD3 (d3) and WEAS Widget (visualise) extras. ```bash python3 -m pip install janus-core[d3,visualise] ``` -------------------------------- ### Install janus-core from GitHub Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs the latest development version of janus-core directly from its GitHub repository. This is useful for users who want to access the newest features or contribute to the project. ```bash python3 -m pip install git+https://github.com/stfc/janus-core.git ``` -------------------------------- ### Install janus-core with MLIP extras Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs janus-core along with specific machine learning interatomic potentials (MLIPs) as optional dependencies (extras). This example shows how to install support for CHGNet and SevenNet. ```python python3 -m pip install janus-core[chgnet,sevennet] ``` -------------------------------- ### Install janus-core from PyPI Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs the latest stable release of the janus-core package and its core dependencies from the Python Package Index (PyPI). This is the recommended method for most users. ```bash python3 -m pip install janus-core ``` -------------------------------- ### Install janus-core with MLIP extras Source: https://github.com/stfc/janus-core/blob/main/README.md Installs janus-core along with specific machine learnt interatomic potential (MLIP) packages. This example shows how to install MACE, CHGNet, and SevenNet. Other extras are available. ```bash python3 -m pip install janus-core[mace,chgnet,sevennet] ``` -------------------------------- ### Output File Naming and Location Example (Bash) Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst Illustrates how to control output file naming and location using the --out and --file-prefix arguments. This example shows how the main output file and auxiliary files (summary, log) are directed to different directories. ```bash janus singlepoint --struct tests/data/NaCl.cif --arch mace_mp --out results/NaCl.extxyz --file-prefix other_results/NaCl ``` -------------------------------- ### Install Extra Dependencies with uv Source: https://github.com/stfc/janus-core/blob/main/docs/source/developer_guide/tutorial.rst Demonstrates how to install specific optional dependencies or all compatible optional dependencies using the 'uv sync' command. This is useful for setting up environments with specific MLIPs. ```bash uv sync --extra mace --extra orb ``` ```bash uv sync --extra all ``` -------------------------------- ### Run NVT Heating Simulation in Janus Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst This example demonstrates how to run an NVT heating simulation from a starting temperature to an ending temperature with specified steps. The '--temp-start', '--temp-end', '--temp-step', and '--temp-time' options control the heating process. ```bash janus md --ensemble nvt --struct tests/data/NaCl.cif --arch mace_mp --temp-start 20 --temp-end 300 --temp-step 20 --temp-time 10 ``` -------------------------------- ### Configuration File Example (YAML) Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst Demonstrates how to configure a singlepoint calculation using a YAML file. This includes specifying the structure file, desired properties, output file, architecture, and calculator keyword arguments. ```yaml struct: "NaCl.cif" properties: - "energy" out: "NaCl-results.extxyz" arch: mace_mp model: medium calc-kwargs: dispersion: True ``` -------------------------------- ### Install and Run Janus-Core Development Dependencies (Shell) Source: https://github.com/stfc/janus-core/blob/main/README.md This snippet guides users through cloning the Janus-Core repository, setting up a virtual environment with dependencies using 'uv', activating the environment, installing pre-commit hooks, and running tests. It assumes 'uv' is already installed. ```shell git clone https://github.com/stfc/janus-core cd janus-core uv sync --extra all source .venv/bin/activate pre-commit install pytest -v ``` -------------------------------- ### MLIP Calculation Output Example (Bash) Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst Demonstrates running a singlepoint calculation with a specific MLIP architecture and model. The output file will contain detailed information about the calculation, including MLIP-specific results. ```bash janus singlepoint --struct tests/data/NaCl.cif --arch mace_mp --model /path/to/mace/model ``` -------------------------------- ### Install ASE from Git Repository Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Installs the latest version of the ASE (Atomic Simulation Environment) library directly from its GitLab repository using pip. This allows access to the most recent code, including development versions. ```bash python3 -m pip install git+https://gitlab.com/ase/ase.git ``` -------------------------------- ### Import Required Libraries Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Imports necessary modules from ase, weas_widget, data_tutorials, matplotlib, numpy, and janus_core for data preparation and simulation setup. ```python from ase.build import bulk from weas_widget import WeasWidget from ase.io import read from data_tutorials.data import get_data import matplotlib.pyplot as plt import numpy as np from janus_core.calculations.md import NVE, NVT from janus_core.helpers.stats import Stats from janus_core.processing import post_process ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Downloads a specific trajectory file ('precomputed_NaCl-traj.xyz') required for the tutorial from a GitHub repository into a local 'data' folder. ```python get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["precomputed_NaCl-traj.xyz"], folder="data", ) ``` -------------------------------- ### Install janus-core with all MLIP extras Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs janus-core with all currently supported machine learning interatomic potentials (MLIPs) and features enabled. This provides comprehensive support for various MLIPs. ```python python3 -m pip install janus-core[all] ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/geom_opt.ipynb Downloads a specific file ('NaCl-deformed.xyz') from a GitHub repository using the `get_data` function from the `data_tutorials` library. The downloaded file is saved into a local 'data' folder. ```python get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["NaCl-deformed.xyz"], folder="data", ) ``` -------------------------------- ### Setup NVT Heating and MD Simulation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Configures an NVT simulation that first heats the structure from 0K to 300K in steps and then performs a short MD run at 300K. It defines temperature ramp parameters and the number of steps for the final MD run. ```python heating = NVT( struct=NaCl.copy(), arch="mace_mp", device="cpu", model="small", calc_kwargs={\"default_dtype\": \"float64\"}, temp_start=0, # Start of temperature ramp temp_end=300.0, # End of temperature ramp temp_step=20, # Temperature ramp increments temp_time=1, # Time at each temperature in ramp temp=300, # MD temperature steps=10, # MD steps at 300K ) ``` -------------------------------- ### Install and Sync Dependencies with uv Source: https://github.com/stfc/janus-core/blob/main/docs/source/developer_guide/get_started.rst Installs and synchronizes project dependencies using the uv package manager. It supports specifying Python versions and installing optional extras for MLIPs. ```shell uv sync -p 3.12 source .venv/bin/activate ``` ```shell uv sync -p 3.12 --extra chgnet --extra sevennet ``` ```shell uv sync -p 3.12 --extra all ``` -------------------------------- ### Install janus-core with uv and MACE extra Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Installs the janus-core package along with the MACE optional dependencies using uv pip. The '-U' flag ensures that dependencies are upgraded to their latest compatible versions. ```bash uv pip install janus-core[mace] -U ``` -------------------------------- ### Install fairchem-core with torch-extras Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/get_started.rst Installs the 'fairchem-core' package with specific PyTorch-related extras, which is a build-time dependency for certain MLIPs like 'fairchem-1'. This command ensures necessary components for PyTorch integration are available. ```python python -m pip install 'fairchem-core[torch-extras]==1.10.0' ``` ```bash uv pip install 'fairchem-core[torch-extras]==1.10.0' --no-build-isolation ``` -------------------------------- ### Full janus eos Configuration with All Parameters (YAML) Source: https://github.com/stfc/janus-core/blob/main/docs/source/examples/eos.rst A comprehensive configuration file for the 'janus eos' command, detailing all available parameters. This example is useful for understanding the full range of options and for advanced customization. ```yaml eos: name: "stiff_gas" parameters: gamma: 1.4 reference_pressure: 1.0e5 reference_density: 1.0e3 sound_speed_squared: 1.4e6 ``` -------------------------------- ### Set Up Environment for Janus-Core Installation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/neb.ipynb Installs and configures the necessary Python packages for running janus-core tutorials, including specific versions of numpy and torch, and the janus-core library itself with MACE and visualization extras. This step is crucial for ensuring compatibility and proper functionality within environments like Google Colab. ```python # import locale # locale.getpreferredencoding = lambda: "UTF-8" # ! pip uninstall numpy -y # Uninstall pre-installed numpy # ! pip uninstall torch torchaudio torchvision transformers -y # Uninstall pre-installed torch # ! uv pip install torch==2.5.1 # Install pinned version of torch # ! uv pip install janus-core[mace,visualise] data-tutorials --system # Install janus-core with MACE and WeasWidget, and data-tutorials # get_ipython().kernel.do_shutdown(restart=True) # Restart kernel to update libraries. This may warn that your session has crashed. ``` -------------------------------- ### Install janus-core with visualization extras Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/python.rst Installs the janus-core package along with extras for visualization, such as WEAS Widget, and potentially other MLIPs like MACE. This command is useful for setting up an environment to run and visualize computational results. ```bash pip install janus-core[mace,visualise] ``` -------------------------------- ### Setup NVT Cooling Simulation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Configures an NVT (constant Number of particles, Volume, Temperature) molecular dynamics simulation for cooling the NaCl structure from 300K to 200K. It specifies the MACE model, device, and simulation parameters like temperature steps and time at each temperature. ```python cooling = NVT( struct=NaCl.copy(), arch="mace_mp", device="cpu", model="small", calc_kwargs={\"default_dtype\": \"float64\"}, temp_start=300.0, temp_end=200.0, temp_step=20, temp_time=5, stats_every=2, ) ``` -------------------------------- ### Setup NVE MD Simulation with RDF Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Configures an NVE (constant Number of particles, Volume, Energy) molecular dynamics simulation using the structure obtained from the heating simulation. It includes post-processing to compute the Radial Distribution Function (RDF). ```python md = NVE( struct=heating.struct, temp=300, stats_every=5, steps=50, post_process_kwargs={"rdf_compute": True, "rdf_rmax": 5, "rdf_bins": 50}, ) ``` -------------------------------- ### Install janus-core with all extras Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/python.rst Installs the janus-core package with all available optional dependencies and features enabled. This is a comprehensive installation that includes support for various MLIPs, visualization tools, and other functionalities. ```bash pip install janus-core[all] ``` -------------------------------- ### Calculate Phonon Band Structure (Orb) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Calculates the phonon band structure for the Orb model. The results are written to a file. ```python phonons_orb.calc_bands(write_bands=True) ``` -------------------------------- ### Visualize Structure with WeasWidget Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Initializes a WeasWidget and displays the generated NaCl structure. This is a visualization step. ```python v=WeasWidget() v.from_ase(NaCl) v ``` -------------------------------- ### Running a Singlepoint Calculation with Configuration (Bash) Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst An example bash command to execute a singlepoint calculation using the janus tool. It specifies the structure file, output file, and points to a configuration file for detailed settings. ```bash janus singlepoint --struct KCl.cif --out KCl-results.cif --config config.yml ``` -------------------------------- ### Print Cell Parameters (MACE) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Prints the lattice parameters of the unit cell for the structure associated with the MACE phonon calculation. This is useful for verifying cell optimization results. ```python print(phonons_mace_pressure.struct.cell.cellpar()) ``` -------------------------------- ### Import Libraries for Data Preparation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/elasticity.ipynb Imports necessary libraries for data preparation and elasticity calculations, including WeasWidget for visualization, ASE for building atomic structures, and specific modules from janus_core. ```python from weas_widget import WeasWidget from ase.build import bulk, nanotube from ase.lattice.cubic import Diamond from ase.io import read import numpy as np import matplotlib.pyplot as plt from janus_core.calculations.elasticity import Elasticity ``` -------------------------------- ### Get Geometry Optimization Help (Shell) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/geomopt.ipynb Displays the command-line help and available options for the `janus geomopt` command, similar to checking help for `janus singlepoint`. ```shell ! janus geomopt --help ``` -------------------------------- ### Initialize Structure for Simulation (Python) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Initializes a structure using ASE's read function and wraps it using WeasWidget. This is typically used to load a starting configuration for a simulation. ```python v=WeasWidget() structure = read("../data/NaCl-1040.extxyz") structure.wrap() v.from_ase(structure) v ``` -------------------------------- ### Phonon Calculation with CHGNet Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Initializes a Phonons object for CHGNet calculations. It sets up the structure, model, supercell, displacement, temperature range, and minimization parameters. The `filter_class` is set to None. ```python phonons_chgnet = Phonons( struct=NaCl.copy(), arch="chgnet", device="cpu", supercell=[2, 2, 2], displacement=0.01, temp_step=10.0, temp_min=0.0, temp_max=1000.0, minimize=True, hdf5=True, plot_to_file=True, symmetrize=False, write_full=True, minimize_kwargs={"filter_class": None}, write_results=True, ) ``` -------------------------------- ### Compare and Save Band Structures (MACE, Lengths Only, Pressure) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Compares band structures from different optimization strategies (default, lengths only, and pressure) and saves them as SVG files. This allows for visual comparison of the effects of different optimization methods. ```python phonons_mace.write_bands(plot_file="NaCl_mace.svg") phonons_mace_lengths_only.write_bands(plot_file="NaCl_lengths_only.svg") phonons_mace_pressure.write_bands(plot_file="NaCl_pressure.svg") ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Downloads necessary data files for the tutorial, specifically the NaCl-1040.extxyz file, from a GitHub repository and saves it to a local 'data' folder. This function is part of the data-tutorials package. ```python from data_tutorials.data import get_data get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["NaCl-1040.extxyz"], folder="../data", ) ``` -------------------------------- ### Install janus-core with PLUMED extra Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Installs the janus-core package with the PLUMED extra dependencies using pip. Note that this requires additional steps to build and install the PLUMED library and set the PLUMED_KERNEL environment variable. ```bash python3 -m pip install janus-core[plumed] ``` -------------------------------- ### Get janus phonons Help (Shell) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/phonons.ipynb Displays the help message for the 'janus phonons' command. This command-line interface is used to initiate phonon calculations with janus-core and provides various options for customization. ```shell ! janus phonons --help ``` -------------------------------- ### Install Specific PyTorch Version Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Installs a specific version of PyTorch (e.g., 2.5.1) using pip. This is useful for ensuring compatibility with specific MLIP versions or for reproducible environments. ```bash python3 -m pip install torch==2.5.1 ``` -------------------------------- ### View MD Summary Configuration Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Displays the content of the `md-summary.yml` file, which provides a detailed summary of the molecular dynamics simulation parameters and settings used, including default values for various options. ```shell $ cat janus_results/NaCl-nvt-T100.0-md-summary.yml ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/eos.ipynb This Python function downloads a CIF file named 'beta_quartz.cif' from a specified GitHub URL into a local 'data' folder, providing the necessary data for subsequent calculations. ```python get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["beta_quartz.cif"], folder="data", ) ``` -------------------------------- ### Compare and Save Band Structures (MACE, CHGNet, Orb) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Compares the band structures calculated using MACE, CHGNet, and Orb MLIPs, saving each as a separate SVG file. This facilitates a direct comparison of the band structures obtained from different models. ```python phonons_mace.write_bands(plot_file="MACE.svg") phonons_chgnet.write_bands(plot_file="chgnet.svg") phonons_orb.write_bands(plot_file="orb.svg") ``` -------------------------------- ### Install Specific ASE Branch from Git Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Installs a specific branch (e.g., 'npt_triangular') of the ASE library from a specified Git repository. This is useful for testing specific features or bug fixes that are not yet merged into the main branch. ```bash python3 -m pip install git+https://gitlab.com/drFaustroll/ase.git@npt_triangular ``` -------------------------------- ### Display Janus MD Command Help Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Executes the `janus md --help` command in the shell to display detailed information about the available options and arguments for running molecular dynamics simulations with Janus-Core. ```shell !janus md --help ``` -------------------------------- ### Install Janus-Core and Dependencies in Colab Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/geom_opt.ipynb Installs or updates numpy and torch to compatible versions for Janus-Core in a Google Colab environment. It then installs janus-core with optional dependencies and data-tutorials. Finally, it restarts the kernel to apply the changes. ```python # import locale # locale.getpreferredencoding = lambda: "UTF-8" # ! pip uninstall numpy -y # Uninstall pre-installed numpy # ! pip uninstall torch torchaudio torchvision transformers -y # Uninstall pre-installed torch # ! uv pip install torch==2.5.1 # Install pinned version of torch # ! uv pip install janus-core[mace,orb,chgnet,visualise] data-tutorials --system # Install janus-core with MACE, Orb, CHGNet, and WeasWidget, and data-tutorials # get_ipython().kernel.do_shutdown(restart=True) # Restart kernel to update libraries. This may warn that your session has crashed. ``` -------------------------------- ### Create Virtual Environment with uv Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Creates and activates a virtual environment using uv, specifying the desired Python version (e.g., 3.12). This is a prerequisite for installing janus-core with uv. ```bash uv venv -p 3.12 source .venv/bin/activate ``` -------------------------------- ### Download Example Data (Python) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/phonons.ipynb Downloads necessary data files (CIF structure and YAML path file) from a remote URL to a local folder. This function is typically part of a data handling utility. ```python get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["mof-5.cif", "paths.yaml"], folder="../data", ) ``` -------------------------------- ### Minimal janus eos Configuration (YAML) Source: https://github.com/stfc/janus-core/blob/main/docs/source/examples/eos.rst A basic configuration file for the 'janus eos' command, showcasing essential parameters. This file is intended for quick setup and basic functionality. ```yaml eos: name: "ideal_gas" parameters: gamma: 1.4 ``` -------------------------------- ### Update PyTorch to Latest Version Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/installation.rst Upgrades the PyTorch library to its latest available version using pip. This can be useful for accessing newer features or bug fixes in MLIPs that depend on PyTorch. ```bash python3 -m pip install -U torch ``` -------------------------------- ### View Simulation Stats File Header Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Displays the first few lines of the simulation statistics file (`stats.dat`) generated by Janus-Core. This allows for a quick inspection of the simulation's progress, including step, time, energy, and temperature. ```shell $ head janus_results/NaCl-nvt-T100.0-stats.dat ``` -------------------------------- ### Set Up Automatic Code Style Checks with pre-commit Source: https://github.com/stfc/janus-core/blob/main/docs/source/developer_guide/get_started.rst Installs pre-commit hooks to automatically format and lint code on every commit. This includes ruff for linting and formatting, and numpydoc for docstring validation. ```shell pre-commit install ``` -------------------------------- ### Phonon Calculation with MACE and Pressure Optimization Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb Initializes a Phonons object for MACE with pressure optimization. It configures the structure, model, supercell, displacement, temperature range, and minimization parameters, including setting a scalar pressure. ```python phonons_mace_pressure = Phonons( struct=NaCl.copy(), arch="mace_mp", device="cpu", model="small", calc_kwargs={"default_dtype": "float64"}, supercell=[2, 2, 2], displacement=0.01, temp_step=10.0, temp_min=0.0, temp_max=1000.0, minimize=True, hdf5=True, plot_to_file=True, symmetrize=False, write_full=True, minimize_kwargs={"filter_kwargs": {"scalar_pressure": 0.1}}, write_results=True, ) ``` -------------------------------- ### Install Janus Core and Dependencies (Python) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/geomopt.ipynb Installs or updates numpy and torch to compatible versions for janus-core, then installs janus-core with optional dependencies (MACE, Orb, Visualise) and data-tutorials. This script is intended for Google Colab environments and may require a kernel restart. ```python # import locale # locale.getpreferredencoding = lambda: "UTF-8" # ! pip uninstall numpy -y # Uninstall pre-installed numpy # ! pip uninstall torch torchaudio torchvision transformers -y # Uninstall pre-installed torch # ! uv pip install torch==2.5.1 # Install pinned version of torch # ! uv pip install janus-core[mace,orb,visualise] data-tutorials --system # Install janus-core with MACE, Orb, and WeasWidget, and data-tutorials # get_ipython().kernel.do_shutdown(restart=True) # Restart kernel to update libraries. This may warn that your session has crashed. ``` -------------------------------- ### Prepare NaCl Structure for Phonon Calculations Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/phonons.ipynb This Python code prepares a Sodium Chloride (NaCl) crystal structure using the ASE library and visualizes it using the WeasWidget. It sets up a bulk NaCl structure with specific lattice parameters and configures visualization options like model style and hydrogen bond display. ```python from ase.build import bulk from weas_widget import WeasWidget from janus_core.calculations.phonons import Phonons NaCl = bulk("NaCl", "rocksalt", a=5.63, cubic=True) v=WeasWidget() v.from_ase(NaCl) v.avr.model_style = 1 v.avr.show_hydrogen_bonds = True v ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/single_point.ipynb Fetches necessary data files for the tutorial, specifically 'sucrose.xyz' and 'NaCl-set.xyz', from a GitHub repository. These files are downloaded into a local 'data' folder, making them available for subsequent simulation and analysis steps. ```python from data_tutorials.data import get_data get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["sucrose.xyz", "NaCl-set.xyz"], folder="data", ) ``` -------------------------------- ### Download Tutorial Data Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/neb.ipynb Downloads essential data files required for the janus-core tutorials, specifically related to ethanol oxidation reactions. These files include initial and final structures for different numbers of water molecules, which are necessary for setting up NEB simulations. ```python from data_tutorials.data import get_data get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["ethanol_reactants.extxyz", "ethanol_products.extxyz","ethanol_reactants_1water.extxyz","ethanol_products_1water.extxyz","ethanol_reactants_2water.extxyz","ethanol_products_2water.extxyz"], folder="../data", ) ``` -------------------------------- ### Minimal Janus Single Point Configuration (YAML) Source: https://github.com/stfc/janus-core/blob/main/docs/source/examples/singlepoint.rst A basic configuration file for the 'janus singlepoint' command. It demonstrates the essential parameters required for a minimal setup. This file is intended for quick setup and testing. ```yaml port: 8080 ``` -------------------------------- ### Load Beta-Quartz Structure and Initialize Visualization Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/eos.ipynb This Python code reads the beta-quartz structure from a local CIF file using ASE and initializes a WeasWidget to visualize it with specific settings for model style and hydrogen bonds. ```python β_quartz = read("data/beta_quartz.cif") v=WeasWidget() v.from_ase(β_quartz) v.avr.model_style = 1 v.avr.show_hydrogen_bonds = True v ``` -------------------------------- ### Install janus-core with D3 dispersion support Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/python.rst Installs the janus-core package with the specific extra dependency for D3 dispersion corrections. This enables the use of DFTD2 and DFTD3 calculations for adding dispersion corrections to MLIP predictions. ```bash pip install janus-core[d3] ``` -------------------------------- ### Analyze Simulation Statistics with Janus Core Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb This snippet demonstrates how to load and plot simulation statistics such as temperature, volume, and pressure from a 'stats.dat' file using the Stats utility from janus_core. It assumes the availability of matplotlib for plotting. ```python stats = Stats("janus_results/NaCl-nvt-T100.0-stats.dat") fig, ax = plt.subplots(ncols=3, figsize=(10,3)) ax[0].plot(stats[0], stats[5]) ax[0].set_xlabel("Step") ax[0].set_ylabel("Temperature") ax[1].plot(stats[0], stats[8]) ax[1].set_xlabel("Step") ax[1].set_ylabel("Volume") ax[2].plot(stats[0], stats[9]) ax[2].set_xlabel("Step") ax[2].set_ylabel("Pressure") plt.tight_layout() ``` -------------------------------- ### Train MLIP Models with Configuration File Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst Trains Machine Learning Interatomic Potentials (MLIPs) by providing a configuration file to the training command. Currently supports MACE models. This process generates 'logs', 'checkpoints', and 'results' directories, saves the trained model, and creates log and summary files. ```bash janus train --mlip-config /path/to/training/config.yml ``` -------------------------------- ### Continue Janus Simulation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb This command-line instruction demonstrates how to restart a Janus simulation using a previous configuration file. It allows overriding parameters like the number of steps to append to the existing simulation. ```bash ! janus md --restart --steps 300 --config config-nvt.yml ``` -------------------------------- ### Import Necessary Libraries for Simulations Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/geom_opt.ipynb Imports core classes and functions from ASE, WeasWidget, data-tutorials, and Janus-Core modules. These are essential for reading structures, creating visualizations, fetching data, and performing single-point energy calculations and geometry optimizations. ```python from ase.io import read from ase.optimize import FIRE from weas_widget import WeasWidget from data_tutorials.data import get_data from janus_core.calculations.single_point import SinglePoint from janus_core.calculations.geom_opt import GeomOpt ``` -------------------------------- ### Define Start and End Structures for NEB Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/neb.ipynb Creates copies of the relaxed LiFePO4 structure and modifies them to define the starting and ending configurations for the NEB calculation along paths b and c. This involves deleting specific atoms to represent the Li diffusion endpoints. ```python # NEB path along b and c directions have the same starting image. # For start bc remove site 5 LFPO_start_bc = LFPO.copy() del LFPO_start_bc[5] # For end b remove site 11 LFPO_end_b = LFPO.copy() del LFPO_end_b[11] # For end c remove site 4 LFPO_end_c = LFPO.copy() del LFPO_end_c[4] ``` -------------------------------- ### Print Simulation Statistics Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Prints the loaded simulation statistics. The exact output depends on the content of the statistics file. ```python print(data) ``` -------------------------------- ### Import Required Libraries Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Imports essential Python libraries for molecular dynamics simulations and data handling, including Path, ase for atomic structure manipulation, numpy for numerical operations, matplotlib for plotting, WeasWidget for visualization, and specific modules from janus_core for processing and statistics. ```python from pathlib import Path from ase.build import bulk from ase.io import read, write import numpy as np import matplotlib.pyplot as plt from weas_widget import WeasWidget import yaml from janus_core.helpers.stats import Stats from janus_core.processing import post_process ``` -------------------------------- ### Fit Equation of State using MACE-MP in Janus Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst This example demonstrates fitting the equation of state for a structure using the MACE-MP force field. It specifies the structure, architecture, volume range, and number of volumes to sample. '--no-minimize' prevents initial geometry optimization. ```bash janus eos --struct tests/data/NaCl.cif --arch mace_mp --no-minimize --min-volume 0.9 --max-volume 1.1 --n-volumes 9 --model small ``` -------------------------------- ### Run NVE MD Simulation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Executes the NVE molecular dynamics simulation. The results, including the computed RDF, will be saved to a file. ```python md.run() ``` -------------------------------- ### Download Tutorial Data (Python) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/phonons.ipynb Downloads the 'NaCl.cif' file from a specified URL and saves it to a local 'data' folder. This function is part of the data-tutorials package and is used to fetch necessary input files for the janus-core calculations. ```python from data_tutorials.data import get_data get_data( url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/", filename=["NaCl.cif"], folder="../data", ) ``` -------------------------------- ### Load Simulation Statistics Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Loads the simulation statistics data from a file generated by the NVT cooling simulation into a Stats object for analysis. ```python data = Stats("janus_results/Cl32Na32-nvt-T300.0-T200.0-stats.dat") ``` -------------------------------- ### Build NaCl Structure Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Creates a bulk NaCl structure using ASE's `bulk` function and replicates it to form a 2x2x2 supercell. ```python NaCl = bulk("NaCl", "rocksalt", a=5.63, cubic=True) NaCl = NaCl * (2, 2, 2) ``` -------------------------------- ### Load and Plot RDF from File Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Loads precomputed RDF data from a file and plots it using Matplotlib. The data is expected to be in a two-column format (bins and counts). ```python import matplotlib.pyplot as plt import numpy as np rdf = np.loadtxt("janus_results/Cl32Na32-nve-T300-rdf.dat") bins, counts = zip(*rdf) ``` ```python plt.plot(bins, counts) plt.ylabel("RDF") plt.xlabel("Distance / Å") plt.show() ``` -------------------------------- ### Run Janus Simulation with Runtime Correlations Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb This command executes a Janus simulation using a specified configuration file that includes settings for runtime correlation calculations (VAF and SAF). ```bash ! janus md --config config-nvt-cor.yml ``` -------------------------------- ### Run NVT Heating and MD Simulation Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/md.ipynb Executes the NVT heating and subsequent MD simulation. The final structure from this simulation is used for the next NVE simulation. ```python heating.run() ``` -------------------------------- ### Run Unit Tests with pytest Source: https://github.com/stfc/janus-core/blob/main/docs/source/developer_guide/get_started.rst Executes unit tests locally using pytest. Requires the 'mace' extra for most tests and 'chgnet' for 'test_descriptors.py'. Other extras are optional. ```shell pytest -v ``` -------------------------------- ### NPT Heating Configuration (YAML) Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/cli/md.ipynb Configuration file for running an NPT simulation with temperature ramping. It specifies ensemble, ensemble keywords (like fixed cell angles), structure file, architecture, temperature parameters, and simulation step settings. ```yaml ensemble: npt ensemble_kwargs: mask: [[1,0,0],[0,1,0],[0,0,1]] struct: ../data/NaCl-1040.extxyz arch: mace_mp temp_start: 1040 temp_end: 1080 temp_step: 5 temp_time: 25 stats_every: 10 traj_every: 10 tracker: False # If you have an Nvidia GPU. #device: cuda ``` -------------------------------- ### Visualize Deformed Structures with WeasWidget Source: https://github.com/stfc/janus-core/blob/main/docs/source/tutorials/python/elasticity.ipynb Uses the WeasWidget to visualize the set of deformed structures generated during an elasticity calculation. The widget allows playback of the structural transformations. ```python from janus_core.calculations import Elasticity from weas.widgets import WeasWidget # Assuming calc_elasticity_aluminium is an already defined Elasticity object v=WeasWidget() v.from_ase(calc_elasticity_aluminium.deformed_structures) v ``` ```python from weas.widgets import WeasWidget from ase.io import read v=WeasWidget() diamond_strained = read("janus_results/C64-elasticity-generated.extxyz", index=":") v.from_ase(diamond_strained) v ``` -------------------------------- ### Fine-tune Foundational MLIP Models Source: https://github.com/stfc/janus-core/blob/main/docs/source/user_guide/command_line.rst Fine-tunes existing foundational MLIP models. This requires specifying the 'foundation_model' option within the configuration file and using the '--fine-tune' flag with the training command. Similar to training, it generates log and summary files. ```bash janus train --mlip-config /path/to/fine/tuning/config.yml --fine-tune ```