My new book on quantum mechanics with Kieran Bjergstrom and Stephen Duffus is soon to be published (we are working on the author proofs at the moment).
The book contains a chapter on scientific coding and good practice and builds an example library and drivers in Swift with quantum physics as its focus.
In advance of publication I have made that code available on GitHub for anyone interested to look at and make use of.
The purpose of this effort was to show what could be done to develop a library within one week (and so will contain some design flaws and have much room for improvement). The focus of the chapter is on pedagogy and good practice and not performance (as there are plenty of other texts on the algorithmic side of scientific computing already in existence).
I have supplied all the code to produce all the figures requiring non-trivial calculations within the book (the current focus is on clarity over speed).
While it does not rival the breadth of provision of quantum libraries in other languages (yet) it may be of interest to those looking to do scientific computing in Swift. In the future I plan to optimise and extend this library (or a suitable revision of it) into a comprehensive and fast toolkit.
Currently the driver routines supplied include code to:
a) Calculate the classical dynamics of a probability density function for a duffing oscillator with an initial condition of a Gaussian distribution in phase space.
b) Calculate Wigner and spin-Wigner and hybrid position-spin Wigner functions.
c) Compute the dynamics of the Jaynes Cummings model (with drivers for atomic version and Wigner functions included).
d) Computing the engine values and vectors of a superconducting interference device.
e) Solve quantum state diffusion dynamics (via an Ito increment method) for the quantum duffing oscillator with damping.
Driver routines can be found here:
And the main library here:
All code is released under the MIT License