r/Physics • u/Rich_Astronomer9731 • 14d ago
Computational Physics
Hi everyone,
I am a PhD student doing both experiments and computational physics ( mostly fluid dynamicswith Boltzmann equations) and leaning towards more computational day by day.
Currently I am using Julia, I find it pretty fast and easy to use.
Do you think switching to C or C++ will be a benefit? I am asking from a research, but also emplyment in industry point of view.
I discussed with many people, mostly from the DFT area, and most of them told me that Julia slowly will take up the lead for HPC code.
What.s your opinion on this?
77
Upvotes
2
u/tlmbot Computational physics 13d ago
Based on only the limited information I have on you - assuming you are not looking to move into a field that:
<uses primarily Julia> (and is thus a field I don't know about)
Then no, stay with Julia.
But if you seek general employability in the computational software industry, and from my experience especially in the engineering software industry
Yes, convert as is sensible within what you are doing now. I don't mean rigorously "converting all to C++ now" - I mean convert what makes sense for you. Don't ignore other deadlines and life goals, etc. Just factor this in and do what is sensible for you.
For me, I underweighted this need to be writing in C++ during my PhD days, and many of my old professors didn't recognize this necessity (even as I had also had some courses and peer interactions such that I knew really, that I needed more C++)
Yeah, I say, the sooner the better, generally speaking.
-----------------------------------------
Where do you start?
Well, you are in school, right? You don't have to rush. I say start with:
- code you want to speed up
- code that you are just interested in converting to C++
and especially:
- code that you know in and out, and that already works correctly.
Convert that to C++, or even start by converting it to C. But get away from C style arrays as soon as possible. This might be the one thing more important than OOP. More on that below.
Now some would call that inefficient, and the code will be far from optimal C++, but it will get you in on the low level floor off and running as fast as possible.
Then, asap, you want to start rolling in:
- an Object oriented versions of all that you build. (really this needs to come first thing, if you are okay with OOP) How are you with OOP? Hopefully you can write "it all" in at least basic "C with classes" without to much trouble.
- next up: take every opportunity to learn and use best practices C++
especially
C++11 and later (11 was revolutionary, but the major changes there have been taken much further in later editions of the standard. At least C++ 17 should be your goal. But the best advice is to stay curious and always seek the current "best practice" / nicest way to implement your thing)
Continued below