Kindfield
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Friends Pages
Public Member Functions | List of all members
RestrictedHartreeFockSolver Class Reference

Solver for the Roothan equation. More...

#include <restrictedhartreefocksolver.h>

Inheritance diagram for RestrictedHartreeFockSolver:
Inheritance graph
[legend]
Collaboration diagram for RestrictedHartreeFockSolver:
Collaboration graph
[legend]

Public Member Functions

 RestrictedHartreeFockSolver (ElectronSystem *electronSystem)
 
virtual ~RestrictedHartreeFockSolver ()
 
virtual void setup ()
 
virtual void advance ()
 
virtual void solve ()
 
virtual double energy ()
 
const mat & densityMatrix () const
 
const mat & coefficientMatrix () const
 
void setInitialCoefficientMatrix (const mat &coefficients)
 
- Public Member Functions inherited from HartreeFockSolver
 HartreeFockSolver (ElectronSystem *electronSystem)
 
virtual ~HartreeFockSolver ()
 
void setElectronSystem (ElectronSystem *electronSystem)
 
ElectronSystemelectronSystem ()
 
double convergenceTreshold () const
 
void setConvergenceTreshold (double convergenceTreshold)
 
int iterationsUsed () const
 
int nIterationsMax () const
 
void setNIterationsMax (int nIterationsMax)
 
const mat & uncoupledMatrix () const
 
const mat & overlapMatrix () const
 
const mat & transformationMatrix () const
 
const field< mat > & coupledMatrix () const
 
double densityMixFactor () const
 
void setDensityMixFactor (double densityMixFactor)
 

Additional Inherited Members

- Public Attributes inherited from HartreeFockSolver
double alpha [4]
 
- Protected Member Functions inherited from HartreeFockSolver
void setupIntegralMatrices ()
 
void normalizeCoefficientMatrix (uint nParticles, mat &coefficientMatrix)
 
- Protected Attributes inherited from HartreeFockSolver
int m_iterationsUsed
 

Detailed Description

Solver for the Roothan equation.

Definition at line 7 of file restrictedhartreefocksolver.h.

Constructor & Destructor Documentation

RestrictedHartreeFockSolver::RestrictedHartreeFockSolver ( ElectronSystem electronSystem)

Definition at line 10 of file restrictedhartreefocksolver.cpp.

10  :
11  HartreeFockSolver(electronSystem),
12  m_initialCoefficientMatrixSetManually(false)
13 {
14 }
RestrictedHartreeFockSolver::~RestrictedHartreeFockSolver ( )
virtual

Definition at line 16 of file restrictedhartreefocksolver.cpp.

17 {
18 
19 }

Member Function Documentation

void RestrictedHartreeFockSolver::advance ( )
virtual

Reimplemented from HartreeFockSolver.

Definition at line 69 of file restrictedhartreefocksolver.cpp.

69  {
72  uint no = f->nBasisFunctions();
73  uint nk = f->nParticles() / 2;
74  setupFockMatrix();
75 
76  const mat &V = transformationMatrix();
77 
78  const mat &F = m_fockMatrix;
79  mat Fprime = V.t() * F * V;
80 
81  mat Cprime;
82  eig_sym(m_fockEnergies, Cprime, Fprime);
83 
84 
85  mat &C = m_coefficientMatrix;
86  C = V*Cprime.submat(0, 0, no - 1, nk - 1);
88 
89  setupDensityMatrix();
90 
91  double energy = 0;
92 
93  const mat& P = m_densityMatrix;
94  const mat& h = uncoupledMatrix();
95  for(uint p = 0; p < no; p++) {
96  for(uint q = 0; q < no; q++) {
97  energy += P(p,q) * h(p,q);
98  }
99  }
100 
101  for(uint p = 0; p < no; p++) {
102  for(uint q = 0; q < no; q++) {
103  for(uint r = 0; r < no; r++) {
104  for(uint s = 0; s < no; s++) {
105  double Qtilde = coupledMatrixTilde(p, q, r, s);
106  energy += 0.25 * Qtilde * P(p,q) * P(s,r);
107  }
108  }
109  }
110  }
111  energy += electronSystem()->additionalEnergyTerms();
112  m_energy = energy;
113 }
const mat & RestrictedHartreeFockSolver::coefficientMatrix ( ) const

Definition at line 141 of file restrictedhartreefocksolver.cpp.

142 {
143  return m_coefficientMatrix;
144 }
const mat & RestrictedHartreeFockSolver::densityMatrix ( ) const

Definition at line 136 of file restrictedhartreefocksolver.cpp.

137 {
138  return m_densityMatrix;
139 }
double RestrictedHartreeFockSolver::energy ( )
virtual

Implements HartreeFockSolver.

Definition at line 131 of file restrictedhartreefocksolver.cpp.

132 {
133  return m_energy;
134 }
void RestrictedHartreeFockSolver::setInitialCoefficientMatrix ( const mat &  coefficients)

Definition at line 56 of file restrictedhartreefocksolver.cpp.

57 {
58  m_initialCoefficientMatrixSetManually = true;
59  m_initialCoefficientMatrix = coefficients;
60 }
void RestrictedHartreeFockSolver::setup ( )
virtual

Reimplemented from HartreeFockSolver.

Definition at line 62 of file restrictedhartreefocksolver.cpp.

62  {
64  resetCoefficientMatrix();
65  resetFockMatrix();
66  setupDensityMatrix();
67 }
void RestrictedHartreeFockSolver::solve ( )
virtual

Reimplemented from HartreeFockSolver.

Definition at line 115 of file restrictedhartreefocksolver.cpp.

115  {
117  for(int i = 0; i < nIterationsMax(); i++) {
118  vec previousFockEnergies = m_fockEnergies;
119  advance();
120  if(i > 0) {
121  double averageEnergyChange = sum(abs(m_fockEnergies - previousFockEnergies))
122  / m_fockEnergies.n_elem;
123  if(averageEnergyChange < convergenceTreshold()) {
124  m_iterationsUsed = i;
125  break;
126  }
127  }
128  }
129 }

The documentation for this class was generated from the following files: