double SpinAdapted::mps_nevpt::type1::do_one(SweepParams &sweepParams, const bool &warmUp, const bool &forward, const bool &restart, const int &restartSize, perturber& pb, int baseState) { int integralIndex = 0; SpinBlock system; system.nonactive_orb() = pb.orb(); const int nroots = dmrginp.nroots(sweepParams.get_sweep_iter()); std::vector<double> finalEnergy(nroots,-1.0e10); std::vector<double> finalEnergy_spins(nroots,0.); double finalError = 0.; sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine if (forward) if (dmrginp.outputlevel() > 0) pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in forwards direction"<<endl; else if (dmrginp.outputlevel() > 0) { pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in backwards direction" << endl; pout << "\t\t\t ============================================================================ " << endl; } InitBlocks::InitStartingBlock (system,forward, baseState, pb.wavenumber(), sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp, integralIndex, pb.braquanta, pb.ketquanta); if(!restart) sweepParams.set_block_iter() = 0; if (dmrginp.outputlevel() > 0) pout << "\t\t\t Starting block is :: " << endl << system << endl; SpinBlock::store (forward, system.get_sites(), system, pb.wavenumber(), baseState); // if restart, just restoring an existing block -- sweepParams.savestate(forward, system.get_sites().size()); bool dot_with_sys = true; vector<int> syssites = system.get_sites(); if (restart) { if (forward && system.get_complementary_sites()[0] >= dmrginp.last_site()/2) dot_with_sys = false; if (!forward && system.get_sites()[0]-1 < dmrginp.last_site()/2) dot_with_sys = false; } if (dmrginp.outputlevel() > 0) mcheck("at the very start of sweep"); // just timer for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) // get_n_iters() returns the number of blocking iterations needed in one sweep { if (dmrginp.outputlevel() > 0) { pout << "\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; pout << "\t\t\t ----------------------------" << endl; } if (dmrginp.outputlevel() > 0) { if (forward) { pout << "\t\t\t Current direction is :: Forwards " << endl; } else { pout << "\t\t\t Current direction is :: Backwards " << endl; } } if (sweepParams.get_block_iter() != 0) sweepParams.set_guesstype() = TRANSFORM; else sweepParams.set_guesstype() = TRANSPOSE; if (dmrginp.outputlevel() > 0) pout << "\t\t\t Blocking and Decimating " << endl; SpinBlock newSystem; // new system after blocking and decimating newSystem.nonactive_orb() = pb.orb(); //Need to substitute by: // if (warmUp ) // Startup(sweepParams, system, newSystem, dot_with_sys, pb.wavenumber(), baseState); // else { // BlockDecimateAndCompress (sweepParams, system, newSystem, false, dot_with_sys, pb.wavenumber(), baseState); // } BlockDecimateAndCompress (sweepParams, system, newSystem, warmUp, dot_with_sys,pb, baseState); //Need to substitute by? system = newSystem; if (dmrginp.outputlevel() > 0){ pout << system<<endl; pout << system.get_braStateInfo()<<endl; system.printOperatorSummary(); } //system size is going to be less than environment size if (forward && system.get_complementary_sites()[0] >= dmrginp.last_site()/2) dot_with_sys = false; if (!forward && system.get_sites()[0]-1 < dmrginp.last_site()/2) dot_with_sys = false; SpinBlock::store (forward, system.get_sites(), system, pb.wavenumber(), baseState); syssites = system.get_sites(); if (dmrginp.outputlevel() > 0) pout << "\t\t\t saving state " << syssites.size() << endl; ++sweepParams.set_block_iter(); #ifndef SERIAL mpi::communicator world; world.barrier(); #endif sweepParams.savestate(forward, syssites.size()); if (dmrginp.outputlevel() > 0) mcheck("at the end of sweep iteration"); } //FIXME //It does not seem necessary. //when we are doing twodot, we still need to do the last sweep to make sure that the //correctionVector and base wavefunction are propogated correctly across sweeps // //especially when we switch from twodot to onedot algorithm // if (!sweepParams.get_onedot() && !warmUp) { // pout << "\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; // pout << "\t\t\t ----------------------------" << endl; // if (dmrginp.outputlevel() > 0) { // if (forward) // pout << "\t\t\t Current direction is :: Forwards " << endl; // else // pout << "\t\t\t Current direction is :: Backwards " << endl; // } // sweepParams.set_onedot() = true; // sweepParams.set_env_add() = 0; // bool dot_with_sys = true; // WavefunctionCanonicalize(sweepParams, system, warmUp, dot_with_sys, targetState, baseState); // sweepParams.set_onedot() = false; // sweepParams.set_env_add() = 1; // } // pout << "\t\t\t Largest Error for Sweep with " << sweepParams.get_keep_states() << " states is " << finalError << endl; pout << "\t\t\t Largest overlap for Sweep with " << sweepParams.get_keep_states() << " states is " << finalEnergy[0] << endl; sweepParams.set_largest_dw() = finalError; pout << "\t\t\t ============================================================================ " << endl; // update the static number of iterations ++sweepParams.set_sweep_iter(); return finalError; }