本文整理汇总了C++中Molecule::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::begin方法的具体用法?C++ Molecule::begin怎么用?C++ Molecule::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sample
/*
* Evaluate Rosenbluth weight, and add to accumulator.
*/
void McChemicalPotential::sample(long iStep)
{
if (isAtInterval(iStep)) {
Species* speciesPtr;
Molecule* molPtr;
Molecule::BondIterator bondIter;
Atom* endPtr;
double w;
double rosenbluth = 1;
double de;
double e = 0;
speciesPtr = &(simulation().species(speciesId_));
// Pop a new molecule off the species reservoir
molPtr = &(speciesPtr->reservoir().pop());
system().addMolecule(*molPtr);
// Loop over molecule growth trials
for (int i = 0; i < nMoleculeTrial_; i++) {
// Pick a random position for the first atom
endPtr = &molPtr->atom(0);
boundary().randomPosition(random(), endPtr->position());
e = system().pairPotential().atomEnergy(*endPtr);
rosenbluth = boltzmann(e);
system().pairPotential().addAtom(*endPtr);
for (molPtr->begin(bondIter); bondIter.notEnd(); ++bondIter) {
addEndAtom(&(bondIter->atom(1)), &(bondIter->atom(0)), bondIter->typeId(), w, de);
e += de;
rosenbluth *= w;
system().pairPotential().addAtom(bondIter->atom(1));
}
rosenbluth = rosenbluth / pow(nTrial_,molPtr->nAtom()-1);
accumulator_.sample(rosenbluth, outputFile_);
system().pairPotential().deleteAtom(*endPtr);
for (molPtr->begin(bondIter); bondIter.notEnd(); ++bondIter) {
system().pairPotential().deleteAtom(bondIter->atom(1));
}
}
// Return additional molecule to reservoir
system().removeMolecule(*molPtr);
speciesPtr->reservoir().push(*molPtr);
}
}
示例2: printMolecule
void printMolecule(const Molecule &m) {
cout << "[";
for (Molecule::const_iterator it = m.begin(); it != m.end(); it++) {
cout << "(" << it->first << ", " << it->second << ") ";
}
cout << "]";
}
示例3: multiplyMolecule
Molecule multiplyMolecule(const Molecule &molecule, int multiplier) {
Molecule output;
for (Molecule::const_iterator it = molecule.begin(); it != molecule.end(); it++) {
output[it->first] = it->second * multiplier;
}
return output;
}
示例4: addMolecules
Molecule addMolecules(const Molecule &molecule1, const Molecule &molecule2) {
Molecule output = molecule1;
for (Molecule::const_iterator it2 = molecule2.begin(); it2 != molecule2.end(); it2++) {
Molecule::iterator ito = output.find(it2->first);
if (ito != output.end()) {
ito->second += it2->second;
} else {
output[it2->first] = it2->second;
}
}
return output;
}
示例5: AddMolecule
void MoleculeGroup::AddMolecule(const int molecule_id, const Molecule& molecule,
const arma::rowvec& position,
const arma::rowvec& velocity)
{
// TODO(Zak): Allow for polyatomic molecules by randomly
// orienting around center of mass position.
// This assert is a placeholder until then.
assert (molecule.num_atoms() == 1);
molecule_names_.push_back(molecule.name());
molecular_index_to_mass_.push_back(molecule.mass());
molecular_index_to_molecule_.push_back(molecule_id);
for (std::vector<Atom>::const_iterator i_atom = molecule.begin();
i_atom != molecule.end(); ++i_atom) {
AddAtom(*i_atom, molecule_id, position, velocity);
}
num_molecules_++;
com_positions_.insert_rows(com_positions_.n_rows, position);
com_velocities_.insert_rows(com_velocities_.n_rows, velocity);
}
示例6: UnitCellToSlab
// Makes a repeating slab out of a single unit cell by creating copies and shifting
Mol_ptr_vec UnitCellToSlab (GridParams& params) {
std::vector<Molecule *> mols;
Molecule * uc = params.unitCell;
VecR yshift, xshift, zshift;
yshift.Zero();
for (int i = 0; i < params.y; i++) {
zshift.Zero();
for (int j = 0; j < params.x; j++) {
xshift.Zero();
if (!(j % 2))
xshift += params.x_shift * 0.5;
for (int k = 0; k < params.z; k++) {
// make a copy of the unitcell
Molecule * copy = new Molecule();
copy->Name(params.name);
// make copies of all the atoms in the unitcell
for (Atom_it atom_i = uc->begin(); atom_i != uc->end(); atom_i++) {
//for (int atom = 0; atom < uc->size(); atom++) {
Atom * pa = new Atom (*(*atom_i));
copy->AddAtom(pa);
}
// shift the new copy to the next lattice point
copy->Shift(yshift + xshift + zshift);
mols.push_back(copy);
xshift += params.x_shift;
}
zshift += params.z_shift;
}
yshift += params.y_shift;
}
return mols;
}
示例7: MinDistance
double Molecule::MinDistance (Molecule& mol) {
// go through the atoms on each molecule and calculate the distance between them, then return the minimum
bool first = true;
double min = 0.0;
for (Atom_it it = this->begin(); it != this->end(); it++) {
for (Atom_it jt = mol.begin(); jt != mol.end(); jt++) {
double temp = ((*it)->Position() - (*jt)->Position()).Magnitude();
//printf ("%f\n", temp);
if (first) {
first = false;
min = temp;
}
if (temp < min) {
min = temp;
}
}
}
return (min);
}