@@ -325,10 +325,11 @@ json GroundStateSolver::optimize(Molecule &mol, FockBuilder &F, OrbitalVector &P
325
325
if (restricted) {
326
326
DoubleVector occNew = getNewOccupations (Phi_n, Phi_mom);
327
327
orbital::set_occupations (Phi_n, occNew);
328
-
329
- // orbital::print(Phi_n);
330
- // mol.calculateOrbitalPositions();
331
- // mol.printOrbitalPositions();
328
+ if (plevel > 1 ) {
329
+ orbital::print (Phi_n);
330
+ mol.calculateOrbitalPositions ();
331
+ mol.printOrbitalPositions ();
332
+ }
332
333
}
333
334
else {
334
335
// in case of unrestricted calculation, get the new occupation for alpha and beta spins independently
@@ -341,10 +342,11 @@ json GroundStateSolver::optimize(Molecule &mol, FockBuilder &F, OrbitalVector &P
341
342
DoubleVector occNew (occAlpha.size () + occBeta.size ());
342
343
occNew << occAlpha, occBeta;
343
344
orbital::set_occupations (Phi_n, occNew);
344
-
345
- // orbital::print(Phi_n);
346
- // mol.calculateOrbitalPositions();
347
- // mol.printOrbitalPositions();
345
+ if (plevel > 1 ) {
346
+ orbital::print (Phi_n);
347
+ mol.calculateOrbitalPositions ();
348
+ mol.printOrbitalPositions ();
349
+ }
348
350
}
349
351
}
350
352
@@ -475,36 +477,28 @@ bool GroundStateSolver::needDiagonalization(int nIter, bool converged) const {
475
477
DoubleVector GroundStateSolver::getNewOccupations (OrbitalVector &Phi_n, OrbitalVector &Phi_mom) {
476
478
DoubleMatrix overlap = orbital::calc_overlap_matrix (Phi_mom, Phi_n).real ();
477
479
DoubleVector occ = orbital::get_occupations (Phi_mom);// get occupation numbers of the orbitals of the first iteration
478
- // get all unique occupation numbers
479
- std::set<double > occupationNumbers (occ.begin (), occ.end ());
480
- // for each unique occupation number, determine which orbitals should be assigned this occupation number; necessary???
481
- double hole, occupied = 0.0 ;
482
- for (auto & occNumber : occupationNumbers) {
483
- if (occNumber > occupied) {
484
- hole = occupied;
485
- occupied = occNumber;
486
- }
487
- else {
488
- hole = occNumber;
489
- }
490
- }
491
- DoubleVector occNew = DoubleVector::Constant (occ.size (), hole);
492
- // create vector which contains the positions of the unique occupation number
480
+ double occ1 = occ (0 );
481
+ DoubleVector occNew = DoubleVector::Constant (occ.size (), occ1);
482
+
483
+ // create vector which contains the positions of the second occupation number
493
484
DoubleVector currOcc = DoubleVector::Zero (occ.size ());
494
485
unsigned int nCurrOcc = 0 ;
495
- for (unsigned int i = 0 ; i < occ.size (); i++) {
496
- if (occ (i) == occupied) {
486
+ double occ2 = 0.0 ;
487
+ for (unsigned int i = 1 ; i < occ.size (); i++) {
488
+ if (occ (i) != occ1) {
489
+ occ2 = occ (i);
497
490
currOcc (i) = 1.0 ;
498
491
nCurrOcc++;
499
492
}
500
493
}
501
- // only consider overlap with orbitals with the current unique occupation number
494
+
495
+ // only consider overlap with orbitals with the second occupation number
502
496
DoubleMatrix occOverlap = currOcc.asDiagonal () * overlap;
503
497
DoubleVector p = occOverlap.colwise ().norm ();
504
498
505
499
// print section
506
- print_utils::matrix (2 , " Overlap matrix" , overlap, 2 );
507
- print_utils::vector (2 , " Total overlap" , p, 2 );
500
+ print_utils::matrix (2 , " MOM overlap matrix" , overlap, 2 );
501
+ print_utils::vector (2 , " MOM total overlap" , p, 2 );
508
502
509
503
// sort by highest overlap
510
504
std::vector<std::pair<double , unsigned >> sortme;
@@ -513,9 +507,10 @@ DoubleVector GroundStateSolver::getNewOccupations(OrbitalVector &Phi_n, OrbitalV
513
507
}
514
508
std::stable_sort (sortme.begin (), sortme.end ());
515
509
std::reverse (sortme.begin (), sortme.end ());
516
- // assign the current unique occupation number to orbitals with highest overlap
510
+
511
+ // assign the second occupation number to orbitals with highest overlap
517
512
for (unsigned int q = 0 ; q < nCurrOcc; q++) {
518
- occNew (sortme[q].second ) = occupied ;
513
+ occNew (sortme[q].second ) = occ2 ;
519
514
}
520
515
sortme.clear ();
521
516
return occNew;
0 commit comments