double SweepOnepdm::do_one(SweepParams &sweepParams, const bool &warmUp, const bool &forward, const bool &restart, const int &restartSize) { SpinBlock system; const int nroots = dmrginp.nroots(); std::vector<double> finalEnergy(nroots,0.); std::vector<double> finalEnergy_spins(nroots,0.); double finalError = 0.; Matrix onepdm(2*dmrginp.last_site(), 2*dmrginp.last_site());onepdm=0.0; for (int i=0; i<nroots; i++) for (int j=0; j<=i; j++) save_onepdm_binary(onepdm, i ,j); sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine pout << ((forward) ? "\t\t\t Starting renormalisation sweep in forwards direction" : "\t\t\t Starting renormalisation sweep in backwards direction") << endl; pout << "\t\t\t ============================================================================ " << endl; InitBlocks::InitStartingBlock (system,forward, sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp); sweepParams.set_block_iter() = 0; pout << "\t\t\t Starting block is :: " << endl << system << endl; SpinBlock::store (forward, system.get_sites(), system); // if restart, just restoring an existing block -- sweepParams.savestate(forward, system.get_sites().size()); bool dot_with_sys = true; sweepParams.set_guesstype() = TRANSPOSE; SpinBlock newSystem; BlockAndDecimate (sweepParams, system, newSystem, warmUp, dot_with_sys); pout.precision(12); pout << "\t\t\t The lowest sweep energy : "<< sweepParams.get_lowest_energy()[0]+dmrginp.get_coreenergy()<<endl; pout << "\t\t\t ============================================================================ " << endl; for (int i=0; i<nroots; i++) for (int j=0; j<=i; j++) { load_onepdm_binary(onepdm, i ,j); accumulate_onepdm(onepdm); save_onepdm_spatial_text(onepdm, i ,j); save_onepdm_text(onepdm, i ,j); save_onepdm_spatial_binary(onepdm, i ,j); } return sweepParams.get_lowest_energy()[0]; }
double SweepTwopdm::do_one(SweepParams &sweepParams, const bool &warmUp, const bool &forward, const bool &restart, const int &restartSize, int state) { Timer sweeptimer; int integralIndex = 0; if (dmrginp.hamiltonian() == BCS) { pout << "Two PDM with BCS calculations is not implemented" << endl; exit(0); } pout.precision(12); SpinBlock system; const int nroots = dmrginp.nroots(); std::vector<double> finalEnergy(nroots,0.); std::vector<double> finalEnergy_spins(nroots,0.); double finalError = 0.; sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine pout << ((forward) ? "\t\t\t Starting renormalisation sweep in forwards direction" : "\t\t\t Starting renormalisation sweep in backwards direction") << endl; pout << "\t\t\t ============================================================================ " << endl; InitBlocks::InitStartingBlock (system,forward, sweepParams.current_root(), sweepParams.current_root(), sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp, integralIndex); if(!restart) sweepParams.set_block_iter() = 0; pout << "\t\t\t Starting block is :: " << endl << system << endl; if (!restart) SpinBlock::store (forward, system.get_sites(), system, sweepParams.current_root(), sweepParams.current_root()); // if restart, just restoring an existing block -- sweepParams.savestate(forward, system.get_sites().size()); bool dot_with_sys = true; array_4d<double> twopdm(2*dmrginp.last_site(), 2*dmrginp.last_site(), 2*dmrginp.last_site(), 2*dmrginp.last_site()); twopdm.Clear(); save_twopdm_binary(twopdm, state, state); for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) { pout << "\n\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; pout << "\t\t\t ----------------------------" << endl; if (forward) p1out << "\t\t\t Current direction is :: Forwards " << endl; else p1out << "\t\t\t Current direction is :: Backwards " << endl; //if (SHOW_MORE) pout << "system block" << endl << system << endl; if (dmrginp.no_transform()) sweepParams.set_guesstype() = BASIC; else if (!warmUp && sweepParams.get_block_iter() != 0) sweepParams.set_guesstype() = TRANSFORM; else if (!warmUp && sweepParams.get_block_iter() == 0 && ((dmrginp.algorithm_method() == TWODOT_TO_ONEDOT && dmrginp.twodot_to_onedot_iter() != sweepParams.get_sweep_iter()) || dmrginp.algorithm_method() != TWODOT_TO_ONEDOT)) sweepParams.set_guesstype() = TRANSPOSE; else sweepParams.set_guesstype() = BASIC; p1out << "\t\t\t Blocking and Decimating " << endl; SpinBlock newSystem; BlockAndDecimate (sweepParams, system, newSystem, warmUp, dot_with_sys, state); for(int j=0;j<nroots;++j) pout << "\t\t\t Total block energy for State [ " << j << " ] with " << sweepParams.get_keep_states()<<" :: " << sweepParams.get_lowest_energy()[j] <<endl; finalEnergy_spins = ((sweepParams.get_lowest_energy()[0] < finalEnergy[0]) ? sweepParams.get_lowest_energy_spins() : finalEnergy_spins); finalEnergy = ((sweepParams.get_lowest_energy()[0] < finalEnergy[0]) ? sweepParams.get_lowest_energy() : finalEnergy); finalError = max(sweepParams.get_lowest_error(),finalError); system = newSystem; pout << system<<endl; SpinBlock::store (forward, system.get_sites(), system, sweepParams.current_root(), sweepParams.current_root()); p1out << "\t\t\t saving state " << system.get_sites().size() << endl; ++sweepParams.set_block_iter(); //sweepParams.savestate(forward, system.get_sites().size()); } //for(int j=0;j<nroots;++j) {int j = state; pout << "\t\t\t Finished Sweep with " << sweepParams.get_keep_states() << " states and sweep energy for State [ " << j << " ] with Spin [ " << dmrginp.molecule_quantum().get_s() << " ] :: " << finalEnergy[j] << endl; } pout << "\t\t\t Largest Error for Sweep with " << sweepParams.get_keep_states() << " states is " << finalError << endl; pout << "\t\t\t ============================================================================ " << endl; int i = state, j = state; //for (int j=0; j<=i; j++) { load_twopdm_binary(twopdm, i, j); //calcenergy(twopdm, i); save_twopdm_text(twopdm, i, j); save_spatial_twopdm_text(twopdm, i, j); save_spatial_twopdm_binary(twopdm, i, j); // update the static number of iterations ++sweepParams.set_sweep_iter(); ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime(); pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl; pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl; return finalEnergy[0]; }
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; }
void SpinAdapted::mps_nevpt::type1::BlockDecimateAndCompress (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, perturber& pb, int baseState) { int sweepiter = sweepParams.get_sweep_iter(); if (dmrginp.outputlevel() > 0) { mcheck("at the start of block and decimate"); pout << "\t\t\t dot with system "<<dot_with_sys<<endl; pout <<endl<< "\t\t\t Performing Blocking"<<endl; } // figure out if we are going forward or backwards dmrginp.guessgenT -> start(); bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; SpinBlock environment, environmentDot, newEnvironment; SpinBlock big; environment.nonactive_orb() = pb.orb(); newEnvironment.nonactive_orb() = pb.orb(); int systemDotStart, systemDotEnd; int environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; int systemDotSize = sweepParams.get_sys_add() - 1; int environmentDotSize = sweepParams.get_env_add() -1; if (forward) { systemDotStart = dmrginp.spinAdapted() ? *system.get_sites().rbegin () + 1 : (*system.get_sites().rbegin ())/2 + 1 ; systemDotEnd = systemDotStart + systemDotSize; environmentDotStart = systemDotEnd + 1; environmentDotEnd = environmentDotStart + environmentDotSize; } else { systemDotStart = dmrginp.spinAdapted() ? system.get_sites()[0] - 1 : (system.get_sites()[0])/2 - 1 ; systemDotEnd = systemDotStart - systemDotSize; environmentDotStart = systemDotEnd - 1; environmentDotEnd = environmentDotStart - environmentDotSize; } systemDot = SpinBlock(systemDotStart, systemDotEnd, pb.orb()); environmentDot = SpinBlock(environmentDotStart, environmentDotEnd, pb.orb()); Sweep::makeSystemEnvironmentBigBlocks(system, systemDot, newSystem, environment, environmentDot, newEnvironment, big, sweepParams, dot_with_sys, useSlater, system.get_integralIndex(), pb.wavenumber(), baseState,pb.braquanta,pb.ketquanta); //analyse_operator_distribution(big); dmrginp.guessgenT -> stop(); dmrginp.multiplierT -> start(); std::vector<Matrix> rotatematrix; if (dmrginp.outputlevel() > 0) mcheck(""); if (dmrginp.outputlevel() > 0) { if (!dot_with_sys && sweepParams.get_onedot()) { pout << "\t\t\t System Block"<<system; } else pout << "\t\t\t System Block"<<newSystem; pout << "\t\t\t Environment Block"<<newEnvironment<<endl; pout << "\t\t\t Solving wavefunction "<<endl; } std::vector<Wavefunction> solution; solution.resize(1); std::vector<Wavefunction> outputState; outputState.resize(1); DiagonalMatrix e; //read the 0th wavefunction which we keep on the ket side because by default the ket stateinfo is used to initialize wavefunction //also when you use spinblock operators to multiply a state, it does so from the ket side i.e. H|ket> //GuessWave::guess_wavefunctions(solution, e, big, sweepParams.set_guesstype(), sweepParams.get_onedot(), dot_with_sys, 0.0, baseState); GuessWave::guess_wavefunctions(solution[0], e, big, sweepParams.set_guesstype(), sweepParams.get_onedot(), baseState, dot_with_sys, 0.0); #ifndef SERIAL mpi::communicator world; broadcast(world, solution, 0); #endif outputState[0].AllowQuantaFor(big.get_leftBlock()->get_braStateInfo(), big.get_rightBlock()->get_braStateInfo(),pb.braquanta); outputState[0].set_onedot(sweepParams.get_onedot()); outputState[0].Clear(); if (pb.type() == TwoPerturbType::Va) big.multiplyCDD_sum(solution[0],&(outputState[0]),MAX_THRD); if (pb.type() == TwoPerturbType::Vi) big.multiplyCCD_sum(solution[0],&(outputState[0]),MAX_THRD); //davidson_f(solution[0], outputState[0]); SpinBlock newbig; if (sweepParams.get_onedot() && !dot_with_sys) { InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, baseState, pb.wavenumber(), systemDot.size(), dmrginp.direct(), system.get_integralIndex(), DISTRIBUTED_STORAGE, false, true,NO_PARTICLE_SPIN_NUMBER_CONSTRAINT,pb.braquanta,pb.ketquanta); InitBlocks::InitBigBlock(newSystem, environment, newbig,pb.braquanta,pb.ketquanta); Wavefunction tempwave = outputState[0]; GuessWave::onedot_shufflesysdot(big.get_braStateInfo(), newbig.get_braStateInfo(), outputState[0], tempwave); outputState[0] = tempwave; tempwave = solution[0]; GuessWave::onedot_shufflesysdot(big.get_ketStateInfo(), newbig.get_ketStateInfo(), solution[0], tempwave); solution[0] = tempwave; big.get_rightBlock()->clear(); big.clear(); } else newbig = big; DensityMatrix bratracedMatrix(newSystem.get_braStateInfo()); bratracedMatrix.allocate(newSystem.get_braStateInfo()); //bratracedMatrix.makedensitymatrix(outputState, newbig, dmrginp.weights(sweepiter), 0.0, 0.0, true); bratracedMatrix.makedensitymatrix(outputState, newbig, std::vector<double>(1,1.0), 0.0, 0.0, true); if (sweepParams.get_noise() > NUMERICAL_ZERO) { pout << "adding noise "<<trace(bratracedMatrix)<<" "<<sweepiter<<" "<<dmrginp.weights(sweepiter)[0]<<endl; bratracedMatrix.add_onedot_noise_forCompression(solution[0], newbig, sweepParams.get_noise()*max(1.0,trace(bratracedMatrix))); if (trace(bratracedMatrix) <1e-14) bratracedMatrix.SymmetricRandomise(); pout << "after noise "<<trace(bratracedMatrix)<<" "<<sweepParams.get_noise()<<endl; } environment.clear(); newEnvironment.clear(); std::vector<Matrix> brarotateMatrix, ketrotateMatrix; LoadRotationMatrix (newSystem.get_sites(), ketrotateMatrix, baseState); double braerror; if (!mpigetrank()) { braerror = makeRotateMatrix(bratracedMatrix, brarotateMatrix, sweepParams.get_keep_states(), sweepParams.get_keep_qstates()); } #ifndef SERIAL broadcast(world, ketrotateMatrix, 0); broadcast(world, brarotateMatrix, 0); #endif if (dmrginp.outputlevel() > 0) pout << "\t\t\t Total bra discarded weight "<<braerror<<endl<<endl; sweepParams.set_lowest_error() = braerror; SaveRotationMatrix (newbig.get_leftBlock()->get_sites(), brarotateMatrix, pb.wavenumber()); //FIXME //It is neccessary for twodot algorithm to save baseState wavefuntion. //I do not know why. solution[0].SaveWavefunctionInfo (newbig.get_ketStateInfo(), newbig.get_leftBlock()->get_sites(), baseState); outputState[0].SaveWavefunctionInfo (newbig.get_braStateInfo(), newbig.get_leftBlock()->get_sites(), pb.wavenumber()); //TODO //Why do I need this? //They should have been consistent. // solution[0].SaveWavefunctionInfo (newbig.get_ketStateInfo(), newbig.get_leftBlock()->get_sites(), baseState); // SaveRotationMatrix (newbig.get_leftBlock()->get_sites(), ketrotateMatrix, baseState); if (dmrginp.outputlevel() > 0) pout <<"\t\t\t Performing Renormalization "<<endl; newSystem.transform_operators(brarotateMatrix, ketrotateMatrix); if (dmrginp.outputlevel() > 0) mcheck("after rotation and transformation of block"); if (dmrginp.outputlevel() > 0){ pout << *dmrginp.guessgenT<<" "<<*dmrginp.multiplierT<<" "<<*dmrginp.operrotT<< " "<<globaltimer.totalwalltime()<<" timer "<<endl; pout << *dmrginp.makeopsT<<" makeops "<<endl; pout << *dmrginp.datatransfer<<" datatransfer "<<endl; pout <<"oneindexopmult twoindexopmult Hc couplingcoeff"<<endl; pout << *dmrginp.oneelecT<<" "<<*dmrginp.twoelecT<<" "<<*dmrginp.hmultiply<<" "<<*dmrginp.couplingcoeff<<" hmult"<<endl; pout << *dmrginp.buildsumblock<<" "<<*dmrginp.buildblockops<<" build block"<<endl; pout << "addnoise S_0_opxop S_1_opxop S_2_opxop"<<endl; pout << *dmrginp.addnoise<<" "<<*dmrginp.s0time<<" "<<*dmrginp.s1time<<" "<<*dmrginp.s2time<<endl; } }
double SweepOnepdm::do_one(SweepParams &sweepParams, const bool &warmUp, const bool &forward, const bool &restart, const int &restartSize, int state) { Timer sweeptimer; int integralIndex = 0; SpinBlock system; const int nroots = dmrginp.nroots(); std::vector<double> finalEnergy(nroots,0.); std::vector<double> finalEnergy_spins(nroots,0.); double finalError = 0.; int pdmsize = dmrginp.spinAdapted() ? 2*dmrginp.last_site() : dmrginp.last_site(); Matrix onepdm(pdmsize, pdmsize);onepdm=0.0; Matrix pairmat; if (dmrginp.hamiltonian() == BCS) { pairmat.ReSize(pdmsize, pdmsize); pairmat = 0.0; save_pairmat_binary(pairmat, state, state); } save_onepdm_binary(onepdm, state ,state); sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine pout << ((forward) ? "\t\t\t Starting renormalisation sweep in forwards direction" : "\t\t\t Starting renormalisation sweep in backwards direction") << endl; pout << "\t\t\t ============================================================================ " << endl; InitBlocks::InitStartingBlock (system,forward, sweepParams.current_root(), sweepParams.current_root(), sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp, integralIndex); sweepParams.set_block_iter() = 0; pout << "\t\t\t Starting block is :: " << endl << system << endl; SpinBlock::store (forward, system.get_sites(), system, sweepParams.current_root(), sweepParams.current_root()); // if restart, just restoring an existing block -- sweepParams.savestate(forward, system.get_sites().size()); bool dot_with_sys = true; sweepParams.set_guesstype() = TRANSPOSE; for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) { pout << "\n\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; pout << "\t\t\t ----------------------------" << endl; if (forward) p1out << "\t\t\t Current direction is :: Forwards " << endl; else p1out << "\t\t\t Current direction is :: Backwards " << endl; if (sweepParams.get_block_iter() == 0) sweepParams.set_guesstype() = TRANSPOSE; else sweepParams.set_guesstype() = TRANSFORM; p1out << "\t\t\t Blocking and Decimating " << endl; SpinBlock newSystem; BlockAndDecimate (sweepParams, system, newSystem, warmUp, dot_with_sys, state); pout.precision(12); system = newSystem; pout << system<<endl; SpinBlock::store (forward, system.get_sites(), system, sweepParams.current_root(), sweepParams.current_root()); p1out << "\t\t\t saving state " << system.get_sites().size() << endl; ++sweepParams.set_block_iter(); //sweepParams.savestate(forward, system.get_sites().size()); } pout << "\t\t\t The lowest sweep energy : "<< sweepParams.get_lowest_energy()[0] << endl; pout << "\t\t\t ============================================================================ " << endl; load_onepdm_binary(onepdm, state ,state); accumulate_onepdm(onepdm); save_onepdm_spatial_text(onepdm, state, state); save_onepdm_text(onepdm, state, state); save_onepdm_spatial_binary(onepdm, state, state); if (dmrginp.hamiltonian() == BCS) { load_pairmat_binary(pairmat, state, state); accumulate_onepdm(pairmat); // FIXME write out text version // only <D{ia}D{jb}> is in the matrix save_pairmat_text(pairmat , state, state); } ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime(); pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl; pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl; return sweepParams.get_lowest_energy()[0]; }
void SweepGenblock::do_one(SweepParams &sweepParams, const bool &forward, int stateA, int stateB) { Timer sweeptimer; int integralIndex = 0; SpinBlock system; sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine pout << ((forward) ? "\t\t\t Starting renormalisation sweep in forwards direction" : "\t\t\t Starting renormalisation sweep in backwards direction") << endl; pout << "\t\t\t ============================================================================ " << endl; InitBlocks::InitStartingBlock (system,forward, stateA, stateB, sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), 0, false, false, integralIndex); sweepParams.set_block_iter() = 0; p2out << "\t\t\t Starting block is :: " << endl << system << endl; bool dot_with_sys = true; for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) { pout << "\n\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; pout << "\t\t\t ----------------------------" << endl; if (forward) { p1out << "\t\t\t Current direction is :: Forwards " << endl; } else { p1out << "\t\t\t Current direction is :: Backwards " << endl; } if (dmrginp.no_transform()) sweepParams.set_guesstype() = BASIC; else if ( sweepParams.get_block_iter() != 0) sweepParams.set_guesstype() = TRANSFORM; else if ( sweepParams.get_block_iter() == 0 ) sweepParams.set_guesstype() = TRANSPOSE; else sweepParams.set_guesstype() = BASIC; p1out << "\t\t\t Blocking and Decimating " << endl; SpinBlock newSystem; BlockAndDecimate (sweepParams, system, newSystem, false, dot_with_sys, stateA, stateB); system = newSystem; SpinBlock::store(forward, system.get_sites(), system, stateA, stateB); //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; ++sweepParams.set_block_iter(); } pout << "\t\t\t Finished Generate-Blocks Sweep. " << endl; pout << "\t\t\t ============================================================================ " << endl; // update the static number of iterations ++sweepParams.set_sweep_iter(); ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime(); pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl; pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl; }
double SweepGenblock::do_one(SweepParams &sweepParams, const bool &warmUp, const bool &forward, const bool &restart, const int &restartSize, int stateA, int stateB) { Timer sweeptimer; int integralIndex = 0; SpinBlock system; const int nroots = dmrginp.nroots(); std::vector<double> finalEnergy(nroots,0.); std::vector<double> finalEnergy_spins(nroots,0.); double finalError = 0.; sweepParams.set_sweep_parameters(); // a new renormalisation sweep routine pout << ((forward) ? "\t\t\t Starting renormalisation sweep in forwards direction" : "\t\t\t Starting renormalisation sweep in backwards direction") << endl; pout << "\t\t\t ============================================================================ " << endl; InitBlocks::InitStartingBlock (system,forward, stateA, stateB, sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp, integralIndex); if(!restart) sweepParams.set_block_iter() = 0; p2out << "\t\t\t Starting block is :: " << endl << system << endl; //if (!restart) SpinBlock::store (forward, system.get_sites(), system, stateA, stateB); // if restart, just restoring an existing block -- sweepParams.savestate(forward, system.get_sites().size()); bool dot_with_sys = true; 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; } for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) { pout << "\n\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl; pout << "\t\t\t ----------------------------" << endl; if (forward) { p1out << "\t\t\t Current direction is :: Forwards " << endl; } else { p1out << "\t\t\t Current direction is :: Backwards " << endl; } //if (SHOW_MORE) pout << "system block" << endl << system << endl; if (dmrginp.no_transform()) sweepParams.set_guesstype() = BASIC; else if (!warmUp && sweepParams.get_block_iter() != 0) sweepParams.set_guesstype() = TRANSFORM; else if (!warmUp && sweepParams.get_block_iter() == 0 && ((dmrginp.algorithm_method() == TWODOT_TO_ONEDOT && dmrginp.twodot_to_onedot_iter() != sweepParams.get_sweep_iter()) || dmrginp.algorithm_method() != TWODOT_TO_ONEDOT)) sweepParams.set_guesstype() = TRANSPOSE; else sweepParams.set_guesstype() = BASIC; p1out << "\t\t\t Blocking and Decimating " << endl; SpinBlock newSystem; BlockAndDecimate (sweepParams, system, newSystem, warmUp, dot_with_sys, stateA, stateB); system = newSystem; //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, stateA, stateB); p1out << "\t\t\t saving state " << system.get_sites().size() << endl; ++sweepParams.set_block_iter(); //if (sweepParams.get_onedot()) //pout << "\t\t\tUsing one dot algorithm!!"<<endl; sweepParams.savestate(forward, system.get_sites().size()); } pout << "\t\t\t Finished Generate-Blocks Sweep. " << endl; pout << "\t\t\t ============================================================================ " << endl; // update the static number of iterations ++sweepParams.set_sweep_iter(); ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime(); pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl; pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl; return finalEnergy[0]; }