Quantum chemistry in Julia

1,179 views
Skip to first unread message

Rick Muller

unread,
Jun 21, 2014, 10:02:37 PM6/21/14
to juli...@googlegroups.com
I have some of the basic quantum chemistry functionality from PyQuante now working in Julia, for anyone who is into this sort of thing: https://github.com/rpmuller/pyquante2/tree/master/julia

Very very preliminary now. Just got a simple Hartree-Fock example working.

I'd welcome anyone's comments. 

Kevin Squire

unread,
Jun 21, 2014, 10:31:37 PM6/21/14
to juli...@googlegroups.com
Hi Rick,

I'm not a quantum chemist (and I don't play one on TV), but I can offer one comment.

At this point, the Task framework hasn't really been optimized.  I believe it's on the list of things to do, but until that happens, you'll probably find Tasks somewhat slow compared to Julia's main iteration scheme using start, next, and done.  You might try changing your iterators to that method.  Iterators.jl is a good package to look at for inspiration.

Cheers!
   Kevin

Rick Muller

unread,
Jun 22, 2014, 8:11:48 AM6/22/14
to juli...@googlegroups.com
That brings up a question I've had: how do I use the stuff in Iterators.jl? I've tried "using Iterators", "using iterators", etc. Do I have to install it separately? I'm using one of the julia 0.3 prerelease versions.

Patrick O'Leary

unread,
Jun 22, 2014, 8:31:59 AM6/22/14
to juli...@googlegroups.com
On Sunday, June 22, 2014 7:11:48 AM UTC-5, Rick Muller wrote:
Do I have to install it separately?

You do. From the Julia REPL, run Pkg.add("Iterators").

Michael Prentiss

unread,
Jun 22, 2014, 3:54:31 PM6/22/14
to juli...@googlegroups.com
This is great.  I have been anticipating more people using Julia for Chemistry and Physics.  I recently have been implementing some molecular dynamics code in Julia.  The main trick is the optimization that needs to be done by hand.  I had a few thoughts.

1. Write your code in Fortran as a basis of comparison.  It should be possible to write Julia so that it is 2 to 3 times slower than Fortran.
2. @inbounds,IProfile,Devectorization, NumericFuns.jl, NumericExtensions.jl, Distance,jl, Control Garbage Collection are your friends.
3. Experiment with tic(), toc() to measure timing.
4.  make sure to follow the performance tips too. http://docs.julialang.org/en/release-0.2/manual/performance-tips

hope this helps.

Rick Muller

unread,
Jun 22, 2014, 6:53:14 PM6/22/14
to juli...@googlegroups.com
Thanks.

Stefan Karpinski

unread,
Jun 24, 2014, 8:11:06 AM6/24/14
to Julia Dev
The @time macro is even better than tic() and toc(). In addition to being a bit easier to use, imo, it will tell you how much total memory allocation your code did and what percentage of time it spent in garbage collection (if any).

Michael Prentiss

unread,
Jun 24, 2014, 3:07:41 PM6/24/14
to juli...@googlegroups.com
Good to know.  Coming from Fortran and Python the function calls are still mysterious to me.  I have waded through the docs and blogs, but I would like more info.  I was wondering if their was a best place to understand function calls e.g.

function g{T <: String}(data::Array{T})
...
end

thanks

Tomas Lycken

unread,
Jun 24, 2014, 3:13:41 PM6/24/14
to juli...@googlegroups.com

That’s actually a definition of a parametric function - start reading about functions, then do types as sort-of an interlude, and then return to methods and especially parametric ones, to understand that specific piece of code.

If a lot of stuff still seems very opaque, it might be worthwhile to spend some time in other parts of the manual as well.

Good luck! =)

// T

Rick Muller

unread,
Jun 27, 2014, 11:27:56 AM6/27/14
to juli...@googlegroups.com
Thanks for that pointer.

I notice that the eig routine calls eigfact, which seems to call the non-hermitian solvers. In factorization.jl I can't find calls to LAPACK.sygv, for example. I don't fully understand what the ishermitian() functions do, however, so there may be some magic I'm missing. 

If I want to use, for example, sygvd should I just call LAPACK.sygvd directly? Or are you waiting for a plucky volunteer to suitably expand the eig calls?

Rick Muller

unread,
Jun 27, 2014, 11:29:35 AM6/27/14
to juli...@googlegroups.com
This is very helpful. I'm not there yet, but I'm learning quickly.

Did you find any references useful in learning how to use @inbounds, NumericFuns, etc.? Or did you just dive into the source?


On Sunday, June 22, 2014 1:54:31 PM UTC-6, Michael Prentiss wrote:
This is great.  I have been anticipating more people using Julia for Chemistry and Physics.  I recently have been implementing some molecular dynamics code in Julia.  The main trick is the optimization that needs to be done by hand.  I had a few thoughts.

1. Write your code in Fortran as a basis of comparison.  It should be possible to write Julia so that it is 2 to 3 times slower than Fortran.
2. @inbounds,IProfile,Devectorization, NumericFuns.jl, NumericExtensions.jl, Distance,jl, Control Garbage Collection are your friends.
3. Experiment with tic(), toc() to measure timing.
4.  make sure to follow the performance tips too. http://docs.julialadng.org/en/release-0.2/manual/performance-tips

Rick Muller

unread,
Jun 27, 2014, 11:34:24 AM6/27/14
to juli...@googlegroups.com
On vacation now, so I have some more time for hacking. FYI, on the plane trip yesterday I noticed some bugs in the HF code, that I think have to do with the eigensolver. Don't try this code for anything you care about.

Michael Prentiss

unread,
Jun 27, 2014, 12:28:47 PM6/27/14
to juli...@googlegroups.com
I have not used eig routine so I can not speak to it, but you are good to look into the LAPACK calls explicitly.

In Julia there is a learning curve, but it is worth it.  Writing code in only a fortran style will lead to slow execution times.
I am glad the notes were helpful.  

I figured this stuff out by reading and reading and reading primarily.
The docs are rather good and helpful with the learning curve.

https://github.com/lindahua  is doing a lot of important low level optimization of things like sum and a lot of other methods.
Reading what he is doing has been valuable.  he is the author of many of these libraries that will eventually put into base.
Diving into the base is one of Julia's best features and is actually part of the point of the project.  
The code is setup for people to digging.

When learning this stuff: start small, trial and error, use the @time macro, ask questions.  

Rick Muller

unread,
Jun 27, 2014, 1:09:27 PM6/27/14
to juli...@googlegroups.com
Awesome. Thanks for your help!

HF bugs fixed. I'll try to push updates to the git repository ASAP.

Xiaodong Qi

unread,
Jul 8, 2014, 10:37:20 PM7/8/14
to juli...@googlegroups.com
I am considering of starting an organization for Quantum (Chemistry&Physics&others) in Julia. Members in this organization can easily share their experiences, and work in a well-organized way, and also attract more users and developers in the common field. So far, it is a pity that there are few packages for quantum science in Julia...  I don't know how far do you want to go in writing Julia packages for quantum chemistry. If you and any of the group members are interested in continuing the Julia journey for quantum science, maybe we should talk. 

Beyond your work, here are some packages I know under this topic:
Quantum.jl -- basic states and operation library for quantum.
QSimulator.jl -- Unitary and Lindbladian evolution in Julia.
Cliffords.jl -- Julia implementation for Cliffords gate simulation.
There are some packages for superconductor circuits control in specific domain. 

Thanks for considering...

Jutho

unread,
Jul 9, 2014, 2:17:27 AM7/9/14
to juli...@googlegroups.com
I'd be happy to contribute. I am working on some code for tensor networks (matrix product states etc), although I don't want to pinpoint a deadline.

Op woensdag 9 juli 2014 04:37:20 UTC+2 schreef Xiaodong Qi:

Jiahao Chen

unread,
Jul 9, 2014, 5:01:38 AM7/9/14
to juli...@googlegroups.com
> I am considering of starting an organization for Quantum
> (Chemistry&Physics&others) in Julia. Members in this organization can easily

+1

It hasn't been that long since I did computational chemistry. I'd be
happy to help.

Thanks,

Jiahao Chen
Staff Research Scientist
MIT Computer Science and Artificial Intelligence Laboratory

Alex

unread,
Jul 9, 2014, 5:07:22 AM7/9/14
to juli...@googlegroups.com
Hi,

I would definitely be interested and might be able to contribute something. I have some code for Lindblad dynamics (Krylov propagator, quantum jump, steady state) and some entanglement measures etc, but I wanted to clean up and document it before making it public. Maybe this provides a good opportunity to do so ...

Best,

Alex.

Rick Muller

unread,
Jul 9, 2014, 12:22:32 PM7/9/14
to juli...@googlegroups.com
I'm interested. I also wrote the beginnings of a vector state simulator in Julia, but it sounds less sophisticated than the stuff that others are talking about.

Jarrett Revels

unread,
Jul 9, 2014, 5:26:06 PM7/9/14
to juli...@googlegroups.com
Hi, I'm the author of Quantum.jl. The package seeks to provide a lot of the basic functionality necessary for a wide array of fundamental quantum work - tensor product structures, abstract state vectors, sparse representations of states and operators, and more. A lot of this functionality has already been implemented. Right now it's in the documentation/testing phase, after which it will be ready for release as an actual package, or at least for use/review by the community. It hasn't been decided whether or not Quantum.jl will merit an official release directly after the documentation/testing is finished (probably in about a week), or whether more optimization work should be done beforehand. 

Xiaodong Qi reached out to me about setting up a communal page of some sort for quantum-related Julia projects, and I think he's onto something there. 
Basically, to anybody wondering whether work is being done to bring quantum mechanics to Julia right now, the answer is yes. We should see 
some progress being made and things being released in the next few weeks.

Xiaodong Qi

unread,
Jul 10, 2014, 1:58:06 AM7/10/14
to juli...@googlegroups.com
Glad to see all of your positive response on initializing the Julia Quantum organization! I just created the organization called JuliaQ on GitHub with Jarrett Revels who has been building a good starting library for our future projects. Please send your GitHub User ID to me so that I can add you into this organization. I have initialized a public page at http://juliaq.github.io/ and all discussions regarding the organization should be posted on our issue tracking page at https://github.com/JuliaQ/JuliaQ.github.io/issues

I will announce JuliaQ in another thread once we have a good shape. Please tell your friends who are interested in contributing to quantum related projects to join us. 
 
PS: I am going to attend a week-long Gordon conference for quantum science in Easton, MA, USA from July 26-Aug 1. I should be able go to MIT for a short visit. If anyone is interested in having a meeting up, we should plan for it... 


On Saturday, June 21, 2014 8:02:37 PM UTC-6, Rick Muller wrote:

Hao Xu

unread,
Jul 23, 2014, 4:25:35 AM7/23/14
to juli...@googlegroups.com

Hi..I am a physics student and I am studying Quantum Mechanics now,and very interesting in the project of JuliaQ. But since I am just learning the Quantum Mechanics these days,I wanna join the development of the JuliaQ  to practice what I learned .And I am in Boston this summer under a Internship of Harvard .So glad to see u at Boston.
在 2014年7月10日星期四UTC-4上午1时58分06秒,Xiaodong Qi写道:

Xiaodong Qi

unread,
Jul 23, 2014, 11:27:42 AM7/23/14
to juli...@googlegroups.com
Glad you find us. The announcement of JuliaQuantum org has been posted in another thread: https://groups.google.com/forum/?fromgroups=#!topic/julia-dev/sEJUskG6Xww. Or, you can visit our website at https://JuliaQuantum.github.io/ . You are invited to join our conversions linked on the website, and we will find out a way for you and others to contribute to the project with your strong suit. Maybe see you in Boston :)
Reply all
Reply to author
Forward
0 new messages