PageRenderTime 51ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/python/README.rst

https://bitbucket.org/mforbes/paper_dvrvsho
ReStructuredText | 96 lines | 83 code | 13 blank | 0 comment | 0 complexity | 47cfd1b92fab902806e1359ecc549279 MD5 | raw file
  1. .. -*- rst -*- -*- restructuredtext -*-
  2. .. This file should be written using the restructure text
  3. .. conventions. It will be displayed on the bitbucket source page and
  4. .. serves as the documentation of the directory.
  5. .. default-role:: math
  6. =============================
  7. Python Implementation Notes
  8. =============================
  9. This file documents some implementation details. Additional notes, test-cases,
  10. and usage can be found in the documented source-code.
  11. Bases
  12. =====
  13. Several different bases are provided in ``bases.py``. We generally advocate
  14. using the ``Fourier`` basis as this is faster (kinetic energy uses the FFTW_).
  15. Originally the ``Dirichlet`` basis was used to provide upper bounds, but
  16. similar bounds can now be obtained with the ``Fourier`` basis using twisted
  17. boundary conditions by applying ``theta_bloch=np.pi``. This augments all
  18. plane-waves with an overall phase `e^{i \theta_B L x} = e^{i k_B x}`.
  19. The choice ``theta_bloch=np.pi`` thus enforces anti-symmetric boundary
  20. conditions. In combination with even parity of the ground state this
  21. effectively enforces Dirichlet boundary conditions and one finds that (once UV
  22. convergence is obtained) the same upper bound is achieved.
  23. Triton and Alpha Particles
  24. ==========================
  25. The directory ``shell_model`` contains Python code for using DVR bases for
  26. a brute force solution to the few-body problem for three- and four-particle
  27. states with simple attractive s-wave interaction. We apply a DVR basis to the
  28. relative Jacobi coordinates to find the three-body ("triton") and four-body
  29. ("alpha particle") bound states. This code requires a few more components to
  30. function efficiently in particular, numexpr_ and anfft_ which wraps the
  31. FFTW_. (The code should still run, albeit more slowly, if these are not
  32. installed.
  33. Using this code, one can find the lowest energy states using a simple Lanczos_
  34. iteration with lattices of up to `18\times 18\times 18` for the "triton" and
  35. `8\times 8 \times 8` for the "alpha particle". These correspond to
  36. wavefunctions with `18^6\approx 10^8` and `8^9\approx 10^8` components (1GB per
  37. wavefunction) respectively, requiring about 12GB of RAM, and can be solved in
  38. less than an hour on a modern laptop. (A more careful implementation caching
  39. matrices on disk and using an in-place FFT could extend these to about `10^9`
  40. components.) This is a fairly straightforward implementation: we have not
  41. attempted to use any special features such a symmetries of the ground state
  42. to reduce the size of the basis.
  43. The python code is organized into the following files:
  44. ``shell_model.py``:
  45. The main code defining the units, problem, Hamiltonian etc.
  46. ``dvr.py``:
  47. Various 1D DVR basis sets including Dirichlet and Sinc bases.
  48. ``bases.py``:
  49. Provides full basis sets for the few-body problem constructed from the DVR
  50. and Fourier bases. Also defines the ``RelCoord`` class which specifies the
  51. appropriate transformations for converting relative Jacobi coordinates to
  52. absolute coordinates for the three- and four-body systems.
  53. ``solvers.py``:
  54. Code for the Lanczos_ solver that finds the lowest few states of the
  55. Hamiltonian. Note: this is a simple implementation that does not implement
  56. re-orthogonalization schemes (to save memory) but works sufficiently well for
  57. the problems considered here.
  58. ``utils.py``:
  59. Tries to implement numexpr_ and anfft_, warning the user about potential
  60. performance problems if these are not provided.
  61. ``figures.py``:
  62. Some code for automating the generation of energies used in the paper.
  63. .. _DVR_Demo.py: \
  64. https://bitbucket.org/mforbes/paper_dvrvsho/src/tip/DVR_Demo.py
  65. .. _plots.py: \
  66. https://bitbucket.org/mforbes/paper_dvrvsho/src/tip/plots.py
  67. .. _View the DVR_Demo Notebook: \
  68. http://nbviewer.ipython.org/urls/bitbucket.org/mforbes/paper_dvrvsho/raw/tip/DVR_Demo.ipynb
  69. .. |EPD| replace:: Enthough Python Distribution (EPD_)
  70. .. _EPD: http://www.enthought.com/products/epd.php
  71. .. _IPython: http://ipython.org/
  72. .. _Ipython notebook: \
  73. http://ipython.org/ipython-doc/dev/interactive/htmlnotebook.html
  74. .. _SciPy: http://www.scipy.org/
  75. .. _NumPy: http://numpy.scipy.org/
  76. .. _matplotlib: http://matplotlib.org/
  77. .. _SymPy: http://sympy.org/
  78. .. _IPython Notebook Viewer: http://nbviewer.ipython.org/
  79. .. _pymmf: https://bitbucket.org/mforbes/pymmf
  80. .. _numexpr: http://code.google.com/p/numexpr/
  81. .. _anfft: https://code.google.com/p/anfft/
  82. .. _FFTW: http://www.fftw.org
  83. .. _Lanczos: http://en.wikipedia.org/wiki/Lanczos_algorithm