23
$\begingroup$

What are the main uses and applications of Julia in Materials Modeling? Python for example is used in codes such as kwant, pymatgen, pyscf and a variety of other things, not to mention workflow automation and data processing. Any available codes or publications out there that are based mainly on the Julia programming language?

$\endgroup$
  • 2
    $\begingroup$ James Whitfield, a Professor at Dartmouth, wrote a Julia code to do the Bravyi-Kitaev transformation on the electronic structure Hamiltonian, but I'm not sure how much further it got developed after he sent it to me in 2017. $\endgroup$ – Nike Dattani May 11 at 14:14
26
$\begingroup$

(Disclaimer: As one of the main authors of a Julia-based DFT code, DFTK, my opinion is definitely biased)

The community of people employing Julia for materials modelling is still small, but a couple of programs exist. Probably a good overview gives https://github.com/svaksha/Julia.jl/blob/master/Chemistry.md. Many projects have only started within the last year, but still show a sizeable set of features, indicating the great potential of Julia for this field. Regarding the workflow, there are not that many packages, but you can just use from python what you need. I'll try to summarise:

Uses of Julia and its design

Julia solves very elegantly what is commonly known as the two-language problem. In computational science one wants to be fast when crunching the numbers (traditionally calling for a language like Fortran, C and C++) and flexible when building models or simulation workflows (calling traditionally for something like python).

This by itself has the trouble that people (read: PhD students) need to actually learn two languages to be able to develop the code, but let's argue this is not a problem in practice. Still, we are faced with making the decision at which point to make the cut between the languages. Where this cut point should be placed is less obvious than it might sound if you keep in mind that materials science is an interdisciplinary field with people from maths, physics, chemistry, computer science, ... working on the same sort of problems, but at very different levels. While for a practitioner all the hairy details SCF algorithm, say, are not so important and can be easily shuffled under the carpet of heavy C or Fortran code, mathematicians actually want to modify exactly those to improve mixing schemes or preconditioning and so on. So for a mathematician this should be high-level python to productively do research, but if one does this, it has too much of a performance impact for large-scale practical calculations to be feasible.

Here Julia is for the rescue, since as commonly quoted it looks like Python, feels like Lisp, runs like Fortran. What this is supposed to mean is that writing Julia code is very similar to Python including hairy parts such as linear algebra. It has stronger type systems and structures similar to functional languages like Lisp and in the end really is as fast as Fortran or C. The reason is that even though it is a high-level language it has "close to the metal" constructs that allow you to directly influence aspects such as vectorisation, parallelisation and so on. The advantage over a two language solution is, however, that you can introduce them step by step once the first version of the code has been written without rewriting it in another language. So first you get things done, then you get them done fast. For any new project in materials modeling, whether you right now think it is performance-critical or not, I think Julia is therefore the perfect language.

Materials-related Julia projects

  • JuliaMolSim: Github organisation for molecular simulation in Julia, packages such as:
    • ASE.jl: (Incomplete) Julia bindings for ASE.
    • DFTK.jl: Flexible Julia code for plane-wave density-functional theory (DFT) and related models. LDA and GGA functionals are supported. Ground-state calculations only for now. Less than 5k lines of code and very hackable. Designed also for mathematical work in the field. Can be used directly from ASE as a calculator using asedftk. Still experimental, but any feedback welcome!
    • JuLIP.jl: Julia Library for Interatomic Potentials. Can be used to rapidly build and test interatomic potentials for defects etc.
  • Molly.jl: Proof of concept molecular-dynamics package in Julia.
  • PorousMaterials.jl: Julia package for modelling adsorption on porous crystals using Monte Carlo methods.
  • Quantica.jl: Julia package for building generic tight-binding models and computing various properties from it.
  • QSimlator.jl: Package for Unitary and Lindbladian evolution in Julia.
  • QuantumLab.jl: Experimental package for more molecular quantum chemistry (roadmap is similar to pyscf)

Workflow

  • For managing a scientific project DrWatson.jl is extremely helpful.
  • The pandas equivalent of Julia is DataFrames.jl. You can also directly use HDF5.jl.
  • Plotting can be done in Plots.jl or matplotlib via PyPlot.jl.
  • Actually you can integrate any python or R package into a Julia script using packages such as PyCall.jl or RCall.jl. For python this integration is two-way, so calling Julia from python is a piece of cake. You can even pip install julia. This is what we use in DFTK to do our lattice and Brillouin zone setup using spglib and pymatgen or import ase.Atoms into our datastructures.

Publications

Not that many I am aware of. We have recently published a few things with DFTK, but they are not so much related to modelling.

Recently,(May 2020) "PWDFT.jl: A Julia package for electronic structure calculation using density functional theory and plane wave basis" was published in Computer Physics Communications.

| cite | improve this answer | |
$\endgroup$
  • 5
    $\begingroup$ Cory Simon's PorousMarerials.jl is a notable example missing from this list. $\endgroup$ – Andrew Rosen May 12 at 6:01
  • 1
    $\begingroup$ Thanks @CharlieCrown. My bad! $\endgroup$ – Michael F. Herbst May 20 at 5:22
  • 3
    $\begingroup$ Came back here to share with you all that this was just published in Computer Physics Communications! "PWDFT.jl: A Julia package for electronic structure calculation using density functional theory and plane wave basis" doi.org/10.1016/j.cpc.2020.107372 $\endgroup$ – Etienne Palos May 22 at 22:10
8
$\begingroup$

And of course, there is Lattices.jl, for defining lattices in Julia. Please note that this package is still in the very early stages of exploring a potential Julian interface for lattices, and should be used with discretion. https://juliaphysics.github.io/Lattices.jl/latest/

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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