Beispiel #1
0
void Feld::load (const KSimpleConfig& config)
{
  if(moving)
    killTimers();

  mol->load(config);

  QString key;

  for (int j = 0; j < FIELD_SIZE; j++) {

    key.sprintf("feld_%02d", j);
    QString line = config.readEntry(key);

    for (int i = 0; i < FIELD_SIZE; i++)
	feld[i][j] = atom2int(line[i].latin1());

  }

  moves = 0;
  chosen = false;
  moving = false;

  undoSize = redoSize = undoBegin = 0;
  emit enableUndo(false);
  emit enableRedo(false);

  xpos = ypos = 0;
  nextAtom();
}
Beispiel #2
0
    void updateCOM() {

      DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_;
      bool needsVel = false;
      if (data.getStorageLayout() & DataStorage::dslVelocity) needsVel = true;

      if (cutoffAtomList.size() == 1) {
        data.position[localIndex_] = cutoffAtomList[0]->getPos();
        if (needsVel)
          data.velocity[localIndex_] = cutoffAtomList[0]->getVel();
      } else {
        std::vector<Atom *>::iterator i;
        Atom * atom;
        RealType totalMass = getMass();
        data.position[localIndex_] = V3Zero;
        if (needsVel) data.velocity[localIndex_] = V3Zero;
        
	for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) {
          data.position[localIndex_] += atom->getMass() * atom->getPos();
          if (needsVel)
            data.velocity[localIndex_] += atom->getMass() * atom->getVel();
	}     
	data.position[localIndex_] /= totalMass;
        if (needsVel) data.velocity[localIndex_] /= totalMass;          
      }      
    }
Beispiel #3
0
    RealType getMass() {
      
      if (!haveTotalMass) {
	totalMass = 0.0;
        
        std::vector<Atom *>::iterator i;
	for(Atom* atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) {
	  RealType mass = atom->getMass();
	  totalMass += mass;
	}
        
	haveTotalMass = true;
      }
      
      return totalMass;
    }