Package org.openpixi.pixi.physics.particles

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


    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


   
    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

    // We need to translate the position of the particle to the coordinates
    // valid at the neighbor.
    // However, we want the particle to keep its position at the local node.
    // Thus, we need a copy of the particle.

    Particle copy = particle.copy();
    copy.addX(-xoffset);
    copy.addPrevX(-xoffset);
    copy.addY(-yoffset);
    copy.addPrevY(-yoffset);
    sharedData.registerBorderParticle(copy);
  }
View Full Code Here

      force.bz = - 0.23; // -ConstantsSI.g;
      //force.gy = -1;
      //force.drag = 0.08;
      s.f.add(force);
      s.particles = InitialConditions.createRandomParticles(s.getWidth(), s.getHeight(), s.getSpeedOfLight(), 1, 1);
      Particle par = (Particle) s.particles.get(0);
      par.setX(s.getWidth() * 0.5);
      par.setY(s.getHeight() * 0.5);
      //System.out.println(this.getWidth() * 0.5 + " x0");
      //System.out.println(this.getHeight() * 0.5 + " y0");
      par.setVx(10);
      par.setVy(10);
      par.setMass(1);
      par.setCharge(1);
    }
    else {
      resetAnimation(0);
    }
    s.prepareAllParticles();
View Full Code Here

      super.paintComponent(graph1);
      reset_trace = false;
    }

    for (int i = 0; i < s.particles.size(); i++) {
      Particle par = (Particle) s.particles.get(i);
      if (par.getCharge() > 0) {
        graph.setColor(Color.red);
      } else {
        graph.setColor(Color.blue);
      }
      double radius = par.getRadius();
      int width = (int) (2*sx*radius);
      int height = (int) (2*sy*radius);
      if(width > 2 && height > 2 && !paint_trace) {
        graph.fillOval((int) (par.getX()*sx) - width/2, (int) (par.getY()*sy) - height/2,  width,  height);
      }
      else {
        graph.drawRect((int) (par.getX()*sx), (int) (par.getY()*sy), 0, 0);
      }
    }

    if(drawCurrentGrid)
    {
View Full Code Here

        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

      sx = getWidth() / s.getWidth();
      sy = getHeight() / s.getHeight();
      repaint();
      if(writePosition)
      {
        Particle par = (Particle) s.particles.get(0);
        System.out.println(par.getX() + " " + par.getY());
        file.writeFile(fileName, fileDirectory, par.getX() + " " + par.getY());
      }
    }
View Full Code Here

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

    // 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();

    // 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);

//    This is what ChargeConservingAreaWeightningTest test for (current during timestep)
//    assertAlmostEquals(text + ", jx", charge * (p.x - sx), jx, ACCURACY_LIMIT);
//    assertAlmostEquals(text + ", jy", charge * (p.y - sy), jy, ACCURACY_LIMIT);
//    This is what is appropriate for CIC: momentary current
    assertAlmostEquals(text + ", jx", charge * p.getVx(), jx, ACCURACY_LIMIT);
    assertAlmostEquals(text + ", jy", charge * p.getVy(), jy, ACCURACY_LIMIT);
  }
View Full Code Here

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

    // 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();

    // 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);

//    This is what ChargeConservingAreaWeightningTest test for (current during timestep)
//    assertAlmostEquals(text + ", jx", charge * (p.x - sx), jx, ACCURACY_LIMIT);
//    assertAlmostEquals(text + ", jy", charge * (p.y - sy), jy, ACCURACY_LIMIT);
//    This is what is appropriate for CIC: momentary current
    assertAlmostEquals(text + ", jx", charge * p.getVx(), jx, ACCURACY_LIMIT);
    assertAlmostEquals(text + ", jy", charge * p.getVy(), jy, ACCURACY_LIMIT);
  }
View Full Code Here

    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

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.