本文整理汇总了C++中SweepParams::set_sweep_iter方法的典型用法代码示例。如果您正苦于以下问题:C++ SweepParams::set_sweep_iter方法的具体用法?C++ SweepParams::set_sweep_iter怎么用?C++ SweepParams::set_sweep_iter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SweepParams
的用法示例。
在下文中一共展示了SweepParams::set_sweep_iter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeStateInfo
//Canonicalize wavefunction, takes the wavefunction and does a sweep to update all the roation matrices so that we get a consistent wavefunction along the whole sweep
void SpinAdapted::Sweep::CanonicalizeWavefunction(SweepParams &sweepParams, const bool &forward, int currentstate)
{
sweepParams.set_sweep_parameters();
sweepParams.set_block_iter() = 0;
std::vector<int> sites;
int new_site, wave_site;
if (forward) {
pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in forwards direction"<<endl;
new_site = 0;
}
else {
pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in backwards direction" << endl;
new_site = dmrginp.spinAdapted() ? dmrginp.last_site()-1 : dmrginp.last_site()/2-1;
}
pout << "\t\t\t ============================================================================ " <<
endl;
if (dmrginp.spinAdapted())
sites.push_back(new_site);
else {
sites.push_back(2*new_site);
sites.push_back(2*new_site+1);
std::sort(sites.begin(), sites.end());
}
//only need statinfos
StateInfo stateInfo1; makeStateInfo(stateInfo1, new_site);
for (; sweepParams.get_block_iter() < sweepParams.get_n_iters(); ) {
pout << "\t\t\t Block Iteration :: " << sweepParams.get_block_iter() << endl;
pout << "\t\t\t ----------------------------" << endl;
if (forward) {
new_site++;
wave_site = new_site+1;
pout << "\t\t\t Current direction is :: Forwards " << endl;
}
else {
new_site--;
wave_site = new_site-1;
pout << "\t\t\t Current direction is :: Backwards " << endl;
}
std::vector<int> complementarySites, spindotsites(1, new_site), oldsites = sites, oldcomplement;
if (dmrginp.spinAdapted())
sites.push_back(new_site);
else {
sites.push_back(2*new_site);
sites.push_back(2*new_site+1);
std::sort(sites.begin(), sites.end());
}
getComplementarySites(sites, complementarySites);
getComplementarySites(oldsites, oldcomplement);
StateInfo siteState, newState1, bigstate, envstate;
makeStateInfo(siteState, new_site);
TensorProduct(stateInfo1, siteState, newState1, NO_PARTICLE_SPIN_NUMBER_CONSTRAINT);
newState1.CollectQuanta();
Wavefunction w; w.set_deltaQuantum() = dmrginp.effective_molecule_quantum_vec();
w.set_onedot(true);
if (!dmrginp.spinAdapted()) {
std::vector<int> spinSites(complementarySites.size()/2, 0);
for (int s=0; s<spinSites.size(); s++)
spinSites[s] = complementarySites[2*s]/2;
StateInfo::restore(!forward, spinSites, envstate, currentstate);
}
else
StateInfo::restore(!forward, complementarySites, envstate, currentstate);
TensorProduct(newState1, envstate, bigstate, PARTICLE_SPIN_NUMBER_CONSTRAINT);
if (sweepParams.get_block_iter() == 0)
GuessWave::transpose_previous_wavefunction(w, bigstate, complementarySites, spindotsites, currentstate, true, true);
else
GuessWave::transform_previous_wavefunction(w, bigstate, oldsites, oldcomplement, currentstate, true, true);
w.SaveWavefunctionInfo(bigstate, sites, currentstate);
//make the newstate
std::vector<Matrix> rotation1;
DensityMatrix tracedMatrix;
tracedMatrix.allocate(*bigstate.leftStateInfo);
operatorfunctions::MultiplyProduct(w, Transpose(const_cast<Wavefunction&> (w)), tracedMatrix, 1.0);
int largeNumber = 1000000;
if (!mpigetrank())
double error = makeRotateMatrix(tracedMatrix, rotation1, largeNumber, sweepParams.get_keep_qstates());
SaveRotationMatrix (sites, rotation1, currentstate);
StateInfo renormState1;
//.........这里部分代码省略.........
示例2: do_one
//.........这里部分代码省略.........
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];
}
示例3: responseSweep
void responseSweep(double sweep_tol, int targetState, vector<int>& projectors, vector<int>& baseStates)
{
double last_fe = 1.e6;
double last_be = 1.e6;
double old_fe = 0.;
double old_be = 0.;
SweepParams sweepParams;
bool direction, warmUp, restart;
int restartSize=0;
direction = true; //forward
warmUp = true; //startup sweep
restart = false; //not a restart
sweepParams.current_root() = -1;
algorithmTypes atype = dmrginp.algorithm_method();
dmrginp.set_algorithm_method() = ONEDOT;
//the baseState is the initial guess for the targetState
if (FULLRESTART) {
sweepParams.restorestate(direction, restartSize);
direction = !direction;
dmrginp.setGuessState() = targetState;
last_fe = SweepResponse::do_one(sweepParams, warmUp, direction, restart, restartSize, targetState, projectors, baseStates);
bool tempdirection;
sweepParams.restorestate(tempdirection, restartSize);
sweepParams.calc_niter();
sweepParams.set_sweep_iter() = 0;
sweepParams.set_restart_iter() = 0;
sweepParams.savestate(tempdirection, restartSize);
}
else if (RESTART) {
dmrginp.set_algorithm_method() = atype;
warmUp = false;
restart = true;
sweepParams.restorestate(direction, restartSize);
last_fe = SweepResponse::do_one(sweepParams, warmUp, direction, restart, restartSize, targetState, projectors, baseStates);
}
else
last_fe = SweepResponse::do_one(sweepParams, warmUp, direction, restart, restartSize, targetState, projectors, baseStates);
dmrginp.set_algorithm_method() = atype;
restart = false;
restartSize = 0;
warmUp = false;
while ( true)
{
old_fe = last_fe;
old_be = last_be;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_be = SweepResponse::do_one(sweepParams, warmUp, !direction, restart, restartSize, targetState, projectors, baseStates);
p1out << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_fe = SweepResponse::do_one(sweepParams, warmUp, direction, restart, restartSize, targetState, projectors, baseStates);
pout << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
}
}
示例4: InitializeOverlapSpinBlocks
//before you start optimizing each state you want to initalize all the overlap matrices
void Sweep::InitializeOverlapSpinBlocks(SweepParams &sweepParams, const bool &forward, int stateA, int stateB)
{
SpinBlock system;
sweepParams.set_sweep_parameters();
if (forward)
pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in forwards direction"<<endl;
else
pout << "\t\t\t Starting sweep "<< sweepParams.set_sweep_iter()<<" in backwards direction" << endl;
pout << "\t\t\t ============================================================================ " << endl;
int restartSize = 0; bool restart = false, warmUp = false;
InitBlocks::InitStartingBlock (system,forward, stateA, stateB, sweepParams.get_forward_starting_size(), sweepParams.get_backward_starting_size(), restartSize, restart, warmUp);
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, stateA, stateB); // 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 (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
{
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;
}
SpinBlock systemDot, environmentDot;
int systemDotStart, systemDotEnd;
int systemDotSize = sweepParams.get_sys_add() - 1;
if (forward)
{
systemDotStart = dmrginp.spinAdapted() ? *system.get_sites().rbegin () + 1 : (*system.get_sites().rbegin ())/2 + 1 ;
systemDotEnd = systemDotStart + systemDotSize;
}
else
{
systemDotStart = dmrginp.spinAdapted() ? system.get_sites()[0] - 1 : (system.get_sites()[0])/2 - 1 ;
systemDotEnd = systemDotStart - systemDotSize;
}
systemDot = SpinBlock(systemDotStart, systemDotEnd, true);
SpinBlock newSystem; // new system after blocking and decimating
newSystem.initialise_op_array(OVERLAP, false);
newSystem.setstoragetype(DISTRIBUTED_STORAGE);
newSystem.BuildSumBlock (NO_PARTICLE_SPIN_NUMBER_CONSTRAINT, system, systemDot);
std::vector<Matrix> brarotateMatrix, ketrotateMatrix;
LoadRotationMatrix(newSystem.get_sites(), brarotateMatrix, stateA);
LoadRotationMatrix(newSystem.get_sites(), ketrotateMatrix, stateB);
newSystem.transform_operators(brarotateMatrix, ketrotateMatrix);
system = newSystem;
if (dmrginp.outputlevel() > 0){
pout << system<<endl;
}
SpinBlock::store (forward, system.get_sites(), system, stateA, stateB);
++sweepParams.set_block_iter();
sweepParams.savestate(forward, syssites.size());
if (dmrginp.outputlevel() > 0)
mcheck("at the end of sweep iteration");
}
pout << "\t\t\t ============================================================================ " << endl;
// update the static number of iterations
return ;
}
示例5: dmrg
void dmrg(double sweep_tol)
{
double last_fe = 10.e6;
double last_be = 10.e6;
double old_fe = 0.;
double old_be = 0.;
SweepParams sweepParams;
int old_states=sweepParams.get_keep_states();
int new_states;
double old_error=0.0;
double old_energy=0.0;
// warm up sweep ...
bool dodiis = false;
int domoreIter = 0;
bool direction;
//this is regular dmrg calculation
if(!dmrginp.setStateSpecific()) {
sweepParams.current_root() = -1;
last_fe = Sweep::do_one(sweepParams, true, true, false, 0);
direction = false;
while ((fabs(last_fe - old_fe) > sweep_tol) || (fabs(last_be - old_be) > sweep_tol) ||
(dmrginp.algorithm_method() == TWODOT_TO_ONEDOT && dmrginp.twodot_to_onedot_iter()+1 >= sweepParams.get_sweep_iter()) )
{
old_fe = last_fe;
old_be = last_be;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_be = Sweep::do_one(sweepParams, false, false, false, 0);
direction = true;
pout << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
//For obtaining the extrapolated energy
old_states=sweepParams.get_keep_states();
new_states=sweepParams.get_keep_states_ls();
last_fe = Sweep::do_one(sweepParams, false, true, false, 0);
direction = false;
new_states=sweepParams.get_keep_states();
pout << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
if (domoreIter == 2) {
dodiis = true;
break;
}
}
}
else { //this is state specific calculation
const int nroots = dmrginp.nroots();
bool direction=true;
int restartsize;
//sweepParams.restorestate(direction, restartsize);
//sweepParams.set_sweep_iter() = 0;
//sweepParams.set_restart_iter() = 0;
algorithmTypes atype;
pout << "STARTING STATE SPECIFIC CALCULATION "<<endl;
for (int i=0; i<nroots; i++) {
atype = dmrginp.algorithm_method();
dmrginp.set_algorithm_method() = ONEDOT;
sweepParams.current_root() = i;
p1out << "RUNNING GENERATE BLOCKS FOR STATE "<<i<<endl;
if (mpigetrank()==0) {
Sweep::InitializeStateInfo(sweepParams, direction, i);
Sweep::InitializeStateInfo(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
Sweep::InitializeStateInfo(sweepParams, direction, i);
Sweep::InitializeStateInfo(sweepParams, !direction, i);
}
for (int j=0; j<i ; j++) {
int integralIndex = 0;
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j, integralIndex);
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j, integralIndex);
}
dmrginp.set_algorithm_method() = atype;
p1out << "RUNNING GENERATE BLOCKS FOR STATE "<<i<<endl;
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, i, i);
sweepParams.set_sweep_iter() = 0;
sweepParams.set_restart_iter() = 0;
sweepParams.savestate(!direction, restartsize);
pout << "STATE SPECIFIC CALCULATION FOR STATE: "<<i<<endl;
//.........这里部分代码省略.........
示例6: restart
void restart(double sweep_tol, bool reset_iter)
{
double last_fe = 100.;
double last_be = 100.;
double old_fe = 0.;
double old_be = 0.;
bool direction;
int restartsize;
SweepParams sweepParams;
bool dodiis = false;
int domoreIter = 2;
sweepParams.restorestate(direction, restartsize);
if (!dmrginp.setStateSpecific()) {
if(reset_iter) { //this is when you restart from the start of the sweep
sweepParams.set_sweep_iter() = 0;
sweepParams.set_restart_iter() = 0;
}
if (restartwarm)
last_fe = Sweep::do_one(sweepParams, true, direction, true, restartsize);
else
last_fe = Sweep::do_one(sweepParams, false, direction, true, restartsize);
while ((fabs(last_fe - old_fe) > sweep_tol) || (fabs(last_be - old_be) > sweep_tol) ||
(dmrginp.algorithm_method() == TWODOT_TO_ONEDOT && dmrginp.twodot_to_onedot_iter()+1 >= sweepParams.get_sweep_iter()) )
{
old_fe = last_fe;
old_be = last_be;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_be = Sweep::do_one(sweepParams, false, !direction, false, 0);
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_fe = Sweep::do_one(sweepParams, false, direction, false, 0);
}
}
else { //this is state specific calculation
const int nroots = dmrginp.nroots();
bool direction;
int restartsize;
sweepParams.restorestate(direction, restartsize);
//initialize state and canonicalize all wavefunctions
int currentRoot = sweepParams.current_root();
for (int i=0; i<nroots; i++) {
sweepParams.current_root() = i;
if (mpigetrank()==0) {
Sweep::InitializeStateInfo(sweepParams, direction, i);
Sweep::InitializeStateInfo(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
}
}
//now generate overlaps with all the previous wavefunctions
for (int i=0; i<currentRoot; i++) {
sweepParams.current_root() = i;
if (mpigetrank()==0) {
for (int j=0; j<i; j++) {
int integralIndex = 0;
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j, integralIndex);
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j, integralIndex);
}
}
}
sweepParams.current_root() = currentRoot;
if (sweepParams.current_root() <0) {
p1out << "This is most likely not a restart calculation and should be done without the restart command!!"<<endl;
p1out << "Aborting!!"<<endl;
exit(0);
}
pout << "RESTARTING STATE SPECIFIC CALCULATION OF STATE "<<sweepParams.current_root()<<" AT SWEEP ITERATION "<<sweepParams.get_sweep_iter()<<endl;
//this is so that the iteration is not one ahead after generate block for restart
--sweepParams.set_sweep_iter(); sweepParams.savestate(direction, restartsize);
for (int i=sweepParams.current_root(); i<nroots; i++) {
sweepParams.current_root() = i;
p1out << "RUNNING GENERATE BLOCKS FOR STATE "<<i<<endl;
if (mpigetrank()==0) {
Sweep::InitializeStateInfo(sweepParams, direction, i);
Sweep::InitializeStateInfo(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, !direction, i);
Sweep::CanonicalizeWavefunction(sweepParams, direction, i);
for (int j=0; j<i ; j++) {
int integralIndex = 0;
Sweep::InitializeOverlapSpinBlocks(sweepParams, direction, i, j, integralIndex);
Sweep::InitializeOverlapSpinBlocks(sweepParams, !direction, i, j, integralIndex);
//.........这里部分代码省略.........
示例7: finalEnergy
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;
//.........这里部分代码省略.........
示例8: do_one
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;
}