Training a neural network with PSIM data using romAI

Vasileios_Vlastos
Vasileios_Vlastos
Altair Employee
edited April 4 in Altair HyperWorks

In this article, we will explore a step-by-step methodology for training a neural network using RomAI.

image.png

Step 1: Data Generation

To train a neural network, it is essential to generate or acquire appropriate training data. One effective method for creating training data is utilizing Hyperstudy, particularly when generating data from other software such as PSIM, Simlab, Feko, etc. If you are unfamiliar with Hyperstudy, you may refer to this article to understand its advantages over manual data creation through scripting.

Once the data is generated, it is stored in various folders and divided into multiple CSV files. To consolidate these files, use the provided 'Find_n_Copy.oml' script to copy all CSV files into a single directory. Subsequently, execute the 'romAI_data_append.oml' script to merge all the files.

Screenshot 2025-04-02 180911.png

When generating training data, it is crucial to avoid including unnecessary variables and data, as this can complicate the processing and significantly slow down the system.

Step 2: Pre-processing

To train a neural network using the RomAI tool, begin by opening the Twin Activate Software. Navigate to the "Tools" tab, where you will find the RomAI Director.

Screenshot 2025-04-02 173508.png

A separate window will appear, and within the "Pre-Processor" tab, you can import your training data.

Screenshot 2025-04-02 174353.png

Load the data into the Pre-Processor tab. If you intend to train a dynamic system, ensure that the data is appropriately filtered. You can apply a filter from inside the romAI Director.

Screenshot 2025-04-01 111556.png

As illustrated, the filtered waveform (green) is smoother than the original waveform. In this example, the cut-off frequency is set at 5kHz, though this value may vary depending on your specific system. It is advisable to experiment with different values to observe the results at the conclusion of the training process. Once you have selected all the relevant and filtered data, click on the "Export to Builder" button.

Step 3: Neural Network Setup

In the Builder tab, you can configure the hidden layers, the number of neurons per hidden layer, the number of epochs, and the test split ratio. If you are uncertain about the optimal settings, RomAI offers an auto-exploration feature. This feature trains multiple neural networks with varying numbers of hidden layers and neurons per hidden layer to help you determine the best configuration.

If you have not experienced with neural networks before, you can attend a course here.

Screenshot 2025-04-03 082851.png

Furthermore, at the Advanced Settings tab, there is a variable named Regularization Coefficient and it refers to the regularization term on the objective function. This helps avoid overfitting and might improve generalization. Due to the nature of Power Electronics systems, it is recommended to set this variable equal to 1e-6

Screenshot 2025-04-01 113512.png

Before initiating the training process, it is advisable to assign a meaningful name to the neural network that reflects the chosen parameters. For instance, you might name a neural network "Iq_prediction_epochs_100_TSR_0_2." This naming convention allows you to easily recall that the network was trained with 100 epochs and a test split ratio of 0.2. You do not need to worry about specifying the number of hidden layers and neurons, as RomAI automatically appends this information to the defined name, resulting in a name like "Iq_prediction_100_epochs_TSR_0_2_relu_30_30."

Screenshot 2025-04-01 113636.png

Step 4: Post-Processing

In post-processing, it is important to evaluate what makes one neural network superior to another. Two key metrics that indicate the reliability of a predictive model and its ability to forecast a waveform similar to the actual data are:

  • Average Root Mean Square Error (Avg RMSE)
  • Test Loss

Both metrics should be minimized as much as possible. It is important to note that these values should not be compared across different systems. Comparisons should only be made within the same system but with varying parameters.

Screenshot 2025-04-01 110143.png

Regardless of the values of these variables, it is essential to verify the predicted waveform against the actual waveform. This can be done by selecting the "Time Simulation" radio button.

Screenshot 2025-04-01 120636.png

Step 5: Twin Activate Deployment

A unique feature of romAI is that it can be deployed in a 1D simulation environment. After completing the training, we can insert a romAI block in Twin Activate model from the Palette Browser

Screenshot 2025-04-02 175023.png

Drag and drop the block into the model. By clicking on the block, you will need to load the folder containing the neural network you have just trained.

Screenshot 2025-04-02 175227.png

Once you click OK, all the inputs and outputs will appear. You can then connect them with signals and scopes, as well as integrate them with other models (e.g., PSIM, Simlab).

Screenshot 2025-04-02 175525.png

For more tips & tricks you can read some relative articles at the links below:
romAI Tips & Tricks for Beginners
Accelerating Battery Charging Simulations with Altair romAI - Part 1
Accelerating Battery Charging Simulations with Altair romAI - Part 1

Comments

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.