Empirical convective heat transfer implementation in Ansys Mechanical

PierreLCV
PierreLCV Member Posts: 24
First Comment Name Dropper

Dear All,
I currently have a Matlab code (also written in Python) which with some hydraulic inputs values (Water Temp, Water Velocity, Pressure) gives me convection heat transfer coefficient in a table depending on the wall surface temperature. With this table i am able to calculate the temperature field in Ansys Mechanical Thermal Analysis with copy/paste this last table in tabular convection boundary condition.
However, this copy/paste step is not very optimal and not compatible with the necessity sometime to use many convective coefficient values...
That is why, i would like to be able to inject directly my Matlab (Python) code in Ansys Mechanical to have a direct link between these two elements and avoid the copy/paste step.
I thought about using pyMechanical but I never used this last package and i do not know how to start or if pyMechanical is able to do it...
Any ideal is welcome, thank you for your help !

Best regards,
Pierre

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary

    Hi Pierre. There are several options for achieving your goal. PyMechanical is most appropriate if you want to call Mechanical from your Matlab code or from a new tool that you plan to create. But it sounds like you instead want to call your Matlab code from within Mechanical. In that case, I suggest you start by using the flow chart here:
    https://discuss.ansys.com/discussion/2833/how-to-choose-between-various-technologies-for-running-scripts-in-mechanical
    You may also want to discuss with your Ansys service provider.

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 241
    First Anniversary First Comment 5 Likes Ansys Employee

    If you are using the Mechanical interface (UI) you have two main options:

    1:
    Call matlab in batch to generate an output file and then read that output file via mechanical scripting

    2:
    Remove MatLab from the process by converting the necessary actions to something compatible with IronPython or CPython. If you rely on any built in MatLab functions these will need to be addressed.

  • PierreLCV
    PierreLCV Member Posts: 24
    First Comment Name Dropper

    Dear Landon & Mike,
    Thank you very much for your reply which made me think more precisely about my need. Indeed, I figure out that call the Matlab (Python) code from Ansys or the inverse is a crucial point. For my case, it appears that i will have to try different h convective coefficient (playing on different parameters) values and depending on the temperature obtained at different measurement point in my mesh after FEA solved process, continue to modify or not the h coefficient. That's why I think (but i would appreciate a lot your point of view) that the best way would be to call Mechanical from my h generation code, what do you think ?

    Thank you !

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary

    This sounds like a good use case for PyMechanical . You may also be interested in using PySystemCoupling

  • PierreLCV
    PierreLCV Member Posts: 24
    First Comment Name Dropper

    Dear Landon,
    Thank you for your quick reply. Indeed, I think that call Mechanical from my h generation code is the most relevant idea, so let's go for pyMechanical.
    So for now, i have a Python code which give me tabular value for different wall temperature and a Mechanical simulation using the classic Workbench/Ansys Thermal Analysis graphical interface.
    Question : how to start ? I have read the pyMechanical documentation (https://mechanical.docs.pyansys.com/version/stable/index.html) and the cheat sheet but it's pretty succinct and I haven't seen any cases dealing with the thermal analysis part...
    Could you please give me some guidelines to start to code my case ? Maybe an example using Ansys Thermal Analysis ?

    Thank you !!

    Pierre

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary

    I think this is pretty much exactly what you are trying to do: https://discuss.ansys.com/discussion/comment/2933#Comment_2933

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary

    If you have access the Ansys Learning Hub (ALH), I would also suggest that you complete the Mechanical Scripting course

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 241
    First Anniversary First Comment 5 Likes Ansys Employee

    If the only thing you are modifying about the model is the heat transfer coefficient, tabular values, PyMAPDL is also a good option.
    You can use the familiar mechanical interface to set up the model, then save this model for solve as a database.db file. Use your heat, transfer coefficient code to generate the text for the APDL table to a separate file and use the /input command to read this input.

  • PierreLCV
    PierreLCV Member Posts: 24
    First Comment Name Dropper

    Dear Landon & Mike,
    Thank you VERY MUCH for your reply.
    Thank you Landon specifically for the case which is very close to what i am looking for, very nice point to start.
    Your solution Mike seems also very interesting so I do not know which one choose...
    I have access to ALH so i think that maybe the best way is to start by the Mechanical Scripting Course as it will be useful for both ?

    Thank you !
    Pierre