Package javax.vecmath

Examples of javax.vecmath.Vector3d


  /**
   * Calculates and imparts the force of the bond to its member atoms
   */
  public void evaluateForce() {

    Vector3d temp3d = new Vector3d();

    temp3d.sub(i.getPosition(), j.getPosition());

    double forceVectorSum = getAnalyticalGradient();

    double unitForce = forceVectorSum / temp3d.length();

    temp3d.scale(unitForce);

    i.addForce(temp3d);
    j.subForce(temp3d);

  }
View Full Code Here


  /**
   * Returns the current length of the bond in Angstroms
   */
  public double getCurrentLength() {

    Vector3d dist = new Vector3d();
    dist.sub(i.getPosition(), j.getPosition());

    return dist.length();
  }
View Full Code Here

  /**
   * Calculates and imparts the vector force of the bond to its member atoms
   */
  public void evaluateForce() {
    Vector3d temp3d = new Vector3d();

    temp3d.sub(i.getPosition(), j.getPosition());

    double unitForce = this.getAnalyticalGradient() / temp3d.length();

    temp3d.scale(unitForce);

    i.addForce(temp3d);
    j.subForce(temp3d);

  }
View Full Code Here

    double cosphi;
    double sinphi;
    double phi;

    Vector3d rij = new Vector3d();
    Vector3d rkj = new Vector3d();
    Vector3d rjk = new Vector3d();
    Vector3d rlk = new Vector3d();
    Vector3d rkl = new Vector3d();

    Vector3d R = new Vector3d();
    Vector3d S = new Vector3d();
    Vector3d n = new Vector3d();

    rij.sub(i, j);

    LOG.debug(" rij is " + rij);
    LOG.debug(" rij length is " + rij.length());

    rkj.sub(k, j);
    LOG.debug(" rkj is " + rkj);
    LOG.debug(" rkj length is " + rkj.length());
    // equ. 5.3b and 5.3c, only this vector needs to be normalised
    rkj.normalize();
   
    rjk.sub(j, k);
    LOG.debug(" rjk is " + rjk);
    LOG.debug(" rjk length is " + rjk.length());

    rlk.sub(l, k);
    LOG.debug(" rlk is " + rlk);
    LOG.debug(" rlk length is " + rlk.length());

    rkl.sub(k, l);
    LOG.debug(" rkl is " + rkl);
    LOG.debug(" rkl length is " + rkl.length());
    LOG.debug(" ");

    // equ. 5.3b
    rkj.scale(rij.dot(rkj));
    R.sub(rij, rkj);
    LOG.debug("R is " + R);

    // Refresh vector
    rkj.sub(k, j);
    rkj.normalize();

    // equ 5.3c
    rkj.scale(rlk.dot(rkj));
    S.sub(rlk, rkj);

    LOG.debug("S is " + S);

    // Normalise both these vectors
    // equ. 5.3a
    R.normalize();
    S.normalize();
   
    //TODO roll this into a private function?

    cosphi = R.dot(S);
    LOG.debug("cosphi is " + cosphi);

    // When calculating phi, arccosine only returns values between 0 and 180
    // degrees. If cosphi is 0.0 then phi could be either -90 degrees or +90
    // degrees and we need to know the correct one when calculating the
    // derivatives.
    // This ambiguity is removed since we also know sinphi -
    // hence if cosphi is 0.0 and sinphi is 1 then phi is +90 degrees.
    // Conversely, if cosphi is 0.0 and sinphi is -1 then phi is -90
    // degrees.

    // equ. 5.2c ?
    n.cross(R, S);
    LOG.debug("n  is " + n);

    // equ. 5.28
    sinphi = n.dot(rkj);
    LOG.debug("sinphi is " + sinphi);

    //TODO hack to prevent signum returning zero
    phi = Math.acos(cosphi) * ((int) Math.signum(sinphi + 0.000000001) );
   
View Full Code Here

   */
  public TorsionGradients getGradients(Point3d i, Point3d j, Point3d k,
      Point3d l) {

    // Figure 5.1
    Vector3d rij = new Vector3d();
    Vector3d rkj = new Vector3d();
    Vector3d rlk = new Vector3d();

    Vector3d rkl = new Vector3d();

    // Normal to plane ijk
    Vector3d m = new Vector3d();

    // Normal to plane jkl
    Vector3d n = new Vector3d();

    // Equ. 5.3a
    Vector3d R = new Vector3d();
    Vector3d S = new Vector3d();

    rij.sub(i, j);
    LOG.debug(" rij is " + rij);
    LOG.debug(" rij length is " + rij.length());

    rkj.sub(k, j);
    LOG.debug(" rkj is " + rkj);
    LOG.debug(" rkj length is " + rkj.length());
    // Equ. 5.3b and 5.3c, only this vector needs to be normalised
    rkj.normalize();

    // Do we need this?
    rlk.sub(l, k);
    LOG.debug(" rlk is " + rlk);
    LOG.debug(" rlk length is " + rlk.length());

    // Equ. 5.3b
    rkj.scale(rij.dot(rkj));
    R.sub(rij, rkj);
    LOG.debug("");
    LOG.debug("R is " + R);

    // Refresh vector since it has been rescaled in calculating R
    rkj.sub(k, j);
    rkj.normalize();

    // Equ 5.3c
    rkj.scale(rlk.dot(rkj));
    S.sub(rlk, rkj);

    LOG.debug("S is " + S);

    // Normalise both these vectors
    // Equ. 5.3a
    R.normalize();
    S.normalize();


    // Now, the gradients

    Vector3d gradPhiI = new Vector3d();
    Vector3d gradPhiJ = new Vector3d();
    Vector3d gradPhiK = new Vector3d();
    Vector3d gradPhiL = new Vector3d();
    Vector3d tempGradPhiL = new Vector3d();

    TorsionGradients gradients = new TorsionGradients();

    // Refresh vars
    rij.sub(i, j);
    rkj.sub(k, j);
    rlk.sub(l, k);
    rkl.sub(k, l);

    // Equ. 5.2b; m is the normal to the plane ijk
    m.cross(rij, rkj);
    // m.normalize();
    LOG.debug("");
    LOG.debug("m (norm to ijk) is " + m);
    LOG.debug("m.lengthSquared is " + m.lengthSquared());

    // Equ. 5.2c; n is the normal to the plane jkl
    n.cross(rlk, rkj);
    // n.normalize();
    LOG.debug("n (norm to jkl) is " + n);
    LOG.debug("n.lengthSquared is " + n.lengthSquared());

    // Equ. 5.11
    gradPhiI.set(m);
    LOG.debug("1.0 / m.length() is " + 1.0 / m.length());

    gradPhiI.scale(1.0 / m.lengthSquared());
    gradPhiI.scale(rkj.length());
    gradients.setI(gradPhiI);

    // Equ. 5.12
    gradPhiL.set(n);
    LOG.debug("1.0 / n.length() is " + 1.0 / n.length());
    gradPhiL.scale(1.0 / n.lengthSquared());
    gradPhiL.scale(rkj.length());
    gradPhiL.negate();
    gradients.setL(gradPhiL);

    // Generate unknown vector, S
    // Equ. 5.20
    S.set(gradPhiI);
    S.scale(rij.dot(rkj));

    tempGradPhiL.set(gradPhiL);
    tempGradPhiL.scale(rkl.dot(rkj));

    S.sub(tempGradPhiL);
    S.scale(1.0 / rkj.lengthSquared());

    LOG.debug("S (unknown) is " + S);
View Full Code Here

          // Get x y and z
          Double vx = iterator.next();
          Double vy = iterator.next();
          Double vz = iterator.next();

          Vector3d velocity = new Vector3d(vx, vy, vz);

          LOG.debug(velocity);
          this.velocities.add(velocity);

        }
View Full Code Here

    myDihedral = new Dihedral(myAtom1, myAtom2, myAtom3, myAtom4, 5.0, 1.0,
        2.0);

    myDihedral.evaluateForce();

    Vector3d ExpectedForceI = new Vector3d(0.0, 0.0, -8.414709848078965);
    Vector3d ExpectedForceJ = new Vector3d(0.0, 0.0, 8.414709848078965);
    Vector3d ExpectedForceK = new Vector3d(0.0, 0.0, 8.414709848078965);
    Vector3d ExpectedForceL = new Vector3d(0.0, 0.0, -8.414709848078965);

    LOG.debug("Force on myAtom1 is " + myAtom1.getForce().toString());
    LOG.debug("Force on myAtom2 is " + myAtom2.getForce().toString());
    LOG.debug("Force on myAtom3 is " + myAtom3.getForce().toString());
    LOG.debug("Force on myAtom4 is " + myAtom4.getForce().toString());
View Full Code Here

    myDihedral = new Dihedral(myAtom1, myAtom2, myAtom3, myAtom4, 10.0,
        2.0, 4.0);

    myDihedral.evaluateForce();

    Vector3d ExpectedForceI = new Vector3d(0.0, 0.0, -36.371897073027256);
    Vector3d ExpectedForceJ = new Vector3d(0.0, 0.0, 36.371897073027256);
    Vector3d ExpectedForceK = new Vector3d(0.0, 0.0, 36.371897073027256);
    Vector3d ExpectedForceL = new Vector3d(0.0, 0.0, -36.371897073027256);

    LOG.debug("Force on myAtom1 is " + myAtom1.getForce().toString());
    LOG.debug("Force on myAtom2 is " + myAtom2.getForce().toString());
    LOG.debug("Force on myAtom3 is " + myAtom3.getForce().toString());
    LOG.debug("Force on myAtom4 is " + myAtom4.getForce().toString());
View Full Code Here

    LOG.debug(gradients.getJ());
    LOG.debug(gradients.getK());
    LOG.debug(gradients.getL());
   
    // Correct Gradients
    Vector3d a = new Vector3d(-0.427895,  -0.383993,   0.458374 );
    Vector3d b = new Vector3d( 0.305333,   0.615610,  -0.638652 );
    Vector3d c = new Vector3d( 0.801409,  -0.417391,   0.178151 );
    Vector3d d = new Vector3d(-0.678846,   0.185773,   0.002127 );
   
    assertEquals(a.x, gradients.getI().x, delta );
    assertEquals(a.y, gradients.getI().y, delta );
    assertEquals(a.z, gradients.getI().z, delta );
   
View Full Code Here

    TorsionGradients gradients;
   
    gradients = torsion.getGradients(i,j,k,l);
   
    // Correct Gradients
    Vector3d a = new Vector3d( 0.062885,  -0.469977,  -0.510851 );
    Vector3d b = new Vector3d(-0.267922,   0.730722,   0.747527 );
    Vector3d c = new Vector3d( 0.799196,  -0.529675,  -0.375642 );
    Vector3d d = new Vector3d(-0.594160,   0.268930,   0.138966 );
   
    LOG.debug(gradients.getI());
    LOG.debug(gradients.getJ());
    LOG.debug(gradients.getK());
    LOG.debug(gradients.getL());
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector3d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.