void SweepTwopdm::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, int state) { //mcheck("at the start of block and decimate"); // figure out if we are going forward or backwards dmrginp.guessgenT -> start(); bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; SpinBlock envDot; 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; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; //if (useSlater) { systemDot = SpinBlock(systemDotStart, systemDotEnd, system.get_integralIndex(), true); //SpinBlock::store(true, systemDot.get_sites(), systemDot); //} //else //SpinBlock::restore(true, spindotsites, systemDot); SpinBlock environment, environmentDot, newEnvironment; int environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); system.addAdditionalCompOps(); InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, sweepParams.current_root(), sweepParams.current_root(), sweepParams.get_sys_add(), dmrginp.direct(), system.get_integralIndex(), DISTRIBUTED_STORAGE, true, true); InitBlocks::InitNewEnvironmentBlock(environment, systemDot, newEnvironment, system, systemDot, sweepParams.current_root(), sweepParams.current_root(), sweepParams.get_sys_add(), sweepParams.get_env_add(), forward, dmrginp.direct(), sweepParams.get_onedot(), nexact, useSlater, system.get_integralIndex(), true, true, true); SpinBlock big; newSystem.set_loopblock(true); system.set_loopblock(false); newEnvironment.set_loopblock(false); InitBlocks::InitBigBlock(newSystem, newEnvironment, big); const int nroots = dmrginp.nroots(); std::vector<Wavefunction> solution(1); DiagonalMatrix e; GuessWave::guess_wavefunctions(solution[0], e, big, sweepParams.get_guesstype(), true, state, true, 0.0); #ifndef SERIAL mpi::communicator world; mpi::broadcast(world, solution, 0); #endif std::vector<Matrix> rotateMatrix; DensityMatrix tracedMatrix(newSystem.get_stateInfo()); tracedMatrix.allocate(newSystem.get_stateInfo()); tracedMatrix.makedensitymatrix(solution, big, std::vector<double>(1,1.0), 0.0, 0.0, false); rotateMatrix.clear(); if (!mpigetrank()) double error = makeRotateMatrix(tracedMatrix, rotateMatrix, sweepParams.get_keep_states(), sweepParams.get_keep_qstates()); #ifndef SERIAL mpi::broadcast(world,rotateMatrix,0); #endif #ifdef SERIAL const int numprocs = 1; #endif #ifndef SERIAL const int numprocs = world.size(); #endif if (sweepParams.get_block_iter() == 0) compute_twopdm_initial(solution, system, systemDot, newSystem, newEnvironment, big, numprocs, state); compute_twopdm_sweep(solution, system, systemDot, newSystem, newEnvironment, big, numprocs, state); if (sweepParams.get_block_iter() == sweepParams.get_n_iters() - 1) compute_twopdm_final(solution, system, systemDot, newSystem, newEnvironment, big, numprocs, state); SaveRotationMatrix (newSystem.get_sites(), rotateMatrix, state); //for(int i=0;i<dmrginp.nroots();++i) solution[0].SaveWavefunctionInfo (big.get_stateInfo(), big.get_leftBlock()->get_sites(), state); newSystem.transform_operators(rotateMatrix); }
void SweepOnepdm::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys) { //mcheck("at the start of block and decimate"); // figure out if we are going forward or backwards dmrginp.guessgenT -> start(); bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; SpinBlock envDot; int systemDotStart, systemDotEnd; int systemDotSize = sweepParams.get_sys_add() - 1; if (forward) { systemDotStart = *system.get_sites().rbegin () + 1; systemDotEnd = systemDotStart + systemDotSize; } else { systemDotStart = system.get_sites() [0] - 1; systemDotEnd = systemDotStart - systemDotSize; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; systemDot = SpinBlock(systemDotStart, systemDotEnd); SpinBlock environment, environmentDot, newEnvironment; int environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); system.addAdditionalCompOps(); InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, sweepParams.get_sys_add(), dmrginp.direct(), DISTRIBUTED_STORAGE, true, true); InitBlocks::InitNewEnvironmentBlock(environment, systemDot, newEnvironment, system, systemDot, sweepParams.get_sys_add(), sweepParams.get_env_add(), forward, dmrginp.direct(), sweepParams.get_onedot(), nexact, useSlater, true, true, true); SpinBlock big; newSystem.set_loopblock(true); system.set_loopblock(false); newEnvironment.set_loopblock(false); InitBlocks::InitBigBlock(newSystem, newEnvironment, big); const int nroots = dmrginp.nroots(); std::vector<Wavefunction> solutions(nroots); for(int i=0;i<nroots;++i) { StateInfo newInfo; solutions[i].LoadWavefunctionInfo (newInfo, newSystem.get_sites(), i); } #ifndef SERIAL mpi::communicator world; mpi::broadcast(world,solutions,0); #endif #ifdef SERIAL const int numprocs = 1; #endif #ifndef SERIAL const int numprocs = world.size(); #endif compute_onepdm(solutions, system, systemDot, newSystem, newEnvironment, big, numprocs); }
void SweepOnepdm::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, int state) { //mcheck("at the start of block and decimate"); // figure out if we are going forward or backwards dmrginp.guessgenT -> start(); bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; SpinBlock envDot; 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; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; systemDot = SpinBlock(systemDotStart, systemDotEnd, system.get_integralIndex(), true); SpinBlock environment, environmentDot, newEnvironment; int environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); newSystem.set_integralIndex() = system.get_integralIndex(); newSystem.default_op_components(dmrginp.direct(), system, systemDot, false, false, true); newSystem.erase(CRE_CRE_DESCOMP); newSystem.erase(CRE_CRE); newSystem.erase(HAM); newSystem.setstoragetype(DISTRIBUTED_STORAGE_FOR_ONEPDM); newSystem.BuildSumBlock (NO_PARTICLE_SPIN_NUMBER_CONSTRAINT, system, systemDot); if (dmrginp.outputlevel() > 0) { pout << "\t\t\t NewSystem block " << endl << newSystem << endl; newSystem.printOperatorSummary(); } InitBlocks::InitNewEnvironmentBlock(environment, systemDot, newEnvironment, system, systemDot, sweepParams.current_root(), sweepParams.current_root(), sweepParams.get_sys_add(), sweepParams.get_env_add(), forward, dmrginp.direct(), sweepParams.get_onedot(), nexact, useSlater, system.get_integralIndex(), false, false, true); SpinBlock big; newSystem.set_loopblock(true); system.set_loopblock(false); newEnvironment.set_loopblock(false); InitBlocks::InitBigBlock(newSystem, newEnvironment, big); const int nroots = dmrginp.nroots(); std::vector<Wavefunction> solution(1); DiagonalMatrix e; GuessWave::guess_wavefunctions(solution[0], e, big, sweepParams.get_guesstype(), true, state, true, 0.0); #ifndef SERIAL mpi::communicator world; mpi::broadcast(world, solution, 0); #endif std::vector<Matrix> rotateMatrix; DensityMatrix tracedMatrix(newSystem.get_stateInfo()); tracedMatrix.allocate(newSystem.get_stateInfo()); tracedMatrix.makedensitymatrix(solution, big, std::vector<double>(1,1.0), 0.0, 0.0, false); rotateMatrix.clear(); if (!mpigetrank()) double error = makeRotateMatrix(tracedMatrix, rotateMatrix, sweepParams.get_keep_states(), sweepParams.get_keep_qstates()); #ifndef SERIAL mpi::broadcast(world,rotateMatrix,0); #endif #ifdef SERIAL const int numprocs = 1; #endif #ifndef SERIAL const int numprocs = world.size(); #endif Matrix onepdm; load_onepdm_binary(onepdm, state ,state); Matrix pairmat; if (dmrginp.hamiltonian() == BCS) load_pairmat_binary(pairmat, state ,state); if (sweepParams.get_block_iter() == 0) { //this is inface a combination of 2_0_0, 1_1_0 and 0_2_0 p2out << "\t\t\t compute 2_0_0"<<endl; compute_one_pdm_2_0_0(solution[0], solution[0], big, onepdm); if (dmrginp.hamiltonian() == BCS) compute_pair_2_0_0(solution[0], solution[0], big, pairmat); p2out << "\t\t\t compute 1_1_0"<<endl; compute_one_pdm_1_1_0(solution[0], solution[0], big, onepdm); if (dmrginp.hamiltonian() == BCS) compute_pair_1_1_0(solution[0], solution[0], big, pairmat); } p2out << "\t\t\t compute 0_2_0"<<endl; compute_one_pdm_0_2_0(solution[0], solution[0], big, onepdm); if (dmrginp.hamiltonian() == BCS) compute_pair_0_2_0(solution[0], solution[0], big, pairmat); p2out << "\t\t\t compute 1_1"<<endl; compute_one_pdm_1_1(solution[0], solution[0], big, onepdm); if (dmrginp.hamiltonian() == BCS) compute_pair_1_1(solution[0], solution[0], big, pairmat); if (sweepParams.get_block_iter() == sweepParams.get_n_iters() - 1) { p2out << "\t\t\t compute 0_2"<<endl; compute_one_pdm_0_2(solution[0], solution[0], big, onepdm); if (dmrginp.hamiltonian() == BCS) compute_pair_0_2(solution[0], solution[0], big, pairmat); } accumulate_onepdm(onepdm); save_onepdm_binary(onepdm, state, state); if (dmrginp.hamiltonian() == BCS) { accumulate_onepdm(pairmat); save_pairmat_binary(pairmat, state, state); } SaveRotationMatrix (newSystem.get_sites(), rotateMatrix, state); solution[0].SaveWavefunctionInfo (big.get_stateInfo(), big.get_leftBlock()->get_sites(), state); newSystem.transform_operators(rotateMatrix); }
void SweepGenblock::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, int stateA, int stateB) { if (dmrginp.outputlevel() > 0) mcheck("at the start of block and decimate"); p1out << "\t\t\t Performing Blocking"<<endl; dmrginp.guessgenT -> start(); // figure out if we are going forward or backwards bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; 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; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; dmrginp.sysdotmake->start(); systemDot = SpinBlock(systemDotStart, systemDotEnd, system.get_integralIndex(), stateA==stateB); dmrginp.sysdotmake->stop(); const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); dmrginp.guessgenT -> stop(); dmrginp.datatransfer -> start(); system.addAdditionalCompOps(); dmrginp.datatransfer -> stop(); dmrginp.initnewsystem->start(); InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, stateA, stateB, sweepParams.get_sys_add(), dmrginp.direct(), system.get_integralIndex(), DISTRIBUTED_STORAGE, dot_with_sys, true); dmrginp.initnewsystem->stop(); pout << "\t\t\t System Block"<<newSystem; newSystem.printOperatorSummary(); std::vector<Matrix> leftrotateMatrix, rightrotateMatrix; LoadRotationMatrix (newSystem.get_sites(), leftrotateMatrix, stateA); LoadRotationMatrix (newSystem.get_sites(), rightrotateMatrix, stateB); #ifndef SERIAL mpi::communicator world; broadcast(world, leftrotateMatrix, 0); broadcast(world, rightrotateMatrix, 0); #endif p1out <<"\t\t\t Performing Renormalization "<<endl<<endl; dmrginp.operrotT->start(); if (stateB == stateA) newSystem.transform_operators(leftrotateMatrix); else newSystem.transform_operators(leftrotateMatrix, rightrotateMatrix); dmrginp.operrotT->stop(); if (dmrginp.outputlevel() > 0) //mcheck("after rotation and transformation of block"); p2out <<newSystem<<endl; newSystem.printOperatorSummary(); //mcheck("After renorm transform"); p2out << *dmrginp.guessgenT<<" "<<*dmrginp.multiplierT<<" "<<*dmrginp.operrotT<< " "<<globaltimer.totalwalltime()<<" timer "<<endl; p2out << *dmrginp.makeopsT<<" "<<*dmrginp.initnewsystem<<" "<<*dmrginp.sysdotmake<<" "<<*dmrginp.buildcsfops<<" makeops "<<endl; p2out << *dmrginp.datatransfer<<" datatransfer "<<endl; p2out <<"oneindexopmult twoindexopmult Hc couplingcoeff"<<endl; p2out << *dmrginp.oneelecT<<" "<<*dmrginp.twoelecT<<" "<<*dmrginp.hmultiply<<" "<<*dmrginp.couplingcoeff<<" hmult"<<endl; p2out << *dmrginp.buildsumblock<<" "<<*dmrginp.buildblockops<<" build block"<<endl; p2out << *dmrginp.blockintegrals<<" "<<*dmrginp.blocksites<<" "<<*dmrginp.statetensorproduct<<" "<<*dmrginp.statecollectquanta<<" "<<*dmrginp.buildsumblock<<" "<<*dmrginp.builditeratorsT<<" "<<*dmrginp.diskio<<" build sum block"<<endl; p2out << "addnoise S_0_opxop S_1_opxop S_2_opxop"<<endl; p3out << *dmrginp.addnoise<<" "<<*dmrginp.s0time<<" "<<*dmrginp.s1time<<" "<<*dmrginp.s2time<<endl; }
void SweepGenblock::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, int stateA, int stateB) { if (dmrginp.outputlevel() > 0) mcheck("at the start of block and decimate"); pout << "\t\t\t Performing Blocking"<<endl; dmrginp.guessgenT -> start(); // figure out if we are going forward or backwards bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; 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; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; systemDot = SpinBlock(systemDotStart, systemDotEnd, stateA==stateB); const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); system.addAdditionalCompOps(); InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, stateA, stateB, sweepParams.get_sys_add(), dmrginp.direct(), DISTRIBUTED_STORAGE, dot_with_sys, true); pout << "\t\t\t System Block"<<newSystem; if (dmrginp.outputlevel() > 0) newSystem.printOperatorSummary(); std::vector<Matrix> leftrotateMatrix, rightrotateMatrix; LoadRotationMatrix (newSystem.get_sites(), leftrotateMatrix, stateA); LoadRotationMatrix (newSystem.get_sites(), rightrotateMatrix, stateB); #ifndef SERIAL mpi::communicator world; broadcast(world, leftrotateMatrix, 0); broadcast(world, rightrotateMatrix, 0); #endif pout <<"\t\t\t Performing Renormalization "<<endl<<endl; if (stateB == stateA) newSystem.transform_operators(leftrotateMatrix); else newSystem.transform_operators(leftrotateMatrix, rightrotateMatrix); if (dmrginp.outputlevel() > 0) //mcheck("after rotation and transformation of block"); if (dmrginp.outputlevel() > 0) pout <<newSystem<<endl; if (dmrginp.outputlevel() > 0) newSystem.printOperatorSummary(); //mcheck("After renorm transform"); }
void SweepGenblock::BlockAndDecimate (SweepParams &sweepParams, SpinBlock& system, SpinBlock& newSystem, const bool &useSlater, const bool& dot_with_sys, int state) { if (dmrginp.outputlevel() > 0) mcheck("at the start of block and decimate"); // figure out if we are going forward or backwards pout << "\t\t\t Performing Blocking"<<endl; dmrginp.guessgenT -> start(); bool forward = (system.get_sites() [0] == 0); SpinBlock systemDot; int systemDotStart, systemDotEnd; int systemDotSize = sweepParams.get_sys_add() - 1; if (forward) { systemDotStart = *system.get_sites().rbegin () + 1; systemDotEnd = systemDotStart + systemDotSize; } else { systemDotStart = system.get_sites() [0] - 1; systemDotEnd = systemDotStart - systemDotSize; } vector<int> spindotsites(2); spindotsites[0] = systemDotStart; spindotsites[1] = systemDotEnd; systemDot = SpinBlock(systemDotStart, systemDotEnd); const int nexact = forward ? sweepParams.get_forward_starting_size() : sweepParams.get_backward_starting_size(); system.addAdditionalCompOps(); InitBlocks::InitNewSystemBlock(system, systemDot, newSystem, sweepParams.get_sys_add(), dmrginp.direct(), DISTRIBUTED_STORAGE, dot_with_sys, true); pout << "\t\t\t System Block"<<newSystem; if (dmrginp.outputlevel() > 0) newSystem.printOperatorSummary(); std::vector<Matrix> rotateMatrix; if (!dmrginp.get_fullrestart()) { //this should be done when we actually have wavefunctions stored, otherwise not!! SpinBlock environment, environmentDot, newEnvironment; int environmentDotStart, environmentDotEnd, environmentStart, environmentEnd; InitBlocks::InitNewEnvironmentBlock(environment, systemDot, newEnvironment, system, systemDot, sweepParams.get_sys_add(), sweepParams.get_env_add(), forward, dmrginp.direct(), sweepParams.get_onedot(), nexact, useSlater, true, true, true); SpinBlock big; InitBlocks::InitBigBlock(newSystem, newEnvironment, big); DiagonalMatrix e; std::vector<Wavefunction> solution(1); GuessWave::guess_wavefunctions(solution[0], e, big, sweepParams.get_guesstype(), true, state, true, 0.0); solution[0].SaveWavefunctionInfo (big.get_stateInfo(), big.get_leftBlock()->get_sites(), state); DensityMatrix tracedMatrix; tracedMatrix.allocate(newSystem.get_stateInfo()); tracedMatrix.makedensitymatrix(solution, big, std::vector<double>(1, 1.0), 0.0, 0.0, false); rotateMatrix.clear(); if (!mpigetrank()) double error = newSystem.makeRotateMatrix(tracedMatrix, rotateMatrix, sweepParams.get_keep_states(), sweepParams.get_keep_qstates()); } else LoadRotationMatrix (newSystem.get_sites(), rotateMatrix, state); #ifndef SERIAL mpi::communicator world; broadcast(world, rotateMatrix, 0); #endif if (!dmrginp.get_fullrestart()) SaveRotationMatrix (newSystem.get_sites(), rotateMatrix, state); pout <<"\t\t\t Performing Renormalization "<<endl<<endl; newSystem.transform_operators(rotateMatrix); if (dmrginp.outputlevel() > 0) mcheck("after rotation and transformation of block"); if (dmrginp.outputlevel() > 0) pout <<newSystem<<endl; if (dmrginp.outputlevel() > 0) newSystem.printOperatorSummary(); //mcheck("After renorm transform"); }