Skip to content

Commit 0dc8e34

Browse files
committed
Contains the changed need to make the Response theory work
1 parent f268660 commit 0dc8e34

28 files changed

+1838
-291
lines changed

BaseOperator.C

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ void SparseMatrix::Randomise ()
213213
SpinAdapted::Randomise(operator_element(lQ, rQ));
214214
}
215215

216+
double trace(const SparseMatrix& lhs)
217+
{
218+
assert(lhs.nrows() == lhs.ncols());
219+
double trace = 0.0;
220+
221+
for(int lQ=0;lQ<lhs.nrows();++lQ)
222+
if(lhs.allowed(lQ,lQ))
223+
for(int i=0;i<(lhs)(lQ,lQ).Nrows();++i)
224+
trace += (lhs)(lQ,lQ)(i+1,i+1);
225+
226+
return trace;
227+
}
228+
216229
double DotProduct(const SparseMatrix& lhs, const SparseMatrix& rhs)
217230
{
218231
double result = 0.;

BaseOperator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ double getCommuteParity(SpinQuantum a, SpinQuantum b, SpinQuantum c);
283283
void Normalise(SparseMatrix& a, int* success = 0);
284284
void ScaleAdd(double d, const SparseMatrix& a, SparseMatrix& b);
285285
double DotProduct(const SparseMatrix& lhs, const SparseMatrix& rhs);
286+
double trace(const SparseMatrix& lhs);
286287
void Scale(double d, SparseMatrix& a);
287288
void assignloopblock(SpinBlock*& loopblock, SpinBlock*& otherblock, SpinBlock* leftSpinBlock, SpinBlock* rightSpinBlock);
288289
void copy(const ObjectMatrix<Matrix>& a, ObjectMatrix<Matrix>& b);

Operators.C

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,14 @@ void SpinAdapted::DesCre::build(const SpinBlock& b)
625625
{
626626
const boost::shared_ptr<SparseMatrix> op1 = leftBlock->get_op_rep(DES, -getSpinQuantum(i), i);
627627
const boost::shared_ptr<SparseMatrix> op2 = rightBlock->get_op_rep(CRE, getSpinQuantum(j), j);
628-
SpinAdapted::operatorfunctions::TensorProduct(rightBlock, *op2, *op1, &b, &(b.get_stateInfo()), *this, 1.0);
628+
double parity = getCommuteParity(op1->get_deltaQuantum()[0], op2->get_deltaQuantum()[0], get_deltaQuantum()[0]);
629+
SpinAdapted::operatorfunctions::TensorProduct(rightBlock, *op2, *op1, &b, &(b.get_stateInfo()), *this, 1.0*parity);
629630
}
630631
else if (rightBlock->get_op_array(DES).has(i))
631632
{
632633
const boost::shared_ptr<SparseMatrix> op1 = rightBlock->get_op_rep(DES, -getSpinQuantum(i), i);
633634
const boost::shared_ptr<SparseMatrix> op2 = leftBlock->get_op_rep(CRE, getSpinQuantum(j), j);
634-
double parity = getCommuteParity(op1->get_deltaQuantum()[0], op2->get_deltaQuantum()[0], get_deltaQuantum()[0]);
635-
SpinAdapted::operatorfunctions::TensorProduct(rightBlock, *op1, *op2, &b, &(b.get_stateInfo()), *this, 1.0*parity);
635+
SpinAdapted::operatorfunctions::TensorProduct(rightBlock, *op1, *op2, &b, &(b.get_stateInfo()), *this, 1.0);
636636
}
637637
else
638638
abort();
@@ -651,15 +651,15 @@ double SpinAdapted::DesCre::redMatrixElement(Csf c1, vector<Csf>& ladder, const
651651

652652
TensorOp D(I, -1), C(J, 1);
653653

654-
TensorOp DC = D.product(C, spin, irrep);
654+
TensorOp CD = C.product(D, spin, irrep);
655655

656656

657657
for (int j = 0; j < deltaQuantum.size(); ++j) {
658658
for (int i=0; i<ladder.size(); i++)
659659
{
660660
int index = 0; double cleb=0.0;
661661
if (nonZeroTensorComponent(c1, deltaQuantum[j], ladder[i], index, cleb)) {
662-
std::vector<double> MatElements = calcMatrixElements(c1, DC, ladder[i]) ;
662+
std::vector<double> MatElements = calcMatrixElements(c1, CD, ladder[i]) ;
663663
element += MatElements[index]/cleb;
664664
break;
665665
}

OverlapHelement.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@ int main(int argc, char* argv []) {
1414
#endif
1515

1616
ReadInputFromC(argv[1], -1);
17+
1718
int mpsstate=0;
1819

1920
readMPSFromDiskAndInitializeStaticVariables(mpsstate);
21+
22+
2023
test();
24+
exit(0);
25+
2126

2227
double overlap, hvalue;
2328

24-
long temp=1, occ;
29+
long temp=1, occ=0;
2530

26-
//occ = temp<<63 | temp<<62 | temp<<61 | temp<<60 | temp<<59 | temp<<58 ;
27-
occ = temp<<63 | temp<<62 | temp<<61 | temp<<60 | temp<<59 | temp<<58 | temp<<57 | temp<<56 | temp<<55 | temp<<54 ;
31+
//11 00 11 11 11 11
32+
occ = temp<<63 | temp<<62 | temp<<61 | temp<<60;// | temp<<57 | temp<<56 | temp<<55 | temp<<54 | temp<<53 | temp<<52;
33+
34+
//11 11 11 00 11 11
35+
//occ = temp<<63 | temp<<62 | temp<<61 | temp<<60 | temp<<59 | temp<<58 | temp<<55 | temp<<54 | temp<<53 | temp<<52;
2836

2937
evaluateOverlapAndHamiltonian(&occ, 1, &overlap, &hvalue);
3038

31-
printf("overlap = %10.5e %i\n", overlap, rank);
32-
printf("helement = %10.5e %i\n", hvalue, rank);
39+
printf("overlap = %15.8e %i\n", overlap, rank);
40+
printf("helement = %15.8e %i\n", hvalue, rank);
3341

3442
#ifndef SERIAL
3543
MPI_Finalize();

davidson.C

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,16 @@ void SpinAdapted::multiply_h::operator()(Wavefunction& c, Wavefunction& v)
2121
block.multiplyH( c, &v, MAX_THRD);
2222
}
2323

24+
SpinAdapted::multiply_h_e::multiply_h_e(const SpinBlock& b, const bool &onedot_, double E0_) : block(b), E0(E0_){}
25+
26+
void SpinAdapted::multiply_h_e::operator()(Wavefunction& c, Wavefunction& v)
27+
{
28+
Wavefunction oi = v; oi.Clear();
29+
block.multiplyH( c, &v, MAX_THRD);
30+
block.multiplyOverlap(c, &oi, MAX_THRD);
31+
ScaleAdd(-E0, oi, v);
32+
}
33+
34+
35+
2436

davidson.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ class multiply_h : public Davidson_functor
2727
void operator()(Wavefunction& c, Wavefunction& v);
2828
const SpinBlock& get_block() {return block;}
2929
};
30+
31+
//H-E
32+
class multiply_h_e : public Davidson_functor
33+
{
34+
private:
35+
const SpinBlock& block;
36+
double E0;
37+
public:
38+
multiply_h_e(const SpinBlock& b, const bool &onedot_, double E0);
39+
void operator()(Wavefunction& c, Wavefunction& v);
40+
const SpinBlock& get_block() {return block;}
41+
};
42+
43+
3044
}
3145

3246
#endif

0 commit comments

Comments
 (0)