本文整理汇总了C++中Wavefunction::get_lattice方法的典型用法代码示例。如果您正苦于以下问题:C++ Wavefunction::get_lattice方法的具体用法?C++ Wavefunction::get_lattice怎么用?C++ Wavefunction::get_lattice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wavefunction
的用法示例。
在下文中一共展示了Wavefunction::get_lattice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: count_subsystem_particle_counts_for_match
bool count_subsystem_particle_counts_for_match (const Wavefunction<amplitude_t>::Amplitude &wf1, const Wavefunction<amplitude_t>::Amplitude &wf2,
const Subsystem &subsystem)
{
assert(subsystem.lattice_makes_sense(wf1.get_lattice()));
assert(subsystem.lattice_makes_sense(wf2.get_lattice()));
// (we are also assuming that the lattices are in fact equivalent)
const PositionArguments &r1 = wf1.get_positions();
const PositionArguments &r2 = wf2.get_positions();
assert(r1.get_N_species() == r2.get_N_species());
assert(r1.get_N_sites() == r2.get_N_sites());
for (unsigned int species = 0; species < r1.get_N_species(); ++species) {
assert(r1.get_N_filled(species) == r2.get_N_filled(species));
unsigned int count1 = 0, count2 = 0;
for (unsigned int i = 0; i < r1.get_N_filled(species); ++i) {
const Particle particle(i, species);
if (subsystem.position_is_within(r1[particle], wf1.get_lattice()))
++count1;
if (subsystem.position_is_within(r2[particle], wf2.get_lattice()))
++count2;
}
if (count1 != count2)
return false;
}
return true;
}
示例2: verify_phibetas
void SwappedSystem::verify_phibetas (const Wavefunction<amplitude_t>::Amplitude &phialpha1, const Wavefunction<amplitude_t>::Amplitude &phialpha2) const
{
#ifdef NDEBUG
(void) phialpha1;
(void) phialpha2;
#else
const PositionArguments &r1 = phialpha1.get_positions();
const PositionArguments &r2 = phialpha2.get_positions();
assert(r1.get_N_species() == r2.get_N_species());
assert(r1.get_N_sites() == r2.get_N_sites());
assert(copy1_subsystem_indices.size() == r1.get_N_species());
assert(copy2_subsystem_indices.size() == r1.get_N_species());
const Lattice &lattice = phialpha1.get_lattice();
for (unsigned int species = 0; species < r1.get_N_species(); ++species) {
const unsigned int N = r1.get_N_filled(species);
assert(N == r2.get_N_filled(species));
// verify that the subsystem index arrays have everything they need (and no duplicates!)
unsigned int c1 = 0, c2 = 0;
for (unsigned int i = 0; i < N; ++i) {
const Particle particle(i, species);
const bool b1 = vector_find(copy1_subsystem_indices[species], i) != -1;
const bool b2 = vector_find(copy2_subsystem_indices[species], i) != -1;
if (b1)
++c1;
if (b2)
++c2;
assert(b1 == subsystem->position_is_within(r1[particle], lattice));
assert(b2 == subsystem->position_is_within(r2[particle], lattice));
}
assert(c1 == c2);
assert(c1 == copy1_subsystem_indices[species].size());
assert(c2 == copy2_subsystem_indices[species].size());
}
assert(phibeta1 != 0);
assert(phibeta2 != 0);
// verify that the positions in the phibeta's are correct
PositionArguments swapped_r1(phialpha1.get_positions()), swapped_r2(phialpha2.get_positions());
swap_positions(swapped_r1, swapped_r2);
for (unsigned int species = 0; species < r1.get_N_species(); ++species) {
for (unsigned int i = 0; i < r1.get_N_filled(species); ++i) {
const Particle particle(i, species);
assert(swapped_r1[particle] == phibeta1->get_positions()[particle]);
assert(swapped_r2[particle] == phibeta2->get_positions()[particle]);
}
}
#endif
}
示例3: initialize
void SwappedSystem::initialize (const Wavefunction<amplitude_t>::Amplitude &phialpha1, const Wavefunction<amplitude_t>::Amplitude &phialpha2)
{
assert(current_state == UNINITIALIZED);
const PositionArguments &r1 = phialpha1.get_positions();
const PositionArguments &r2 = phialpha2.get_positions();
// FIXME: we need a way to assert that phialpha1 and phialpha2 represent
// the same wave function, just with different amplitudes. Then again,
// we're only calling this function from two places in the code where this
// can be easily verified ...
#ifndef NDEBUG
assert(r1.get_N_species() == r2.get_N_species());
for (unsigned int i = 0; i < r1.get_N_species(); ++i)
assert(r1.get_N_filled(i) == r2.get_N_filled(i));
#endif
assert(r1.get_N_sites() == r2.get_N_sites());
assert(subsystem->lattice_makes_sense(phialpha1.get_lattice()));
assert(subsystem->lattice_makes_sense(phialpha2.get_lattice()));
assert(&phialpha1.get_lattice() == &phialpha2.get_lattice());
const unsigned int N_species = r1.get_N_species();
copy1_subsystem_indices.resize(N_species);
copy2_subsystem_indices.resize(N_species);
for (unsigned int species = 0; species < N_species; ++species) {
const unsigned int N = r1.get_N_filled(species);
for (unsigned int i = 0; i < N; ++i) {
const Particle particle(i, species);
if (subsystem->position_is_within(r1[particle], phialpha1.get_lattice()))
copy1_subsystem_indices[species].push_back(i);
if (subsystem->position_is_within(r2[particle], phialpha2.get_lattice()))
copy2_subsystem_indices[species].push_back(i);
}
}
assert(subsystem_particle_counts_match());
reinitialize_phibetas(phialpha1, phialpha2);
current_state = READY;
}
示例4: update
void SwappedSystem::update (const Particle *particle1, const Particle *particle2, const Wavefunction<amplitude_t>::Amplitude &phialpha1, const Wavefunction<amplitude_t>::Amplitude &phialpha2)
{
// this function should be called *after* the phialpha's have been updated
assert(current_state == READY);
current_state = UPDATE_IN_PROGRESS;
const PositionArguments &r1 = phialpha1.get_positions();
const PositionArguments &r2 = phialpha2.get_positions();
#ifndef NDEBUG
assert(r1.get_N_species() == r2.get_N_species());
for (unsigned int i = 0; i < r1.get_N_species(); ++i)
assert(r1.get_N_filled(i) == r2.get_N_filled(i));
#endif
assert(!particle1 || r1.particle_is_valid(*particle1));
assert(!particle2 || r2.particle_is_valid(*particle2));
const Lattice &lattice = phialpha1.get_lattice();
// these will be will be >= 0 if the particle was in the subsystem before,
// -1 if the particle was not in the subsystem before, and -2 if the
// particle isn't even being moved.
int pairing_index1 = (!particle1) ? -2 : vector_find(copy1_subsystem_indices[particle1->species], particle1->index);
int pairing_index2 = (!particle2) ? -2 : vector_find(copy2_subsystem_indices[particle2->species], particle2->index);
const bool particle1_now_in_subsystem = (particle1 && subsystem->position_is_within(r1[*particle1], lattice));
const bool particle2_now_in_subsystem = (particle2 && subsystem->position_is_within(r2[*particle2], lattice));
const int delta1 = (particle1_now_in_subsystem ? 1 : 0) + (pairing_index1 >= 0 ? -1 : 0);
#ifndef NDEBUG
const int delta2 = (particle2_now_in_subsystem ? 1 : 0) + (pairing_index2 >= 0 ? -1 : 0);
#endif
assert(particle1 || delta1 == 0);
assert(particle2 || delta2 == 0);
assert(delta1 == delta2);
const int delta = delta1;
assert(delta == 0 || (particle1 && particle2 && particle1->species == particle2->species));
assert(delta == 0 || particle1_now_in_subsystem == particle2_now_in_subsystem);
// to ensure only a single update is necessary to the phibeta's, we require
// that a particle only be moved in one copy if the particle number is not
// changing
assert(delta != 0 || !(particle1 && particle2));
// remember a few things in case we need to cancel
recent_delta = delta;
if (particle1)
recent_particle1 = *particle1;
if (particle2)
recent_particle2 = *particle2;
if (delta == -1) {
// if a particle of the same type leaves each subsystem simultaneously,
// we need to use some special logic in case we have to re-pair the
// remaining particles in the subsystem. (re-pair in the sense of what
// gets swapped with what)
// these repeat some logic in the "if" statement, but are a useful
// sanity check nonetheless (for now)
assert(pairing_index1 >= 0 && pairing_index2 >= 0);
assert(!particle1_now_in_subsystem);
assert(!particle2_now_in_subsystem);
const unsigned int species = particle1->species;
std::vector<unsigned int> &c1_s = copy1_subsystem_indices[species];
std::vector<unsigned int> &c2_s = copy2_subsystem_indices[species];
if (pairing_index1 != pairing_index2) {
// in order to re-pair the particles left behind, we move the pair
// that is leaving the subsystem to the max_pairing_index, and move
// the pair that is staying behind to the min_pairing_index.
phibeta1->swap_particles(c1_s[pairing_index1], c1_s[pairing_index2], species);
phibeta2->swap_particles(c2_s[pairing_index1], c2_s[pairing_index2], species);
if (pairing_index1 < pairing_index2)
std::swap(c1_s[pairing_index1], c1_s[pairing_index2]);
else
std::swap(c2_s[pairing_index1], c2_s[pairing_index2]);
}
// update the phibeta's
const unsigned int max_pairing_index = std::max(pairing_index1, pairing_index2);
assert(!phibeta1_dirty && !phibeta2_dirty);
{
Move move;
move.push_back(SingleParticleMove(Particle(c1_s[max_pairing_index], species), r1[*particle1]));
phibeta1->perform_move(move);
}
{
Move move;
move.push_back(SingleParticleMove(Particle(c2_s[max_pairing_index], species), r2[*particle2]));
phibeta2->perform_move(move);
}
phibeta1_dirty = true;
phibeta2_dirty = true;
//.........这里部分代码省略.........