Ansys Mechanical "Post-Commands(APDL)"-like Object with ACT

Options
av
av Member Posts: 7
First Comment
edited June 11 in Structures

Hallo everyone,

I want to generate a "Post-Commands(APDL)"-like Object with ACT in Ansys Mechanical.
My goal: I want to call a Post-Macro written in APDL (using the stream.Write() function), which operates on the result file and generates a text-File as a result. I would pass the macro arguments based on the properties of the object defined by the user. I want to work this both when I solve the analysis (write to ds.dat) and when I evaluate while postprocessing (write to post.dat).

I've made several trials with the function/callback "getcommands", but it seams it only works if I've inserted the object prior to solving the analysis. If I have already generated the results, and then I add the post-object, I can't solve the object.

If I use the "ongenerate" callback function, the ADPL commands are written both into the ds.dat and in the post.dat, causing solving my APDL code twice. (but then ignoring the content of other "normal" Commands(APDL) objects...)

Is there a possibility to create a post-commands-like object otherwise? With which callbacks is it posible? Your help is greatly appreciated!

Thanks,
av

Best Answer

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 316
    First Answer First Anniversary First Comment 5 Likes
    Answer ✓
    Options

    I don't think there is a direct way to do it, but you could do it with brute force pythonic scripting. By this I mean you can use python to call a batch run of MAPDL after creating the proper input commands. This is effectively what the APDL command snippet post object is doing. It creates a post-only .dat file and plugs in your user-defined APDL into the middle of the input after doing some basic operations like setting /POST1 for example.

    You have solved the model, so you at least have the results file, and possibly the .db file (you can toggle this option before solve, but often you don't need this file). You should be able to have an ACT object that you can trigger with an apply/cancel property or an callback. Once you trigger the python method, it should take in some object properties, Analysis context, and create a self-sufficient APDL input file. After creating the file, you use python to call APDL in batch mode and run the dynamically-created input file. APDL commands will then do whatever it is your commands do, and close. This will complete the python callback and return the user to the mechanical UI ready for next action.

Answers

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 183
    First Answer First Comment First Anniversary Ansys Employee
    admin
    Options

    This is for sure a job for the superheroes of the @AKD-Scripting-Team !

  • av
    av Member Posts: 7
    First Comment
    Options

    Could a superhero of the AKD-Scripting-Team give me a hint how to solve the problem?

    (I have figured it out that I need the "getpostcommands" callback, and that the object works better with the "Solve clicked in Mechanical" than with the "Executing post commands clicked in Mechanical". However, to program gets into a loop if I try to call the "Solve" function inside the "ongenerate-callback" function. I have also tried to add a read-only property to the object with a "switch behaviour" in order not to get into the loop, but unfortunatelly Workbench crashed while executing the code.)

    Thank you!

  • av
    av Member Posts: 7
    First Comment
    Options

    Dear Mike,
    Thank you for your suggestion and for the detailed discription of the possible solution. I will try to implement that in my code and give you a respons whether I succeded.