CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Coupling Python and CFX

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By ghorrocks
  • 2 Post By ghorrocks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2025, 10:44
Default Coupling Python and CFX
  #1
Member
 
Join Date: Dec 2023
Posts: 51
Rep Power: 4
smhk is on a distinguished road
Hi,
I have a case that requires coupling my Python code with CFX so that I can send input variables (from Python) to Ansys CFX and then extract outputs (simulation results) to my Python code for further calculations.
What are the tools for this, and where can I start?
Thank you.
smhk is offline   Reply With Quote

Old   July 17, 2025, 12:35
Default
  #2
Senior Member
 
Join Date: Jun 2009
Posts: 1,945
Rep Power: 34
Opaque will become famous soon enough
Quote:
Originally Posted by smhk View Post
Hi,
I have a case that requires coupling my Python code with CFX so that I can send input variables (from Python) to Ansys CFX and then extract outputs (simulation results) to my Python code for further calculations.
What are the tools for this, and where can I start?
Thank you.
What is your real goal? What are you trying to model?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   July 17, 2025, 16:20
Default
  #3
Member
 
Join Date: Dec 2023
Posts: 51
Rep Power: 4
smhk is on a distinguished road
Quote:
Originally Posted by Opaque View Post
What is your real goal? What are you trying to model?
Uncertainty quantification on a diffuser
smhk is offline   Reply With Quote

Old   July 17, 2025, 19:11
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 18,018
Rep Power: 146
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Have you had a look at the workbench parameterisation stuff and the operating point stuff in CFX? These are already built in and may do what you want.

Are you looking to do a series of simulations and then the python analyses it as post processing, or does the python generate new simulation conditions based on the previous set of simulation results?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   July 18, 2025, 06:20
Default
  #5
Member
 
Join Date: Dec 2023
Posts: 51
Rep Power: 4
smhk is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
Have you had a look at the workbench parameterisation stuff and the operating point stuff in CFX? These are already built in and may do what you want.

Are you looking to do a series of simulations and then the python analyses it as post processing, or does the python generate new simulation conditions based on the previous set of simulation results?

I've seen and used parametrization in workbench but very deeply.Python generates new simulation conditions but they are not based on previous results.
Actually new conditions are set based on sampling method (called Sobol sampling) in Python then these conditions are used in the simulations then results go to a Python code for statistical post processing.
smhk is offline   Reply With Quote

Old   July 18, 2025, 06:28
Default
  #6
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 18,018
Rep Power: 146
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
If you are generating a long list of simulations, then running them then post processing them - this is easy.

The way I would do it in your circumstance is to make a master CFX run, generate a def file and extract the CCL file from that. Then get your python to read in the CCL and generate lots of CCL files, one CCL for each simulation. Get the python to also generate a batch file to write the CCL into the def file and run them all using the command line (cfx5cmds -write -def Master.def -text Run123.ccl; cfx5solve -def Master.def repeated for each run). Then you can post process at your liesure.
smhk likes this.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   July 20, 2025, 12:09
Default
  #7
Member
 
Join Date: Dec 2023
Posts: 51
Rep Power: 4
smhk is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
If you are generating a long list of simulations, then running them then post processing them - this is easy.

The way I would do it in your circumstance is to make a master CFX run, generate a def file and extract the CCL file from that. Then get your python to read in the CCL and generate lots of CCL files, one CCL for each simulation. Get the python to also generate a batch file to write the CCL into the def file and run them all using the command line (cfx5cmds -write -def Master.def -text Run123.ccl; cfx5solve -def Master.def repeated for each run). Then you can post process at your liesure.

Thank you. I will try that.
smhk is offline   Reply With Quote

Old   December 1, 2025, 01:29
Default
  #8
Member
 
Join Date: Dec 2023
Posts: 51
Rep Power: 4
smhk is on a distinguished road
Hello again,
There is another question, what if I want to change the geometry too.
I mean beside of boundary condition changes I want to use python to sample some new angles that I want to apply on my geometry and the mesh. Can I change the mesh file using .ccl? (I couldn't find the mesh location(address) in .ccl file. It seems that mesh is included in .def file).


Do you think that I can do meshing with design modeler and turbogrid separately and then use .ccl file to call these meshes for each simulation?
smhk is offline   Reply With Quote

Old   December 1, 2025, 02:24
Default
  #9
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 18,018
Rep Power: 146
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
The mesh is input into the simulation in CFX-Pre. So it you want to change the mesh you will need to run CFX-Pre from the command line. Alternately, if you want to dynamically change your mesh you will need to control your meshing program from the command line this depends on what meshing software you use.

But this all starts getting difficult, so I would consider moving into Workbench where this can all be done in a few simulations blocks and maybe a parametric block. While I am no fan of Workbench, it does do this sort of stuff really well. Workbench is by far the easiest way to do it.
Opaque and smhk like this.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Reply

Tags
cfx, coupling, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ansys CFX Possibly using the wrong fluid AmreD CFX 4 May 5, 2023 13:27
Regestry Exception when running batch commands of CFX simulations Eman Eal CFX 1 October 20, 2022 18:36
Ansys CFX’s Future butterflymuzzy CFX 23 June 24, 2022 08:29
Python compatibility with CFx jmex CFX 4 January 2, 2020 05:56
Optimization study with ANSYS CFX (FLUENT) and MATLAB rusham ANSYS 0 January 25, 2018 05:54


All times are GMT -4. The time now is 01:13.