Sharing Topology in Ansys Discovery Using Scripting
Hello everyone, this is Mohsen from Ozen Engineering. Today, I want to discuss scripting in Ansys Discovery and demonstrate how to prepare a script by recording our actions in the software.
Model Overview
This model contains many bodies. Specifically, there are 64 components, each containing 32 bodies, totaling approximately 2000 bodies. We also have thousands of faces and edges to be shared.
Getting Started with Scripting
- Ensure the script tools tab is activated. If not, start the scripting editor.
- By default, recording is on. You can save and later debug or run the prepared script.
Performing Operations
Let's perform some operations:
- Share topology and confirm the action.
- After sharing topology manually, the corresponding script appears in the editor.
Script Details
- Each operation has a block: one for sharing and another for unsharing.
- Tolerances for shared topology are in millimeters, rounded to 0.
- Save the script in the same folder as the model for future use.
Running the Script
To run the script:
- First, unshare, then share the topology.
- The console will display the operation's progress.
Measuring Time
To measure the time spent on sharing topology:
- Add a block for unsharing and another for sharing.
- Import time, calculate elapsed time, and print it to the console.
Performance Results
For unsharing and sharing all faces and edges, the recorded time was 41 seconds. This represents a 20% decrease compared to 48 seconds when performed manually.
Using the Script on Other Models
The same script can be applied to other models. For example, with a model containing over 7000 bodies, expect thousands of faces and tens of thousands of edges to be shared.
Adjusting Tolerances
Before running the script on a new model, adjust the tolerance for sharing topology. Ensure it is set to 0.11 for consistency.
Conclusion
Thanks to Ansys Discovery's capabilities, we can record operations and create scripts for automation. Be mindful of tolerances when automating shared topology.
For more information, please contact us at Ozen Engineering.
Hello everyone, this is Mohsen from Ozen Engineering. Today, I want to talk a little bit about scripting in Ansys Discovery and show you how to prepare a script by recording what we are doing in Ansys Discovery. This model actually has many bodies.
If you can see here, I have 64 components, and in each component, I have 32. So, 64 times 32 bodies are here, which is about 2000 bodies. We have thousands of faces and edges to be shared here that you can see.
Either you have the script tools here, the tab here is activated; if not, you can come here and start the scripting editor here. So, as you can see, by default, recording is on, and we can save it here and then we can debug or run the script later that is prepared. Let's do some operations here.
For example, for this one, let's just say that we will share topology and say yes. So, after finishing sharing the topology that I just did manually, you should see some scripting appear here in the editor. You can see that what I shared manually is scripted here.
Let's go on sharing, but before that, we have to be sure that it is on for the recording, then translating that to this operation has been done for sharing. Let's start.
You can see that this quickly populated here, this operation, so for each operation, we have a block; this is for sharing, and this is for unsharing.
The good thing is that we have the tolerances in millimeters for the share for the share topology, basically the same amount that you have here, 0. So, this is 0 rounded up.
I can save it or save as; it will be on the same block that we have; save the model in the same folder, and later I can read it. You can see that it is a new script, the same as before, that we have it. Now, if I want to run this again, you can see that I can see whatever I have before.
So, let's do first unsharing for this one and then sharing. So now I want to run this one; this is for the run. Okay, let's do it here. So, first on sharing, it says that here the first block, and now the second block for this script.
Okay, it is done, and as you can see, we have the operation done here in this console. So, if I go and want to do a little bit more scripting here, this is basically the one that we had here before for sharing on sharing.
Okay, I can add this block to this before sharing; I have one block for unsharing and another block for sharing. I just wanted to measure the time that is spent for sharing the topology. I just added imported time, calculated the elapsed time, and here I just printed the time.
So, as you can see, every time I open a new script, I will have a new console for that. Let's go for unsharing and then sharing and then measure the time for that. This is for the run. If you are creating the script yourself, you can debug it first and then run it.
Okay, so when I come here to this pod, and it says that it is for the rod. Let's start unsharing and unsharing and see how much time it takes to finish sharing topology for that. Thank you for watching.
As you can see, 41 seconds that I have here, it is printed into the console, and this is the time that was recorded here, 41 seconds for unsharing and sharing all these faces and edges together.
So, again, the main part of this scripting is only this part, which is for sharing topology or if you want to add on sharing topology.
The rest is just for calculating the time spent, and this one is for printing into the console, and this one is for printing into the file that you need to give the address for that. This is the format for the printing. I performed shared topology manually and measured the time.
So, almost, if I can say that, 40 seconds compared to 48 seconds, it is like about a 20% decrease. So, scripting can also accelerate sharing topology for this model for the same rendering quality. I already saved this script; I can use it for any other model that I have.
This is another example; let's use the same script. As you can see here, it is the same script; calculate on this part, this whole time.
Ansys software has many bodies, as you can see, more than 7000 bodies, so we expect to see thousands of faces and maybe tens of thousands of edges to be shared between these more than 7000 bodies. Let's start the script, but before that, we need to adjust the tolerance for sharing topology.
So, come here; you can see that it is 0, so I have to adjust that to 0. If I create this or scale it for the unsharing and sharing, I would see the same amount here, this 0. 11. So, be careful that you need to adjust the tolerances every time you are using this script for a new model.
So, we can start now. Thanks for the help of Ansys in writing this script and also the capability that is included in Ansys Discovery, that we can record our operation and, by doing so, create a script for that.
Here, for splitting edges, because we have tens of thousands of edges, so we expect to see a longer time for performing sharing topology, and also thousands of faces to be shared. I will be back when the running is done for this script. Still ongoing. So, almost done.
You see that the time is printed here; we can see that it is also printed into the file. You can see that it is also the time that took to perform unsharing and sharing topology here for this model. So, again, the main blocks are these; only this one if you want to automate the shared topology.
And what we need here is to be careful about the tolerances here. So, in this video, I just showed you how to create a script for automating the operation that you want in Ansys Discovery for sharing on sharing and a little bit add more lines for calculating the time.
So, hopefully, it can help you for starting a script in Ansys Discovery. Thank you for watching this video. Please contact us at https://ozeninc.com/contact for more information.