How to process topology optimizations on different geometries automatically?

rabe Member Posts: 5
Name Dropper First Comment

Hey everyone,

my goal is to perform a topology optimization (TO) on 50+ geometries in ANSYS. For a single simulation my current plan is pretty straightforward: I open a new Workbench file, create a static-structural module, connect a topology optimization module to it and basically do all the neccessary steps in ANSYS Mechanical (import geometry, meshing, boundary conditions, TO parameters, solving, post-processing and so on).

Since I also use Python in the background to do some other stuff the idea was to automate this process for multiple geometries using the PyANSYS (in the form of PyMechanical to be specific) interface. For some general code ideas I was able to use the 'script recording' functionality within Mechanical. But one major issue is the setup of the two modules involved here ('static-structural' and 'TO'):
How exactly do I create them using PyMechanical and how exactly do I establish the 'connection' between these two modules (displayed by the lines in Workbench) using the Python interface?

So far the progress stops at the creation of the modules:

import ansys.mechanical.core as mech
app = mech.App(version=231)
statAnalysis = Model.AddStaticStructuralAnalysis()
topOptAnalysis = Model.AddTopologyOptimizationAnalysis()

How to go ahead from here? Or is there another way to achieve the setup mentioned at the top? Ideally I am looking for a MWE.

Thanks for your time!


  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 158
    100 Comments 25 Likes 5 Answers First Anniversary

    I think the implementation really depends on how you are connecting the two analyses. I assume the output of one analysis is the input to the other. Depending on what exactly this is, you may need to rely on a Workbench connection, in which case you can also run WB/Mechanical in batch from python. You also may be able to make the connection in PyMechanical by setting a property of the analysis, but again it depends on what you mean by the connection.
    Lastly, you can also solve the first analysis and then use PyDPF, to transfer data to the next analysis, to mimic what is done in WB without the need to actually use workbench.

    In short... what is the connection you are trying to make between the analyses?

  • rabe
    rabe Member Posts: 5
    Name Dropper First Comment
    edited October 6

    Thanks for your comment @Mike.Thompson.
    You are right that I should clarify the connection term of my inital post. I am referring to the connections between the analysis systems within the Workbench project schematic, so for example that two systems share engineering data, geometry, model and that the solution of the static analysis is transferred to the setup of the topology optimization (see screenshot).