JuliaAttic / QuBase.jl

A foundational library for quantum mechanics in Julia
Other
43 stars 6 forks source link

Spin ops refactor for fewer temporary arrays and type stability #28

Closed jrevels closed 9 years ago

jrevels commented 9 years ago

The type instability of spin was making me uneasy, so I fixed it by making it an actual value, which I'm now convinced makes more sense in this context.

In addition, this PR refactors the construction functions we had to avoid making as many temporary arrays.

acroy commented 9 years ago

Thanks, Jarrett! Looks good to me. If you happen to have a reference for the spin operators, it might be good to include it.

jrevels commented 9 years ago

You mean just for explanation's sake? I just added some references to the spin and ladder operators wikipedia pages, let me know if that suffices.

Also, why did we named these functions spin_Jx, spin_Jy, spin_Jz instead of spinx, spiny, spinz? The J makes me think of orbital angular momentum rather than spin. I see that they use J here, though. Is this common/standard? My inexperience is starting to show :)

In the same vein, if we did rename them to spinx etc., perhaps we could rename spin_Jp to spinplus and spin_Jm to spinminus?

BTW, it seems addition/subtraction wasn't imported, so I fixed that on master and merged it back in.

jrevels commented 9 years ago

Also @amitjamadagni my apologies for all of this review/revision happening so late after the initial spin PR, I was quite busy during that time and didn't review as thoroughly as I should have.

amitjamadagni commented 9 years ago

@jrevels sure, no problem, please do let me know if I can chip in here and make any contributions. Thanks.

acroy commented 9 years ago

You mean just for explanation's sake? I just added some references to the spin and ladder operators wikipedia pages, let me know if that suffices.

Yes. I think we should start to add such things at least for the more physics-related stuff. We will have to properly document it anyways and then it will be helpful to have some hint where to look it up.

Also, why did we named these functions spin_Jx, spin_Jy, spin_Jz instead of spinx, spiny, spinz?

Dunno. I am not much of a spin-person, but I guess J is rather angular momentum and S is spin. QuTiP uses J for some reason and I think this was reason for Amit's choice. I am fine with both, spinJ or renaming everything to just spin. As long as we are clear about the definition, it shouldn't really matter.

jrevels commented 9 years ago

After referring to the QuTip page, I just went with removing the caps and underscores to make things easier to type (spinjx, spinjy etc.).

Any qualms before I merge this in (after the build passes, of course)?

acroy commented 9 years ago

Thanks! Looks good to me. If you feel like it, maybe squashing into fewer/single commits would be nice.