18 m_electronSystem(basisFunction),
19 m_convergenceTreshold(1e-8),
20 m_nIterationsMax(1e3),
21 m_densityMixFactor(0.5),
28 cleanUpCoupledMatrix();
33 allocateCoupledMatrix();
35 m_hasBeenSetup =
true;
54 setupUncoupledMatrix();
56 setupTransformationMatrix();
60 void HartreeFockSolver::allocateCoupledMatrix() {
63 m_coupledMatrix.set_size(n,n);
64 for(
int i = 0; i < int(n); i++) {
65 for(
int j = 0; j < int(n); j++) {
66 m_coupledMatrix(i,j) = zeros(n,n);
71 void HartreeFockSolver::setupTransformationMatrix()
76 m_transformationMatrix = U*diagmat(1.0/sqrt(s));
79 void HartreeFockSolver::cleanUpCoupledMatrix() {
80 m_coupledMatrix.reset();
83 void HartreeFockSolver::setupOverlapMatrix() {
86 m_overlapMatrix.reset();
87 m_overlapMatrix = zeros(nOrbitals,nOrbitals);
88 for(uint p = 0; p < nOrbitals; p++) {
89 for(uint q = 0; q < nOrbitals; q++) {
95 void HartreeFockSolver::setupUncoupledMatrix() {
98 m_uncoupledMatrix.reset();
99 m_uncoupledMatrix = zeros(nOrbitals,nOrbitals);
100 for(uint p = 0; p < nOrbitals; p++) {
101 for(uint q = 0; q < nOrbitals; q++) {
107 void HartreeFockSolver::setupCoupledMatrix() {
110 for(uint p = 0; p < n; p++) {
111 for(uint r = 0; r < n; r++) {
112 for(uint q = p; q < n; q++) {
113 for(uint s = r; s < n; s++) {
121 for(uint p = 0; p < n; p++) {
122 for(uint r = 0; r < n; r++) {
123 for(uint q = p; q < n; q++) {
124 for(uint s = r; s < n; s++) {
125 double originalValue = m_coupledMatrix(p,r)(q,s);
126 m_coupledMatrix(q,s)(p,r) = originalValue;
127 m_coupledMatrix(q,r)(p,s) = originalValue;
128 m_coupledMatrix(p,s)(q,r) = originalValue;
129 m_coupledMatrix(r,p)(s,q) = originalValue;
130 m_coupledMatrix(s,p)(r,q) = originalValue;
131 m_coupledMatrix(r,q)(s,p) = originalValue;
132 m_coupledMatrix(s,q)(r,p) = originalValue;
143 uint nk = nParticles;
145 const mat& S = m_overlapMatrix;
146 mat& C = coefficientMatrix;
148 for(uint k = 0; k < nk; k++) {
150 for(uint p = 0; p < no; p++){
151 for(uint q = 0; q < no; q++){
152 factor += C(p,k) * S(p,q) * C(q,k);
155 C.col(k) = C.col(k) / sqrt(factor);
166 return m_convergenceTreshold;
175 m_electronSystem = basisFunction;
179 return m_electronSystem;
183 return m_overlapMatrix;
188 return m_transformationMatrix;
193 return m_coupledMatrix;
198 return m_nIterationsMax;
208 return m_uncoupledMatrix;
213 return m_densityMixFactor;