26 #include "MPIchemps2.h" 52 if ( mx_elem != NULL ){
delete [] mx_elem; }
67 f1 =
new int[Ham->
getL()];
68 f2 =
new int[Ham->
getL()];
70 int DMRGirrepOrder[8];
71 DMRGirrepOrder[0] = 0;
72 DMRGirrepOrder[1] = 5;
73 DMRGirrepOrder[2] = 7;
74 DMRGirrepOrder[3] = 2;
75 DMRGirrepOrder[4] = 6;
76 DMRGirrepOrder[5] = 3;
77 DMRGirrepOrder[6] = 1;
78 DMRGirrepOrder[7] = 4;
81 for (
int irrep=0; irrep<8; irrep++){
82 for (
int HamOrb=0; HamOrb<Ham->
getL(); HamOrb++){
90 assert( DMRGOrb==Ham->
getL() );
107 f1 =
new int[Ham->
getL()];
108 f2 =
new int[Ham->
getL()];
110 int DMRGirrepOrder[4];
111 DMRGirrepOrder[0] = 0;
112 DMRGirrepOrder[1] = 2;
113 DMRGirrepOrder[2] = 3;
114 DMRGirrepOrder[3] = 1;
119 for (
int HamOrb=Ham->
getL()-1; HamOrb>=0; HamOrb--){
121 f1[HamOrb] = DMRGOrb;
122 f2[DMRGOrb] = HamOrb;
127 for (
int irrep=1; irrep<4; irrep++){
128 for (
int HamOrb=0; HamOrb<Ham->
getL(); HamOrb++){
130 f1[HamOrb] = DMRGOrb;
131 f2[DMRGOrb] = HamOrb;
136 assert( DMRGOrb==Ham->
getL() );
159 f1 =
new int[Ham->
getL()];
160 f2 =
new int[Ham->
getL()];
163 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){ f1[ ham_orb ] = -2; }
164 for (
int dmrg_orb = 0; dmrg_orb < Ham->
getL(); dmrg_orb++ ){
166 assert( dmrg2ham[ dmrg_orb ] >= 0 );
167 assert( dmrg2ham[ dmrg_orb ] < Ham->
getL() );
168 f2[ dmrg_orb ] = dmrg2ham[ dmrg_orb ];
169 f1[ dmrg2ham[ dmrg_orb ] ] = dmrg_orb;
173 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){ assert( f1[ ham_orb ] >= 0 ); }
179 assert(
gSy() == 7 );
180 const int num_irreps = 8;
181 const int irrep_ag = 0;
182 const int irrep_b1g = 1;
183 const int irrep_b2g = 2;
184 const int irrep_b3g = 3;
185 const int irrep_au = 4;
186 const int irrep_b1u = 5;
187 const int irrep_b2u = 6;
188 const int irrep_b3u = 7;
190 double * sp_energies =
new double[ Ham->
getL() ];
191 int * dmrg2ham =
new int[ Ham->
getL() ];
192 int * partners =
new int[ Ham->
getL() ];
195 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){
196 double value = Ham->
getTmat( ham_orb, ham_orb );
197 for (
int irrep = 0; irrep < num_irreps; irrep++ ){
199 for (
int frozen_orb = 0; frozen_orb < Ham->
getL(); frozen_orb++ ){
201 if ( counter < docc[ irrep ] ){
202 value += 2 * Ham->
getVmat( ham_orb, frozen_orb, ham_orb, frozen_orb )
203 - Ham->
getVmat( ham_orb, ham_orb, frozen_orb, frozen_orb );
209 sp_energies[ ham_orb ] = value;
213 for (
int cnt = 0; cnt < Ham->
getL(); cnt++ ){ partners[ cnt ] = -2; }
217 for (
int ham_orb = Ham->
getL() - 1; ham_orb >= 0; ham_orb-- ){
219 dmrg2ham[ dmrg_orb ] = ham_orb;
220 for (
int partner_orb = 0; partner_orb < Ham->
getL(); partner_orb++ ){
222 if ( fabs( sp_energies[ ham_orb ] - sp_energies[ partner_orb ] ) < sp_threshold ){
223 partners[ dmrg_orb ] = partner_orb;
232 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){
234 dmrg2ham[ dmrg_orb ] = ham_orb;
235 for (
int partner_orb = 0; partner_orb < Ham->
getL(); partner_orb++ ){
237 if ( fabs( sp_energies[ ham_orb ] - sp_energies[ partner_orb ] ) < sp_threshold ){
238 partners[ dmrg_orb ] = partner_orb;
245 const int num_delta_ug = dmrg_orb;
246 assert( (num_delta_ug % 2) == 0 );
249 for (
int cnt = 0; cnt < num_delta_ug; cnt++ ){
250 assert( partners[ cnt ] >= 0 );
251 dmrg2ham[ dmrg_orb ] = partners[ cnt ];
256 for (
int ham_orb = Ham->
getL() - 1; ham_orb >= 0; ham_orb-- ){
258 bool is_a_partner =
false;
259 for (
int cnt = 0; cnt < num_delta_ug; cnt++ ){
260 if ( ham_orb == partners[ cnt ] ){ is_a_partner =
true; }
262 if ( is_a_partner ==
false ){
263 dmrg2ham[ dmrg_orb ] = ham_orb;
270 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){
272 bool is_a_partner =
false;
273 for (
int cnt = 0; cnt < num_delta_ug; cnt++ ){
274 if ( ham_orb == partners[ cnt ] ){ is_a_partner =
true; }
276 if ( is_a_partner ==
false ){
277 dmrg2ham[ dmrg_orb ] = ham_orb;
284 for (
int ham_orb = Ham->
getL() - 1; ham_orb >= 0; ham_orb-- ){
286 dmrg2ham[ dmrg_orb ] = ham_orb;
292 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){
294 dmrg2ham[ dmrg_orb ] = ham_orb;
300 for (
int ham_orb = Ham->
getL() - 1; ham_orb >= 0; ham_orb-- ){
302 dmrg2ham[ dmrg_orb ] = ham_orb;
308 for (
int ham_orb = 0; ham_orb < Ham->
getL(); ham_orb++ ){
310 dmrg2ham[ dmrg_orb ] = ham_orb;
315 assert( dmrg_orb == Ham->
getL() );
318 #ifdef CHEMPS2_MPI_COMPILATION 322 cout <<
"Reordered the orbitals according to d(infinity)h:" << endl;
324 for ( dmrg_orb = 0; dmrg_orb < Ham->
getL(); dmrg_orb++ ){
325 const int ham_orb = dmrg2ham[ dmrg_orb ];
326 cout <<
" DMRG orb " << dmrg_orb <<
" [" << myIrreps.
getIrrepName(Ham->
getOrbitalIrrep( ham_orb )) <<
"] has SP energy = " << sp_energies[ ham_orb ] << endl;
332 delete [] sp_energies;
352 return mx_elem[ alpha + L * ( beta + L * ( gamma + L * delta ) ) ];
358 mx_elem[ alpha + L * ( beta + L * ( gamma + L * delta ) ) ] = value;
364 if ( mx_elem == NULL ){ mx_elem =
new double[ L*L*L*L ]; }
365 const double prefact = 1.0/(N-1);
367 for (
int orb1 = 0; orb1 < L; orb1++){
368 const int map1 = (( !bReorder ) ? orb1 : f2[ orb1 ]);
369 for (
int orb2 = 0; orb2 < L; orb2++){
370 const int map2 = (( !bReorder ) ? orb2 : f2[ orb2 ]);
371 for (
int orb3 = 0; orb3 < L; orb3++){
372 const int map3 = (( !bReorder ) ? orb3 : f2[ orb3 ]);
373 for (
int orb4 = 0; orb4 < L; orb4++){
374 const int map4 = (( !bReorder ) ? orb4 : f2[ orb4 ]);
376 + prefact*((orb1==orb3)?Ham->
getTmat(map2,map4):0)
377 + prefact*((orb2==orb4)?Ham->
getTmat(map1,map3):0) );
389 cout <<
"Problem::Problem() : Irrep out of bound : Irrep = " <<
gIrrep() << endl;
393 cout <<
"Problem::checkConsistency() : TwoS = " <<
gTwoS() << endl;
397 cout <<
"Problem::checkConsistency() : N = " <<
gN() << endl;
401 cout <<
"Problem::checkConsistency() : L = " <<
gL() << endl;
405 cout <<
"Problem::checkConsistency() : N > 2*L ; N = " <<
gN() <<
" and L = " <<
gL() << endl;
408 if ( (
gN()%2) != (
gTwoS()%2) ){
409 cout <<
"Problem::checkConsistency() : N%2 != TwoS%2 ; N = " <<
gN() <<
" and TwoS = " <<
gTwoS() << endl;
413 cout <<
"Problem::checkConsistency() : TwoS > L - |N-L| ; N = " <<
gN() <<
" and TwoS = " <<
gTwoS() <<
" and L = " <<
gL() << endl;
void setMxElement(const int alpha, const int beta, const int gamma, const int delta, const double value)
Set the matrix elements: Note that each time you create a DMRG object, they will be overwritten with ...
int getNumberOfIrreps() const
Get the number of irreps for the currently activated group.
void setup_reorder_dinfh(int *docc, const double sp_threshold=1e-5)
Reorder the orbitals for d(infinity)h. Previous reorderings are cleared.
bool gReorder() const
Get whether the Hamiltonian orbitals are reordered for the DMRG calculation.
int getOrbitalIrrep(const int nOrb) const
Get an orbital irrep number.
static int mpi_rank()
Get the rank of this MPI process.
double getVmat(const int index1, const int index2, const int index3, const int index4) const
Get a Vmat element.
bool checkConsistency() const
Check whether the given parameters L, N, and TwoS are not inconsistent and whether 0<=Irrep<nIrreps...
void setup_reorder_custom(int *dmrg2ham)
Reorder the orbitals to a custom ordering. Previous reorderings are cleared.
double getTmat(const int index1, const int index2) const
Get a Tmat element.
int gN() const
Get the targeted particle number.
int gTwoS() const
Get twice the targeted spin.
double gMxElement(const int alpha, const int beta, const int gamma, const int delta) const
Get a specific interaction matrix element.
int gf1(const int HamOrb) const
Get the DMRG index corresponding to a Ham index.
void SetupReorderC2v()
Reorder the orbitals, so that they form irrep blocks, with order of irreps A1 B1 B2 A2...
int gL() const
Get the number of orbitals.
void SetupReorderD2h()
Reorder the orbitals, so that they form irrep blocks, with order of irreps Ag B1u B3u B2g B2u B3g B1g...
virtual ~Problem()
Destructor.
void construct_mxelem()
Construct a table with the h-matrix elements (two-body augmented with one-body). Remember to recall t...
Problem(const Hamiltonian *Hamin, const int TwoSin, const int Nin, const int Irrepin)
Constructor.
int getL() const
Get the number of orbitals.
int gIrrep() const
Get the targeted irrep.
string getIrrepName(const int irrepNumber) const
Get the name of the irrep with number irrepNumber of the activated group. The irrep with number 0 is ...
int gSy() const
Get the point group symmetry.
int gf2(const int DMRGOrb) const
Get the Ham index corresponding to a DMRG index.