Preprocessing

Preprocessing

Topics related to geometry, meshing, and CAD.

How Can I create a link between Ansys and Matlab?

    • LaraDlg
      Subscriber

      Hello,

      Starting in Ansys, I wanted to export the matrix of nodes of my deformed geometry (shell of an opened skull) into Matlab in order to compute the volume of a convex hull and then send the result back to Ansys to use the volume value as a parameter.

      Is there a way to achieve that?

      Or is it possible to compute the volume of a convex hull directly in APDL?

      Many thanks in advance for your help!

    • 1shan
      Ansys Employee
      Is the volume of hull same as volume of the deformed mesh, or is it something different that needs further processing? If its the same you may use the volume result https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v211/en/wb_sim/ds_volume_result.html to calculate and parameterize the volume of deformed body. I haven't used it but there is a way to link ANSYS and Matlab using AnsysAAS (check this /forum/discussion/633/download-matlab-toolbox-ansysaas). For your case you might want to define the expressions as parameters in excel - https://www.youtube.com/watch?v=_mMpBe5IEtM, and link it to your analysis which might be easier.
      Regards Ishan.
    • LaraDlg
      Subscriber

      Volume hull is supposed to be an approximation because I didn't find a way to compute it in Ansys (my deformed geometry is opened)
      Right now I'm exporting the mesh for each design point of my DoE into matlab, calculate the volume and then import the results in a .csv file back in the DoE in a new project in Ansys to analyse the response surface.
      I don't know if I'm clear enough but do you think it would work?
      Many thanks
      Lara
    • peteroznewman
      Subscriber
      In 's other discussion /forum/discussion/26920/how-to-parametrized-the-boundary-box-of-the-deformed-geometry#latest
      I described a method to measure the volume using Fluid elements. Do you think that would work?
    • LaraDlg
      Subscriber
      This is one of my models, I don't think I could fill that with fluid elements without considerably increasing the complexity and the computational time (already high). And how to define the boundary at the opening?
    • 1shan
      Ansys Employee
      Thanks for the suggestion. It looks like the geometry needs to be fully enclosed in order to use hydrostatic elements. However, I saw this example - https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v194/ans_str/strhydroexample.html, where negative volume elements have been used to model an open piston cylinder geometry. Not sure if this "trick" could be used for the above model. I'll have to check.
      I'm exporting the mesh for each design point of my DoE into matlab, calculate the volume and then import the results in a .csv file back in the DoE in a new project in Ansys to analyse the response surface" - this could work but it will be a manual process! You could automate it by using python scripts (which calculates the hull volume) in ANSYS(https://www.youtube.com/watch?v=oX5hDU0Qg-Q). The Customization Suite 2021 R1 contains all required information about this. Check this Example which shows how to use external solver to get the output for inputs from the workbench.
      Also, have you tried correlating the spring length with the volume change? It looks like the slot in the skull will be opening and closing about the corner (like a pivot). You can easily find out the cross section area (and its centroid) in a cad tool and then use the "Pappus Theorem for Volume of Revolution" to calculate volume it spans during deformation. You could parameterize the spring length, send it to excel calculate the volume and send this as an output parameter. This is obviously an approximation (so is the volume of hull) bit it will be easier to implement and automate for DOE study. You could compare it with the volume of hull obtained using MATLAB and check whether they are close or not.
      Regards Ishan
    • LaraDlg
      Subscriber

      Thank you for your reply! I'm going to look into the Python method.
      As for your second proposition, we thought about it too but unfortunately it would not work for the whole population as some models have a more complicated opening and also expand laterally.
      Many thanks for your help Lara
    • LaraDlg
      Subscriber

      I tried to open the links that you suggested but I can't log in, is there a way to find them from the customer e portal?
      Thank you Lara
    • peteroznewman
      Subscriber
    • LaraDlg
      Subscriber
      Thank you for the tips!
    • LaraDlg
      Subscriber

      I have been looking into the Python option you gave me (I'm a beginner).
      I understood that I have to create an ACT extension in order to calculate my volume in an object result (using Scipy it's a little bit more complicated than I thought)
      To compute the hull volume, I need to use a matrix containing the x-y-z coordinates of the deformed mesh (previously I just wrote 3 columns in a txt files and did the post processing in matlab)
      My question is : can I get such matrix as an output of APDL and then call it in my extension files?
      I tried using *DIM, *VCUM, *VFILL but I didn't manage to have my matrix (or vector) as an output in the first place
      Many thanks!
Viewing 10 reply threads
  • The topic ‘How Can I create a link between Ansys and Matlab?’ is closed to new replies.