Log in
Log in Simulate Now
Log in Simulate Now

How to Plot Data Arrays Using the OnScale Solve Jupyter Notebook

By Oliver Mashari 23 March 2021

Following on from our blog post How to Run a Simulation in OnScale Solve, this post will teach you how to plot data arrays using the OnScale Solve Jupyter Notebook. This article will cover:

  • Opening results after a simulation 
  • Opening the Jupyter Notebook
  • Downloading results from the Jupyter Notebook
  • Plotting data arrays

Download the post processing script plot_data_arrays.py to follow along!

After the simulation finishes you will be able to open the results by clicking Load Results. This is how the UI should look if you are following on from this blog post.

OnScale Solve
Jupyter is a graphical interface in the browser that allows you to run some python code in the cloud (or MATLAB code with Octave). If this is your first time hearing about Jupyter Notebooks, we recommend having a look at the website
jupyter.org to get some knowledge about how it works. It has become a really popular tool in data analysis, so understanding it will only benefit you.

To open a Notebook, first click on the second small icon of the floating bar near the right:

OnScale Solve

After clicking this you should see something similar to the following: 

Jupyter Notebook Library

On the left, you will find your simulation data files (raw data files this time!) and on the right, you have the different programs (called “Jupyter Kernels”) that you can use to process your raw data.

OnScale Solve is currently in its beta stage so the Jupyter Notebook doesn’t support the X window graphical system needed to plot data arrays, so we will show you how to export simulation results from the Notebook and detail the steps needed to run the  post-processing script. Before we move onto exporting the results you will need Python 3.7.1+ installed (add to PATH during install).

With Python installed, open a PowerShell terminal. Run the following commands to install the necessary libraries needed to process the results:

  • pip install pyvista
  • pip install matplotlib
  • pip install numpy

Let’s look at exporting our simulation results. When submitted to the cloud the job is assigned a random job ID. The outputs will be stored in the directory with that job ID.

Select all files in the output folder and right click to download the files. Move the files and the python script we shared at the beginning (plot_data_arrays.py) to the same directory and open a PowerShell terminal from this directory.

The python script will find a read any VTU or PVTU files stored in the directory or any subdirectories, and plot the first data array stored in that file. It makes use of the pyvista and matplotlib libraries to do so. In the PowerShell terminal run following the command:

  • python plot_data_arrays.py

How to plot arraysIn the image above if you look at the PowerShell output you can see that a list of array names has been printed to the terminal. To visualize these arrays open up the plot_data_arrays.py file in any text editor search for the string ‘Displacement’ and replace with any of the arrays printed to the terminal. Let’s plot ‘Strain’.

Python ScriptNow that you can export your data, you can explore more advanced methods of working with the output files. You should now start to get an idea of the potential of post-processing under the hood. 

Got some ideas of post-processing that you would like to perform, but you don’t know how to write the script? Write and tell us what you want to see and we will make it happen!

Also if you have some useful scripts that you would like to share with us, please don’t hesitate. If you agree, we can even put it in the example folder to benefit all OnScale Solve Users.

How to Get Started With OnScale Solve:

Engineers, designers, analysts, and current OnScale users can learn more about OnScale Solve and run their first cloud engineering simulation study by accessing these resources:

  • Create your Free private account here.
  • Watch a quick guided video tour of the software, from log in to simulation.
  • Run your first simulation by following a 10-minute online tutorial.
  • Ask for technical support by emailing support@onscale.com.

We hope to see all your great post-processing ideas coming to life soon with all the new tools we put at your disposal!

Discover how customers like you found success by
leaving traditional engineering simulation behind

Try OnScale following
our simulation guides

Simulate Now

Discuss your engineering
applications with us

Request a Demo