[lammps-users] installing and using Lammps in Google Colab

Hello there.

I’m new to LAMMPS but I have knowledge of some python programming and wanted to try using LAMMPS via python in the Google Colaboratory

Here are my questions:

  1. Is it possible to install LAMMPS in google colab?
  2. And if yes, how do I go about doing this? Are there any existing tutorials on how to do this? I’ve tried searching but I can’t seem to find one.

Hello JC,

It is possible.

I would recommend using cmake and installing it once and then saving the executable+shared object library and using them in future sessions.

There should be enough information about how to install using cmake and making a shared library for python in the LAMMPS documentation.

If you have anymore trouble after reading the documentation, feel free to reach out to me.

Best,
Charlie

Hello there.

I’m new to LAMMPS but I have knowledge of some python programming and wanted to try using LAMMPS via python in the Google Colaboratory

Here are my questions:

  1. Is it possible to install LAMMPS in google colab?

yes. google colab sessions are essentially virtual machines running ubuntu linux and you have a shell escape (“!”), so you can do most of what you could do on a desktop terminal.

  1. And if yes, how do I go about doing this? Are there any existing tutorials on how to do this? I’ve tried searching but I can’t seem to find one.

My colleague Richard Berger has done a small demonstration some time ago. While there is a pre-compiled package for the LAMMPS executables, it doesn’t seem to include the python module. So you would have to compile LAMMPS from source. Commands for that are included in the attached notebook file. Since LAMMPS is a large package, you need some patience… For more information about compiling LAMMPS from source, please see: https://docs.lammps.org/Build.html

HTH,
Axel.

UsingLammpsInColabDemo.ipynb (267 KB)

Thanks for taking the time to answer my question.

If it’s alright with you, I just have a few more questions about this part of your email:

“While there is a pre-compiled package for the LAMMPS executables, it doesn’t seem to include the python module. So you would have to compile LAMMPS from source.”

  1. So does that mean that within google colab, I can use lammps like how I normally would if I did in a computer (that is via the command prompt)?
  2. If the pre-compiled doesnt include the python module, how come the last part of the notebook you shared has a section where it seems that lammps was imported into python?

Thanks for taking the time to answer my question.

If it’s alright with you, I just have a few more questions about this part of your email:

“While there is a pre-compiled package for the LAMMPS executables, it doesn’t seem to include the python module. So you would have to compile LAMMPS from source.”

  1. So does that mean that within google colab, I can use lammps like how I normally would if I did in a computer (that is via the command prompt)?

there is a demo for that in the notebook I sent to the list.

  1. If the pre-compiled doesnt include the python module, how come the last part of the notebook you shared has a section where it seems that lammps was imported into python?

please have a closer look at the notebook and compare it with the LAMMPS manual and then you should be able answer this question yourself.

axel.