Esempio n. 1
0
double Molecule::dist(Molecule &other) {
    double minSqr = 1e9; //large value;
    Bounds bounds = state->bounds;
    for (int id : ids) {
        Vector pos = state->idToAtom(id).pos;
        for (int idOther : other.ids) {
            minSqr = fmin(minSqr, bounds.minImage((pos - state->idToAtom(idOther).pos)).lenSqr() );
        }
    }
    return sqrt(minSqr);
}
Esempio n. 2
0
void Molecule::unwrap() {
    Vector weightedPos(0, 0, 0);
    double sumMass = 0;
    Vector firstPos = state->idToAtom(ids[0]).pos;
    Bounds bounds = state->bounds;
    for (int id : ids) {
		int idx = state->idToIdx[id];
		Atom &a = state->atoms[idx];
        a.pos = firstPos + bounds.minImage(a.pos - firstPos);

    }
}
Esempio n. 3
0
Vector Molecule::COM() {
    Vector weightedPos(0, 0, 0);
    double sumMass = 0;
    Vector firstPos = state->idToAtom(ids[0]).pos;
    Bounds bounds = state->bounds;
    for (int id : ids) {
        Atom &a = state->idToAtom(id);
        Vector pos = firstPos + bounds.minImage(a.pos - firstPos);
        double mass = a.mass;
        weightedPos += pos * mass;
        sumMass += mass;
    }
    return weightedPos / sumMass;
}
Esempio n. 4
0
Vector Molecule::size() {
    Vector firstPos = state->idToAtom(ids[0]).pos;
    Vector lo = firstPos;
    Vector hi = firstPos;
    Bounds bounds = state->bounds;
    for (int id : ids) {
        Atom &a = state->idToAtom(id);
        Vector pos = firstPos + bounds.minImage(a.pos - firstPos);
        for (int i=0; i<3; i++) {
            lo[i] = fmin(lo[i], pos[i]);
            hi[i] = fmax(hi[i], pos[i]);
        }
    }
    return hi - lo;
    

}