1
$\begingroup$

I need to do numerical simulations to predict the behavior of a plasma in a gridded ion engine. For that I will propably use a Particle In Cell algorithm. I'm wondering which software to use since the existing simulations in this field are mostly written in Fortran and this doesn't seem like the best option today especially with the rise of GPUs. Thus, I was thinking of Tensorflow which would allow me to easily leverage the speed of GPUs without adding any further complexity. However, although it is mentionned in the Tensorflow documentation that it can be used for scientific computing, I could barely find any examples. Moreover, the Tensorflow documentation for the low-level API is extremely brief and there doesn't seem to exist any tutorials on how to structure code fully written with the Core API.

Is Tensorflow the right option ? If yes, could you point me to any example using it in this context (preferably using TF 2.0) or any ressources about this topic ?

$\endgroup$
4
  • 1
    $\begingroup$ There are a lot of publicly available (and modernized) PIC codes and there is nothing wrong with FORTRAN used with MPI on supercomputers, I think... $\endgroup$
    – honeste_vivere
    Commented Sep 26 at 12:20
  • 1
    $\begingroup$ @honeste_vivere to be honest I don't know much about Fortran. I'm still a student and I candidely assumed that since Fortran was developped in the 70s there would be better software since then. It espescially looked quite complex compared to TensorFlow or numpy. Plus I'm no programming expert and I thought I might miss on a lot of optimizations that tensorflow (or numpy actually) already implements, Is it really that much faster that it would compensate for that ? $\endgroup$ Commented Sep 27 at 0:56
  • 1
    $\begingroup$ Some of the finite element libraries have PIC capabilities; for example, you may want to look at deal.II's step-19 tutorial program, along with several others of its tutorials. (Disclaimer: I'm one of the authors of deal.II.) $\endgroup$ Commented Sep 30 at 1:30
  • $\begingroup$ Is this a large simulation? If it is a small one, just use the language you are most familiar with. The time you spent on looking for a suitable tool might allow you to write and run a few simulations using an arbitrary language. $\endgroup$ Commented Sep 30 at 2:16

2 Answers 2

3
$\begingroup$

Generally speaking, you are not going to find any physics/scientific computing routines written in TensorFlow that are as optimized and verified as those in FORTRAN. Something that sounds similar to what you are attempting are lattice Boltzmann methods for fluid dynamics. These have been massively parallelized with GPUs but IIRC they are typically written in some low level language and interface with the GPU via CUDA and not through any Tensorflow interface. My gut says TF might be a poor choice because memory management with tensor objects and computational graphs can scale quite poorly and I don't think you would really be using many of these features at all unless you were trying to compute sensitivities or adjoints of your simulation. I think perhaps some sort of TF user group would be best to ask just because they are probably more aware of the specific downsides of the language. If you really want to use GPUs, I would maybe suggest prototyping in Python or a more comfortable language and interfacing with the GPU through CUDA. It is likely that performing basic numerical tasks will be more efficient in terms of memory and compute than an equivalent calculation in TensorFlow.

$\endgroup$
2
  • $\begingroup$ I don't think LBM is a good example here. Actually both methods (LBM and PIC) use the Boltzmann equations as a starting point, however LBM is a pure Eulerian model whereas PIC is primarily a Lagrangian model (often combined with EM fields). The numerics and algorithms are rather different. However, I would agree that TF is a poor choice for PIC. $\endgroup$
    – ConvexHull
    Commented Sep 30 at 21:25
  • $\begingroup$ Yes you are correct that the two algorithms are very different. I only mention is here because LBM are very popular example of GPU scaling in scientific computing. The key is that the algorithm must have components that can be reduced to embarrassingly parallel operations with little necessary cross communication. It seems like PIC on GPUs is [active research[(sciencedirect.com/science/article/pii/S0010465521000503) with some promising results $\endgroup$
    – whpowell96
    Commented Sep 30 at 22:26
-1
$\begingroup$

If you want a differentiable solver, that might be the only reason to use TensorFlow or JAX or a similar differentiable framework. See this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.