In this blog post we will describe how to batch process FEA simulation data automatically using a review script in OnScale.
One of the major hassles in simulation is processing the results. Most of the time we know what kind of results we need to get out of a simulation, however there can be a lot of “reformatting” required. For example, you may want to display some graphics or take screen captures at different angles to create a report. Well… you will be glad to know that ALL of that can be automated using review post-processing scripts in OnScale.
1- What is a review script?
Review is the “hidden” name of the post-processing engine behind the interface.
Whatever you do in post-processing (or “Review”) can be done in 2 ways:
Here’s a practical example of a script which transforms the data contained into an “xx.flxhst” file into a “mydata.txt” text format file that can be read with another software like Python or MATLAB:
This script is straightforward and simple to understand:
Note: For review to find the xx.flxhst file, the file must be in the same directory as the script.
Note2: If you are wondering “why do I need to convert the ‘flxhst’ into a text file?” The answer is that an “flxhst” file is a binary file (filled with 1 and 0) that only the OnScale post-process can read. If you want to see the numbers inside, you need to convert it into “text”. This is useful if your plan is to process the data afterwards with another program such as Python
2- How to write a review script?
First, you need to know what you want to do and how to write it into review script language.
You can find some examples here.
Then, you need to open OnScale Analyst Mode and create a new file:
Then paste your script in it:
When you save it, choose to save it under the “.revinp” format
(revinp is the contraction of review input)
You will then see the color change to display the “review script” language syntax:
3- How to execute?
Review scripts can be executed on the cloud like OnScale Models.
Just Click on run and that will work.
The script will then be executed and provide the results that you requested.
Those results will be stored in the cloud, so you will need to click on “storage” to download them:
This is what you should get at the end:
4- How to debug?
In case you have a problem in your script, let’s MAKE a bug and see what happens as an example. Here we changed f1 to f2 (which doesn’t exist)
Let’s run the script again!
The script is 100% processed… but no mydata.txt is generated
(which was expected)
There is a “myscript.revprt” file in it. Errors, warnings and problems will be listed in that file.
Let’s open it to see what’s inside:
So, we can see in that file that there is a message printed out after the execution of each command. After the command has a problem (we made the problem, so we knew where it was), it is written:
“Plotting data not found
Interpretation of plot command failed on argument 1:f2″
So, you see? If you have a problem in your script, you just need to open that “revprt” file and read what is written in it to understand where your problem is. If it’s because you didn’t write the command correctly, then just “right-click” on the command and check the help to see how the syntax should be written:
5- Do I really need review scripts?
Not always! If you only need to perform one simple operation which is supported in the GUI, then you won’t need a script! For example, all the things I showed you here (generation of a text file from a flxhst file) can be done through the interface as well!
Just open the “xx.flxhst” file, then right-click> Export Selected Curve > to Csv
(Or Space Delimited, whatever you prefer)
OnScale has already plenty of good functions that can be performed through the interface itself:
For example, performing FFTs, Impedance or Admittance calculation can all be done through the interface.
So… when are review scripts useful? When you must do a repetitive task on large amount of Data for example! Imagine you want to do a Design of Experiment and run 1000 simulations…
Do you want to click and export the data curve in text format 1000 times through the GUI??
Of course not! In this case you can easily setup a review script that will automate this kind of repetitive tasks which do not really bring any value. In fact, you can have you full customized reporting system all built with review scripts!
Cool, right? Probably worth investigating what are the other more advanced things you can do with review scripts. Lucky for you, we have a page on our support center in which we display a few simple scripts. You can take inspiration from them and start to write your own scripts in no time.
6- Can I use other type of script?
If you can find a way to export the results in text, then you can easily process those results with other kinds of scripts. Python is the easiest here, but in case you have a MATLAB or a “bash script” expert in your team, that might also be a solution for you!
A quick word of conclusion:
In this article, we explained how to use the power of scripting to extract and process results quickly and automatically. Review scripts can do all of that for you and the syntax is quite simple. In fact, if you are searching for a specific script, we probably already have it ready for you in our support center and if you want to handle more complex stuff, you can totally use either MATLAB or Python scripts too…
We will write an article soon about how to do that in Python on the blog, so make sure that you are subscribed to our blog and you regularly come to check our new articles