That's pretty much the same scenario. One crucial thing is to call Python only once per time step by using list/vector arguments/parameters. Then it worked without significant performance loss. Calling Python within every call to source and only passing scalar values resulted in a performance degradation by a factor of 200.
Kind regards Bernd -- _________________________________________________________________ Bernd Flemisch IWS, Universität Stuttgart phone: +49 711 685 69162 Pfaffenwaldring 61 email: be...@iws.uni-stuttgart.de D-70569 Stuttgart url: www.iws.uni-stuttgart.de/en/lh2/<http://www.iws.uni-stuttgart.de/en/lh2/> _________________________________________________________________ ________________________________ Von: DuMux <dumux-boun...@listserv.uni-stuttgart.de> im Auftrag von leopold.stad...@baw.de <leopold.stad...@baw.de> Gesendet: Donnerstag, 9. September 2021 13:35:30 An: DuMux User Mailing List Betreff: Re: [DuMux] Using Embedded Python in DuMux Hi Bernd, thank you for this nice example. I've used embedded Python 10 years ago. My code was much less elegant and so I thought that one has to do this nowadays with Pybind11. However, looking into your example it looks like the Python/C API does also the job. For me it helps a lot to see how the Python interpreter is initialized and finalized in problem.hh and how data is converted. Actually I need a simple Python function for the source term so there are just a few parameters which have to be passed between C++ and Python. Best regards, Leo Flemisch, Bernd <bernd.flemi...@iws.uni-stuttgart.de> hat am 09.09.2021 12:27 geschrieben: Hi Leo, we're doing this here: https://git.iws.uni-stuttgart.de/dumux-appl/dumux-turing/-/tree/master/test/stochastic I needed the python3-dev package and had to run the executable with PYTHONPATH=. ./test_stochastic Kind regards Bernd <https://git.iws.uni-stuttgart.de/dumux-appl/dumux-turing/-/tree/master/test/stochastic> -- _________________________________________________________________ Bernd Flemisch IWS, Universität Stuttgart phone: +49 711 685 69162 Pfaffenwaldring 61 email: be...@iws.uni-stuttgart.de D-70569 Stuttgart url: www.iws.uni-stuttgart.de/en/lh2/<http://www.iws.uni-stuttgart.de/en/lh2/> _________________________________________________________________ ________________________________ Von: DuMux <dumux-boun...@listserv.uni-stuttgart.de> im Auftrag von leopold.stad...@baw.de <leopold.stad...@baw.de> Gesendet: Donnerstag, 9. September 2021 11:58:04 An: dumux@listserv.uni-stuttgart.de Betreff: [DuMux] Using Embedded Python in DuMux Dear DuMux developers and users, I'm interested to call Python from a DuMux application (embedded Python). Has anyone tried this before with DuMux? I'm also interested to use embedded Python in a parallel application in combination with MPI4py. Maybe it is a good idea if I open an issue in gitlab and try to add a small test (dumux/test/python) to check if/how embedded Python works. Best regards, Leo Im Auftrag Dr.-Ing. Leopold Stadler -- Referat Numerische Verfahren im Wasserbau Abteilung Wasserbau im Binnenbereich Bundesanstalt für Wasserbau Federal Waterways Engineering and Research Institute Kußmaulstraße 17 | 76187 Karlsruhe https://www.baw.de _______________________________________________ DuMux mailing list DuMux@listserv.uni-stuttgart.de https://listserv.uni-stuttgart.de/mailman/listinfo/dumux Im Auftrag Dr.-Ing. Leopold Stadler -- Referat Numerische Verfahren im Wasserbau Abteilung Wasserbau im Binnenbereich Bundesanstalt für Wasserbau Federal Waterways Engineering and Research Institute Kußmaulstraße 17 | 76187 Karlsruhe https://www.baw.de
_______________________________________________ DuMux mailing list DuMux@listserv.uni-stuttgart.de https://listserv.uni-stuttgart.de/mailman/listinfo/dumux