Scripting for Postprocessing in ANSYS AEDT
Hello everyone, this is Mohsen Seraj from Ozen Engineering. Today, I want to discuss an example of scripting that I created by recording actions in ANSYS Electronic Desktop (AEDT). Essentially, this script simplifies the creation of cut planes, allowing for customization and automation in post-processing.
Model Overview
The model you are seeing includes the following components:
- Fans - Fan 1 and Fan 2
- Generic components like a heat sink
- PVC and bridge-like solids
- Boundary conditions for the grid and sidewalls
We have thermal boundary conditions for heat dissipation, defined in terms of the heat transfer coefficient. Additionally, we can check the thermal properties of the materials used.
Materials and Importing Files
We have a library of materials that can be exported or imported. An IDF file has been imported, showing components like copper traces on the PBC board. We can switch between the ECAD and MCAD models as needed.
Simulation Setup
Before running the simulation, let's review the setup:
- 500 iterations for the simulation
- Solving for temperature and flow, using Fluent turbulent models
- No heat radiation considered
- Convergence values set for rigid walls
- Initial boundary conditions and under-relaxation factors adjustable
- Discretization schemes can be first or second order
Ambient conditions are set at 20°C, with zero gauge pressure and gravity considered in the negative Z direction.
Running the Simulation
To start the simulation:
- Right-click to initiate the simulation for rigid walls.
- Monitor temperatures for DDRs, the bridge, and large flash memory.
- Check the mesh using the mesh viewer, with approximately 470,000 cells.
Mesh Quality
Mesh quality is assessed by:
- Face alignment with a minimum of 0.4
- Volume and skewness checks
Scripting for Postprocessing
To create a script for postprocessing:
- Save the solution and start recording the script.
- Create a draw plane for the fan and plot temperature contours.
- Export the cut plane as a JPEG file.
Use the Visual Basic Editor or another editor to view the Python script. The script includes modules for creating cut planes, plotting temperature, and saving images.
Automating the Script
Enhancements to the script include:
- Adding a loop to create multiple cut planes.
- Defining plane names and positions dynamically.
- Saving images with descriptive filenames.
Ensure correct indentation to avoid syntax errors. The modified script automates the creation of multiple cut planes and saves temperature plots as JPEG files.
Running the New Script
Execute the new script to generate multiple cut planes and save the resulting temperature plots. This process creates 24 files, demonstrating the script's capability to automate postprocessing tasks in ANSYS AEDT.
Conclusion
This tutorial demonstrated how to create and modify scripts in ANSYS AEDT for postprocessing. For more information, please contact us at Ozen Engineering.
Scripting for Postprocessing in ANSYS AEDT Hello everyone, this is Mohsen Seraj from Ozen Engineering.
Today, I want to talk about an example of scripting that I created by recording what I am going to do in ANSYS Electronic Desktop (AEDT), and basically, this script is for simplifying the cut planes, so a little bit of work on that after creating it to customize it to create additional cut planes for post-processing.
This is the model that you are seeing, and as you can see in the model, we have fans - fan 1 and fan 2 - generic components like we have a heat sink, also we have PVC imported here. We have some solids that are like a bridge, as you can see here.
We have some boundary conditions for the grid here that you can see if you want to see the properties.
For the sidewalls, we have thermal boundary conditions for heat dissipation that are in terms of the heat transfer coefficient, and we can also check the thermal properties, mostly thermal properties that we have.
So, we have a library of materials, or we can export or import the material information and read it here. Also, I imported an IDF file here. These are the components that you can see.
If I want to see what we have here for the PBC board, these are the copper traces that you can see here that we have. I can go back to the ECAD model that we have here, the MCAD model. So, this is about the model.
Here, I just want to show you that I have to quickly set up the model, run it, and then for post-processing, I'm going to create a cut plane and record it for scripting, and then use that script, customize it, and then reuse it for customization and automation.
For example, for the board, I have this, it is for the temperature, to monitor the temperature of the bridge, and also the temperature of the DDRs, and for large flash memory. These are all for the temperature.
I can, for example, for this phase, come and assign also flow monitors, for example, mass flow rate or volume flow rate going out or in this phase. So, I can now come and run it.
Before that, let's check the setup for the solution. 500 iterations, the maximum that I considered for running the simulation. I want to solve temperature and flow, not only thermal conditions.
Also, I am considering Fluent turbulent models, no heat radiation here, and for convergence, for the rigid walls, I consider this value for the fellow rigid wall, and for sure, a much smaller value for rigid walls for energy.
Solver setup, basically, these are like initial boundary conditions that we have here, and I can also, if I want to change the under-relaxation factor, I can do it here, and also for the discretization, if I want to change the scheme for the discretization, first or second order, or for the PISO or other PISO, these are similar coupling methods that we had from Fluent.
So, these are the setup that we have. Also, to check the ambient condition, you can come to the desktop and design setting. So, I am getting 20 degrees for the temperature in degree Celsius, zero gauge pressure, and this is the same 20 degrees for radiation temperature.
These are the ambient conditions, gravity, if I want to consider that in the Z direction, negative, and the other things if I want to pour content. So, let's come here and start the simulation. I can right-click here and go for the rigid walls.
You can see the steps that are taking for solving the model. The thermophilic solution has not been started yet. So, we are starting to see the rigid ones. Let's check the monitors. This is the monitor for DDRs.
The max temperature is up to about 60 to 64. This one is the monitor of temperature of the bridge, and the maximum temperature of that is a little bit below 50 degrees Celsius.
And the last one, this is the temperature monitoring temperature for large flash memory, and the maximum is like 36-37 degrees, so we're good here. Let's start going for the scripting. Before scripting, let's check the mesh a little bit.
We can go for the mesh viewer here, in the simulation tab, in this section, mesh viewer. We have about less than half a million cells, 470,000 cells, almost.
If I want to show the cut plane, this is in the X direction, that if I check the mesh, you can see that the way that we mesh it, these are all by default settings that we have.
And I can go for different, this is I guess X cut plane, I can move it around to see what's going on, or here at the DDRs, you can see the mesh. Also, if I change the cut plane, for example, say that in Z direction, you can see the mesh also. Check the mesh here.
If you want to do some changes or not, we just use the default setup for the mesh. If you want to check specific body mesh, say that for example this one, you can see the mesh for DDRs, you can see it here, one of the DDRs, or if I check this fan on the heat sink, you can see the mesh also here.
So, this is for the body, if I want to go for a specific geometry part of the component of the geometry or that. And this is for the walls that you can see back to cut plane that I already showed you. Let's check the quality.
The quality for face alignment, you can see that the minimum is 0. 4. If I check the volume and skewness, I can check it, for example, the minimum is like something for this part. If I click here, you can see where I have that low skewness for the mesh around the fans that we have.
Or for the face alignment, come here, for example, in this range, you can see that again where I have elements with this range for the face alignment. So, you can see the elements in the mesh, you can check the quality of the mesh by face alignment, volume, or skewness.
And for the mesh display, you can see that here. Let's go for scripting. Save the solution, and then in the automation, we can start recording the script. From now on, whatever I will do, it will be created as a plot based on that.
I can say record script to the file and give it a name, like I say that plot cut plane for example. Save it. And now we start working on the post-processing. Let's first create a plane. Go to the Draw menu and create a draw plane for the fan, click in the center, and then in this direction.
So, we now create a plane, you can see it here, this is the plane that I created. Click on the plane, you can come here to the field overlays and say that, and then I can give it a name or use the same name that I have, and done.
Yeah, this is the contour for the temperature on this plane as you can see, and the maximum is 26.76 degrees, and this is here. So, basically, I created like a draw plane or cut plane and plot the contours of the temperature on this one. Then I can export this quad-plane and save it.
I can say that export it could be JPEG. I can say that, for example, quad-plane temperature, and save it. So, back to the automation, and say that stop recording. Let's look at the script. I use the Visual Basic Editor. If you have another editor, you can use it to see the Python script.
As you can see, at the beginning, it is populated with initializing the project, selecting the current project, and the AEDT design that we have. And after that, we have one block, one editor for creating the code plane that we have.
And these are the various parameters to design the code plane that we have. This is the first cut plane that I have here, and this is the name that I use for it. So, the next module is the one that I create the temperature plot here.
You see that the information populated here for the temperature plot. And I use plane 1 cut plane here, okay, that I have it, I already designed the cut plane here. And the last block or last module, it is for saving the code plane as a JPEG file that I have in the desired location that I want it.
This is the address bar for it, okay, and JPEG format, and resolution for that.
So, these are the main modules that were created by AEDT itself, just by recording the workflow that I had done in AEDT when preparing the quad plane and using that quad plane to create a plot for the temperature across that and saving it as an image file with JPEG format.
Now, I want to just do some changes to that for kind of automating post-processing. This is the new code. So, I added this part, it is basically a loop for creating multiple code planes, multiple codes.
I consider a range from minus 25 mm up to a position of 175 mm in each direction with the increment of 50 mm.
I use a norm parameter variable for looping and then define the code planes with the word plane with the extension in with this one, which shows that what is the plane, the code plane number one, number two, whatever, and then have the temperature into and enter the name of the software.
And with the string, it is for adding the number, and for post name for the image file, and also plane exposition, it shows that at what position this code plane is. And the other one is by an Ozen Engineering ANSYS expert.
So, one thing that you need to be careful about is to not get a syntax error, which is the indentation. You see that indentation is based on this in the original code. This is the indentation that we have in the modified one.
Be careful about this indentation, that all these modules for cut plane, for creating the field plot, and also for exporting and saving, these ones should be inside this loop. I used the plane exposition this line as a name for that to set the exposition here.
Previously, I had it with a constant number, 19 mm, now I have it with the position of the cut plane.
This is one change that I need to do here, another one is for the name, okay, in this line that I use plane one name here, this plane one name here, originally, now in the new code, I use plain name, that plain name defined here on top. You can see that.
These are the changes in the first module for creating cut planes.
Then, in the next module for creating the field plot for temperature, you know that here I use temperature1 name here in the original script, which is here, given here, when I created the plot for the temperature, temperature1, you can see that here, name temperature 1. Now, I'm using post name, and you see the post name is given here.
So, it could be temperature 1, temperature 2, temperature 3, you will see that we will have more on this list here when we run this new code. This is one change in the second module.
In this module, another change here is that I'm using the name for the plain code, originally it is plain1 that I created, now I'm going to use again plain name here that it is plain1, plain2, plain3, plain4 with use of this string here.
The results are the same in this module, and in the last module for saving as a JPEG image the contour that I created, I used the same address, the same location, the working directory that I have, so I use it here as you can see. I add these three lines here in the last module.
Before the last module, I added these three lines. First one is the path root, I define the path root here, and then I use this path root.
Now, before that, for the file name, to give it a name for the images, images, JPEG files, I use the name temp-cot-x plus a string that it is, you remember that plane x position is here, okay, that gives me the position in the x direction in millimeters.
This is for the file name, and JPEG format, and then in the file path, I use the path root plus file name.
And then in the arguments here, in the original file, I have the argument here that it is the address bar, it is where I will, the working directory is, you remember that JPEG format and the resolution, okay, in my code that I just created by help of the ANSYS resources that we have.
If you have this new file path, you can change the resolution of the new file path. And the rest is the same as before. So, these are the changes that I made to the original code.
I created under a different name in the same working directory, and then I'm going to use this new code for automating, creating, creating multiple code planes, and then create a plot, temperature plot, on each of these code planes, and save these as these images of the image file as a JPEG file.
Let's go and run this new code. This is the model in the automation part. Go for run script. I created this script, and see. So, you can see that the new code balance created one by one. And we're going to have the contours on that. And we can see that we have 24 files.
And these are the files we have. So, we, first of all, with this new script, we could create multiple cut planes. This is the first thing, and second, we could save these contours in the JPEG files here.
So, in this video, I wanted to show you that how to create a script in ANSYS AEDT here in the automation section. If you come to the deduces tab, click here to record script. So, whatever you do after that, it will be translated into the Python script.
I first created a draw plane and used it as a cut plane, this plane here, and plot the temperature across that plane, and then save it. You remember that I just came to the modeler and export that, save it in the JPEG file format. So, this script showed you that you have to do this.
Here, this is the original one that I created, and then I worked on this original code and converted that to the code that I can have, basically, multiple plain code created, and then on each of that, we can have the plot for the temperature, and then save it in the working directory we're working on, the folder that we have it here, we have it, we have the model there.
So, hopefully, you can learn a little bit about how to start scripting in ANSYS AEDT. Please contact us at https://ozeninc.com/contact for more information.