English
Log in
Log in Simulate Now
English
Log in Simulate Now

How to Extract a Field Value at an XYZ Location Using the OnScale Solve Juypter Notebook

By Kevin Chan 30 March 2021

Following on from our blog post How to Run a Simulation in OnScale Solve this post will teach you how to extract a field value at an XYZ location using the OnScale Solve Jupyter Notebook. This article will cover:

  • Opening results after a simulation 
  • Opening the Jupyter Notebook
  • Uploading a Python Notebook file and executing

Showing results in the UI

After a simulation finishes you will be able to open the results. 

Click Load Results and your simulated geometry should appear like what is shown below:

OnScale Solve

Accessing the Jupyter Notebook

To access Jupyter Notebook functionality, you can click on the icon:

Jupyter Notebook

This will open up the interface allowing you to select between using a Python or Octave notebook to process the simulation outputs. 

Within this interface, we can also upload our custom Python Notebooks directly into simulation directory. Click on the upload icon and select the notebook file wish to upload:

Jupyter Notebook File

Your selected python notebook should appear in the working directory allowing you to open/modify and execute the code.

Running the Python Notebook

You can download the python notebook we want to use for the example here:

Download Python Notebook

To run the code, simply use the play icon to step through code section. 

Extracting Field Value

The notebook is live and interactive, so outputs are immediately generated and displayed as the code is executed.

The example file should do the following:

  • Install PyVista
    – A library that handles VTK (The Visualization Toolkit) format (.vtu)
  • Locate and read the VTK data files (.vtu or .pvtu)
  • Determine what array data is available in the data files
  • Utilise the numpy library for handling array of points
  • Use PyVista functions to return the quantity value at the requested points

Extract Field Value

This script can be modified to extract any of the calculated data arrays at any point within the mesh bounds.

Simply add or modify the existing points stored in a and b with new XYZ position:

XYZ position

You can modify which array quantity you would like to extract by modifying the array name for the result data structure:

Extracting a Field Value

The array names are shown in the mesh or mesh.array_names output

Array Names

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!

Kevin Chan
Kevin Chan

Kevin is a Senior Application Engineer at OnScale. He tests and helps with the development of OnScale. His background and experience with the solvers has allowed him to work on a wide range of projects with a big focus on MEMS & RF. Kevin holds a MEng in Electronic and Electrical Engineering at the University of Strathclyde.

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