Commit b6b1dd62 by Francois Gygi

Fixed use of preconditioner


git-svn-id: http://qboxcode.org/svn/qb/trunk@192 cba15fb0-1239-40c8-b417-11db7ca47a34
parent c8d415f5
......@@ -3,7 +3,7 @@
// PSDAWavefunctionStepper.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: PSDAWavefunctionStepper.C,v 1.6 2004-03-18 20:07:18 fgygi Exp $
// $Id: PSDAWavefunctionStepper.C,v 1.7 2004-04-17 01:15:55 fgygi Exp $
#include "PSDAWavefunctionStepper.h"
#include "Wavefunction.h"
......@@ -60,17 +60,20 @@ void PSDAWavefunctionStepper::update(Wavefunction& dwf)
double* dc = (double*) dwf.sd(ispin,ikp)->c().valptr();
double* dc_last = (double*) dwf_last_.sd(ispin,ikp)->c().valptr();
const int mloc = wf_.sd(ispin,ikp)->c().mloc();
const int ngwl = wf_.sd(ispin,ikp)->basis().localsize();
const int nloc = wf_.sd(ispin,ikp)->c().nloc();
// next line: add enhancement factor to descent direction
// since there is no instability of the Anderson iteration
// This improves convergence in most cases
const double psda_enhancement_factor = 2.0;
for ( int n = 0; n < nloc; n++ )
{
// note: double mloc length for complex<double> indices
double* dcn = &dc[2*mloc*n];
for ( int i = 0; i < mloc; i++ )
// loop to ngwl only since diag[i] is not defined on [0:mloc-1]
for ( int i = 0; i < ngwl; i++ )
{
const double fac = diag[i];
const double f0 = -psda_enhancement_factor*fac * dcn[2*i];
......@@ -81,7 +84,7 @@ void PSDAWavefunctionStepper::update(Wavefunction& dwf)
}
// dwf now contains the preconditioned descent
// direction -K(HV-VA)
// Anderson extrapolation
if ( extrapolate_ )
{
......@@ -177,9 +180,9 @@ void PSDAWavefunctionStepper::update(Wavefunction& dwf)
extrapolate_ = true;
enum ortho_type { GRAM, LOWDIN, ORTHO_ALIGN, RICCATI };
//const ortho_type ortho = GRAM;
//const ortho_type ortho = LOWDIN;
const ortho_type ortho = ORTHO_ALIGN;
//const ortho_type ortho = GRAM;
switch ( ortho )
{
......
......@@ -3,7 +3,7 @@
// PSDWavefunctionStepper.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: PSDWavefunctionStepper.C,v 1.4 2004-03-11 21:52:31 fgygi Exp $
// $Id: PSDWavefunctionStepper.C,v 1.5 2004-04-17 01:15:55 fgygi Exp $
#include "PSDWavefunctionStepper.h"
#include "Wavefunction.h"
......@@ -62,13 +62,15 @@ void PSDWavefunctionStepper::update(Wavefunction& dwf)
const double* dcoeff =
(const double*) dwf.sd(ispin,ikp)->c().cvalptr();
const int mloc = wf_.sd(ispin,ikp)->c().mloc();
const int ngwl = wf_.sd(ispin,ikp)->basis().localsize();
const int nloc = wf_.sd(ispin,ikp)->c().nloc();
for ( int n = 0; n < nloc; n++ )
{
// note: double mloc length for complex<double> indices
double* c = &coeff[2*mloc*n];
const double* dc = &dcoeff[2*mloc*n];
for ( int i = 0; i < mloc; i++ )
// loop to ngwl only since diag[i] is not defined on [0:mloc-1]
for ( int i = 0; i < ngwl; i++ )
{
const double fac = diag[i];
const double delta_re = fac * dc[2*i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment