Commit 8ae210ec by Francois Gygi

rel1_46_0


git-svn-id: http://qboxcode.org/svn/qb/trunk@684 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 0baddf85
......@@ -11,7 +11,7 @@
# or <http://www.gnu.org/licenses/>.
#
#-------------------------------------------------------------------------------
# $Id: Makefile,v 1.59 2008-11-14 04:08:05 fgygi Exp $
# $Id: Makefile,v 1.60 2009-03-08 01:16:33 fgygi Exp $
#------------------------------------------------------------------------------
#
include $(TARGET).mk
......@@ -238,15 +238,14 @@ bisection1.o: Context.h Sample.h AtomSet.h Atom.h D3vector.h UnitCell.h
bisection1.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
bisection1.o: SampleReader.h Basis.h FourierTransform.h Timer.h SlaterDet.h
bisection1.o: Matrix.h
bisection-2008-10-23.o: Context.h Sample.h AtomSet.h Atom.h D3vector.h
bisection-2008-10-23.o: UnitCell.h ConstraintSet.h Wavefunction.h
bisection-2008-10-23.o: SharedFilePtr.h Control.h SampleReader.h
bisection-2008-10-23.o: SampleWriter.h Basis.h FourierTransform.h Timer.h
bisection-2008-10-23.o: SlaterDet.h Matrix.h isodate.h jade.h
bisection.o: Context.h Sample.h AtomSet.h Atom.h D3vector.h UnitCell.h
bisection.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
bisection.o: SampleReader.h SampleWriter.h Basis.h FourierTransform.h Timer.h
bisection.o: SlaterDet.h Matrix.h isodate.h jade.h
bisection_level4.o: Context.h Sample.h AtomSet.h Atom.h D3vector.h UnitCell.h
bisection_level4.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
bisection_level4.o: SampleReader.h SampleWriter.h Basis.h FourierTransform.h
bisection_level4.o: Timer.h SlaterDet.h Matrix.h isodate.h jade.h
bisection_save.o: Context.h Sample.h AtomSet.h Atom.h D3vector.h UnitCell.h
bisection_save.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
bisection_save.o: SampleReader.h SampleWriter.h Basis.h FourierTransform.h
......@@ -293,6 +292,8 @@ ChargeDensity.o: SlaterDet.h Matrix.h
ChargeDensity.o: Timer.h Context.h
ChargeMixCoeff.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
ChargeMixCoeff.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
ChargeMixNdim.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
ChargeMixNdim.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
ChargeMixRcut.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
ChargeMixRcut.o: ConstraintSet.h Wavefunction.h SharedFilePtr.h Control.h
ComputeMLWFCmd.o: ComputeMLWFCmd.h UserInterface.h Sample.h AtomSet.h
......@@ -459,10 +460,10 @@ qb.o: FoldInWsCmd.h HelpCmd.h KpointCmd.h ListAtomsCmd.h ListSpeciesCmd.h
qb.o: LoadCmd.h MoveCmd.h PrintCmd.h QuitCmd.h RandomizeWfCmd.h ResetVcmCmd.h
qb.o: RunCmd.h SaveCmd.h SetCmd.h SpeciesCmd.h StatusCmd.h StrainCmd.h
qb.o: TorsionCmd.h AtomsDyn.h Cell.h CellDyn.h SlaterDet.h Basis.h Matrix.h
qb.o: CellLock.h CellMass.h ChargeMixCoeff.h ChargeMixRcut.h Debug.h Ecut.h
qb.o: Ecutprec.h Ecuts.h Emass.h ExtStress.h FermiTemp.h Dt.h Nempty.h
qb.o: NetCharge.h Nrowmax.h RefCell.h Stress.h Thermostat.h ThTemp.h ThTime.h
qb.o: ThWidth.h WfDiag.h WfDyn.h Xc.h
qb.o: CellLock.h CellMass.h ChargeMixCoeff.h ChargeMixNdim.h ChargeMixRcut.h
qb.o: Debug.h Ecut.h Ecutprec.h Ecuts.h Emass.h ExtStress.h FermiTemp.h Dt.h
qb.o: Nempty.h NetCharge.h Nrowmax.h RefCell.h Stress.h Thermostat.h ThTemp.h
qb.o: ThTime.h ThWidth.h WfDiag.h WfDyn.h Xc.h
qbox_xmlns.o: qbox_xmlns.h
QuitCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h D3vector.h
QuitCmd.o: UnitCell.h ConstraintSet.h Wavefunction.h SharedFilePtr.h
......@@ -630,7 +631,7 @@ truncateMLWF.o: Timer.h SlaterDet.h Matrix.h isodate.h jade.h MLWFTransform.h
truncateMLWF.o: BasisMapping.h ComputeMLWFCmd.h UserInterface.h
UnitCell.o: UnitCell.h D3vector.h
UnitCell.o: D3vector.h
UserInterface.o: UserInterface.h
UserInterface.o: UserInterface.h qbox_xmlns.h
Wavefunction.o: Wavefunction.h D3vector.h UnitCell.h SharedFilePtr.h
Wavefunction.o: SlaterDet.h Context.h Basis.h Matrix.h Timer.h jacobi.h
Wavefunction.o: D3vector.h UnitCell.h SharedFilePtr.h
......
......@@ -15,7 +15,7 @@
// BLAS Header file
//
////////////////////////////////////////////////////////////////////////////////
// $Id: blas.h,v 1.8 2008-09-08 15:56:19 fgygi Exp $
// $Id: blas.h,v 1.9 2009-03-08 01:16:33 fgygi Exp $
#ifndef BLAS_H
#define BLAS_H
......@@ -39,6 +39,7 @@
#define dgemv dgemv_
#define dscal dscal_
#define dsyev dsyev_
#define dsysv dsysv_
#define zdscal zdscal_
#define idamax idamax_
#define dvea dvea_
......@@ -53,13 +54,13 @@ FTN_LINK {
#endif
void dcopy(int *n, double *x, int *incx,
double *y, int *incy );
double *y, int *incy );
void zcopy(int *n, std::complex<double> *x, int *incx,
std::complex<double> *y, int *incy );
std::complex<double> *y, int *incy );
void daxpy(int *n, double *alpha, double *x, int *incx,
double *y, int *incy );
double *y, int *incy );
double ddot(const int *n, const double *a, const int *inca,
const double *b, const int *incb);
const double *b, const int *incb);
double dnrm2(const int *n, const double *a, const int *inca);
void drot(int*, double*, int*, double*, int*, double*, double*);
void dgemm(char *ta, char *tb, int *m, int *n, int *k,
......@@ -70,31 +71,32 @@ void zgemm(char *ta, char *tb, int *m, int *n, int *k,
std::complex<double> *b, int *ldb,
std::complex<double> *beta, std::complex<double> *c, int *ldc);
void dgemv( char *ta, int *m, int *n,
double *alpha, double *a, int *tda,
double *x, int *incx,
double *beta, double *y, int *incy );
double *alpha, double *a, int *tda,
double *x, int *incx,
double *beta, double *y, int *incy );
void dger(int *,int *, double *, double *, int *,
double *, int *, double *, int *);
double *, int *, double *, int *);
void dscal(int *len, double *alpha, double *x, int *incx);
double dasum(int *len, double *x, int *incx);
int idamax(int *len, double *x, int *incx);
double dasum(int *len, double *x, int *incx);
int idamax(int *len, double *x, int *incx);
void dsyev(char *c1,char *c2,int *n,
double *a,int *lda, double *wr,
double *wrk,int *lwrk, int *ierr);
double *a,int *lda, double *wr,
double *wrk,int *lwrk, int *ierr);
void dsysv(char*,int*,int*,double*,int*,int*,double*,int*,double*,int*,int*);
void zdscal_(int *n,double *alpha,std::complex<double> *x,int *incx);
void dgbmv(char *trans, int *m, int *n,
int *kl, int *ku, double *alpha, double *a,
int *lda, double *x, int *incx, double *beta,
double *y, int *incy);
int *kl, int *ku, double *alpha, double *a,
int *lda, double *x, int *incx, double *beta,
double *y, int *incy);
void dsbmv(char *uplo, int *n, int *k,
double *alpha, double *a, int *lda, double *x, int *incx,
double *beta, double *y, int *incy);
double *alpha, double *a, int *lda, double *x, int *incx,
double *beta, double *y, int *incy);
void sspev(char *vec,char *uplo,int *size,double *ap,
double *wr,double *z,int *n,double *wrk,int *ierr);
double *wr,double *z,int *n,double *wrk,int *ierr);
void dgesv(int *n, int *nrhs, double *a, int *lda, int *ipiv,
double *b, int *ldb, int *info);
double *b, int *ldb, int *info);
void dvea(int*,double*,int*,double*,int*,double*,int*);
void dyax(int*,double*,double*,int*,double*,int*);
......
TODO: change all char* name() functions to const char* name ()
(causes warning at compile time on tribe).
--------------------------------------------------------------------------------
To fix memory leaks:
(check with valgrind on melodie:
mpirun -np 1 /usr/bin/valgrind --leak-check=full --show-reachable=yes \
../../src/qb t.i 2>&1 | tee valgrind.r
see: http://valgrind.org/docs/manual/mc-manual.html
rel1_46_0
AndersonMixer.C, BOSampleStepper.C: Implemented multidimensional Anderson
acceleration of charge mixing.
Added charge_mix_ndim to specify dimension of Anderson acceleration of
charge mixing. charge_mix_ndim=0 results in simple mixing.
--------------------------------------------------------------------------------
rel1_45_3
UserInterface.C: modified server mode to allow multiple commands in input file.
......
......@@ -15,17 +15,18 @@
# x8664_gcc.mk
#
#-------------------------------------------------------------------------------
# $Id: pavane.mk,v 1.8 2008-09-08 15:56:20 fgygi Exp $
# $Id: pavane.mk,v 1.9 2009-03-08 01:16:33 fgygi Exp $
#
PLT=Linux_x8664
#-------------------------------------------------------------------------------
GCCDIR=/usr/lib/gcc/x86_64-redhat-linux/3.4.3
#MPIDIR=$(HOME)/software/mpich/mpich-1.2.6
MPIDIR=/opt/mpich-1.2.6
MPIDIR=/opt/mpich-1.2.7p1
XERCESCDIR=$(HOME)/software/xerces/Linux_x8664/xerces-c-src_2_7_0
PLTOBJECTS = readTSC.o
CXX=/usr/bin/g++
#CXX=/usr/bin/g++
CXX=mpicxx
LD=$(CXX)
PLTFLAGS += -DIA32 -DUSE_FFTW -D_LARGEFILE_SOURCE \
......@@ -42,13 +43,16 @@
CXXFLAGS= -g -Wunused -D$(PLT) $(INCLUDE) $(PLTFLAGS) $(DFLAGS)
LIBPATH = -L$(GCCDIR)/lib -L$(FFTWDIR)/.libs -L/usr/X11R6/lib \
LIBPATH = -L$(FFTWDIR)/.libs -L/usr/X11R6/lib \
-L$(MPIDIR)/lib -L$(BLASDIR) -L$(LAPACKDIR) \
-L$(XERCESCDIR)/lib -L$(HOME)/lib
LIBS = $(PLIBS) $(GCCDIR)/libg2c.a -lfftw \
-llapack -lblas -lm -lmpich \
$(XERCESCDIR)/lib/libxerces-c.a
LIBS = $(PLIBS) -lpthread -lfftw \
-llapack -lm -Xlinker -Bstatic \
-lc -lgfortran -static-libgcc -lmpich -lxerces-c \
-Xlinker -Bdynamic
#LIBS = $(PLIBS) -lfftw -llapack -lblas -lm -lmpich \
# $(XERCESCDIR)/lib/libxerces-c.a
LDFLAGS = $(LIBPATH) $(LIBS)
......
......@@ -15,10 +15,10 @@
// release.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: release.C,v 1.68 2008-12-04 20:04:02 fgygi Exp $
// $Id: release.C,v 1.69 2009-03-08 01:16:33 fgygi Exp $
#include "release.h"
std::string release(void)
{
return std::string("1.45.3");
return std::string("1.46.0");
}
......@@ -15,7 +15,7 @@
// testAndersonMixer.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: testAndersonMixer.C,v 1.6 2008-11-14 04:08:05 fgygi Exp $
// $Id: testAndersonMixer.C,v 1.7 2009-03-08 01:16:33 fgygi Exp $
#include <iostream>
......@@ -25,14 +25,21 @@ using namespace std;
#include "Context.h"
#include "AndersonMixer.h"
// use: testAndersonMixer ndim nmax niter
int main(int argc, char** argv)
{
#if USE_MPI
MPI_Init(&argc,&argv);
#endif
{
const int ndim = 20;
const int niter = 10;
if ( argc != 4 )
{
cout << " use: testAndersonMixer ndim nmax niter" << endl;
return 1;
}
const int ndim = atoi(argv[1]);
const int nmax = atoi(argv[2]);
const int niter = atoi(argv[3]);
Context ctxt;
......@@ -41,29 +48,32 @@ int main(int argc, char** argv)
PMPI_Get_processor_name(processor_name,&namelen);
// cout << " Process " << ctxt.mype() << " on " << processor_name << endl;
const double alpha = 1.0;
vector<double> x,f,xlast,fbar;
double theta;
const double alpha = 0.1;
vector<double> x,f,xbar,fbar;
x.resize(ndim);
xlast.resize(ndim);
f.resize(ndim);
xbar.resize(ndim);
fbar.resize(ndim);
AndersonMixer mixer(x.size(),&ctxt);
AndersonMixer mixer(ndim,nmax,&ctxt);
for ( int i = 0; i < ndim; i++ )
x[i] = (i+5);
xlast = x;
for ( int iter = 0; iter < niter; iter++ )
{
// compute gradient
#if 1
// quadratic form
for ( int i = 0; i < ndim; i++ )
//f[i] = -(i+1) * (x[i]-1.0) - 0.1 * x[i]*x[i]*x[i];
f[i] = -(i+1) * (x[i]-i);
//f[i] = -(0.1*i+1)*(x[i]-i);
#if 1
// precondition f
for ( int i = 0; i < ndim; i++ )
f[i] *= 1.0/(i+3);
#endif
#else
// Rosenbrock function
assert(ndim%2==0);
......@@ -77,24 +87,24 @@ int main(int argc, char** argv)
#endif
double resnorm = 0.0;
for ( int i = 0; i < x.size(); i++ )
for ( int i = 0; i < ndim; i++ )
resnorm += f[i]*f[i];
#if USE_MPI
ctxt.dsum(1,1,&resnorm,1);
#endif
cout << " resnorm: " << sqrt(resnorm) << endl;
mixer.update(&x[0],&f[0],&xbar[0],&fbar[0]);
mixer.update(&f[0],&theta,&fbar[0]);
cout << " theta: " << theta << " resnorm: " << resnorm << endl;
#if 0
// precondition fbar
for ( int i = 0; i < ndim; i++ )
fbar[i] /= (i+3);
//fbar[i] *= 1.0/(i+2);
#endif
for ( int i = 0; i < x.size(); i++ )
{
// xbar = x + theta * ( x - xlast )
// x = xbar + fbar
double xtmp = x[i];
x[i] += theta * ( x[i] - xlast[i] ) + alpha * fbar[i];
xlast[i] = xtmp;
}
for ( int i = 0; i < ndim; i++ )
x[i] = xbar[i] + alpha * fbar[i];
}
}
#if USE_MPI
......
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