//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 ; }
void SpinAdapted::InitBlocks::InitNewOverlapEnvironmentBlock(SpinBlock &environment, SpinBlock& environmentDot, SpinBlock &newEnvironment, const SpinBlock &system, SpinBlock &systemDot, int leftState, int rightState, const int &sys_add, const int &env_add, const bool &forward, int integralIndex, const bool &onedot, const bool& dot_with_sys, int constraint) { // now initialise environment Dot int systemDotStart, systemDotEnd, environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; int systemDotSize = sys_add - 1; int environmentDotSize = 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; environmentStart = environmentDotEnd + 1; environmentEnd = dmrginp.spinAdapted() ? dmrginp.last_site() - 1 : dmrginp.last_site()/2 - 1; } else { systemDotStart = dmrginp.spinAdapted() ? system.get_sites()[0] - 1 : (system.get_sites()[0])/2 - 1 ; systemDotEnd = systemDotStart - systemDotSize; environmentDotStart = systemDotEnd - 1; environmentDotEnd = environmentDotStart - environmentDotSize; environmentStart = environmentDotEnd - 1; environmentEnd = 0; } std::vector<int> environmentSites; environmentSites.resize(abs(environmentEnd - environmentStart) + 1); for (int i = 0; i < abs(environmentEnd - environmentStart) + 1; ++i) *(environmentSites.begin () + i) = min(environmentStart,environmentEnd) + i; p2out << "\t\t\t Restoring block of size " << environmentSites.size () << " from previous iteration" << endl; if(dot_with_sys && onedot) { newEnvironment.set_integralIndex() = integralIndex; SpinBlock::restore (!forward, environmentSites, newEnvironment, leftState, rightState); } else { environment.set_integralIndex() = integralIndex; SpinBlock::restore (!forward, environmentSites, environment, leftState, rightState); } if (dmrginp.outputlevel() > 0) mcheck(""); // now initialise newEnvironment if (!dot_with_sys || !onedot) { newEnvironment.set_integralIndex() = integralIndex; newEnvironment.initialise_op_array(OVERLAP, false); //newEnvironment.set_op_array(OVERLAP) = boost::shared_ptr<Op_component<Overlap> >(new Op_component<Overlap>(false)); newEnvironment.setstoragetype(DISTRIBUTED_STORAGE); newEnvironment.BuildSumBlock (constraint, environment, environmentDot); p2out << "\t\t\t Environment block " << endl << environment << endl; environment.printOperatorSummary(); p2out << "\t\t\t NewEnvironment block " << endl << newEnvironment << endl; newEnvironment.printOperatorSummary(); } else { p2out << "\t\t\t Environment block " << endl << newEnvironment << endl; newEnvironment.printOperatorSummary(); } }