Commit 260a4beb by Francois Gygi

modif for use with ElectricEnthalpy

git-svn-id: http://qboxcode.org/svn/qb/branches/efield@1585 cba15fb0-1239-40c8-b417-11db7ca47a34
parent a6c432ac
......@@ -15,7 +15,6 @@
// MLWFTransform.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: MLWFTransform.C,v 1.6 2008-09-08 15:56:18 fgygi Exp $
#include <iostream>
#include <iomanip>
......@@ -33,7 +32,8 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
MLWFTransform::MLWFTransform(const SlaterDet& sd) : sd_(sd),
cell_(sd.basis().cell()), ctxt_(sd.context()), bm_(BasisMapping(sd.basis()))
cell_(sd.basis().cell()), ctxt_(sd.context()), bm_(BasisMapping(sd.basis())),
maxsweep_(50), tol_(1.e-8)
{
a_.resize(6);
adiag_.resize(6);
......@@ -45,6 +45,14 @@ cell_(sd.basis().cell()), ctxt_(sd.context()), bm_(BasisMapping(sd.basis()))
adiag_[k].resize(n);
}
u_ = new DoubleMatrix(ctxt_,n,n,nb,nb);
sdcosx_ = new SlaterDet(sd_);
sdcosy_ = new SlaterDet(sd_);
sdcosz_ = new SlaterDet(sd_);
sdsinx_ = new SlaterDet(sd_);
sdsiny_ = new SlaterDet(sd_);
sdsinz_ = new SlaterDet(sd_);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -53,24 +61,26 @@ MLWFTransform::~MLWFTransform(void)
for ( int k = 0; k < 6; k++ )
delete a_[k];
delete u_;
delete sdcosx_;
delete sdcosy_;
delete sdcosz_;
delete sdsinx_;
delete sdsiny_;
delete sdsinz_;
}
////////////////////////////////////////////////////////////////////////////////
void MLWFTransform::compute_transform(void)
void MLWFTransform::update(void)
{
const int maxsweep = 50;
const double tol = 1.e-8;
SlaterDet sdcosx(sd_), sdsinx(sd_),
sdcosy(sd_), sdsiny(sd_),
sdcosz(sd_), sdsinz(sd_);
// recompute cos and sin matrices
const ComplexMatrix& c = sd_.c();
ComplexMatrix& ccosx = sdcosx.c();
ComplexMatrix& csinx = sdsinx.c();
ComplexMatrix& ccosy = sdcosy.c();
ComplexMatrix& csiny = sdsiny.c();
ComplexMatrix& ccosz = sdcosz.c();
ComplexMatrix& csinz = sdsinz.c();
ComplexMatrix& ccosx = sdcosx_->c();
ComplexMatrix& csinx = sdsinx_->c();
ComplexMatrix& ccosy = sdcosy_->c();
ComplexMatrix& csiny = sdsiny_->c();
ComplexMatrix& ccosz = sdcosz_->c();
ComplexMatrix& csinz = sdsinz_->c();
// proxy real matrices cr, cc, cs
DoubleMatrix cr(c);
DoubleMatrix ccx(ccosx);
......@@ -184,8 +194,11 @@ void MLWFTransform::compute_transform(void)
a_[4]->ger(-1.0,cr,0,ccz,0);
a_[5]->gemm('t','n',2.0,cr,csz,0.0);
a_[5]->ger(-1.0,cr,0,csz,0);
int nsweep = jade(maxsweep,tol,a_,*u_,adiag_);
}
////////////////////////////////////////////////////////////////////////////////
void MLWFTransform::compute_transform(void)
{
int nsweep = jade(maxsweep_,tol_,a_,*u_,adiag_);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -15,7 +15,6 @@
// MLWFTransform.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: MLWFTransform.h,v 1.5 2008-09-08 15:56:18 fgygi Exp $
#ifndef MLWFTRANSFORM_H
#define MLWFTRANSFORM_H
......@@ -39,15 +38,38 @@ class MLWFTransform
BasisMapping bm_;
std::vector<DoubleMatrix*> a_; // cosine and sine matrices
DoubleMatrix* u_; // orthogonal transformation
std::vector<std::vector<double> > adiag_; // diagonal elements
std::vector<std::vector<double> > adiag_; // diagonal elements adiag_[k][i]
SlaterDet *sdcosx_, *sdsinx_,
*sdcosy_, *sdsiny_,
*sdcosz_, *sdsinz_;
double tol_;
int maxsweep_;
public:
DoubleMatrix* a(int k) { return a_[k]; };
SlaterDet* sdcosx(void) { return sdcosx_; };
SlaterDet* sdcosy(void) { return sdcosy_; };
SlaterDet* sdcosz(void) { return sdcosz_; };
SlaterDet* sdsinx(void) { return sdsinx_; };
SlaterDet* sdsiny(void) { return sdsiny_; };
SlaterDet* sdsinz(void) { return sdsinz_; };
// diagonal element i of matrix a_[k]
double adiag(int k, int i) { return adiag_[k][i]; }
void update(void); // compute matrices for Berry phase and MLWF
void compute_transform(void);
void compute_sincos(const int n, const std::complex<double>* f,
std::complex<double>* fc, std::complex<double>* fs);
void apply_transform(SlaterDet& sd);
void set_tol(double t) { tol_ = t; }
void set_maxsweep(int n) { maxsweep_ = n; }
double spread2(int i, int j);
double spread2(int i);
double spread2(void);
......
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