Skip to content

Commit 7d204e1

Browse files
authored
Additional debugging functions for ConstDensitySolver (#140)
add some new public functions to constDensitySolver for getting internally used quantities like hamiltonian for comparison with e.g. barger propagator values for testing / debugging
1 parent a25cf4a commit 7d204e1

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

nuTens/propagator/const-density-solver.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,40 @@ void ConstDensityMatterSolver::calculateEigenvalues(Tensor &eigenvectors, Tensor
66
{
77
NT_PROFILE();
88

9-
hamiltonian.setValue({"..."}, (Tensor::div(diagMassMatrix, energiesRed) - electronOuter));
9+
buildHamiltonian();
1010

1111
Tensor::eigh(hamiltonian, eigenvalues, eigenvectors);
1212

1313
}
1414

15+
void ConstDensityMatterSolver::buildHamiltonian() {
16+
17+
NT_PROFILE();
18+
19+
hamiltonian.setValue({"..."}, (Tensor::div(diagMassMatrix, energiesRed) - electronOuter));
20+
21+
}
22+
23+
Tensor ConstDensityMatterSolver::getHamiltonian() {
24+
25+
NT_PROFILE();
26+
27+
buildHamiltonian();
28+
29+
return hamiltonian;
30+
31+
}
32+
33+
Tensor ConstDensityMatterSolver::getElectronOuterProduct() {
34+
35+
NT_PROFILE();
36+
37+
buildElectronOuterProduct();
38+
39+
return electronOuter;
40+
41+
}
42+
1543
void ConstDensityMatterSolver::buildElectronOuterProduct()
1644
{
1745

nuTens/propagator/const-density-solver.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,28 @@ class ConstDensityMatterSolver : public BaseMatterSolver
115115
return density;
116116
}
117117

118-
/// @brief Set new mass eigenvalues for this solver
119-
/// @param[in] energies Tensor of energies, expected to have a batch
120-
/// dimension and two further dimensions to make casting unambiguous i.e.
121-
/// shape should look like {Nbatches, 1, 1}.
118+
/// @brief Calculate the hamiltonian eigenvalues and eigenvectors, i.e. the effective Mass^2 states and effective mixing matrix
122119
/// @param[out] eigenvectors The returned eigenvectors
123120
/// @param[out] eigenvalues The corresponding eigenvalues
124121
void calculateEigenvalues(Tensor &eigenvectors, Tensor &eigenvalues) override;
125122

123+
/// construct the outer product of the electron row of the mixing matrix, used in building the hamiltonian, and return a copy of it
124+
/// potentially useful for debugging
125+
Tensor getElectronOuterProduct();
126+
127+
/// construct the hamiltonian and return a copy of it
128+
/// potentially useful for debugging
129+
Tensor getHamiltonian();
130+
126131
private:
127132

128133
/// @brief construct the outer product of the electron neutrino row of the mixing
129134
/// matrix used to construct the hamiltonian
130135
void buildElectronOuterProduct();
131136

137+
/// @brief Construct the hamiltonian
138+
void buildHamiltonian();
139+
132140
Tensor mixingMatrix;
133141
Tensor masses;
134142
Tensor diagMassMatrix;

0 commit comments

Comments
 (0)