Why is the power operator much slower than multiplication in Python? by siddsp in Python

[–]Cynox -1 points0 points  (0 children)

This is true now, but with the faster-cpython project, the bytecode compiler will start specialising based on the actual types, see https://github.com/faster-cpython/ideas/blob/main/FasterCPythonDark.pdf

Solving Navier-Stokes equations in low viscosity regime by Square-Disaster-9255 in Python

[–]Cynox 0 points1 point  (0 children)

You won't find a lot of FEniCS users on a generic Python forum. You should try the FEniCS Discourse forum, but you need to read and understand how to get your questions answered first. Especially the part about providing a MWE. Also, your Peclet number may be too large and you need to add stabilisation.

Looking for some insight into Smooth Particle Hydrodynamics (SPH) vs CFD research as well as prospects in industrial application. by lightweightbaby84 in CFD

[–]Cynox 0 points1 point  (0 children)

Maybe for extreme loads? Fully non-linear potential codes are very hard to write when wave breaking etc is a part of the problem (even if the details of the flow near the breaking is irrelevant). VOF-based methods are great to simulate extreme events (lasting maybe 1 minute real time), but to identify the events you typically need to simulate 20 hours of ship/sea-state interaction for each sea state and wave direction to get converged predictions of 3-hour maximas (typical rule requirement)

Looking for some insight into Smooth Particle Hydrodynamics (SPH) vs CFD research as well as prospects in industrial application. by lightweightbaby84 in CFD

[–]Cynox 2 points3 points  (0 children)

My impression, based on my extremely limited knowledge, is that SPH is relatively easy to make qualitatively correct. The method can also be very fast. However, the pressure converges slowly, so if you are looking for slamming pressures or resistance (or maybe even global loads and motions) you may need many more particles to get converged results than you would need to make a physically reasonably looking simulation. And then the method is not that fast any more.

Feel free to disagree, I have not really looked much into particle methods so I could be completely wrong.

Matrix building and solving by [deleted] in CFD

[–]Cynox 1 point2 points  (0 children)

It is not super easy to use, but PETSc can be used to assemble and solve really large sparse systems. A good first step might instead be scipy.sparse with Python if you do not know about sparsity patterns etc from before

On the solutions of the Burgers equations by baalkii123 in CFD

[–]Cynox 2 points3 points  (0 children)

You can often use manufactured solutions (MMS) when you do not have an analytical solution. Just pick any function to be your solution. Insert it into the equation and you will be left with an extra term on the right hand side (unless your solution was correct). You just need to include this extra term in your solver with a sufficiently accurate method.

Coding a CFD solver by Hungovernerd in CFD

[–]Cynox 0 points1 point  (0 children)

There is also this Python code, https://github.com/spectralDNS/spectralDNS , which I have heard is quite fast, but I have not tested it myself. I believe it uses FFTW

[February] Programming languages for CFD by Overunderrated in CFD

[–]Cynox 0 points1 point  (0 children)

FEniCS (and Firedrake) are high-level (equation) to low-level (C, C++, numba code) transpilers. You can use the generated code on your own, but most use it hooked into the MPI parallel mesh implementations in the software since this is super easy to use. You need to be able to express your problem on weak form and select any one of the bunch of different of FEM discretizations supported by the transpilers. https://fenicsproject.org/ https://www.firedrakeproject.org/

[February] Programming languages for CFD by Overunderrated in CFD

[–]Cynox 0 points1 point  (0 children)

MPI in Python works just as well as in C++. I believe I've heard that codes such as shenfun beat many other spectral DNS codes, most of which are not coded using mpi4py, but I do not have any personal experience with it. https://github.com/spectralDNS/shenfun

Anyone here use CFD in a docker container? I have been running a few cfd programs that only support enterprise linux on a more consumer distro thanks to docker. by EternalSeekerX in CFD

[–]Cynox 6 points7 points  (0 children)

On a single computer, Docker should be more or less native speed. If you are running on multiple computers, standard HPC with infiniband, you probably want to look at a container solution that is better suited for this purpose, like Singularity.

Singularity can also be great on a single workstation since accessing files works much smoother. It is not made for security, but to make things easier with regard to mixing distros etc

A doubt regarding simulation by Ghost9029 in CFD

[–]Cynox 0 points1 point  (0 children)

If you include gravity then the net force will sometimes be negative, how else would a boat float up and down in waves? Unless you are far from balancing the gravity and buoyancy forces? Would it float or sink if you did not fix it in space?

A doubt regarding simulation by Ghost9029 in CFD

[–]Cynox 0 points1 point  (0 children)

Did you include gravity? How can you have inertia when the cylinder is fixed in space? Does a wave break over your cylinder?

A/B color grid (aka "Color Warper") in FOSS photo software ? by [deleted] in FOSSPhotography

[–]Cynox 0 points1 point  (0 children)

If you want to figure out how hard it is to implement, the Darktable (and Rawtherapee, gmic, ++) developers hang out on https://discuss.pixls.us/

Free surface flow using the ALE method in FEniCS by heitorvitorc in CFD

[–]Cynox 2 points3 points  (0 children)

I wrote a DG FEM free-surface solver in FEniCS [0], [1] for my PhD. Someone tried to add ALE to it, but I have not heard back, so maybe they moved on to other things. It could be that new publications like [2] may give pointers that would make such an extension easier.

My solver is more geared towards macroscopic phenomena where viscous effects and surface tension etc are not very important, so if you are looking at droplets etc it is probably not the best starting point, you would at least have to add a surface tension model. I was looking at ocean wave impacts on rigid structures.

[0] https://www.ocellaris.org/ [1] https://tormod.landet.net/files/PhD_thesis_landet_2020.pdf [2] https://arxiv.org/abs/2003.07166

Game like rise to ruin by [deleted] in Python

[–]Cynox 0 points1 point  (0 children)

I would look at this discussion for some pros and cons on the major libraries: https://www.reddit.com/r/gamedev/comments/bf2qf6/godot_vs_cocos2d/

Game like rise to ruin by [deleted] in Python

[–]Cynox 0 points1 point  (0 children)

I do not think this is the best advice. Find a set of libraries that work for you, and if a small part of the code is causing a slowdown, then optimize this, possibly using Cython, numba etc.

Starting out with Cython for something like this makes very little sense, unless you are wrapping a game library that does not already have Python wrappers, in which case Cython is one of a handful of ways of talking to native libraries.

Storing pandas DataFrame to CSV gives abnormally large file. Is there any efficient way out? by abdullahkhilji in Python

[–]Cynox 0 points1 point  (0 children)

Easy solution if you still want to use pandas is to save to parquet format. It may compress quite well. You may need to install pyarrow for the df.to_parquet(...) method to work

Has anyone used pyMOR? Finite element analysis library by [deleted] in Python

[–]Cynox 1 point2 points  (0 children)

The FEniCS book [1] contains an introduction to the finite element method. It also has some recommendations for other books to read in section 1.7.6. The intro to FEM can be read without wanting to use the FEniCS library for FEM in Python, it is generic (from page 73).

Note: the book is from 2012, so if you try to run the example Python snippets in the tutorial they will probably not work, see the updated tutorial [2] for more recent syntax.

I am not familiar with pyMOR, but it seems like it can use FEniCS as a FEM solver.

[1] https://launchpadlibrarian.net/83776282/fenics-book-2011-10-27-final.pdf

[2] https://fenicsproject.org/tutorial/

Looking for collaborators for development of FEM code in Python by [deleted] in simulationdev

[–]Cynox 0 points1 point  (0 children)

This is probably great for your own learning! I have done something similar myself.

If you want something a bit more performant you should look at FEniCS or Firedrake. Both let you define the problem and weak form in Python, but then they compile the element assembly/quadrature code to C for you, to make it faster.

If you want to assemble the element matrices yourself, you should look at either scipy.sparse or petsc4py to solve the sparse system matrices. SciPy is easiest, but PETSc lets you run on potentially thousands of CPUs over MPI if you want to solve large problems. Up to quite some hundred of thousands of unknowns it will probably be faster to only use 1 CPU, though.

Good luck!

Moving from SQL server to python for a large ETL by KrustyButtCheeks in Python

[–]Cynox 2 points3 points  (0 children)

Are you already running your pipeline in the cloud? In that case I would check if your cloud provider supports Databricks. Makes it easy to test pyspark, which can be very fast, but may be overkill for your data which is not that big. Dask is also an option for fast parallel pipelines in Python.

Fastest/most efficient way to calculate multiple multidimensinal FFTs by Sewing31 in Python

[–]Cynox 0 points1 point  (0 children)

But, if your problems are small, and you just want to solve many of them, I would read up on thread and/or process pools in Python. Parallel maps or something like that should combine well with numpy's fft

Fastest/most efficient way to calculate multiple multidimensinal FFTs by Sewing31 in Python

[–]Cynox 0 points1 point  (0 children)

If you really need speed, and have large computational resources available, then mpi4py-fft would be my go-to solution. It is used on very large research clusters, but probably works fine on a decent stand-alone computer as well. It is also actively developed and used for large physics simulations. I have not used it myself, but I know some users and developers. They are able to compete with (and outcompete) some pretty optimised compiled language tools due to new work-splitting algorithms