Package org.openpixi.pixi.physics.particles

Examples of org.openpixi.pixi.physics.particles.Particle


  /**
   * Test if prepare and complete return to the same initial conditions
   */
  public void testPrepareComplete() {
    Particle p = new ParticleFull();
    ConstantForce f = new ConstantForce();
    double step = 1.0;

    f.ex = 1.234;
    f.ey = 3.456;
    f.bz = 7.890;
    f.gx = 2.468;
    f.gy = 3.579;
    f.drag = 5.432;

    p.setX(23.456);
    p.setY(35.689);
    p.setRadius(13.579);
    p.setVx(12.345);
    p.setVy(76.543);
    p.setMass(7.654);
    p.setCharge(5.432);

    Particle pcopy = p.copy();

    solver.prepare(p, f, step);
    solver.complete(p, f, step);

    assertAlmostEquals("x", pcopy.getX(), p.getX(), ACCURACY_LIMIT);
    assertAlmostEquals("y", pcopy.getY(), p.getY(), ACCURACY_LIMIT);
    assertAlmostEquals("vx", pcopy.getVx(), p.getVx(), ACCURACY_LIMIT);
    assertAlmostEquals("vy", pcopy.getVy(), p.getVy(), ACCURACY_LIMIT);

    for (int i=0; i<1000; i++)
    {
      solver.prepare(p, f, step);
      solver.complete(p, f, step);
    }

    assertAlmostEquals("x", pcopy.getX(), p.getX(), ACCURACY_LIMIT);
    assertAlmostEquals("y", pcopy.getY(), p.getY(), ACCURACY_LIMIT);
    assertAlmostEquals("vx", pcopy.getVx(), p.getVx(), ACCURACY_LIMIT);
    assertAlmostEquals("vy", pcopy.getVy(), p.getVy(), ACCURACY_LIMIT);
  }
View Full Code Here


  public static ArrayList<Particle> createRandomParticles(double width, double height, double maxspeed, int count, double radius) {

    ArrayList<Particle> particlelist = new ArrayList<Particle>(count);

    for (int k = 0; k < count; k++) {
      Particle p = new ParticleFull();
      p.setX(width * Math.random());
      p.setY(height * Math.random());
      p.setRadius(radius);
      phi = 2 * Math.PI * Math.random();
      p.setVx(maxspeed * Math.cos(phi));
      p.setVy(maxspeed * Math.sin(phi));
      p.setMass(1);
            //overall charge is 0:
      if (k<count/2) {
        p.setCharge(.01);
      } else {
        p.setCharge(-.01);
      }
      particlelist.add(p);
    }

    return particlelist;
View Full Code Here

TOP

Related Classes of org.openpixi.pixi.physics.particles.Particle

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.