Exposing MotionView’s Python Application Programming Interface (API) was one of the highlights of Altair HyperWorks 2021. Using the MotionView Python API, users have been given the ability to programmatically interact with both MotionView entities and MotionView procedures. Users can now use the Python API to create, modify, extend and delete MotionView entities or to introduce automations and new workflows using the Python language. But they can also take advantage of the huge number of Python libraries in data management, modeling and visualization. And in Artificial Intelligence (AI) as well.
Let’s start building our case with a real-life scenario: You start your car and you realize that it does not sound as it is supposed to. The sound is not entirely unfamiliar, so you try to identify what is possibly going wrong. Is it a bad CV joint, a thrown rod, a grinding or bad transmission, a seized or even a flooded engine? And what maybe causing this problem? Is it a part failure, some sort of shaft misalignment, oil starvation, flooding or some other defect? In the world of Machine Learning (ML) this is nothing more than a classification problem. And an algorithm can solve it for you, if trained properly, as soon as you have (i) a well posed model, (ii) the algorithm itself and (iii) a good set of data.
MotionView will help you to build your model. Assume the simplest case, that of a gearbox that may work flawlessly (class 0) or may have a defect due to some gear misalignment (class 1), lubrication (class 2) or even both (class 3). A user can easily build a gearbox in MotionView in simple steps, using two gear CAD geometries, one of which might be slightly misaligned related to the other by a given angle (φ). The two bodies are assumed in contact between them, which is characterized by the friction coefficient (μ). An input torque (T) is given on the driving gear. The two gears can only rotate about their main axes, and the force (F) measured on the joint of the driven gear is recorded. A simple schematic representation can be shown below:

The problem can now be stated as: Given (T, F), estimate (μ, φ); or alternatively associate the (input, output) with the fault class {0, 1, 2, 3}. This problem can be easily solved using a logistic regression algorithm, assuming that there exists a proper set of data. But where can we find the data?
Aut inveniam viam aut faciam (I shall either find a way or make one) said Hannibal before crossing the Alps with his elephants. Since we do not have real data, we can use MotionView/MotionSolve to generate simulation data and use these instead. Using the new MotionView Python API one can generate multiple variations of the same gearbox, solve it using MotionSolve and then use the simulation results to train an algorithm and make predictions.
So, this is how we can train MotionView using its Python API and a set of Python libraries to detect faults:
- An input space for φ, μ and T is generated using Latin−Hypercube sampling from the pyDOE package. Then:
- Given (φi, μi), the faults are classified and each of the models (examples) is assigned one of the four classes defined above (targets).
- Given (Ti, φi, μi) a MotionSolve deck is created and solved (here 300 decks).
- The generated joint forces Fi from the simulation are read back to MotionView.
- A fast Fourier transform (FFT) is performed inside MotionView and the peak frequency (fpi) and the peak amplitude (api) are stored (features).
- MotionView processes the data: using pandas, the sets can be plotted, the distributions can be visualized and the outliers can be identified.
- Training can now start. The dataset is split into a training and a validation set. A logistic regression algorithm is used for the fitting and the prediction.
The end result looks like this:

Is this enough? No, this is just the first step. The user can take it from here and improve it. He can introduce more examples, he can refine the input/output, he can add more fault classes.
Does it worth it? To answer the original question, yes it’s worth to learn. And now, with the MotionView Python API one has all the tools at his disposal and one way to go. #onlyforward
Acknowledgments: This work was done together with Gaurav Bokil, Advanced Trainee, MotionView.