Fluidsim is an extensible framework for studying fluid dynamics with numericalsimulations using Python. Fluidsim is an object-oriented library to developFluidsim "solvers" (i.e. Python packages solving equations) by writing mainlyPython code. The result is very efficient even compared to a pure Fortranor C++ code since the time-consuming tasks are performed by optimized compiledfunctions.
Fluidsim is aHPC code. Itis part of the wider projectFluidDyn and itspseudospectral solvers rely on the libraryfluidfft to use very efficient FFTlibraries. Fluidfft is written in C++, Cython and Python. Fluidfft andfluidsim take advantage ofPythran, anahead-of-time compiler which produces very efficient binaries bycompiling Python via C++11.
An advantage of a CFD code written mostly in Python is that, to runsimulations and analyze the results, the users communicate (possiblyinteractively) together and with the machine with Python, which isnowadays among the best languages to do these tasks. Moreover, it ismuch simpler and faster than with pure Fortran or C++ codes to add anycomplicated analysis or to write a modified solver. Fluidsim can also beused to extend existing solvers with Python interfaces such asBasilisk.
Fluidsim is a HPC codewritten mostly in Python. It uses the libraryFluidfft to use very efficient FFT libraries.Fluidfft is written in C++, Cython and Python. Fluidfft and fluidsim takeadvantage of Pythran, a staticPython compiler which produces very efficient binaries by compiling Python viaC++11. Pythran is actually used in Fluidsim throughTransonic, which is a new and cool project forHPC with Python.
An advantage of a CFD code written mostly in Python is that to run simulations andanalyze the results, the users communicate (possibly interactively) together andwith the machine with Python, which is nowadays among the best languages to dothese tasks. Moreover, it is much simpler and faster than with pure Fortran or C++codes to add any complicate analysis or to write a modified solver.
The list of solvers implemented using Fluidsim (see fluidsim.solvers,snek5000 and fluidsimfoam) gives a good idea of the versatility of thisframework. The main Fluidsim package contains mostly solvers solving equationsover a periodic space:
The student version of FluidSIM has been revised and now offers significantly more advantages than in the past. For example, the new student version includes a completethe full electrotechnical functionality which means that comprehensive electropneumatic circuit diagrams can be drawn and simulated. The basic circuits from our pneumatics technology package (TP 101) and electropneumatics technology package (TP 201) are available in separate libraries. All of the circuits can be saved and reused again later if necessary. The CD-ROM includes the complete manual in pdf format. The student version can be installed without a dongle.
FluidSIM revolutionizes the way users learn and simulate circuit diagrams. With its new web version and integration into Festo LX, it now offers maximum flexibility and accessibility, empowering learners, and engineers to excel in automation engineering.
Bring your ideas to life: With FluidSIM, you can easily bring your circuit diagrams to life with a variety of over 800 components to choose from in the fields of pneumatics, hydraulics, and electrical engineering. With real-time simulations, you can witness your circuit designs. You can observe the effects of your creations and gain a deeper understanding of how components interact.
Festo is a global player and an independent family-owned company with headquarters in Esslingen am Neckar, Germany. Festo has set standards in industrial automation technology and technical education ever since its establishment, thereby making a contribution to sustainable development of the environment, the economy and society. The company supplies pneumatic and electrical automation technology to 300,000 customers of factory and process automation in over thirty-five industries. The products and services are available in 176 countries. With about 20,800 employees in over 250 branch offices in 61 countries worldwide, Festo is always near to the customer. Festo Didactic SE is a leading provider of technical education and training and offers its customers worldwide comprehensive digital and physical learning solutions in the industrial environment.
The solution we choose was to build differently depending of the result of import mpi4py and import pythran with try/except statements. It is far from optimal but it works. Of course, it forbids the use of isolated build and therefore pyproject.toml. Note that it is similar to how conda works (the package installed by a command depends on what was installed in the environment).
If you need different wheel filenames, you need to argue for a revision to the wheel spec. If you can explain how the package index would store these variant wheels without a filename spec change, then that would probably clarify how installers like pip could be told which variety to choose.
For example one could publish both projects MyProjectPure (pure Python) and MyProjectC (built with C extensions). And to link them somehow on the metadata-level they could both announce as Provides-Dist: MyProject. This way tools (installers) could react appropriately and for example make sure only one or the other is installed.
It is strange (and unfortunate) to have to do this by hand but it could work. For example fluidsim-purepy could depend on fluidfft-purepy and fluidsim[mpi] (here, just an extras_require since there is no extension using MPI in fluidsim) could depend on fluidfft-mpi.
However, there is only one pyproject.toml in the root directory of a repository, so only one variant of the package can be installed directly from the repository (with something like pip install git+ -sans-paille/pythran#egg=pythran).
The real problems here are not about providing a mechanism to do this (as you can see, such a mechanism already exists), but more about recording metadata about it. How do you tag the wheels? How do you tell pip which version you want? How do you declare dependencies on this?
I understood pyproject.toml and the isolated builds were used in particular to avoid setup_requires and having to specify build dependencies in the file setup.py. I also read that there are potential problems with setup_requires. I would prefer something cleaner than using both [build-system] requires plus setup_requires.
You mention get_requires_for_bdist_wheel and PEP 517. It would be good to provide somewhere simple but realistic examples of how to use these things. I find only the PEP on the web (maybe I was just not able to find the good resource) and this part Build backend interface is not simple. For example, I guess it should not be very difficult to reproduce your example (build dependency depending on an environment variable) with get_requires_for_bdist_wheel but how?
Yes, an environment variable is not sufficient. Something like pip install my-super-package[a-string-about-the-variant] would be nice. Of course the name of the wheel should somehow contain a-string-about-the-variant.
I understood pyproject.toml and the isolated builds were used in particular to avoid setup_requires and having to specify build dependencies in the file setup.py . I also read that there are potential problems with setup_requires . I would prefer something cleaner than using both [build-system] requires plus setup_requires .
Then you would declare that fluidsim depends on fluidsim-purepy-backend (or just have fluidsim-purepy-backend ship with fluidsim unconditionally), and have pythran and pythran-with-mpi extras that add dependencies on the other two.
If we had Recommends-Dist and a system for saying what groups of packages can satisfy a given dependency, you could get the default values you want with the correct fallbacks. For example, you could add a dummy package fluidsim.backend, which can be satisfied by either fluidsim-pythran-backend or fluidsim-purepy, and a recommends-dist on fluidsim-pythran-backend, so that if fluidsim-pythran-backend is unavailable or hard to install for whatever reason, you fall back to fluidsim-purepy. The extras pythran and pythran-with-mpi would add hard dependencies.
The Python package fluidsim is introduced in this article as an extensible framework for Computational Fluid Mechanics (CFD) solvers. It is developed as a part of FluidDyn project [2], an effort to promote open-source and open-science collaboration within fluid mechanics community and intended for both educational as well as research purposes. Solvers in fluidsim are scalable, High-Performance Computing (HPC) codes which are powered under the hood by the rich, scientific Python ecosystem and the Application Programming Interfaces (API) provided by fluiddyn and fluidfft packages [11]. The present article describes the design aspects of fluidsim, which includes use of Python as the main language; focus on the ease of use, reuse and maintenance of the code without compromising performance. The implementation details including optimization methods, modular organization of features and object-oriented approach of using classes to implement solvers are also briefly explained. Currently, fluidsim includes solvers for a variety of physical problems using different numerical methods (including finite-difference methods). However, this metapaper shall dwell only on the implementation and performance of its pseudo-spectral solvers, in particular the two- and three-dimensional Navier-Stokes solvers. We investigate the performance and scalability of fluidsim in a state of the art HPC cluster. Three similar pseudo-spectral CFD codes based on Python (Dedalus, SpectralDNS) and Fortran (NS3D) are presented and qualitatively and quantitatively compared to fluidsim. The source code is hosted at Bitbucket as a Mercurial repository bitbucket.org/fluiddyn/fluidsim and the documentation generated using Sphinx can be read online at fluidsim.readthedocs.io.
b1e95dc632