本文整理汇总了C++中SweepParams::get_lowest_energy方法的典型用法代码示例。如果您正苦于以下问题:C++ SweepParams::get_lowest_energy方法的具体用法?C++ SweepParams::get_lowest_energy怎么用?C++ SweepParams::get_lowest_energy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SweepParams
的用法示例。
在下文中一共展示了SweepParams::get_lowest_energy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_one
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];
}
示例2: do_one
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
//.........这里部分代码省略.........
示例3: dmrg_stateSpecific
void dmrg_stateSpecific(double sweep_tol, int targetState)
{
double last_fe = 10.e6;
double last_be = 10.e6;
double old_fe = 0.;
double old_be = 0.;
int ls_count=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 direction;
int restartsize;
sweepParams.restorestate(direction, restartsize);
//initialize array of size m_maxiter or dmrginp.max_iter() for dw and energy
sweepParams.current_root() = targetState;
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) )
{
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);
pout << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter())
break;
last_fe = Sweep::do_one(sweepParams, false, direction, false, 0);
new_states=sweepParams.get_keep_states();
pout << "\t\t\t Finished Sweep Iteration "<<sweepParams.get_sweep_iter()<<endl;
}
pout << "Converged Energy " << sweepParams.get_lowest_energy()[0]<< std::endl;
if(dmrginp.max_iter() <= sweepParams.get_sweep_iter()) {
pout << "Maximum sweep iterations achieved " << std::endl;
}
//one has to canonicalize the wavefunction with atleast 3 sweeps, this is a quirk of the way
//we transform wavefunction
if (mpigetrank()==0) {
Sweep::InitializeStateInfo(sweepParams, !direction, targetState);
Sweep::InitializeStateInfo(sweepParams, direction, targetState);
Sweep::CanonicalizeWavefunction(sweepParams, !direction, targetState);
Sweep::CanonicalizeWavefunction(sweepParams, direction, targetState);
Sweep::CanonicalizeWavefunction(sweepParams, !direction, targetState);
Sweep::InitializeStateInfo(sweepParams, !direction, targetState);
Sweep::InitializeStateInfo(sweepParams, direction, targetState);
}
}