Examples of ParticleFull


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

  /**
   * Used for debugging purposes when there is a need of a specific particle(s).
   */
  public static void createParticles(Settings settings) {
    Particle p1 = new ParticleFull();
    p1.setX(75);
    p1.setY(35);
    p1.setVx(2);
    p1.setVy(0);
    p1.setRadius(1);
    p1.setMass(1);
    p1.setCharge(0.1);
    settings.addParticle(p1);
  }
View Full Code Here

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

  /**
   * 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

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

    stt.setBoundary(GeneralBoundaryType.Periodic);
    stt.setParticleSolver(new EulerRichardson());

    for (int k = 0; k < count; k++) {
      Particle par = new ParticleFull();
      par.setX(stt.getSimulationWidth() * Math.random());
      par.setY(stt.getSimulationHeight() * Math.random());
      par.setRadius(15);
      par.setVx(10 * Math.random());
      par.setVy(0);
      par.setMass(1);
      par.setCharge(.001);
      stt.addParticle(par);
    }

    Simulation simulation = new Simulation(stt);
    return simulation;
View Full Code Here

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

  /**
   * Test if solver solves similar to Euler
   */
  public void testCompareWithEuler() {
    Particle p = new ParticleFull();
    ConstantForce f = new ConstantForce();
    double step = 0.00001d;
    Solver solver2 = new Euler();

    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();
    Particle p2 = p.copy();

    solver.prepare(p, f, step);
    solver2.prepare(p2, f, step);

    for (int i=0; i<100; i++)
    {
      solver.step(p, f, step);
      solver2.step(p2, f, step);
    }

    solver.complete(p, f, step);
    solver2.complete(p2, f, step);

    if (VERBOSE) {
      System.out.println("" + this.getClass().getSimpleName());
      System.out.println("x: " + pcopy.getX() + " -> " + p2.getX() + " vs. " + p.getX());
      System.out.println("y: " + pcopy.getY() + " -> " + p2.getY() + " vs. " + p.getY());
    }

    double accuracy = 0.001d;
    assertAlmostEquals("x", p2.getX(), p.getX(), accuracy);
    assertAlmostEquals("y", p2.getY(), p.getY(), accuracy);
    assertAlmostEquals("vx", p2.getVx(), p.getVx(), accuracy);
    assertAlmostEquals("vy", p2.getVy(), p.getVy(), accuracy);
  }
View Full Code Here

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

  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

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

  stt.setBoundary(GeneralBoundaryType.Periodic);
            stt.setGridSolver(new SimpleSolver());

  for (int k = 0; k < 2; k++) {
    Particle par = new ParticleFull();
    par.setX(stt.getSimulationWidth() * 1/9.0*(k+4));
    par.setY(stt.getSimulationHeight() * 1/2);
    par.setRadius(radius);
    par.setVx(0);
    par.setVy(0);
    par.setMass(1);
    par.setCharge(charge*(1-2*k));
    stt.addParticle(par);
  }
           
            stt.setPoissonSolver(new PoissonSolverFFTPeriodic());
            stt.useGrid(true);
View Full Code Here

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

    Settings stt = GridTestCommon.getCommonSettings();
    stt.setGridSolver(new SimpleSolver());
    stt.setInterpolator(new ChargeConservingCIC());

    // Add single particle
    Particle p = new ParticleFull();
    p.setX(x1);
    p.setY(y1);
    p.setVx((x2 - x1) / stt.getTimeStep());
    p.setVy((y2 - y1) / stt.getTimeStep());
    p.setMass(1);
    p.setCharge(charge);
    stt.addParticle(p);

    Simulation s = new Simulation(stt);
    s.prepareAllParticles();

    // Advance particle
    s.particlePush();

    // The simulation always creates its own copy of particles
    // (in fact the setting class does so)
    // and we would like to obtain the reference to our initial particle p.
    p = s.particles.get(0);

    //Remember old values after boundary check
    double sx = p.getPrevX();
    double sy = p.getPrevY();

    // Calculate current
    s.getInterpolation().interpolateToGrid(s.particles, s.grid, s.tstep);

    double jx = GridTestCommon.getJxSum(s.grid);
    double jy = GridTestCommon.getJySum(s.grid);

    if (VERBOSE) System.out.println("Total current " + text + ": jx = " + jx + ", jy = " + jy
        + " (from " + sx + ", " + sy + " to " + p.getX() + ", " + p.getY() + ")");

//    GridTestCommon.checkSignJx(s.grid);
//    GridTestCommon.checkSignJy(s.grid);

//    assertAlmostEquals(text + ", jx", charge * (p.getX() - sx) / s.tstep, jx, ACCURACY_LIMIT);
View Full Code Here

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

    Settings stt = GridTestCommon.getCommonSettings();
    stt.setGridSolver(new SimpleSolver());
    stt.setInterpolator(new ChargeConservingCIC());

    // Add single particle
    Particle p = new ParticleFull();
    p.setX(x1);
    p.setY(y1);
    p.setVx(vx);
    p.setVy(vy);
    p.setMass(1);
    p.setCharge(charge);
    stt.addParticle(p);

    ConstantForce force = new ConstantForce();
    force.ex = ex;
    force.bz = bz;
    stt.addForce(force);

    Simulation s = new Simulation(stt);
    s.prepareAllParticles();

    // The simulation always creates its own copy of particles
    // (in fact the setting class does so)
    // and we would like to obtain the reference to our initial particle p.
    p = s.particles.get(0);

    // Advance particle
    s.particlePush();

    //Remember old values after boundary check
    double sx = p.getPrevX();
    double sy = p.getPrevY();

    // Calculate current
    s.getInterpolation().interpolateToGrid(s.particles, s.grid, s.tstep);

    double jx = GridTestCommon.getJxSum(s.grid);
    double jy = GridTestCommon.getJySum(s.grid);

    if (VERBOSE) System.out.println("Total current " + text + ": jx = " + jx + ", jy = " + jy
        + " (from " + sx + ", " + sy + " to " + p.getX() + ", " + p.getY() + ")");

//    GridTestCommon.checkSignJx(s.grid);
//    GridTestCommon.checkSignJy(s.grid);
//
//    assertAlmostEquals(text + ", jx", charge * (p.getX() - sx) / s.tstep, jx, ACCURACY_LIMIT);
View Full Code Here

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

   
    ArrayList<Particle> particles = new ArrayList<Particle>();
   
    for (int i=0; i < 100; i++) {
      Particle p = new ParticleFull();
      p.setX(random.nextDouble()*stt.getSimulationWidth());
      p.setY(random.nextDouble()*stt.getSimulationHeight());
      //Assign random integer charge in the range (-10,10)
      //Accuracy decreases with non integer charge, more particles
      //as well as more cells.
      p.setCharge((random.nextInt(20)-10));
      particles.add(p);
    }
   
    InterpolatorAlgorithm interpolation = new CloudInCell();
   
View Full Code Here

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

        grid.getCell(x, y).resetCurrent();
      }
    }

   
    Particle p = new ParticleFull();
    p.setX(x1);
    p.setY(y1);
    p.setVx((x2 - x1) / stt.getTimeStep());
    p.setVy((y2 - y1) / stt.getTimeStep());
    p.setCharge(charge);
   
    InterpolatorAlgorithm interpolation = new CloudInCell();

    interpolation.interpolateToGrid(p, grid, stt.getTimeStep());

   
    double jx = GridTestCommon.getJxSum(grid);
    double jy = GridTestCommon.getJySum(grid);

    assertAlmostEquals(text + ", jx", charge * p.getVx(), jx, ACCURACY_LIMIT);
    assertAlmostEquals(text + ", jy", charge * p.getVy(), jy, ACCURACY_LIMIT);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.