-
Notifications
You must be signed in to change notification settings - Fork 25
Davidson works when doubles folding in ADC(2) #176
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
base: master
Are you sure you want to change the base?
Changes from all commits
a5ba0e5
615032e
e14f645
23b7557
4906cff
bcc13f9
1197c30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| from .functions import ones_like | ||
| from .Intermediates import Intermediates | ||
| from .AmplitudeVector import AmplitudeVector | ||
|
|
||
| # from .solver.explicit_symmetrisation import IndexSymmetrisation | ||
|
|
||
| class AdcExtraTerm: | ||
| def __init__(self, matrix, blocks): | ||
|
|
@@ -650,3 +650,56 @@ def block_view(self, block): | |
| "projected ADC matrices.") | ||
| # TODO The way to implement this is to ask the inner matrix to | ||
| # a block_view and then wrap that in an AdcMatrixProjected. | ||
|
|
||
|
|
||
| class AdcMatrixFolded(AdcMatrix): | ||
| def __init__(self, matrix): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you initialize the class, you should also set an |
||
| """ | ||
| Initialise a ADC(2) matrix when using doubles-folding. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| matrix : AdcMatrix | ||
| ADC(2) matrix | ||
| """ | ||
| super().__init__(matrix.method, matrix.ground_state, | ||
|
TianLin-228 marked this conversation as resolved.
|
||
| block_orders=matrix.block_orders, | ||
| intermediates=matrix.intermediates) | ||
| if matrix.method.name != "adc2": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an idea for a more general approach: |
||
| raise TypeError("The matrix should be ADC2 Matrix for doubles-folding.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would call it: |
||
|
|
||
| from .solver.explicit_symmetrisation import IndexSymmetrisation | ||
| self.isymm = IndexSymmetrisation(matrix) | ||
|
|
||
| def diagonal(self): | ||
| """ | ||
| Return the approximate diagonal of the ADC(2) matrix with doubles-folding. | ||
| """ | ||
| return AmplitudeVector(ph=super().diagonal().ph) | ||
|
|
||
| def u2_fold(self, other): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename it so that it is a bit more meaningful: |
||
| """ | ||
| Return the doubles component of u in terms of its singles component. | ||
| """ | ||
| diag = super().diagonal().pphh | ||
| e = diag.ones_like() | ||
| u2 = self.block_apply("pphh_ph", other.ph) / (e * self.omega - diag) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to get the correct symmetry: try to explicitly symmetrise it: |
||
| return self.isymm.symmetrise(AmplitudeVector(pphh=u2)) | ||
|
|
||
| def matvec(self, other): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, you can rename |
||
| """ | ||
| Compute the doubles-folded matrix-vector product of the singles vector with | ||
| an effective ADC matrix which depends on the eigenvalue(omega). | ||
| """ | ||
| u2 = self.u2_fold(other) | ||
| return AmplitudeVector(ph=self.block_apply("ph_ph", other.ph) | ||
| + self.block_apply("ph_pphh", u2.pphh)) | ||
|
|
||
| def unfold(self, other): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| """ | ||
| Recompute the doubles component and return the complete vector. | ||
| """ | ||
| other_symm = self.isymm.symmetrise(other) | ||
| u2 = self.u2_fold(other_symm) | ||
|
|
||
| return AmplitudeVector(ph=other_symm.ph, pphh=u2.pphh) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move it into a separate file within the solver directory, since it’s currently quite solver-specific (for example, the
unfold_solutionfunction clearly refers to solving the eigenvalue problem handled in the solver) and specific to ADC(2). I’d also rename it toAdc2MatrixFolded.However, we should consider how to generalize it in the future. :)