Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-spinadapted and bcs calculations enabled #1

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d1740ef
fixed restart with bcs onepdm
zhengbx Dec 31, 2015
d440dc0
boost three-index performance by pre-build two index comp operators
zhengbx Jan 5, 2016
25980df
more output information
zhengbx Jan 5, 2016
cdb79a1
fix bug with openmp
zhengbx Jan 5, 2016
870e981
improved safety for shared memory object
zhengbx Jan 8, 2016
c0139a5
a simpler solution
zhengbx Jan 8, 2016
d20bd6e
remove potential error for orbitals > 100
zhengbx Jan 12, 2016
2f28ed6
use -DMKL_DIRECT_CALL to accelerate small matrix optimization
zhengbx Jan 29, 2016
1f0cffd
bug fix
zhengbx Feb 8, 2016
b534cbb
merge master branch
zhengbx Jun 7, 2016
85af9c2
fix bug in 'add_local_indices'
zhengbx Jun 23, 2016
c506bc3
use unsigned long instead of ulong
zhengbx Jun 23, 2016
1edda97
Implemented build StackCreDesComp::buildfromCreDes
zhengbx Jun 23, 2016
703e554
implemented StackDesDesComp::buildfromDesDes for BCS with DES
zhengbx Jun 23, 2016
b80a1cd
implemented StackDesDesComp::buildfromDesDes for BCS
zhengbx Jun 24, 2016
0daee2e
implemted StackCreCreComp::buildfromCreCre for BCS
zhengbx Jun 24, 2016
b47bef7
bug fix
zhengbx Jun 24, 2016
664fabd
fix problems in OH
zhengbx Jun 25, 2016
f337d8d
bug in canonicalizating BCS state; onepdm calculation
zhengbx Jul 25, 2016
67570a9
a bug for BCS compress
zhengbx Jul 26, 2016
0cd35d3
fixed nonspinadapted compression (w. nonsymmetric operators), spin-ad…
zhengbx Aug 1, 2016
f39f7e2
fixed BCS compress
zhengbx Aug 2, 2016
690bf8c
enabling response for bcs
zhengbx Aug 12, 2016
bf7dd8d
bug fix
zhengbx Aug 13, 2016
048f30d
parallel OH
zhengbx Aug 13, 2016
0ee79d8
allow (1) compute specific pdms (2) ket and bra have different dimens…
zhengbx Aug 13, 2016
dd4e7aa
previous disabled cpu affinity settings
zhengbx Aug 13, 2016
09df7ba
header file required for some compilers
zhengbx Sep 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OverlapHelement.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int argc, char* argv []) {
//readMPSFromDiskAndInitializeStaticVariables();
//initializeGlobalMPS(mpsstate);

if (rank =0)
if (rank == 0)
printf("Reading file %s\n", argv[2]);
test(argv[2]);
//exit(0);
Expand Down
417 changes: 291 additions & 126 deletions StackOperators.C

Large diffs are not rendered by default.

69 changes: 49 additions & 20 deletions Stack_op_components.C
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,18 @@ namespace SpinAdapted {
vec.resize(spinvec.size());
vector<int> orbs(2); orbs[0] = i; orbs[1] = j;
for (int j=0; j<spinvec.size(); j++) {
vec[j]=boost::shared_ptr<StackCreDesComp>(new StackCreDesComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
vec[j]->set_deltaQuantum(1, spinvec[j]);
vec[j]=boost::shared_ptr<StackCreDesComp>(new StackCreDesComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
if (dmrginp.hamiltonian() == BCS) {
vec[j]->resize_deltaQuantum(3);
vec[j]->set_deltaQuantum(0) = spinvec[j];
vec[j]->set_deltaQuantum(1) = SpinQuantum(2, spinvec[j].get_s(), spinvec[j].get_symm());
vec[j]->set_deltaQuantum(2) = SpinQuantum(-2, spinvec[j].get_s(), spinvec[j].get_symm());
} else {
vec[j]->set_deltaQuantum(1, spinvec[j]);
}
}
}

Expand Down Expand Up @@ -628,11 +635,18 @@ namespace SpinAdapted {
vec.resize(spinvec.size());
vector<int> orbs(2); orbs[0] = i; orbs[1] = j;
for (int j=0; j<spinvec.size(); j++) {
vec[j]=boost::shared_ptr<StackDesCreComp>(new StackDesCreComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
vec[j]->set_deltaQuantum(1, spinvec[j]);
vec[j]=boost::shared_ptr<StackDesCreComp>(new StackDesCreComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
if (dmrginp.hamiltonian() == BCS) {
vec[j]->resize_deltaQuantum(3);
vec[j]->set_deltaQuantum(0) = spinvec[j];
vec[j]->set_deltaQuantum(1) = SpinQuantum(2, spinvec[j].get_s(), spinvec[j].get_symm());
vec[j]->set_deltaQuantum(2) = SpinQuantum(-2, spinvec[j].get_s(), spinvec[j].get_symm());
} else {
vec[j]->set_deltaQuantum(1, spinvec[j]);
}
}
}

Expand Down Expand Up @@ -729,11 +743,19 @@ namespace SpinAdapted {
vec.resize(spinvec.size());
vector<int> orbs(2); orbs[0] = i; orbs[1] = j;
for (int j=0; j<spinvec.size(); j++) {
vec[j]=boost::shared_ptr<StackDesDesComp>(new StackDesDesComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
vec[j]->set_deltaQuantum(1, -spinvec[j]);
vec[j]=boost::shared_ptr<StackDesDesComp>(new StackDesDesComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;

if (dmrginp.hamiltonian() == BCS) {
vec[j]->resize_deltaQuantum(3);
vec[j]->set_deltaQuantum(0) = -spinvec[j];
vec[j]->set_deltaQuantum(1) = -SpinQuantum(0, spinvec[j].get_s(), spinvec[j].get_symm());
vec[j]->set_deltaQuantum(2) = -SpinQuantum(-2, spinvec[j].get_s(), spinvec[j].get_symm());
} else {
vec[j]->set_deltaQuantum(1, -spinvec[j]);
}
}
}

Expand Down Expand Up @@ -829,11 +851,18 @@ namespace SpinAdapted {
vec.resize(spinvec.size());
vector<int> orbs(2); orbs[0] = i; orbs[1] = j;
for (int j=0; j<spinvec.size(); j++) {
vec[j]=boost::shared_ptr<StackCreCreComp>(new StackCreCreComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
vec[j]->set_deltaQuantum(1, spinvec[j]);
vec[j]=boost::shared_ptr<StackCreCreComp>(new StackCreCreComp);
vec[j]->set_orbs() = orbs;
vec[j]->set_initialised() = true;
vec[j]->set_fermion() = false;
if (dmrginp.hamiltonian() == BCS) {
vec[j]->resize_deltaQuantum(3);
vec[j]->set_deltaQuantum(0) = spinvec[j];
vec[j]->set_deltaQuantum(1) = SpinQuantum(0, spinvec[j].get_s(), spinvec[j].get_symm());
vec[j]->set_deltaQuantum(2) = SpinQuantum(-2, spinvec[j].get_s(), spinvec[j].get_symm());
} else {
vec[j]->set_deltaQuantum(1, spinvec[j]);
}
}
}

Expand Down
94 changes: 92 additions & 2 deletions Stackspinblock.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void StackSpinBlock::printOperatorSummary()
#ifndef SERIAL
mpi::communicator world;

//pout << "Printing Operators of this Block" << endl;
//pout << *this << endl;

if (mpigetrank() != 0) {
for (std::map<opTypes, boost::shared_ptr< StackOp_component_base> >::const_iterator it = ops.begin(); it != ops.end(); ++it)
sendobject(it->second->get_size(), 0);
Expand All @@ -90,7 +93,7 @@ void StackSpinBlock::printOperatorSummary()
}
else
{
p2out << "\t\t\t " << it->second->size()<<" : "<<it->second->get_op_string()<<" Virtual Operators ";
p2out << "\t\t\t " << it->second->size()<<" : "<<it->second->get_op_string()<<" Virtual Operators ";
}

vector<int> numops(calc.size(), 0);
Expand All @@ -102,6 +105,14 @@ void StackSpinBlock::printOperatorSummary()
p2out << " " << numops[proc]<<" ";
}
p2out << endl;
//if (it->second->get_op_string() == "STACKHAM" || it->second->get_op_string() == "STACKCRECREDES_COMP" || it->second->get_op_string() == "STACKDESDES_COMP" || it->second->get_op_string() == "STACKCREDES_COMP" || it->second->get_op_string() == "STACKCRE" || it->second->get_op_string() == "STACKCRECRE" || it->second->get_op_string() == "STACKCREDES" || it->second->get_op_string() == "STACKCRECRE" || it->second->get_op_string() == "STACKOVERLAP") {
//if (it->second->get_op_string() == "STACKCREDES_COMP" || it->second->get_op_string() == "STACKDESCRE_COMP") {
// if (it->second->is_core()) {
// for (int i = 0; i < it->second->size(); ++i) {
// pout << *it->second->get_local_element(i)[0] << endl;
// }
// }
//}
}
}
#else
Expand Down Expand Up @@ -964,6 +975,85 @@ int procWithMinOps(std::vector<boost::shared_ptr<StackSparseMatrix> >& allops)
return minproc;
}

std::vector<boost::shared_ptr<StackSparseMatrix>> StackSpinBlock::prebuild(int num_threads) const {
std::vector<boost::shared_ptr<StackSparseMatrix>> comps;
if (dmrginp.hamiltonian() == HUBBARD) return comps;

StackSpinBlock* loopBlock=(leftBlock->is_loopblock()) ? leftBlock : rightBlock;
StackSpinBlock* otherBlock = loopBlock == leftBlock ? rightBlock : leftBlock;

if (otherBlock->get_rightBlock() == 0) return comps;

for (int i = 0; i < loopBlock->get_op_array(CRE_DES).get_size(); ++i)
for (int j = 0; j < loopBlock->get_op_array(CRE_DES).get_local_element(i).size(); ++j) {
boost::shared_ptr<StackSparseMatrix> op1 = loopBlock->get_op_array(CRE_DES).get_local_element(i)[j];
int I = op1->get_orbs(0);
int J = op1->get_orbs(1);
if (otherBlock->get_op_array(CRE_DESCOMP).has_local_index(I, J)) {
boost::shared_ptr<StackSparseMatrix> op2;
if (!dmrginp.spinAdapted() || dmrginp.hamiltonian() == BCS)
op2 = otherBlock->get_op_array(CRE_DESCOMP).get_element(I, J).at(0);
else
op2 = otherBlock->get_op_rep(CRE_DESCOMP, -op1->get_deltaQuantum()[0], I, J);

if (!op2->memoryUsed()) comps.push_back(op2);

if (otherBlock->has(DES_CRECOMP)) {
if (!dmrginp.spinAdapted() || dmrginp.hamiltonian() == BCS)
op2 = otherBlock->get_op_array(DES_CRECOMP).get_element(I, J).at(0);
else
op2 = otherBlock->get_op_rep(DES_CRECOMP, op1->get_deltaQuantum()[0], I, J);

if (!op2->memoryUsed()) comps.push_back(op2);
}
}
}

for (int i = 0; i < loopBlock->get_op_array(CRE_CRE).get_size(); ++i)
for (int j = 0; j < loopBlock->get_op_array(CRE_CRE).get_local_element(i).size(); ++j) {
boost::shared_ptr<StackSparseMatrix> op1 = loopBlock->get_op_array(CRE_CRE).get_local_element(i)[j];
int I = op1->get_orbs(0);
int J = op1->get_orbs(1);
if (otherBlock->get_op_array(DES_DESCOMP).has_local_index(I, J)) {
boost::shared_ptr<StackSparseMatrix> op2;
if (!dmrginp.spinAdapted() || dmrginp.hamiltonian() == BCS)
op2 = otherBlock->get_op_array(DES_DESCOMP).get_element(I, J).at(0);
else
op2 = otherBlock->get_op_rep(DES_DESCOMP, -op1->get_deltaQuantum()[0], I, J);

if (!op2->memoryUsed()) comps.push_back(op2);

if (otherBlock->has(CRE_CRECOMP)) {
if (!dmrginp.spinAdapted() || dmrginp.hamiltonian() == BCS)
op2 = otherBlock->get_op_array(CRE_CRECOMP).get_element(I, J).at(0);
else
op2 = otherBlock->get_op_rep(CRE_CRECOMP, op1->get_deltaQuantum()[0], I, J);

if (!op2->memoryUsed()) comps.push_back(op2);
}
}
}

// Now allocate comps
double additionalMem = 0.;
for (int i = 0; i < comps.size(); ++i) {
comps.at(i)->allocate(otherBlock->get_braStateInfo(), otherBlock->get_ketStateInfo());
additionalMem += comps.at(i) -> memoryUsed();
}
p3out << "additional memory used for pre-build complimentary operators "
<< additionalMem*8/1.e9 << " GB" << endl;

SplitStackmem();

// omp parallel build
#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < comps.size(); ++i)
comps.at(i)->build(*otherBlock);
MergeStackmem();

return comps;
}

void StackSpinBlock::multiplyH(StackWavefunction& c, StackWavefunction* v, int num_threads) const
{

Expand Down Expand Up @@ -1159,7 +1249,7 @@ void StackSpinBlock::multiplyH(StackWavefunction& c, StackWavefunction* v, int n
}
}


for (int i = 0; i<numthrds; i++) {
if (collected[i]==2) {
if (loopBlock == get_leftBlock()) v_array[i].CollectQuantaAlongRows(*loopBlock->get_ketStateInfo().unCollectedStateInfo, otherBlock->get_ketStateInfo());
Expand Down
1 change: 1 addition & 0 deletions Stackspinblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class StackSpinBlock
void BuildSingleSlaterBlock(std::vector<int> sts);
void set_loopblock(bool p_loopblock){loopblock = p_loopblock;}
friend ostream& operator<< (ostream& os, const StackSpinBlock& b);
std::vector<boost::shared_ptr<StackSparseMatrix>> prebuild(int num_threads) const;
void multiplyH(StackWavefunction& c, StackWavefunction* v, int num_threads) const;
void multiplyH_2index(StackWavefunction& c, StackWavefunction* v, int num_threads) const;
void multiplyOverlap(StackWavefunction& c, StackWavefunction* v, int num_threads) const;
Expand Down
Loading