Skip to content

Commit aa7b8a3

Browse files
committed
Completely got rid of BTAS from block. Now all the overlap functionality is implemented from inside the spinblock.
1 parent 5b41067 commit aa7b8a3

15 files changed

+406
-1135
lines changed

dmrg.C

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ Sandeep Sharma and Garnet K.-L. Chan
4242
#include "BaseOperator.h"
4343
#include "dmrg_wrapper.h"
4444

45-
#ifdef USE_BTAS
46-
#include "overlaptensor.h"
47-
#include "btas/SPARSE/STArray.h"
48-
#include "btas/SPARSE/SDcontract.h"
49-
#include <btas/TVector.h>
50-
#endif
51-
5245
#ifndef SERIAL
5346
#include <boost/mpi/environment.hpp>
5447
#include <boost/mpi/communicator.hpp>
@@ -160,12 +153,11 @@ int calldmrg(char* input, char* output)
160153
}
161154
for (int istate = 0; istate<dmrginp.nroots(); istate++)
162155
for (int j=istate; j<dmrginp.nroots() ; j++) {
163-
Sweep::InitializeAllOverlaps(sweepParams, !direction, istate, j);
164-
Sweep::InitializeAllOverlaps(sweepParams, direction, istate, j);
156+
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, j, istate);
157+
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, j, istate);
165158
}
166-
Sweep::calculateAllOverlap(O);
159+
//Sweep::calculateAllOverlap(O);
167160
}
168-
cout <<"overlap"<<endl<< O <<endl;
169161
break;
170162

171163
case (CALCHAMILTONIAN):
@@ -185,7 +177,7 @@ int calldmrg(char* input, char* output)
185177
}
186178
}
187179

188-
Sweep::calculateHMatrixElements(H);
180+
//Sweep::calculateHMatrixElements(H);
189181
pout << "overlap "<<endl<<O<<endl;
190182
pout << "hamiltonian "<<endl<<H<<endl;
191183
break;
@@ -346,8 +338,8 @@ void restart(double sweep_tol, bool reset_iter)
346338
sweepParams.current_root() = i;
347339
if (mpigetrank()==0) {
348340
for (int j=0; j<i; j++) {
349-
Sweep::InitializeAllOverlaps(sweepParams, !direction, i, j);
350-
Sweep::InitializeAllOverlaps(sweepParams, direction, i, j);
341+
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j);
342+
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j);
351343
}
352344
}
353345
}
@@ -376,8 +368,8 @@ void restart(double sweep_tol, bool reset_iter)
376368
Sweep::CanonicalizeWavefunction(sweepParams, !direction, i);
377369
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
378370
for (int j=0; j<i ; j++) {
379-
Sweep::InitializeAllOverlaps(sweepParams, direction, j, i);
380-
Sweep::InitializeAllOverlaps(sweepParams, !direction, j, i);
371+
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j);
372+
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j);
381373
}
382374
}
383375
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, i, i);
@@ -471,9 +463,9 @@ void dmrg(double sweep_tol)
471463

472464
bool direction;
473465
int restartsize;
474-
sweepParams.restorestate(direction, restartsize);
475-
sweepParams.set_sweep_iter() = 0;
476-
sweepParams.set_restart_iter() = 0;
466+
//sweepParams.restorestate(direction, restartsize);
467+
//sweepParams.set_sweep_iter() = 0;
468+
//sweepParams.set_restart_iter() = 0;
477469

478470
if (dmrginp.outputlevel() > 0)
479471
pout << "STARTING STATE SPECIFIC CALCULATION "<<endl;
@@ -489,12 +481,16 @@ void dmrg(double sweep_tol)
489481
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
490482
Sweep::CanonicalizeWavefunction(sweepParams, !direction, i);
491483
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
484+
Sweep::InitializeStateInfo(sweepParams, direction, i);
485+
Sweep::InitializeStateInfo(sweepParams, !direction, i);
492486

493-
for (int j=0; j<i ; j++) {
494-
Sweep::InitializeAllOverlaps(sweepParams, direction, j, i);
495-
Sweep::InitializeAllOverlaps(sweepParams, !direction, j, i);
496-
}
497487
}
488+
489+
for (int j=0; j<i ; j++) {
490+
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j);
491+
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j);
492+
}
493+
498494
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, i, i);
499495
sweepParams.set_sweep_iter() = 0;
500496
sweepParams.set_restart_iter() = 0;
@@ -627,6 +623,8 @@ void dmrg_stateSpecific(double sweep_tol, int targetState)
627623
Sweep::CanonicalizeWavefunction(sweepParams, !direction, targetState);
628624
Sweep::CanonicalizeWavefunction(sweepParams, direction, targetState);
629625
Sweep::CanonicalizeWavefunction(sweepParams, !direction, targetState);
626+
Sweep::InitializeStateInfo(sweepParams, !direction, targetState);
627+
Sweep::InitializeStateInfo(sweepParams, direction, targetState);
630628

631629
}
632630

initblocks.C

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,72 @@ void SpinAdapted::InitBlocks::InitNewEnvironmentBlock(SpinBlock &environment, Sp
237237

238238
}
239239

240+
241+
void SpinAdapted::InitBlocks::InitNewOverlapEnvironmentBlock(SpinBlock &environment, SpinBlock& environmentDot, SpinBlock &newEnvironment,
242+
const SpinBlock &system, SpinBlock &systemDot, int leftState, int rightState,
243+
const int &sys_add, const int &env_add, const bool &forward,
244+
const bool &onedot, const bool& dot_with_sys)
245+
{
246+
// now initialise environment Dot
247+
int systemDotStart, systemDotEnd, environmentDotStart, environmentDotEnd, environmentStart, environmentEnd;
248+
int systemDotSize = sys_add - 1;
249+
int environmentDotSize = env_add - 1;
250+
if (forward)
251+
{
252+
systemDotStart = dmrginp.spinAdapted() ? *system.get_sites().rbegin () + 1 : (*system.get_sites().rbegin ())/2 + 1 ;
253+
systemDotEnd = systemDotStart + systemDotSize;
254+
environmentDotStart = systemDotEnd + 1;
255+
environmentDotEnd = environmentDotStart + environmentDotSize;
256+
environmentStart = environmentDotEnd + 1;
257+
environmentEnd = dmrginp.spinAdapted() ? dmrginp.last_site() - 1 : dmrginp.last_site()/2 - 1;
258+
}
259+
else
260+
{
261+
systemDotStart = dmrginp.spinAdapted() ? system.get_sites()[0] - 1 : (system.get_sites()[0])/2 - 1 ;
262+
systemDotEnd = systemDotStart - systemDotSize;
263+
environmentDotStart = systemDotEnd - 1;
264+
environmentDotEnd = environmentDotStart - environmentDotSize;
265+
environmentStart = environmentDotEnd - 1;
266+
environmentEnd = 0;
267+
}
268+
269+
std::vector<int> environmentSites;
270+
environmentSites.resize(abs(environmentEnd - environmentStart) + 1);
271+
for (int i = 0; i < abs(environmentEnd - environmentStart) + 1; ++i) *(environmentSites.begin () + i) = min(environmentStart,environmentEnd) + i;
272+
273+
274+
if (dmrginp.outputlevel() > 0)
275+
pout << "\t\t\t Restoring block of size " << environmentSites.size () << " from previous iteration" << endl;
276+
277+
if(dot_with_sys && onedot)
278+
SpinBlock::restore (!forward, environmentSites, newEnvironment, leftState, rightState);
279+
else
280+
SpinBlock::restore (!forward, environmentSites, environment, leftState, rightState);
281+
if (dmrginp.outputlevel() > 0)
282+
mcheck("");
283+
284+
// now initialise newEnvironment
285+
if (!dot_with_sys || !onedot)
286+
{
287+
newEnvironment.initialise_op_array(OVERLAP, false);
288+
//newEnvironment.set_op_array(OVERLAP) = boost::shared_ptr<Op_component<Overlap> >(new Op_component<Overlap>(false));
289+
newEnvironment.setstoragetype(DISTRIBUTED_STORAGE);
290+
291+
newEnvironment.BuildSumBlock (NO_PARTICLE_SPIN_NUMBER_CONSTRAINT, environment, environmentDot);
292+
if (dmrginp.outputlevel() > 0) {
293+
pout << "\t\t\t Environment block " << endl << environment << endl;
294+
environment.printOperatorSummary();
295+
pout << "\t\t\t NewEnvironment block " << endl << newEnvironment << endl;
296+
newEnvironment.printOperatorSummary();
297+
}
298+
}
299+
else if (dmrginp.outputlevel() > 0) {
300+
pout << "\t\t\t Environment block " << endl << newEnvironment << endl;
301+
newEnvironment.printOperatorSummary();
302+
}
303+
304+
}
305+
240306
void SpinAdapted::InitBlocks::InitBigBlock(SpinBlock &leftBlock, SpinBlock &rightBlock, SpinBlock &big)
241307
{
242308
//set big block components

initblocks.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ namespace InitBlocks
2626
const int &sys_add, const int &env_add, const bool &forward, const bool &direct, const bool &onedot,
2727
const bool &nexact, const bool &useSlater,
2828
bool haveNormops = true, bool haveCompops = true, const bool& dot_with_sys = true);
29+
30+
void InitNewOverlapEnvironmentBlock(SpinBlock &environment, SpinBlock& environmentDot, SpinBlock &newEnvironment,
31+
const SpinBlock &system, SpinBlock &systemDot, int leftState, int rightState,
32+
const int &sys_add, const int &env_add, const bool &forward,
33+
const bool &onedot, const bool& dot_with_sys);
34+
2935
void InitBigBlock(SpinBlock &leftBlock, SpinBlock &rightBlock, SpinBlock &big);
3036
}
3137
}

makefile

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ LAPACKBLAS = -lmkl_intel_lp64 -lmkl_sequential -lmkl_core
1414

1515
#use these variable to set if we will use mpi or not
1616
USE_MPI = yes
17-
USE_BTAS = yes
1817
USE_MKL = yes
1918

2019
ifeq ($(USE_MKL), yes)
@@ -69,12 +68,6 @@ FLAGS = -I${MKLFLAGS} -I$(INCLUDE1) -I$(INCLUDE2) -I$(NEWMATINCLUDE) -I$(BOOSTI
6968
-I$(HOME)/modules/npdm -I$(HOME)/modules/two_index_ops -I$(HOME)/modules/three_index_ops -I$(HOME)/modules/four_index_ops -std=c++0x \
7069
-I$(HOME)/modules/ResponseTheory
7170

72-
ifeq ($(USE_BTAS), yes)
73-
FLAGS += -I$(BTAS)/include -DUSE_BTAS
74-
LIBS = -L$(BTAS)/lib -lbtas
75-
else
76-
LIBS =
77-
endif
7871

7972
LIBS += -L$(NEWMATLIB) -lnewmat $(BOOSTLIB) $(LAPACKBLAS) -lgomp
8073
MPI_OPT = -DSERIAL
@@ -131,9 +124,6 @@ SRC_spin_library = modules/ResponseTheory/sweepCompress.C fciqmchelper.C dmrg.C
131124

132125
#SRC_spin_library = fciqmchelper.C fiedler.C IrrepSpace.C least_squares.C sweep_mps.C dmrg.C readinput.C save_load_block.C timer.C SpinQuantum.C Symmetry.C input.C Schedule.C orbstring.C slater.C csf.C spinblock.C StateInfo.C set_spinblock_components.C op_components.C Operators.C BaseOperator.C screen.C MatrixBLAS.C operatorfunctions.C opxop.C wavefunction.C solver.C linear.C davidson.C sweep_params.C sweep.C initblocks.C guess_wavefunction.C density.C rotationmat.C renormalise.C couplingCoeffs.C distribute.C new_anglib.C modules/twopdm/sweep.C modules/twopdm/twopdm.C modules/twopdm/twopdm_2.C modules/onepdm/sweep.C modules/onepdm/onepdm.C modules/generate_blocks/sweep.C fci.C $(SRC_genetic) SpinSpace.C include/IntegralMatrix.C $(SRC_npdm)
133126

134-
BTAS_source = btas/lib/Dreindex.C btas/lib/clapack.C btas/lib/libbtas.C
135-
136-
BTAS_obj=$(BTAS_source:.C=.o)
137127
OBJ_OH+=$(SRC_OH:.C=.o)
138128
OBJ_spin_adapted=$(SRC_spin_adapted:.C=.o)
139129
OBJ_spin_library=$(SRC_spin_library:.C=.o)
@@ -147,34 +137,21 @@ OBJ_spin_library=$(SRC_spin_library:.C=.o)
147137

148138
all : $(EXECUTABLE) libqcdmrg.a OH
149139

150-
library : libqcdmrg.a $(NEWMATLIB)/libnewmat.a $(BTAS)/lib/libbtas.a
140+
library : libqcdmrg.a $(NEWMATLIB)/libnewmat.a
151141

152142
libqcdmrg.a : $(OBJ_spin_library)
153143
$(AR) $(ARFLAGS) $@ $^
154144
$(RANLIB) $@
155-
ifeq ($(USE_BTAS), yes)
156-
157-
OH : $(OBJ_OH) $(NEWMATLIB)/libnewmat.a $(BTAS)/lib/libbtas.a
158-
$(CXX) $(FLAGS) $(OPT) -o OH $(OBJ_OH) $(LIBS)
159-
160145

161-
$(EXECUTABLE) : $(OBJ_spin_adapted) $(NEWMATLIB)/libnewmat.a $(BTAS)/lib/libbtas.a
162-
$(CXX) $(FLAGS) $(OPT) -o $(EXECUTABLE) $(OBJ_spin_adapted) $(LIBS)
163-
else
164146
$(EXECUTABLE) : $(OBJ_spin_adapted) $(NEWMATLIB)/libnewmat.a
165147
$(CXX) $(FLAGS) $(OPT) -o $(EXECUTABLE) $(OBJ_spin_adapted) $(LIBS)
166148

167149
OH : $(OBJ_OH) $(NEWMATLIB)/libnewmat.a
168150
$(CXX) $(FLAGS) $(OPT) -o OH $(OBJ_OH) $(LIBS)
169151

170-
endif
171-
172152
$(NEWMATLIB)/libnewmat.a :
173153
cd $(NEWMATLIB) && $(MAKE) -f makefile libnewmat.a
174154

175-
$(BTAS)/lib/libbtas.a: $(BTAS_obj)
176-
ar cr $(BTAS)/lib/libbtas.a $(BTAS_obj)
177-
178155
clean:
179156
rm *.o include/*.o modules/generate_blocks/*.o modules/onepdm/*.o modules/twopdm/*.o modules/npdm/*.o $(NEWMATLIB)*.o libqcdmrg.so $(EXECUTABLE) $(NEWMATLIB)/libnewmat.a genetic/gaopt genetic/*.o btas/lib/*.o btas/lib/libbtas.a modules/two_index_ops/*.o modules/three_index_ops/*.o modules/four_index_ops/*.o
180157

renormalise.C

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace SpinAdapted{
3939
void SpinBlock::RenormaliseFrom(vector<double> &energies, vector<double> &spins, double& error, vector<Matrix>& rotateMatrix,
4040
const int keptstates, const int keptqstates, const double tol, SpinBlock& big,
4141
const guessWaveTypes &guesswavetype, const double noise, const double additional_noise, const bool &onedot, SpinBlock& System,
42-
SpinBlock& sysDot, SpinBlock& envDot, SpinBlock& environment, const bool& dot_with_sys,
42+
SpinBlock& sysDot, SpinBlock& environment, const bool& dot_with_sys,
4343
const bool& warmUp, int sweepiter, int currentRoot, std::vector<Wavefunction>& lowerStates)
4444
{
4545
int nroots = dmrginp.nroots(sweepiter);
@@ -68,7 +68,6 @@ void SpinBlock::RenormaliseFrom(vector<double> &energies, vector<double> &spins,
6868
wave_solutions[i] = tempwave;
6969
}
7070
*this = newsystem;
71-
envDot.clear();
7271
big.get_rightBlock()->clear();
7372
big.clear();
7473
}

rotationmat.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Sandeep Sharma and Garnet K.-L. Chan
1212
#include <vector>
1313
#include "Operators.h"
1414
#include "multiarray.h"
15-
#ifdef USE_BTAS
16-
#include "btas/SPARSE/STArray.h"
17-
#endif
1815

1916
namespace SpinAdapted{
2017

@@ -29,9 +26,6 @@ bool can_connect(int n, int spin, int right_block_size);
2926

3027
void allocate(const StateInfo& row, const StateInfo& col, std::vector<Matrix>& rotations);
3128

32-
#ifdef USE_BTAS
33-
void UnCollectQuantaAlongRows(const StateInfo& sRow, const StateInfo& sCol, const std::vector<Matrix> &inRotation, btas::STArray<double, 3>& SiteTensor);
34-
#endif
3529

3630
}
3731
#endif

save_load_block.C

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ std::string SpinBlock::restore (bool forward, const vector<int>& sites, SpinBloc
2525
Timer disktimer;
2626
std::string file;
2727

28-
//we only every save one set of spin blocks because they take up so much memory, so the spin block names are not indexed with states
2928
if (forward)
30-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% sites[0] % "-" % sites[sites.size()-1] % "." % mpigetrank() % ".tmp" );
29+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% sites[0] % "-" % sites[sites.size()-1] % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
3130
else
32-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% sites[0] % "-" % sites[sites.size()-1] % "." % mpigetrank() % ".tmp" );
31+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% sites[0] % "-" % sites[sites.size()-1] % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
3332

3433
if (dmrginp.outputlevel() > 0)
3534
pout << "\t\t\t Restoring block file :: " << file << endl;
@@ -64,15 +63,15 @@ void SpinBlock::store (bool forward, const vector<int>& sites, SpinBlock& b, int
6463
std::string file;
6564
if(dmrginp.spinAdapted()) {
6665
if (forward)
67-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% sites[0] % "-" % sites[sites.size()-1] % "." % mpigetrank() % ".tmp" );
66+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% sites[0] % "-" % sites[sites.size()-1] % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
6867
else
69-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% sites[0] % "-" % sites[sites.size()-1] % "." % mpigetrank() % ".tmp" );
68+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% sites[0] % "-" % sites[sites.size()-1] % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
7069
}
7170
else {
7271
if (forward)
73-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% (sites[0]/2) % "-" % (sites[sites.size()-1]/2) % "." % mpigetrank() % ".tmp" );
72+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-forward-"% (sites[0]/2) % "-" % (sites[sites.size()-1]/2) % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
7473
else
75-
file = str(boost::format("%s%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% (sites[0]/2) % "-" % (sites[sites.size()-1]/2) % "." % mpigetrank() % ".tmp" );
74+
file = str(boost::format("%s%s%d%s%d%s%d%s%d%s%d%s") % dmrginp.save_prefix() % "/SpinBlock-backward-"% (sites[0]/2) % "-" % (sites[sites.size()-1]/2) % "." % left % "." % right % "." % mpigetrank() % ".tmp" );
7675
}
7776

7877
if (dmrginp.outputlevel() > 0)

0 commit comments

Comments
 (0)