Skip to content

Commit 59d8522

Browse files
author
Michael Roemelt
committed
Changed renormalization scheme in nevpt2 module. Furthermore, some technical problems are solved
1 parent 3bf5156 commit 59d8522

15 files changed

+770
-86
lines changed

dmrg_tests/h2o_nevpt2/Reference.dat

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
E(0,ijab) = -0.050586917139
2-
E(-1,iab) = -0.061685762413
3-
E(1,ija) = -0.016787887683
4-
E(-2,ab) = -0.037628743088
5-
E(2,ij) = -0.003958073413
6-
E(0,ia) = -0.034667933585
7-
E(-1,a) = -0.002668278247
8-
E(1,i) = -0.000587432173
9-
2+
E(-1,iab) = -0.061685764182
3+
E(1,ija) = -0.016787887161
4+
E(-2,ab) = -0.037628743292
5+
E(2,ij) = -0.003981453837
6+
E(0,ia) = -0.034668073973
7+
E(-1,a) = -0.017609783168
8+
E(1,i) = -0.008658853623

modules/nevpt2/nevpt2.C

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,10 +2869,12 @@ namespace SpinAdapted{
28692869
//-----------------------------------------------------
28702870
//construct or read the effective one-electron matrices
28712871
//-----------------------------------------------------
2872-
GenerateHeff(OrbWin,h,h_eff,h_eff_,IJKL,IKJL,IJAB,IAJB,IJKA,IKJA);
2872+
//GenerateHeff(OrbWin,h,h_eff,h_eff_,IJKL,IKJL,IJAB,IAJB,IJKA,IKJA);
28732873
//ReadHeff(OrbWin,h_eff,h_eff_,BaseName,ReOrder);
2874-
Info.AddH(h);Info.AddH(h_eff);Info.AddH(h_eff_);
2875-
2874+
//Info.AddH(h);Info.AddH(h_eff);Info.AddH(h_eff_);
2875+
Info.GetH(1,h_eff);
2876+
Info.GetH(2,h_eff_);
2877+
28762878
//-------------------------
28772879
//Read the orbital energies
28782880
//-------------------------

modules/nevpt2/nevpt2_mpi.C

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,23 @@ void PALDivideLoop(int &start_loc, int &stop_loc, int start_global, int stop_glo
9090
stop_loc = stop_global;
9191
}
9292
else{
93-
int loopsize = stop_global - start_global + 1;
93+
int loopsize = stop_global - start_global;
9494
int numproc = world.size();
9595
int quot = loopsize / numproc;
9696
int iproc = world.rank();
97-
start_loc = iproc * quot;
98-
stop_loc = (iproc+1) * quot;
97+
start_loc = iproc * quot + start_global;
98+
stop_loc = (iproc+1) * quot + start_global;
9999
if (numproc>=loopsize){
100100
if (iproc>=loopsize){
101101
start_loc = -1;
102102
stop_loc = -1;
103103
}
104104
else{
105-
start_loc = iproc;
106-
stop_loc = iproc + 1;
105+
start_loc = iproc + start_global;
106+
stop_loc = iproc + 1 + start_global;
107107
}
108108
}
109-
if (world.rank()==numproc-1){
109+
else if (world.rank()==numproc-1){
110110
stop_loc = stop_global;
111111
}
112112

modules/nevpt2/nevpt2_opconstruct.C

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,10 @@ namespace SpinAdapted{
996996
int NActive = big.get_sites().size();
997997
int NExternal = a1-a0+1;
998998
int OrbDim = NInternal+NActive+NExternal;
999-
int t,u,v,i,a,tu;
999+
int t=1,u=-1,v=-1,i,a,tu;
10001000
int t_,u_,v_;
10011001
int dummy;
10021002
SpinQuantum WFQ = WF.get_deltaQuantum(0);
1003-
boost::shared_ptr<Matrix> Kut;
10041003
SpinBlock *leftBlock = big.get_leftBlock();
10051004
SpinBlock *rightBlock = big.get_rightBlock();
10061005
double twoS = (double) WFQ.get_s().getirrep();
@@ -1014,6 +1013,7 @@ namespace SpinAdapted{
10141013
//---------------------------------------------------
10151014
//open the integral file
10161015
IKJL.OpenFileRead();
1016+
boost::shared_ptr<Matrix> Kut = IKJL.GetMatrix(0,0);
10171017
//Open the operator arrays and prepare the buffer
10181018
CCD.OpenFileRead();
10191019
CCD.ResetBuffer();
@@ -1075,7 +1075,7 @@ namespace SpinAdapted{
10751075
}
10761076

10771077
//if necessary, get the integral matrix
1078-
if ((t!=t_)||(u!=u_)){
1078+
if ((t!=t_)||(u!=u_)&&!DummyIter){
10791079
Kut = IKJL.GetMatrix(u+NInternal,t+NInternal);
10801080
}
10811081
//the possible quanta
@@ -1158,7 +1158,7 @@ namespace SpinAdapted{
11581158
}
11591159

11601160
//if necessary, get the integral matrix
1161-
if ((t!=t_)||(u!=u_)){
1161+
if ((t!=t_)||(u!=u_)&&!DummyIter){
11621162
Kut = IKJL.GetMatrix(u+NInternal,t+NInternal);
11631163
}
11641164
//the possible quanta
@@ -3367,11 +3367,10 @@ namespace SpinAdapted{
33673367
int NExternal = a1-a0+1;
33683368
int NOcc = NInternal + NActive;
33693369
int OrbDim = NInternal+NActive+NExternal;
3370-
int t,u,v,i,a,tu;
3370+
int t=-1,u=-1,v=-1,i,a,tu;
33713371
int t_,u_,v_;
33723372
int dummy;
33733373
SpinQuantum WFQ = WF.get_deltaQuantum(0);
3374-
boost::shared_ptr<Matrix> Ktv;
33753374
SpinBlock *leftBlock = big.get_leftBlock();
33763375
SpinBlock *rightBlock = big.get_rightBlock();
33773376
double twoS = (double) WFQ.get_s().getirrep();
@@ -3387,6 +3386,7 @@ namespace SpinAdapted{
33873386
//---------------------------------------------------
33883387
//open the integral file
33893388
IKJA.OpenFileRead();
3389+
boost::shared_ptr<Matrix> Ktv = IKJA.GetMatrix(0,0);
33903390
//Open the operator arrays and prepare the buffer
33913391
CDD.OpenFileRead();
33923392
CDD.ResetBuffer();
@@ -3447,7 +3447,7 @@ namespace SpinAdapted{
34473447
}
34483448

34493449
//if necessary, get the integral matrix
3450-
if ((t!=t_)||(v!=v_)){
3450+
if ((t!=t_)||(v!=v_)&&!DummyIter){
34513451
Ktv = IKJA.GetMatrix(t+NInternal,v+NInternal);
34523452
}
34533453
//the possible quanta
@@ -3526,7 +3526,7 @@ namespace SpinAdapted{
35263526
DummyIter = true;
35273527
}
35283528
//if necessary, get the integral matrix
3529-
if ((t!=t_)||(v!=v_)){
3529+
if ((t!=t_)||(v!=v_)&&!DummyIter){
35303530
Ktv = IKJA.GetMatrix(t+NInternal,v+NInternal);
35313531
}
35323532
//the possible quanta

modules/nevpt2/nevpt2_operators.C

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,12 @@ namespace SpinAdapted {
759759
//============================================================================
760760
template <class T>
761761
void OperatorArray<T>::CalcBufferSize(int MaxMemSize, int M){
762-
int ElementSize = M * M * 8;
763-
BufferSize = MaxMemSize*1000000/ElementSize;
762+
long ElementSize = M * M * sizeof(double);
763+
double ElementSize_ = (double) M * M * sizeof(double);
764+
double tmp = (double) MaxMemSize;
765+
tmp *= 1024.0 * 1024.0;
766+
tmp /= ElementSize_;
767+
BufferSize = (long) tmp;
764768
if (BufferSize==0) BufferSize = 1;
765769
}
766770

@@ -1405,7 +1409,7 @@ namespace SpinAdapted {
14051409

14061410
case _COULOMB_:
14071411
//resize the vector that holds the integral matrices
1408-
N = (dim1+1)*(dim1/2);
1412+
N = (dim1+1)*(dim1)/2;
14091413
rep.resize(N);
14101414
//resize and fill the IndexMap
14111415
IndexMap.ReSize(dim1,dim2);
@@ -1428,7 +1432,7 @@ namespace SpinAdapted {
14281432

14291433
case _EXCHANGE_:
14301434
//resize the vector that holds the integral matrices
1431-
N = (dim1+1)*(dim1/2);
1435+
N = (dim1+1)*(dim1)/2;
14321436
rep.resize(N);
14331437
//resize and fill the IndexMap
14341438
IndexMap.ReSize(dim1,dim2);

modules/nevpt2/nevpt2_operators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ namespace SpinAdapted {
141141
ofstream ofs; //the output file stream
142142
ifstream ifs; //the input file stream
143143
std::vector<BufferElement<T> > Buffer; //InCore buffer for operators read from disk
144-
int BufferSize; //number of element in Buffer
144+
long BufferSize; //number of element in Buffer
145145
int CurrentElement; //the current element read from the buffer
146146
long BufferPosition; //the position of the buffer in the file
147147
bool HaveStateInfo; //do we have a StateInfo file?

modules/nevpt2/nevpt2_pal.C

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <boost/serialization/serialization.hpp>
55
#include "nevpt2_operators.h"
66
#include "distribute.h"
7+
#include "density.h"
78

89
#ifndef SERIAL
910
#include <boost/mpi/environment.hpp>
@@ -18,9 +19,6 @@ namespace SpinAdapted{
1819
//============================================================================
1920
void AddPalWavefunction(Wavefunction &WF){
2021
#ifndef SERIAL
21-
//copy the original wavefunction to the receive buffer
22-
boost::shared_ptr<Wavefunction> tmp_recv = boost::make_shared<Wavefunction>(WF);
23-
boost::shared_ptr<Wavefunction> tmp_send;
2422

2523
//the communicator
2624
mpi::communicator world;
@@ -34,10 +32,11 @@ namespace SpinAdapted{
3432

3533
//receive and accumulate the data
3634
for (int isender=0;isender<sendlist.size();isender++){
35+
boost::shared_ptr<Wavefunction> tmp_recv (new Wavefunction());
3736
//receive
38-
world.recv(sendlist[isender],0,tmp_recv);
37+
world.recv(sendlist[isender],0,*tmp_recv);
3938
//accumulate
40-
ScaleAdd(1.0,*(tmp_recv),WF);
39+
ScaleAdd(1.0,*tmp_recv,WF);
4140
}//isender
4241

4342
//send the data
@@ -48,6 +47,43 @@ namespace SpinAdapted{
4847
#endif
4948
}
5049

50+
//============================================================================
51+
// Add all contributions from different processes to a wavefunction
52+
//============================================================================
53+
void AddPalDensity(DensityMatrix &D){
54+
#ifndef SERIAL
55+
56+
//the communicator
57+
mpi::communicator world;
58+
int WorldSize=world.size();
59+
if (WorldSize==1) return;
60+
int rank = world.rank();
61+
62+
//determine the send-recv structure
63+
std::vector<int> sendlist;
64+
makesendlist(sendlist);
65+
66+
//receive and accumulate the data
67+
for (int isender=0;isender<sendlist.size();isender++){
68+
boost::shared_ptr<DensityMatrix> tmp_recv (new DensityMatrix());
69+
//DensityMatrix part;
70+
//receive
71+
world.recv(sendlist[isender],0,*tmp_recv);
72+
//accumulate
73+
ScaleAdd(1.0,*tmp_recv,D);
74+
//clear memory
75+
//part.Clear();
76+
}//isender
77+
78+
//send the data
79+
if (rank!=0) world.send(receivefrom(),0,D);
80+
81+
//broadcast the accumulated result
82+
boost::mpi::broadcast(world,D,0);
83+
#endif
84+
}
85+
86+
5187
//============================================================================
5288
// Add all contributions from different processes to a set of wavefunctions
5389
//============================================================================

modules/nevpt2/nevpt2_pal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
namespace SpinAdapted{
1616
//============================================================================
17-
// Add all contributions from different processes to a wavefunction
17+
// Add all contributions from different processes to a wavefunction/density
1818
//============================================================================
1919
void AddPalWavefunction(Wavefunction &WF);
20+
void AddPalDensity(DensityMatrix &D);
2021

2122
//============================================================================
2223
// Add all contributions from different processes to a set of wavefunctions

0 commit comments

Comments
 (0)