Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding Kronecker products using method similar Celio's #74 #80

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joelvdavies
Copy link
Contributor

@joelvdavies joelvdavies commented Mar 24, 2023

This PR is a bit of a mess and should not be merged unless cleaned up and thoroughly tested. It essentially copies CelioHamiltonian and Hamiltonian into a class Hamiltonian2 and keeps all interaction matrices small, constructing the full hamiltonian only when its about to be diagonalized. Its based on #79 and uses dense matrices everywhere.

The system

name
    Test
spins
    e mu H
hyperfine 2
    580 5   10
    5   580 9
    10  9   580
hyperfine 3
    150 3   4
    3   150 5
    4   5   150
orientation
    zcw(20)
field
    range(1.8, 2.6, 100)
experiment
    alc

Takes ~14 seconds (4 of which are the construction of the hamiltonian). Using dense matrices alone it takes around 9 seconds.

name
   Test
spins
   mu 13e 13e 5e
dipolar 1 2
   0 0 1
dipolar 1 3
   0 0 -1
dipolar 1 4
   0 0 1
time
   range(0, 0.1, 500)

Goes from using 800Mb down to 500 (from 2.1Gb without the method and just using dense), and from 298 seconds down to 60. The performance can likely be further improved using parallelised C++ for constructing the Hamiltonian. Most of the memory usage saving is actually due to commenting out the construction of self._single_spinops in experiment.py. This should only be used if necessary as the matrices are all large. Perhaps this should just be left as sparse for the time being?

The linbladian would still need something similar - only constructing the full matrix just before its used.

The branch itself is referenced here: https://github.com/muon-spectroscopy-computational-project/Developer-notes/blob/main/muspinsim/improving_sparse_matrices.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant