|
[Sponsors] |
February 13, 2021, 09:18 |
Using python for OpenFoam
|
#1 |
Member
Jigs
Join Date: Sep 2017
Location: Pune
Posts: 42
Rep Power: 9 |
Hello folks,
Hope everyone is well and safe! I am learning python and knows little, can work with tkinter. I am looking to integrate python with openfoam in a way that i want to create an interface for openfoam. As such i am learning by my own, i need some guidance. I have come across pyFoam and i am trying to learn that as well. The problem i am facing is not proper knowledge. Can someone help me with step by step, where should i start. I have literally jumped into the pool and struggling to swim. I think i should atleast get some idea of the swimming. Can someone point me in the right direction? Thanks in advance! |
|
February 13, 2021, 14:55 |
|
#2 |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
This is a really good idea, but I wouldn't recommend it to a beginner.
if you would really like to do it, I would recommend trying to see the few OpenFOAM GUIs available in the wild. But in my own personal opinion ( which you can reject if it doesn't suit you): Here's something that can be feasible, and will actually be a very good tool. I know something like this will be immensely helpful to me. I can't speak for others though. - Run OpenFOAM on Linux. Understand how to use it and how it works. - Create bash scripts to automate creation of the different dictionary files used by OpenFOAM. - When you get more knowledgeable in using the linux grep, sed, awk tools, you can create a bash script to directly change the value inside the dictionary files (say mach_no = 1.5 ) to (say mach_no = 3.6 ) etc. This bash script should have command-line arguments that allow the user to change the different values in the dictionary file. It can be something like $ ./editor.sh --mach 3.6 --freestream-temp 300 --solver explicit - The user could call your bash script from the terminal and pass in the variable they want to change. You can even make the bash script use autocomplete feature, so that the configuration parameters mach, freestream-temp, solver etc get autocompleted by the bash shell of the Linux terminal. - Then you can create a GUI in python to take all of the inputs and call one of the previously developed bash scripts to do the required work. Best of luck |
|
February 13, 2021, 15:01 |
|
#3 |
Senior Member
M
Join Date: Dec 2017
Posts: 701
Rep Power: 12 |
Well. Your task is either fairly easy or extremely hard. Why? It depends heavily on what you want your interface to be able to do. Do you want just a simple interface where you can adjust some basic settings for a certain setup? That might be easy. Do you want a UI to control OF entirely? Well, I don't say its impossible, but there is a quadrillion of options in OF and that's really hard.
However, I would suggest starting with a really easy case, probably a tutorial? And create something for this - for instance allowing the user of your interface to adjust some options in fvSchemes. Then maybe switching some boundary conditions. And then go from there and see how far you get. Keep in mind that OF is constantly evolving and whatever you write might not work with future versions. The syntax of functions e.g. is changed from time to time. You need to keep updating all the time or stick to a certain version. |
|
February 14, 2021, 04:03 |
|
#4 |
Member
Jigs
Join Date: Sep 2017
Location: Pune
Posts: 42
Rep Power: 9 |
Thanks AtoHM and aerosayan, I appreciate your reply. You both perfectly understood me. I am not entirely looking to control OF with interface but just simple simulations. Yes I am familiar with OF on linux and also with python. I am not sure how to link bash commands with python. Also exploring pyFoam so that i can use its feature.Thanks again, can you help me with a simple example? So that using it, i can learn and create my own.
|
|
February 14, 2021, 11:22 |
|
#5 |
Senior Member
M
Join Date: Dec 2017
Posts: 701
Rep Power: 12 |
As I said, tutorials are a great way to start off. OF comes with a number of tutorials and there are also additional tutorials available for new OF users. Some for example are available here https://holzmann-cfd.com/community/training-cases which is page by moderator on this very forum: https://www.cfd-online.com/Forums/members/tobi.html
|
|
February 26, 2021, 00:22 |
Using python for OpenFoam
|
#6 |
New Member
daniel charles
Join Date: Feb 2021
Posts: 1
Rep Power: 0 |
Hello everyone,
I found this script made by a researcher in Chalmers during his study on porous media. The background of the study and specific model assumptions are not so important I think. He is actually using the script to alternate between incompressible and compressible simulation on the fly, we can hopefully start with simpler stuff like calling applications and running them. The way he does it, the way he creates the python script, linking to the python library we talked about in our first meeting (pyFoam) may shed some light to you more experienced coders on how Butterfly can perhaps interface with OpenFoam in the same way. I hope it helps! http://publications.lib.chalmers.se/...ext/160199.pdf (page 53) Kind regards, Daniel Charles. |
|
Tags |
automation, cfd, openfoam, python |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[PyFoam] Using pyFoamPlotWatcher.py To Plot Residuals | m_ridzon | OpenFOAM Community Contributions | 22 | January 26, 2021 19:48 |
Running Fluent from Python: UDF Compilation problems | Ames | Fluent UDF and Scheme Programming | 5 | November 16, 2020 07:12 |
[OpenFOAM] using the python shell in paraFoam | colinB | ParaView | 14 | September 14, 2015 10:04 |
[OpenFOAM] paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7 | aylalisa | ParaView | 4 | June 13, 2014 09:52 |
CentFOAM Python Script Installation: Error | socon009 | OpenFOAM Installation | 2 | May 26, 2012 10:36 |