Cloud computing¶
Google Colab runs MPM3S in your web browser on a Google machine with an NVIDIA GPU, so nothing has to be installed on your own computer. MPM3S is kept in your Google Drive, which Colab connects to.
Before you start¶
- Download the MPM3S ZIP from GitHub, as in Downloading MPM3S from GitHub (the ZIP tab). Leave it zipped.
- Upload
MPM3S.jl-master.zipto My Drive in Google Drive: New → File upload. A single ZIP uploads much faster than the unzipped folder. - Open Google Colab, signed in to the same Google account, and choose New notebook. Colab saves it in the Colab Notebooks folder of your Drive.
Colab set-up¶
Click a screenshot to open it full size.
1. Start a Python runtime with a GPU. Choose Runtime → Change runtime type. Set Runtime type to Python 3 (1) and Hardware accelerator to T4 GPU (2), then click Save (3). The notebook starts in Python because Google Drive can only be connected from Python; it is switched to Julia in step 5.
2. Connect your Google Drive. Paste this into the first code cell and click its run button (1):
Allow Colab to access your Google Drive when asked. The cell prints Mounted at /content/drive: My Drive is now the folder /content/drive/MyDrive.
3. Check that the drive is connected. Click the Files icon (1) in the left sidebar. A drive folder (2) is now listed; inside it, MyDrive holds the ZIP you uploaded. If drive is missing, click the refresh icon at the top of the panel.
4. Unzip MPM3S in the terminal. Click Terminal (1) at the bottom of the window. In the terminal (2), run:
unzip lists each file as it is extracted (inflating: ...). This leaves an MPM3S folder in your Drive, so it only has to be done once.
5. Switch the runtime to Julia. Open Runtime → Change runtime type again, set Runtime type to Julia (1), keep T4 GPU, and click Save (2). Google Drive stays connected, and the runtime name at the bottom right of the window now ends in (Julia).
6. Install MPM3S. Click + Code (1) to add a cell, paste this into it and click its run button (2):
using Pkg;
Pkg.activate("/content/drive/MyDrive/MPM3S");
cd("/content/drive/MyDrive/MPM3S");
Pkg.instantiate();
using MPM3S
Do not run the first cell again: it is Python, and the notebook now runs Julia.
7. Wait for the packages to install. While the cell runs, its run button becomes a spinning stop button (1) and the bottom bar shows Executing. Pkg.instantiate() installs the packages MPM3S needs (2), which can take several minutes, and using MPM3S then loads it. When a green tick appears next to the cell, MPM3S is ready.
8. Run a problem. Click + Code (1) to add a cell, paste the command for the problem into it and click its run button (2). Tutorial 3, for example, is run with:
Step 6 left Julia in the MPM3S folder, so the path is relative to it, as on your own computer. The input file must have "GPU": "on", as Tutorial 3's does. The bottom bar shows Executing (3) until the analysis has finished.
9. Find the results in your Google Drive. The output files are saved in your Google Drive, in the MPM3S folder. Open Google Drive and go to My Drive → MPM3S (1): Tutorial 3 writes its output to vtk_CPT_dr32 (2), which fills up while the analysis runs. To view the results, right-click the folder, choose Download, and open the files in ParaView, as in Viewing the output.
Your own problems¶
Upload the problem's folder into MPM3S in your Drive, for example MPM3S/my_runs/input_data.json, and give that path in step 8: MPM3S.non_linear_solve("my_runs/input_data.json");. Set "GPU": "on" in the input file to use Colab's GPU.
STL files must be converted to a mesh text file first
MPM3S meshes each .stl file with Gmsh and saves the mesh as the text file named in the input file's "mesh cache". Gmsh does not run on Colab, so make the text file on your own computer, with MPM3S installed with Julia, and upload it to the same folder as the .stl file. For the cone of Tutorial 3, from the MPM3S folder:
julia> using MPM3S
julia> MPM3S.RigidBodies.body_mesh("validation_data_and_jsons/CPT.stl", "validation_data_and_jsons/CPT_mesh.txt");
- The first path is the
.stlfile, and the second is the text file to write; give it the name used for"mesh cache"in the input file. - If the text file already exists, it is read rather than made again, so delete it first whenever the
.stlfile changes. - The tutorials'
.stlfiles already come with their text files (e.g.CPT_mesh.txt), so they run on Colab as they are.
Starting a new session¶
Colab wipes its machine when a session ends, but the MPM3S folder stays in your Drive. To carry on, open the notebook again and repeat steps 1, 2, 5, 6 and 7: skip the unzip in step 4. The packages are installed again in step 7, as they are lost with the machine. The results from earlier runs stay in your Drive.








