Molten NaCl Example

In this walkthrough we will look at a system of molten NaCl to see how MDSuite can be used for the analysis of real systems

Library imports

For this specific tutorial we will use our designate data server zinchub to load the data. This is the only import other than mdsuite required for any analysis.

[1]:
from zinchub import DataHub
import mdsuite as mds
2022-07-27 15:40:31.780147: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:31.780173: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-07-27 15:40:37.469007: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublas.so.11'; dlerror: libcublas.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.469269: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.469495: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.469716: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.469936: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusolver.so.11'; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.470160: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.470382: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /opt/slurm/lib:/opt/slurm/lib:
2022-07-27 15:40:37.470409: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

With the following two lines we download the data from zinchub.

[2]:
NaCl = DataHub(url="https://github.com/zincware/DataHub/tree/main/NaCl_gk_i_q", tag="v0.1.0")
NaCl.get_file(path=".")
[2]:
'NaCl_gk_i_q.lammpstraj'

Starting your project

Now we can start an MDSuite project and add some data to it. Creating a project is as simple as calling the Project class with the name.

[3]:
project = mds.Project("NaCl_Example")
2022-07-27 15:40:42,240 - INFO: Creating new project NaCl_Example

Now we can add an experiment to the project. In this case, we pass the downloaded data directly to this experiment rather than add it at a later stage.

[4]:
project.add_experiment(
        name="NaCl_example_data",
        timestep=0.002,
        temperature=1400.0,
        units="metal",
        simulation_data="NaCl_gk_i_q.lammpstraj",
    )
2022-07-27 15:40:42,670 - INFO: Creating a new experiment!
100%|███████████████████████████████████| 1/1 [00:07<00:00,  7.08s/it]
[4]:
exp_NaCl_example_data

System analysis

Now we can start looking at the system and learning from it. Let’s start with a radial distribution function to see the structure.

[5]:
project.run.RadialDistributionFunction(number_of_configurations=100, plot=True)
2022-07-27 15:40:50.595608: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
100%|███████████████████████████████| 100/100 [00:50<00:00,  1.96it/s]
Loading BokehJS ...
[5]:
{'NaCl_example_data': Exp1_Radial_Distribution_Function_1}

This looks nice, but let’s kick it up a notch and look at bond distributions with the angular distribution functions.

[6]:
project.run.EinsteinDiffusionCoefficients()
2022-07-27 15:41:42,672 - INFO: starting Einstein Diffusion Computation
2022-07-27 15:41:42,673 - INFO: starting Einstein Diffusion Computation
Applying transformation 'Unwrapped_Positions' to 'Na': 100%|█| 1/1 [00
Applying transformation 'Unwrapped_Positions' to 'Cl': 100%|█| 1/1 [00
Na: 100%|███████████████████████████████| 1/1 [00:01<00:00,  1.57s/it]
Cl: 100%|███████████████████████████████| 1/1 [00:01<00:00,  1.55s/it]
Loading BokehJS ...
[6]:
{'NaCl_example_data': Exp1_Einstein Self-Diffusion Coefficients_2}
[7]:
project.run.EinsteinDiffusionCoefficients(species=["Na"], data_range=50)
2022-07-27 15:41:47,665 - INFO: starting Einstein Diffusion Computation
2022-07-27 15:41:47,667 - INFO: starting Einstein Diffusion Computation
Na: 100%|███████████████████████████████| 1/1 [00:01<00:00,  1.48s/it]
Loading BokehJS ...
[7]:
{'NaCl_example_data': Exp1_Einstein Self-Diffusion Coefficients_3}
[8]:
project.run.AngularDistributionFunction(number_of_configurations=50, plot=True, cutoff=3.6)
100%|██████████████████████████████████| 2/2 [03:36<00:00, 108.42s/it]
Loading BokehJS ...
[8]:
{'NaCl_example_data': Exp1_Angular_Distribution_Function_4}

Finally, let’s take a look at the Green-Kubo diffusion coefficients and ionic conductivity.

[9]:
project.run.GreenKuboDiffusionCoefficients(
        data_range=102, plot=True, correlation_time=10
    )
Na: 100%|███████████████████████████████| 1/1 [00:03<00:00,  3.57s/it]
Cl: 100%|███████████████████████████████| 1/1 [00:03<00:00,  3.68s/it]
Loading BokehJS ...
[9]:
{'NaCl_example_data': Exp1_Green Kubo Self-Diffusion Coefficients_5}
[10]:
project.run.GreenKuboIonicConductivity(
        data_range=300, plot=True, correlation_time=1
    )
Applying transformation 'Ionic_Current': 100%|█| 1/1 [00:00<00:00,  5.
100%|███████████████████████████████████| 1/1 [00:01<00:00,  1.14s/it]
Loading BokehJS ...
[10]:
{'NaCl_example_data': Exp1_Green_Kubo_Ionic_Conductivity_6}