### Start and Run MPS Jobs (Bash) Source: https://github.com/snurr-group/graspa/blob/main/Examples/MPS/README.md This script demonstrates how to start the MPS daemon, create separate directories for multiple simulations, prepare input files, run the simulations in parallel, and finally shut down the MPS daemon. It assumes the existence of specific input files (`.def`, `simulation.input`, `.cif`) and the executable `nvc_main.x`. ```bash #!/bin/bash runs=3 currentdir=$(pwd) ./start_as_root.sh for ((i = 0; i < $runs; i++)); do echo $i mkdir $i cp $currentdir/*.def $i/; cp $currentdir/simulation.input $i/; cp $currentdir/*.cif $i/ cd $currentdir/$i sed -i 's/xxx/'$i'/g' simulation.input ../../../src_clean/nvc_main.x > result & cd ../ done wait ./stop_as_root.sh ``` -------------------------------- ### Setup Allegro Model and DNN Preparation Source: https://github.com/snurr-group/graspa/blob/main/libtorch-patch/Allegro/PATCH_ALLEGRO_main.cpp.txt Initializes and prepares the Allegro model and associated DNN components. This involves reading the model, matching elements, generating unit cell boxes, copying atom data, and calculating model energy. It includes error handling for unsupported framework configurations and options for re-using or initializing the model. ```c++ if(Vars.SystemComponents[a].UseAllegro) { printf("Setting up Allegro model\n"); Vars.SystemComponents[a].DNN.ReadModel(Vars.SystemComponents[a].ModelName[0]); printf("DONE Reading the model, model name %s\n", Vars.SystemComponents[a].ModelName[0].c_str()); Vars.SystemComponents[a].DNN.Match_Element_PseudoAtom_with_model(Vars.SystemComponents[a].PseudoAtoms); Vars.SystemComponents[a].DNN.UCAtoms.resize(Vars.SystemComponents[a].NComponents.x); Vars.SystemComponents[a].DNN.ReplicaAtoms.resize(Vars.SystemComponents[a].NComponents.x); //Copy Boxsize to DNN UCBox// Vars.SystemComponents[a].DNN.GenerateUCBox(Vars.Box[a].Cell, Vars.SystemComponents[a].NumberofUnitCells); printf("Generated UC Box\n"); //Copy First unit cell of atoms to UCAtoms// //Also Initialize for Adsorbate// for(size_t comp = 0; comp < Vars.SystemComponents[a].NComponents.x; comp++) { int3 Ncells = {1,1,1}; //If we copy adsorbates, we copy the first template atom (no need to divide number of atoms by unit cells) if(comp == 0) { Ncells = Vars.SystemComponents[a].NumberofUnitCells; if(!Vars.SystemComponents[a].rigid[comp] || Vars.SystemComponents[a].NComponents.y != 1) throw std::runtime_error("Currently only allows rigid framework and no semi-flexible framework model!!!! If you want, write your own!!!!"); } Vars.SystemComponents[a].DNN.CopyAtomsFromFirstUnitcell(Vars.SystemComponents[a].HostSystem[comp], comp, Ncells, Vars.SystemComponents[a].PseudoAtoms, Vars.SystemComponents[a].ConsiderThisAdsorbateAtom); } printf("DONE Copying Framework + template adsorbate atom into UCAtoms for Allegro\n"); //As a test, replace UCatoms by preset values// //Initialize the atom sizes size_t comp = 1; //Copy some molecule positions into UCAtoms// //Use the initialization setup (position in Vars.SystemComponents[a].HostSystem[comp], already copied)// printf("DONE Setting Test Adsorbate positions\n"); Vars.SystemComponents[a].DNN.NReplicacell = {3,3,3}; //Default// bool Initialize = true; double DNN_E = Vars.SystemComponents[a].DNN.MCEnergyWrapper(1, Initialize, Vars.SystemComponents[a].DNNEnergyConversion); printf("%s, sum (from Unitcell values): %f\n", Initialize ? "Initialize Model": "Re-using Model", DNN_E); //DO another position for the test molecules// double3 d_val = {1.0, 1.0, 1.0}; for(size_t i = 0; i < Vars.SystemComponents[a].DNN.UCAtoms[comp].size; i++) Vars.SystemComponents[a].DNN.UCAtoms[comp].pos[i] += d_val; Initialize = false; DNN_E = Vars.SystemComponents[a].DNN.MCEnergyWrapper(1, Initialize, Vars.SystemComponents[a].DNNEnergyConversion); printf("%s, sum (from Unitcell values): %f\n", Initialize ? "Initialize Model": "Re-using Model", DNN_E); } ``` -------------------------------- ### Automate Example Simulations with Python and Pytest Source: https://context7.com/snurr-group/graspa/llms.txt This snippet demonstrates how to automate the execution of simulation tests using Python scripts and the pytest framework. It includes running designated simulation folders and executing the pytest suite for validation. ```bash # Run test simulations cd Examples/ python run_designated_folders.py # Execute pytest suite pytest -s test_examples.py # pytest checks: # - Energy drift over simulation # - Simulation time performance # - Output file consistency # - Statistical properties ``` -------------------------------- ### Automate Batch Simulations with Python (Python) Source: https://context7.com/snurr-group/graspa/llms.txt This Python script automates the execution of multiple gRASPA simulations. It defines lists of basic simulation directories and reference calculation directories, then iterates through them, changes to each directory, runs the simulation using 'nvc_main.x', cleans up unnecessary files, and returns to the home directory. This script is useful for running multiple examples efficiently. ```python # run_designated_folders.py import os homedir = os.getcwd() repodir = os.path.dirname(homedir) basics = ['CO2-MFI', 'Methane-TMMC', 'Bae-Mixture', 'NU2000-pX-LinkerRotations', 'Tail-Correction'] ref_calc = ['Reference_NIST_SPCE/Box-1/', 'Reference_NIST_SPCE/Box-2/', 'Reference_NIST_SPCE/Box-3/', 'Reference_NIST_SPCE/Box-4/'] sims = [] sims.extend(basics) sims.extend(ref_calc) for direct in sims: os.chdir(f"{direct}") os.system(f"{repodir}/src_clean/nvc_main.x > output.txt") os.system("rm -r AllData FirstBead Lambda Movies Restart TMMC") os.chdir(f"{homedir}") print(f"Simulation {direct} has finished.\n") ``` -------------------------------- ### Basic Compilation of gRASPA (Bash) Source: https://context7.com/snurr-group/graspa/llms.txt This bash snippet outlines the basic steps to compile gRASPA from its source code without ML potential support. It involves navigating to the 'src_clean' directory, making the compilation script executable, and running the compilation. It also includes a step to verify the creation of the main executable 'nvc_main.x' and a test run using an example. ```bash # Basic compilation (without ML potentials) cd src_clean/ chmod +x ../NVC_COMPILE ../NVC_COMPILE # Verify executable is created ls -lh nvc_main.x # Test with example cd ../Examples/CO2-MFI/ ../../src_clean/nvc_main.x > output.txt ``` -------------------------------- ### Install CppFlow with CMake and Make Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Clones the CppFlow repository, creates a build directory, configures the build using CMake with the TensorFlow prefix path, and installs CppFlow. CppFlow acts as a bridge between C++ and TensorFlow. ```shellscript git clone https://github.com/serizba/cppflow cd cppflow mkdir build cd build cmake -DCMAKE_PREFIX_PATH=~/ctensorflow/ .. make install DESTDIR=~/ctensorflow/ ``` -------------------------------- ### NVT-Gibbs Ensemble Simulation Configuration (Text) Source: https://context7.com/snurr-group/graspa/llms.txt This snippet shows the 'simulation.input' configuration for an NVT-Gibbs ensemble simulation, which is used to study phase equilibria between two simulation boxes. It defines the number of cycles and specific parameters for the Gibbs ensemble, including volume and particle exchange probabilities and maximum volume change. It also details the initial setup for two boxes, one representing the liquid phase and the other the vapor phase. ```text # simulation.input for Gibbs ensemble NumberOfInitializationCycles 100000 NumberOfEquilibrationCycles 0 NumberOfProductionCycles 500000 # Gibbs ensemble parameters UseGibbsEnsemble yes NumberOfSimulations 2 GibbsVolumeChangeProbability 0.1 GibbsParticleTransferProbability 0.1 MaxGibbsVolumeChange 500.0 # Box 0 (liquid phase) Component 0 MoleculeName H2O CreateNumberOfMolecules 500 TranslationProbability 1.0 RotationProbability 1.0 # Box 1 (vapor phase) Component 0 MoleculeName H2O CreateNumberOfMolecules 50 TranslationProbability 1.0 RotationProbability 1.0 ``` -------------------------------- ### Run TMMC Simulation for Methane Adsorption (Bash) Source: https://context7.com/snurr-group/graspa/llms.txt This snippet demonstrates how to initiate a Transition-Matrix Monte Carlo (TMMC) simulation for methane adsorption. It involves changing to the example directory and executing the main simulation binary. The output is redirected to 'output.txt'. TMMC generates a collection matrix and bias factors, providing insights into macrostate probabilities and free energies. ```bash # Run TMMC simulation for methane adsorption cd Examples/Methane-TMMC/ ../../src_clean/nvc_main.x > output.txt # TMMC generates collection matrix and bias factors # Output includes macrostate probabilities and free energies ``` -------------------------------- ### Download and Unzip LibTorch Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Downloads the LibTorch library with CUDA 11.7 support and unzips it. LibTorch is required for PyTorch functionalities, particularly for models like Allegro. ```shellscript wget https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu117.zip unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu117.zip ``` -------------------------------- ### Patch gRASPA for Allegro Model Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Modifies the `patch.py` script to include the Allegro model for ML potential functionality and then executes the script. The patched source code is placed in the `patch_libtorch_Allegro/` directory. ```shellscript python patch.py ``` -------------------------------- ### Create Symbolic Link for LibTorch Library Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Creates a symbolic link to a specific LibTorch dynamic library. This step may be required on some university clusters, though potentially not on NERSC itself, to ensure gRASPA/Allegro can locate necessary runtime libraries. ```shellscript ln -s libnvrtc-builtins-7237cb5d.so.11.7 libnvrtc-builtins.so.11.7 ``` -------------------------------- ### Compile gRASPA with ML Potential Support (Bash) Source: https://context7.com/snurr-group/graspa/llms.txt This bash snippet details the process of compiling gRASPA with support for ML potentials, specifically Allegro via LibTorch. It includes downloading and unzipping the LibTorch library, patching the gRASPA source code by modifying 'patch.py', and then compiling the patched code using a specific compilation script. Ensure you have the correct LibTorch version matching your CUDA installation. ```bash # Installation with ML potential support (Allegro via LibTorch) # 1. Install LibTorch wget https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu117.zip unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cu117.zip # 2. Patch gRASPA source code # Modify line 65 in patch.py: patch_model=['Allegro'] python patch.py # 3. Compile patched code cd patch_libtorch_Allegro/ chmod +x ../libtorch_NVC_COMPILE ../libtorch_NVC_COMPILE ``` -------------------------------- ### Patch gRASPA for Lin Model Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Modifies the `patch.py` script to use CppFlow for the Lin model and then executes the script. The patched code for the Lin model is placed in the `patch_cppflow_LCLIN` folder. ```shellscript tf_or_torch = ['cppflow'] patch_model=['LCLIN'] python patch.py ``` -------------------------------- ### Crystallographic Structure Input (CIF Format) Source: https://context7.com/snurr-group/graspa/llms.txt Example structure definition in CIF (Crystallographic Information File) format. This defines the unit cell parameters, symmetry, and atomic positions for a material like MFI zeolite. ```text # MFI-2x2x2-P1.cif example structure data_MFI _cell_length_a 40.044 _cell_length_b 39.798 _cell_length_c 26.778 _cell_angle_alpha 90.0 _cell_angle_beta 90.0 _cell_angle_gamma 90.0 _symmetry_space_group_name_H-M 'P 1' loop_ _atom_site_label _atom_site_type_symbol _atom_site_fract_x _atom_site_fract_y _atom_site_fract_z _atom_site_charge Si1 Si 0.4221 0.0573 0.3345 2.05 O1 O 0.3945 0.0649 0.2956 -1.025 O2 O 0.4565 0.0849 0.3312 -1.025 ``` -------------------------------- ### Adapt gRASPA Source Code for NERSC Filesystem Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Uses `sed` commands to replace `std::filesystem` with `std::experimental::filesystem` and adjust include paths for filesystem operations. This is necessary to adapt the gRASPA code to the NERSC cluster's specific C++ standard library configuration. ```shellscript sed -i "s/std::filesystem/std::experimental::filesystem/g" * sed -i "s///g" * ``` -------------------------------- ### Read Allegro Model Parameters Source: https://github.com/snurr-group/graspa/blob/main/libtorch-patch/Allegro/PATCH_ALLEGRO_main.cpp.txt Conditionally reads Allegro model parameters if the component is set to use Allegro. This function is part of the main Allegro integration process. ```c++ if(Comp_for_DNN_Model[i].UseAllegro) { ReadAllegroModelParameters(Comp_for_DNN_Model[i]); } ``` -------------------------------- ### Configure TensorFlow Environment Variables Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Adds the TensorFlow C++ API library path to the `LIBRARY_PATH` and `LD_LIBRARY_PATH` environment variables in the `.bashrc` file. This ensures the system can find the TensorFlow libraries during compilation and runtime. ```shellscript export LIBRARY_PATH=$LIBRARY_PATH:~/ctensorflow/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/ctensorflow/lib ``` -------------------------------- ### Download and Extract TensorFlow C++ API Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Downloads the TensorFlow 2 C++ API for GPU on Linux and extracts it to a local directory. This is a prerequisite for integrating TensorFlow functionality. ```shellscript mkdir ctensorflow cd ctensorflow wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz tar -xvf libtensorflow-gpu-linux-x86_64-2.11.0.tar.gz cd .. vi .bashrc ``` -------------------------------- ### Model Training Output Log (Example) Source: https://github.com/snurr-group/graspa/blob/main/Examples/CO2_MgMOF74_LCLin/ML_potential_details/Training_Lin_model/DNN_LinModel_train.ipynb This represents a typical output log generated during the training of a machine learning model. It displays epoch-by-epoch progress, including training loss, mean absolute error, validation loss, validation mean absolute error, and the learning rate. This log is crucial for monitoring training performance and diagnosing potential issues like overfitting or underfitting. The format is standard for many deep learning frameworks. ```text Epoch 1/100000 125/125 [==============================] - 2s 4ms/step - loss: 0.0721 - mean_absolute_error: 0.1232 - val_loss: 0.0183 - val_mean_absolute_error: 0.0681 - lr: 0.0010 Epoch 2/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0241 - mean_absolute_error: 0.0765 - val_loss: 0.0131 - val_mean_absolute_error: 0.0692 - lr: 0.0010 Epoch 3/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0178 - mean_absolute_error: 0.0707 - val_loss: 0.0083 - val_mean_absolute_error: 0.0470 - lr: 0.0010 Epoch 4/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0086 - mean_absolute_error: 0.0494 - val_loss: 0.0145 - val_mean_absolute_error: 0.0622 - lr: 0.0010 Epoch 5/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0092 - mean_absolute_error: 0.0494 - val_loss: 0.0067 - val_mean_absolute_error: 0.0407 - lr: 0.0010 Epoch 6/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0079 - mean_absolute_error: 0.0467 - val_loss: 0.0069 - val_mean_absolute_error: 0.0434 - lr: 0.0010 Epoch 7/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0046 - mean_absolute_error: 0.0375 - val_loss: 0.0031 - val_mean_absolute_error: 0.0332 - lr: 0.0010 Epoch 8/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0063 - mean_absolute_error: 0.0430 - val_loss: 0.0038 - val_mean_absolute_error: 0.0346 - lr: 0.0010 Epoch 9/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0068 - mean_absolute_error: 0.0443 - val_loss: 0.0041 - val_mean_absolute_error: 0.0347 - lr: 0.0010 Epoch 10/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0044 - mean_absolute_error: 0.0365 - val_loss: 0.0069 - val_mean_absolute_error: 0.0445 - lr: 0.0010 Epoch 11/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0077 - mean_absolute_error: 0.0493 - val_loss: 0.0043 - val_mean_absolute_error: 0.0365 - lr: 0.0010 Epoch 12/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0050 - mean_absolute_error: 0.0398 - val_loss: 0.0081 - val_mean_absolute_error: 0.0543 - lr: 0.0010 Epoch 13/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0056 - mean_absolute_error: 0.0406 - val_loss: 0.0038 - val_mean_absolute_error: 0.0362 - lr: 0.0010 Epoch 14/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0047 - mean_absolute_error: 0.0395 - val_loss: 0.0057 - val_mean_absolute_error: 0.0390 - lr: 0.0010 Epoch 15/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0039 - mean_absolute_error: 0.0355 - val_loss: 0.0038 - val_mean_absolute_error: 0.0330 - lr: 0.0010 Epoch 16/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0036 - mean_absolute_error: 0.0345 - val_loss: 0.0032 - val_mean_absolute_error: 0.0317 - lr: 0.0010 Epoch 17/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0051 - mean_absolute_error: 0.0407 - val_loss: 0.0047 - val_mean_absolute_error: 0.0348 - lr: 0.0010 Epoch 18/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0031 - mean_absolute_error: 0.0322 - val_loss: 0.0043 - val_mean_absolute_error: 0.0332 - lr: 8.0000e-04 Epoch 19/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0051 - mean_absolute_error: 0.0376 - val_loss: 0.0040 - val_mean_absolute_error: 0.0356 - lr: 8.0000e-04 Epoch 20/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0031 - mean_absolute_error: 0.0315 - val_loss: 0.0030 - val_mean_absolute_error: 0.0300 - lr: 8.0000e-04 Epoch 21/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0030 - mean_absolute_error: 0.0312 - val_loss: 0.0038 - val_mean_absolute_error: 0.0350 - lr: 8.0000e-04 Epoch 22/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0022 - mean_absolute_error: 0.0268 - val_loss: 0.0038 - val_mean_absolute_error: 0.0308 - lr: 8.0000e-04 Epoch 23/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0028 - mean_absolute_error: 0.0308 - val_loss: 0.0029 - val_mean_absolute_error: 0.0284 - lr: 8.0000e-04 Epoch 24/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0028 - mean_absolute_error: 0.0295 - val_loss: 0.0028 - val_mean_absolute_error: 0.0281 - lr: 8.0000e-04 Epoch 25/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0023 - mean_absolute_error: 0.0283 - val_loss: 0.0039 - val_mean_absolute_error: 0.0339 - lr: 8.0000e-04 Epoch 26/100000 125/125 [==============================] - 0s 2ms/step - loss: 0.0029 - mean_absolute_error: 0.0315 - val_loss: 0.0042 - val_mean_absolute_error: 0.0335 - lr: 8.0000e-04 Epoch 27/100000 ``` -------------------------------- ### Compile gRASPA with NERSC Compilation Script Source: https://github.com/snurr-group/graspa/blob/main/Cluster-Setup/NERSC/readme.md Makes the `NVC_COMPILE_NERSC` script executable and runs it to compile the gRASPA code. This script contains the necessary flags and commands for compiling gRASPA on the NERSC cluster using the NVIDIA HPC SDK. It is noted that `NVC_COMPILE_NERSC_VANILLA` can be used for the vanilla version. ```shellscript chmod +x NVC_COMPILE_NERSC ./NVC_COMPILE_NERSC ``` -------------------------------- ### Launch Multiple Simulations with MPS (Bash) Source: https://context7.com/snurr-group/graspa/llms.txt This bash script facilitates running multiple simulations concurrently on a single GPU using the Multi-Process Service (MPS). It starts the MPS daemon, then launches several simulation instances in separate directories, modifying the input file for each. Finally, it waits for all processes to complete and stops the MPS daemon. The 'watch -n0.5 nvidia-smi' command is used to monitor GPU utilization during the run. ```bash #!/bin/bash # mps_run script runs=3 currentdir=$(pwd) # Start MPS daemon ./start_as_root.sh # Launch multiple simulations for ((i = 0; i < $runs; i++)); do echo $i mkdir $i cp $currentdir/*.def $i/ cp $currentdir/simulation.input $i/ cp $currentdir/*.cif $i/ cd $currentdir/$i sed -i 's/xxx/'$i'/g' simulation.input ../../../src_clean/nvc_main.x > result & cd ../ done # Wait for all processes to complete wait # Stop MPS daemon ./stop_as_root.sh ``` ```bash # Monitor GPU utilization during MPS run watch -n0.5 nvidia-smi ``` -------------------------------- ### Keras Model Training Output Log Source: https://github.com/snurr-group/graspa/blob/main/Examples/Ar_MgMOF74_LCLin/ML_potential_details/Training_Lin_model/DNN_train_float32.ipynb This is an example of the output logs generated during the training of a Keras model. It displays the progress of each epoch, including loss and mean absolute error for both the training and validation sets, as well as the current learning rate (lr). This output is generated when `verbose=1` is set in the `model.fit` method. ```text Epoch 1/100000 500/500 [==============================] - 3s 3ms/step - loss: 14060.7246 - mean_absolute_error: 41.1378 - val_loss: 1709.2434 - val_mean_absolute_error: 20.8028 - lr: 0.0010 Epoch 2/100000 500/500 [==============================] - 1s 2ms/step - loss: 2318.6445 - mean_absolute_error: 16.6884 - val_loss: 1190.0320 - val_mean_absolute_error: 11.7065 - lr: 0.0010 Epoch 3/100000 500/500 [==============================] - 1s 2ms/step - loss: 1225.8893 - mean_absolute_error: 11.8960 - val_loss: 1046.8752 - val_mean_absolute_error: 12.1191 - lr: 0.0010 Epoch 4/100000 500/500 [==============================] - 1s 2ms/step - loss: 1170.1034 - mean_absolute_error: 11.2820 - val_loss: 1144.0524 - val_mean_absolute_error: 12.9772 - lr: 0.0010 Epoch 5/100000 500/500 [==============================] - 1s 2ms/step - loss: 910.9819 - mean_absolute_error: 10.0821 - val_loss: 545.5269 - val_mean_absolute_error: 8.6725 - lr: 0.0010 Epoch 6/100000 500/500 [==============================] - 1s 2ms/step - loss: 864.9779 - mean_absolute_error: 9.6837 - val_loss: 748.4333 - val_mean_absolute_error: 10.8502 - lr: 0.0010 Epoch 7/100000 500/500 [==============================] - 1s 2ms/step - loss: 667.4968 - mean_absolute_error: 8.6852 - val_loss: 410.5316 - val_mean_absolute_error: 7.0981 - lr: 0.0010 Epoch 8/100000 500/500 [==============================] - 1s 2ms/step - loss: 873.6649 - mean_absolute_error: 9.5307 - val_loss: 468.0074 - val_mean_absolute_error: 7.1819 - lr: 0.0010 Epoch 9/100000 500/500 [==============================] - 1s 2ms/step - loss: 717.4338 - mean_absolute_error: 9.0054 - val_loss: 1566.9860 - val_mean_absolute_error: 16.9786 - lr: 0.0010 Epoch 10/100000 500/500 [==============================] - 1s 2ms/step - loss: 691.6623 - mean_absolute_error: 8.6600 - val_loss: 2860.1206 - val_mean_absolute_error: 20.1359 - lr: 0.0010 Epoch 11/100000 500/500 [==============================] - 1s 2ms/step - loss: 570.0209 - mean_absolute_error: 7.9987 - val_loss: 407.0331 - val_mean_absolute_error: 6.0953 - lr: 0.0010 Epoch 12/100000 500/500 [==============================] - 1s 2ms/step - loss: 508.8945 - mean_absolute_error: 7.3302 - val_loss: 446.1164 - val_mean_absolute_error: 6.3406 - lr: 0.0010 Epoch 13/100000 500/500 [==============================] - 1s 2ms/step - loss: 662.7073 - mean_absolute_error: 8.3351 - val_loss: 487.0874 - val_mean_absolute_error: 7.0252 - lr: 0.0010 Epoch 14/100000 500/500 [==============================] - 1s 2ms/step - loss: 580.6765 - mean_absolute_error: 8.0184 - val_loss: 1850.6664 - val_mean_absolute_error: 15.7349 - lr: 0.0010 Epoch 15/100000 500/500 [==============================] - 1s 2ms/step - loss: 792.3494 - mean_absolute_error: 8.6553 - val_loss: 358.0082 - val_mean_absolute_error: 6.1186 - lr: 0.0010 Epoch 16/100000 500/500 [==============================] - 1s 2ms/step - loss: 480.0647 - mean_absolute_error: 6.9948 - val_loss: 379.7430 - val_mean_absolute_error: 6.0166 - lr: 0.0010 Epoch 17/100000 500/500 [==============================] - 1s 2ms/step - loss: 559.7564 - mean_absolute_error: 7.7743 - val_loss: 1124.4520 - val_mean_absolute_error: 12.9972 - lr: 0.0010 Epoch 18/100000 500/500 [==============================] - 1s 2ms/step - loss: 403.7167 - mean_absolute_error: 6.3432 - val_loss: 432.4240 - val_mean_absolute_error: 6.1128 - lr: 0.0010 Epoch 19/100000 500/500 [==============================] - 1s 2ms/step - loss: 466.1626 - mean_absolute_error: 6.8776 - val_loss: 484.8942 - val_mean_absolute_error: 6.4753 - lr: 0.0010 Epoch 20/100000 500/500 [==============================] - 1s 2ms/step - loss: 316.5132 - mean_absolute_error: 5.8391 - val_loss: 369.0351 - val_mean_absolute_error: 7.6894 - lr: 0.0010 Epoch 21/100000 500/500 [==============================] - 1s 2ms/step - loss: 432.2688 - mean_absolute_error: 6.7057 - val_loss: 282.9934 - val_mean_absolute_error: 5.4766 - lr: 0.0010 Epoch 22/100000 500/500 [==============================] - 1s 2ms/step - loss: 401.3378 - mean_absolute_error: 6.6276 - val_loss: 240.4399 - val_mean_absolute_error: 5.2316 - lr: 0.0010 Epoch 23/100000 500/500 [==============================] - 1s 2ms/step - loss: 333.6879 - mean_absolute_error: 6.1483 - val_loss: 330.3794 - val_mean_absolute_error: 7.9191 - lr: 0.0010 Epoch 24/100000 500/500 [==============================] - 1s 2ms/step - loss: 371.3149 - mean_absolute_error: 6.3752 - val_loss: 243.8103 - val_mean_absolute_error: 4.6550 - lr: 0.0010 Epoch 25/100000 500/500 [==============================] - 1s 2ms/step - loss: 506.5237 - mean_absolute_error: 6.8634 - val_loss: 216.9355 - val_mean_absolute_error: 4.3337 - lr: 0.0010 Epoch 26/100000 ``` -------------------------------- ### Define Project Parameters and File Paths Source: https://github.com/snurr-group/graspa/blob/main/Examples/Ar_MgMOF74_LCLin/ML_potential_details/Training_Lin_model/DNN_train_float32.ipynb Sets up key parameters and file paths for the project. This includes physical constants (k2kjmol), simulation control variables (nframe), MOF file details, supercell scaling factors, and the path to a molecular dynamics movie file. ```python # define some parameters # Constant k2kjmol = 0.00831446 # constants. Convert K to kJ/mol # number of movie frames nframe = 10000 # MOF information mof_file = "MgMOF-74-1x1x1-P1-VASP_charged.cif" sc_fac= [1,1,2] # multiply by this vector to get a supercell # Movie file movie_file = "Movies/System_0/Movie_MgMOF-74-1x1x1-P1-VASP_charged_1.1.2_80000.000000_0.000000_allcomponents.pdb" ``` -------------------------------- ### Define Parameters for VASP Input Preparation Source: https://github.com/snurr-group/graspa/blob/main/Examples/CO2_MgMOF74_LCLin/ML_potential_details/Data_generation/DFT/Single_point/pdb2poscar.ipynb Defines key parameters for the script, including the number of movie frames to process, the path to the MOF CONTCAR file, and the path to the CO2 PDB movie file. ```python # define some parameters # Constant # k2kjmol = 0.00831446 # constants. Convert K to kJ/mol # number of movie frames nframe = 1 # MOF CONTCAR information # Take CONTCAR from single point calculations of MOF mof_file = "sp_mof211/CONTCAR" # Movie file movie_file = "co2_movie_2000_211.pdb" ``` -------------------------------- ### Generate VASP Input Files and Submit Jobs Source: https://github.com/snurr-group/graspa/blob/main/Examples/CO2_MgMOF74_LCLin/ML_potential_details/Data_generation/DFT/Single_point/pdb2poscar.ipynb Creates directories for CO2-only and CO2+MOF DFT runs, writes POSCAR files, copies VASP input files (INCAR, KPOINTS, etc.), and submits jobs using `sbatch`. This process is repeated for each CO2 configuration. ```python # change directory os.chdir('sp_system') path0 = os.getcwd() os.chdir('all_211') path1 = os.getcwd() # create a directory for each element in co2 list for i in range(len(co2)): dir_name = str(i) os.chdir(path1) os.mkdir(dir_name) ##### create a CO2 DFT runs for reference os.chdir(dir_name) os.mkdir('co2') os.chdir('co2') # write POSCAR file write('POSCAR',co2[i]) # copy other input files to this directory copy2(path0+'/INCAR', './') copy2(path0+'/KPOINTS', './') copy2(path0+'/perl_gpu.sh', './') copy2(path0+'/POTCAR_co2', './POTCAR') copy2(path0+'/vdw_kernel.bindat', './') # submit jobs subprocess.run(['sbatch', 'perl_gpu.sh']) ##### create a CO2+MOF DFT runs os.chdir(path1+'/'+dir_name) os.mkdir('system') os.chdir('system') # write POSCAR file system = mof + co2[i] write('POSCAR',system) # copy other input files to this directory copy2(path0+'/INCAR', './') copy2(path0+'/KPOINTS', './') copy2(path0+'/perl_gpu.sh', './') copy2(path0+'/POTCAR_system', './POTCAR') copy2(path0+'/vdw_kernel.bindat', './') # submit jobs subprocess.run(['sbatch', 'perl_gpu.sh']) ``` -------------------------------- ### Import Libraries for VASP Input Preparation Source: https://github.com/snurr-group/graspa/blob/main/Examples/CO2_MgMOF74_LCLin/ML_potential_details/Data_generation/DFT/Single_point/pdb2poscar.ipynb Imports necessary Python libraries for numerical operations, plotting, file system manipulation, and interacting with VASP input/output files. Dependencies include numpy, matplotlib, os, subprocess, ase, and pymatgen. ```python import numpy as np import matplotlib.pyplot as plt import os import subprocess from ase import Atoms from ase.io import read, write from pymatgen.io.cif import CifParser from shutil import copy2 plt.rcParams['font.size'] = '15' ``` -------------------------------- ### Configure ML Potential for Host-Guest Interactions (Text) Source: https://context7.com/snurr-group/graspa/llms.txt This snippet illustrates the configuration for using Machine Learning (ML) potentials, specifically Allegro, within the 'simulation.input' file. It enables the use of ML potentials for host-guest interactions and specifies the path to the trained model, energy units, length units, and calculation type. It also defines parameters for a specific molecular component. ```text # ML potential parameters in simulation.input UseDNNHostGuest yes DNNModelPath ./deployed_model.pt DNNEnergyUnit eV DNNLengthUnit Angstrom DNNCalculationType LibTorch Component 0 MoleculeName Ar IdealGasRosenbluthWeight 1.0 FugacityCoefficient 1.0 TranslationProbability 1.0 RotationProbability 1.0 SwapProbability 1.0 CreateNumberOfMolecules 0 ``` -------------------------------- ### Prepare System Components with LCLin Data Source: https://github.com/snurr-group/graspa/blob/main/cppflow-patch/LCLIN/PATCH_LCLIN_main.cpp.txt This C++ snippet prepares system components by copying DNN model details from another component if 'UseLCLin' is enabled. It iterates through the DNN models, copies min/max values, input layer information, and then calls 'Prepare_FeatureMatrix'. This prepares the component for subsequent processing. ```C++ if(Vars.SystemComponents[a].UseLCLin) { for(size_t x = 0; x < Comp_for_DNN_Model[a].DNNModel.size(); x++) { Vars.SystemComponents[a].DNNModel.push_back(Comp_for_DNN_Model[a].DNNModel[x]); Vars.SystemComponents[a].DNNMinMax = Comp_for_DNN_Model[a].DNNMinMax; Vars.SystemComponents[a].InputLayer= Comp_for_DNN_Model[a].InputLayer; } Prepare_FeatureMatrix(Vars.Sims[a], Vars.SystemComponents[a], Vars.SystemComponents[a].HostSystem, Vars.Box[a]); } ``` -------------------------------- ### Run gRASPA Simulation and Redirect Output Source: https://context7.com/snurr-group/graspa/llms.txt Executes the gRASPA simulation executable and redirects its standard output to a file named 'output.txt'. This is a common first step in running a simulation. ```bash #!/bin/bash cd ../Examples/Ar_MgMOF74_Allegro/ ../../patch_libtorch_Allegro/nvc_main.x > output.txt ``` -------------------------------- ### Configure Multi-Component GCMC Simulation Input with Identity Swap Source: https://context7.com/snurr-group/graspa/llms.txt This snippet illustrates the `simulation.input` file configuration for multi-component mixture adsorption, featuring identity swap moves for efficient equilibration. It includes parameters for multiple components, their mole fractions, and relevant probabilities for exchange. ```text # simulation.input for CO2/CH4 mixture NumberOfInitializationCycles 300000 NumberOfEquilibrationCycles 0 NumberOfProductionCycles 1000000 UseChargesFromCIFFile yes UseMaxStep yes MaxStepPerCycle 1 ChargeMethod Ewald Temperature 296 Pressure 500000 OverlapCriteria 1e5 CutOffVDW 12.8 CutOffCoulomb 12.0 EwaldPrecision 1e-6 Component 0 MoleculeName CO2 IdealGasRosenbluthWeight 1.0 FugacityCoefficient 0.9730021872 MolFraction 0.5 TranslationProbability 1.0 RotationProbability 1.0 ReinsertionProbability 1.0 IdentityChangeProbability 1.0 SwapProbability 1.0 CreateNumberOfMolecules 0 Component 1 MoleculeName methane IdealGasRosenbluthWeight 1.0 FugacityCoefficient 0.9894689168 MolFraction 0.5 TranslationProbability 1.0 ReinsertionProbability 1.0 IdentityChangeProbability 1.0 SwapProbability 1.0 CreateNumberOfMolecules 0 ``` -------------------------------- ### Define Parameters for PDB to EXTXYZ Conversion Source: https://github.com/snurr-group/graspa/blob/main/Examples/Ar_MgMOF74_LCLin/ML_potential_details/Data_generation/pdb2extxyz.ipynb Defines essential parameters for the conversion process. This includes physical constants, simulation parameters like the number of frames, atom types for adsorbates and host structures, MOF file paths, supercell scaling factors, and movie file paths. ```python # define some parameters # Constant k2kjmol = 0.00831446 # constants. Convert K to kJ/mol # number of movie frames # there are total of 10k frames available nframe = 10000 # atom type in adsorbate molecules ads_atom = ['Ar'] # atom type in host solid adsorbent host_atom_type = ['Mg','O','C','H'] # MOF information mof_file = "MgMOF-74-1x1x1-P1-VASP_charged.cif" sc_fac= [1,1,2] # multiply by this vector to get a supercell # Movie file movie_file = "Movies/System_0/Movie_MgMOF-74-1x1x1-P1-VASP_charged_1.1.2_80000.000000_0.000000_allcomponents.pdb" ``` -------------------------------- ### Read CO2 Configurations from PDB Movie Source: https://github.com/snurr-group/graspa/blob/main/Examples/CO2_MgMOF74_LCLin/ML_potential_details/Data_generation/DFT/Single_point/pdb2poscar.ipynb Reads CO2 configurations from a PDB movie file. It iterates through each frame, extracting atomic symbols and positions, and creates an ASE Atoms object for each CO2 configuration, incorporating the MOF's cell and periodic boundary conditions. ```python co2 = [0 for i in range(nframe)] # Read the movie file into a numpy array # read PDF file f = open(movie_file) # loop over each frame for i in range(nframe): # read first two lines line = [next(f).strip().split() for x in range(2)] symbols = [] pos = [] cell = mof.cell while 1: line = next(f).strip().split() if line[0] == 'ENDMDL': break symbols.append(line[2]) pos.append([float(line[4]), float(line[5]), float(line[6])]) # create Atoms object co2[i] = Atoms(symbols=symbols, positions=pos, cell=cell, pbc=True) ``` -------------------------------- ### Run Basic GCMC Simulation using gRASPA Executable Source: https://context7.com/snurr-group/graspa/llms.txt This snippet shows how to run a single-component Grand Canonical Monte Carlo simulation for gas adsorption in porous materials using the gRASPA executable. It involves navigating to the simulation directory and redirecting the output to a file for later analysis. ```bash # Navigate to simulation directory with input files cd Examples/CO2-MFI/ # Run gRASPA executable ../../src_clean/nvc_main.x > output.txt # View results tail -n 50 output.txt ```