// Descr: evident
TEST(GeometryTest, GetBond)
{
    vector<Bond> bonds;


    Bond bond1 = Bond(1, 2, 3.0, false);
    Bond bond2 = Bond(3, 4, 3.0, false);
    Bond bond3 = Bond(2, 3, 3.0, false);

    bonds.push_back(bond1);
    EXPECT_EQ( 1, bonds[0].atom1);
    bonds.push_back(bond2);
    bonds.push_back(bond3);

    Bond testBond1 = getBond(bonds, 1, 2);
    Bond testBond2 = getBond(bonds, 3, 4);
    Bond testBond3 = getBond(bonds, 2, 3);
    Bond testBond4 = getBond(bonds, 1, 4);

    EXPECT_EQ( bond1.atom1, testBond1.atom1);
    EXPECT_EQ( -1 , testBond4.atom1);

	EXPECT_TRUE( bond1.atom1 == testBond1.atom1 && bond1.atom2 == testBond1.atom2 && bond1.distance == testBond1.distance );
	EXPECT_TRUE( bond2.atom1 == testBond2.atom1 && bond2.atom2 == testBond2.atom2 && bond2.distance == testBond2.distance );
	EXPECT_TRUE( bond3.atom1 == testBond3.atom1 && bond3.atom2 == testBond3.atom2 && bond3.distance == testBond3.distance );
	EXPECT_TRUE( testBond4.atom1 == -1 && testBond4.atom2 == -1 && testBond4.distance == -1.0 );

}
Exemplo n.º 2
0
/* This is implemented like this so that it doesn't read any particles other
   than a and b. To do otherwise would make it rather annoying to use in
   evaluate.
*/
Bond get_bond(Bonded a, Bonded b) {
  if (a == b) return Bond();
  ParticleIndexes ba = a.get_bond_indexes();
  ParticleIndexes bb = b.get_bond_indexes();
  std::sort(bb.begin(), bb.end());
  for (unsigned int i = 0; i < ba.size(); ++i) {
    if (std::binary_search(bb.begin(), bb.end(), ba[i])) {
      return Bond(a.get_model(), ba[i]);
    }
  }
  return Bond();
}
Exemplo n.º 3
0
ParticleIndexes BondPairContainer::get_all_possible_indexes() const {
  ParticleIndexes scapp = sc_->get_all_possible_indexes();
  ParticleIndexes ret(3 * scapp.size());
  for (unsigned int i = 0; i < scapp.size(); ++i) {
    ret[i * 3] = scapp[i];
    ret[i * 3 + 1] =
        Bond(get_model(), scapp[i]).get_bonded(0).get_particle_index();
    ret[i * 3 + 2] =
        Bond(get_model(), scapp[i]).get_bonded(1).get_particle_index();
  }
  return ret;
}
Exemplo n.º 4
0
int BondedPairFilter::get_value_index(
    Model *m, const ParticleIndexPair &pip) const {
  if (!Bonded::get_is_setup(m, pip[0]) || !Bonded::get_is_setup(m, pip[1])) {
    return false;
  }
  Bonded ba(m, pip[0]);
  Bonded bb(m, pip[1]);
  Bond bd = get_bond(ba, bb);
  return bd != Bond();
}
// Descr: evident
TEST(GeometryTest, GetOppositeAtom)
{
    Bond testBond = Bond(1, 3, 5.5, true);
    Angle testAngle = Angle(2, 6, 30, false);
    Dihedral testDihed = Dihedral(3, 7, 180, true);

    //test with bonds
    EXPECT_EQ(3, getOppositeAtom(testBond, 1));
    EXPECT_EQ(1, getOppositeAtom(testBond, 3));
    EXPECT_EQ(-1, getOppositeAtom(testBond, 4));

    EXPECT_EQ(6, getOppositeAtom(testAngle, 2));
    EXPECT_EQ(2, getOppositeAtom(testAngle, 6));
    EXPECT_EQ(-1, getOppositeAtom(testAngle, 5));

    EXPECT_EQ(7, getOppositeAtom(testDihed, 3));
    EXPECT_EQ(3, getOppositeAtom(testDihed, 7));
    EXPECT_EQ(-1, getOppositeAtom(testDihed, 6));

    // Second suite
    testBond = Bond(11, 12, 3.5, true);
    testAngle = Angle(1, 22, 30, false);
    testDihed = Dihedral(5, 9, 180, true);


    EXPECT_EQ(12, getOppositeAtom(testBond, 11));
    EXPECT_EQ(11, getOppositeAtom(testBond, 12));
    EXPECT_EQ(-1, getOppositeAtom(testBond, 13));

    EXPECT_EQ(22, getOppositeAtom(testAngle, 1));
    EXPECT_EQ(1, getOppositeAtom(testAngle, 22));
    EXPECT_EQ(-1, getOppositeAtom(testAngle, 15));

    EXPECT_EQ(9, getOppositeAtom(testDihed, 5));
    EXPECT_EQ(5, getOppositeAtom(testDihed, 9));
    unsigned long inval = (unsigned long) -1;
    EXPECT_EQ(-1, getOppositeAtom(testDihed, inval));
}
// Descr: evident
TEST(GeometryTest, GetAllBonds)
{
	vector<Bond> bonds;

    Bond bond1 = Bond(1, 2, 3.0, false);
    Bond bond2 = Bond(3, 4, 3.0, false);
    Bond bond3 = Bond(2, 3, 3.0, false);

    bonds.push_back(bond1);
    bonds.push_back(bond2);
    bonds.push_back(bond3);

    vector<unsigned long> testBonds1 = getAllBonds(bonds, 1);
    vector<unsigned long> testBonds2 = getAllBonds(bonds, 2);
    vector<unsigned long> testBonds3 = getAllBonds(bonds, 3);
    vector<unsigned long> testBonds4 = getAllBonds(bonds, 4);
    vector<unsigned long> testBonds5 = getAllBonds(bonds, 5);

	EXPECT_TRUE(testBonds1[0] == 2 && testBonds1.size() == 1);
	EXPECT_TRUE(testBonds2[0] == 1 && testBonds2[1] == 3 && testBonds2.size() == 2);
	EXPECT_TRUE(testBonds3[0] == 4 && testBonds3[1] == 2 && testBonds3.size() == 2);
	EXPECT_TRUE(testBonds4[0] == 3 && testBonds4.size() == 1);
	EXPECT_TRUE(testBonds5.size() == 0);
}
Exemplo n.º 7
0
void Bond::show(std::ostream &out) const {
  if (*this == Bond()) {
    out << "Null Bond";
    return;
  }
  out << "Bond between " << get_bonded(0).get_particle()->get_name() << " and "
      << get_bonded(1).get_particle()->get_name();
  if (get_type() != NONBIOLOGICAL) {
    out << " of type " << get_type();
  }
  if (get_order() != 1) out << " and order " << get_order();
  if (get_particle()->has_attribute(internal::get_bond_data().length_)) {
    out << " and length "
        << get_particle()->get_value(internal::get_bond_data().length_);
  }
}
// Descr: evident
TEST(GeometryTest, GetCommonAtom)
{
	vector<Bond> bondVect(7);
    bondVect[0] =Bond(2,1,0.5,false);
    bondVect[1] =Bond(3,2,0.5,false);
    bondVect[2] =Bond(4,1,1.336532,true);
    bondVect[3] =Bond(5,1,1.8119,true);
    bondVect[4] =Bond(6,5,1.090187,true);
    bondVect[5] =Bond(7,5,1.090135,true);
    bondVect[6] =Bond(8,5,1.090135,true);

	EXPECT_EQ(1, getCommonAtom(bondVect,4,5) );
	EXPECT_EQ(2, getCommonAtom(bondVect,1,3) );
	EXPECT_EQ(5, getCommonAtom(bondVect,6,8) );
	EXPECT_EQ(1, getCommonAtom(bondVect,2,5) );
	EXPECT_EQ(-1, getCommonAtom(bondVect,3,5) );
	EXPECT_EQ(-1, getCommonAtom(bondVect,8,2) );

}
Exemplo n.º 9
0
Cell& Cell::operator=(const Cell& rhs){
  if(this!=&rhs){
    delete [] x;
    delete [] xc;
    delete [] xtmp;
    delete [] v;
    delete [] A0;
    delete [] force;
    delete pBond;
    delete pAngle;
    delete [] edgeFlag;
    
    nn=rhs.nn; nb=rhs.nb; na=rhs.na;
    ns=rhs.ns;
    rho=rhs.rho; m=rhs.m;
    ks=rhs.ks; kb=rhs.kb;
    kp=rhs.kp;
    g=rhs.g;
    periodicX = rhs.periodicX;
    periodicY = rhs.periodicY;

    x=new double[nn*2];
    xtmp=new double[nn*2];
    v=new double[nn*2];
    force=new double[nn*2];
    for (int i=0;i<nn;i++){
      x[2*i]=rhs.x[2*i];
      x[2*i+1]=rhs.x[2*i+1];
      xtmp[2*i]=rhs.xtmp[2*i];
      xtmp[2*i+1]=rhs.xtmp[2*i+1];
      v[2*i]=rhs.v[2*i];
      v[2*i+1]=rhs.v[2*i+1];
      force[2*i]=rhs.force[2*i];
      force[2*i+1]=rhs.force[2*i+1];
    }
    xc=new double[ns*2];
    A0=new double[ns];
    edgeFlag= new int[ns];
    for (int i=0;i<ns;i++){
      xc[2*i]=rhs.xc[2*i];
      xc[2*i+1]=rhs.xc[2*i+1];
      A0[i]=rhs.A0[i];
      edgeFlag[i]=0;
    }
    int size;
    pBond = new Bond;
    size = rhs.pBond->size;
    *pBond = Bond(size);
    for (int i=0;i<pBond->size;i++){
      pBond->first[i]=rhs.pBond->first[i];
      pBond->next[i]=rhs.pBond->next[i];
      pBond->L0[i]=rhs.pBond->L0[i];
    }

    pAngle = new Angle;
    size = rhs.pAngle->size;
    *pAngle = Angle(size);
    for (int i=0;i<pAngle->size;i++){
      pAngle->left[i]=rhs.pAngle->left[i];
      pAngle->middle[i]=rhs.pAngle->middle[i];
      pAngle->right[i]=rhs.pAngle->right[i];
      pAngle->ang0[i]=rhs.pAngle->ang0[i];
    }
  }
  return *this;
}
Exemplo n.º 10
0
Cell& Cell::operator=(const Cell& rhs){
  if(this!=&rhs){
    delete [] x;
    delete [] xtmp;
    delete [] v;
    delete [] x0;
    delete [] xR;
    delete [] force;
    delete pBond;
    delete pAngle;
    
    delete [] angRef;

    nn=rhs.nn; nb=rhs.nb; na=rhs.na;
    rho=rhs.rho; m=rhs.m;
    ks=rhs.ks; kb=rhs.kb;
    kp=rhs.kp;
    g=rhs.g;
    A0=rhs.A0;

    x=new double[nn*2];
    xtmp=new double[nn*2];
    x0=new double[nn*2];
    xR=new double[nn*2];
    v=new double[nn*2];
    force=new double[nn*2];
    angRef = new double[nn];
    for (int i=0;i<nn;i++){
      x[2*i]=rhs.x[2*i];
      x[2*i+1]=rhs.x[2*i+1];
      xtmp[2*i]=rhs.xtmp[2*i];
      xtmp[2*i+1]=rhs.xtmp[2*i+1];
      x0[2*i]=rhs.x0[2*i];
      x0[2*i+1]=rhs.x0[2*i+1];
      xR[2*i]=rhs.xR[2*i];
      xR[2*i+1]=rhs.xR[2*i+1];
      v[2*i]=rhs.v[2*i];
      v[2*i+1]=rhs.v[2*i+1];
      force[2*i]=rhs.force[2*i];
      force[2*i+1]=rhs.force[2*i+1];
      angRef[i]=rhs.angRef[i];
    }
    int size;
    pBond = new Bond;
    size = rhs.pBond->size;
    *pBond = Bond(size);
    for (int i=0;i<pBond->size;i++){
      pBond->first[i]=rhs.pBond->first[i];
      pBond->next[i]=rhs.pBond->next[i];
      pBond->L0[i]=rhs.pBond->L0[i];
    }

    pAngle = new Angle;
    size = rhs.pAngle->size;
    *pAngle = Angle(size);
    for (int i=0;i<pAngle->size;i++){
      pAngle->left[i]=rhs.pAngle->left[i];
      pAngle->middle[i]=rhs.pAngle->middle[i];
      pAngle->right[i]=rhs.pAngle->right[i];
      pAngle->ang0[i]=rhs.pAngle->ang0[i];
    }
  }
  return *this;
}