pythonfluentansys

Parametrizing Ansys Fluent with python in linux


I'm trying to do a parametric study in Ansys fluent through python. The idea is to calculate some parameters before feeding them to fluent as boundary conditions and initial conditions.

I have searched wide and far but could not come into any pertinent information... maybe i'm not looking with the good keywords.

Or is there an equivalent of ANSYS Parametric Design Language (APDL) for fluent ? I can only find information for mechanical.

Do anyone could guide me in the good direction or somewhere to go look for more information.

P.S. I could not find any information in CFD-online, ansys site or here in stack overflow.


Solution

  • So after some long search around the global internet I found how to do it. There are two main forms of doing it :

    Ansys Workbench


    Directly with scripting, I did not used this method hence this is what I understood without trying or testing it. You can run the workbench in batch mode with the following bash command :

    runwb2 -B -R "path/script.py"
    

    Where -B stands for batch mode and -R excecutes the specified script.

    An example and explanations can be found here : Scripted CFD simulations and postprocessing in Fluent and ParaVIEW

    Ansys Fluent


    TL;DR : Use Journals and python to modify journals, then run fluent through python.

    First the simulation must be prepared with fluent GUI. You need to fix all non variable parameters as well defining monitors. You save all that information into a case file.

    Once done that you must create a template with the commands to initialize the calculations. The easiest way is to search in the net and try everything in the TUI at fluent. Once everything has been validated, you create a template (The easiest way is to use jinja2)

    Finally, a simple loop over the parameters to test with the following bash command with python can do magic:

    # Running fluent
    bashCommand = "fluent 3ddp -i "+ journal_output + " >& outputfile &"
    process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
    output, error = process.communicate()
    

    It works really well and once you get use to Fluent commands it is quite easy !