Python Result - Pressure Plot

Jaaroon
Jaaroon Member Posts: 7
Name Dropper First Comment
**
edited October 2023 in Structures

Is there a way to use a python result object to create a contour plot of all applied pressures in Ansys Mechanical?
It seems like the result file does not contain pressure information.
How can I access the applied pressure to generate a plot showing the pressure in each time step?

Answers

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

    I don't think this is stored in the results file. You could parse the model and if the pressures were from Mechanical you can look at the values in the loads themselves and create a plot. Would you need element-by-element for something like an imported pressure with spatial variation, or just a simple pressure?

    If you want to go by the results file, you could also look at the nodal forces and determine loads. If pressure is the only external load on that element, then you can isolate it.

  • Jaaroon
    Jaaroon Member Posts: 7
    Name Dropper First Comment
    **

    I am using a script in Mechanical to apply a spatial varying pressure load to my model, where a distinct pressure is applied to each element surface. Now I would like to visualize the applied pressure loads as a contour plot. If you have an idea of how to access the applied load values to create a contour plot that would be very helpful.

  • Mike Rife
    Mike Rife Member, Employee Posts: 50
    10 Comments First Answer 5 Likes First Anniversary
    ✭✭✭✭

    Hi Jaaroon & Michael
    Pressures are stored in the MAPDL result file. But it is not easy to get to them. They are stored in SMISC items of the element type.

    1 If you use the option to apply pressure to a surface effect element the SMISC items are very straight-forward. But Mech DPF does not yet support surface effect elements. Nor does PyDPF. So maybe you can request as an enhancement. See the MAPDL Element help on Surf154.

    2 The typical solid elements have a different SMISC ID number (for pressure) for each node on each face. This requires some pretty fancy programming to extract out the data...well fancy to me. See the MAPDL element help for whichever element type the model uses.

    3 Perhaps an better option would be to create a DPF Field at the same time in your existing script. Then map the field onto the Mechanical mesh and plot.

    Mike

  • Jaaroon
    Jaaroon Member Posts: 7
    Name Dropper First Comment
    **

    Thanks for the insight.

    I am indeed using surface elements. But accessing the elemental pressure values from the result seems to not be an option at this stage if I understand you correctly.

    Would there be any way to access the pressure values from the analysis definition rather than the result file?
    Otherwise, the option to create a DPF field manually based on the import data might be an option worth exploring.

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

    @Mike Rife are the values stored any differently if they are applied via APD table vs a simple number?

  • Mike Rife
    Mike Rife Member, Employee Posts: 50
    10 Comments First Answer 5 Likes First Anniversary
    ✭✭✭✭

    @Mike.Thompson said:
    @Mike Rife are the values stored any differently if they are applied via APD table vs a simple number?

    @Mike.Thompson no as they are result values.

  • Jaaroon
    Jaaroon Member Posts: 7
    Name Dropper First Comment
    **

    Just to keep you updated. I was successful generating a pressure plot reading the pressure data from the external file.

    But I would still really appreciate a solution to extract the applied pressure loads directly from the analysis or result object, to get a pressure plot that is not dependent on the external file.

  • Mike Rife
    Mike Rife Member, Employee Posts: 50
    10 Comments First Answer 5 Likes First Anniversary
    ✭✭✭✭

    Jaroon
    Does the plot have to be done via a Mech DPF script? Why not just a WB Mechanical commands object? If that is a linear shell model with the pressure applied to the top face (and not with a surface effect elements), then the following Solution CO will give the result pressure plot:

    set,last

    etable,smisc22,smisc,22
    etable,smisc23,smisc,23
    etable,smisc24,smisc,24
    etable,smisc25,smisc,25

    sadd,sij,smisc22,smisc23,.25,.25,0
    sadd,skl,smisc24,smisc25,.25,.25,0
    sadd,shellpress,sij,skl,1,1,0

    /show,png
    pletab,shellpress,noav
    /show

    Mike

  • Jaaroon
    Jaaroon Member Posts: 7
    Name Dropper First Comment
    **

    @Mike Rife

    Using the MechDPF is just a preference, and I would also like to be able to visualize the pressure over multiple timesteps at best.

    But thanks for that example. I was not aware of this option. Generally, I use the surface effect elements when I assign pressure loads, but I am not sure that it really makes a difference when the pressure is defined for each element anyways.