Package org.openpixi.pixi.physics

Examples of org.openpixi.pixi.physics.Settings


      testMove(x1, y1, x2, y2, +1, "random boundary " + i);
    }
  }

  private void testMoveSimple(double x1, double y1, double x2, double y2, double charge, String text) {
    Settings stt = GridTestCommon.getCommonSettings();
    Grid grid = new Grid(stt);
   
    //We iterate over all the grid cells manually to avoid dependence of this
    //test on the cellIterator implementation. But using the grid method
    //grid.resetCharge() should also work!
    for (int x = -grid.EXTRA_CELLS_BEFORE_GRID; x <
        (grid.getNumCellsX()+grid.EXTRA_CELLS_AFTER_GRID); x++) {
      for (int y = -grid.EXTRA_CELLS_BEFORE_GRID; y <
          (grid.getNumCellsY()+grid.EXTRA_CELLS_AFTER_GRID); y++) {
        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);
View Full Code Here


    assertAlmostEquals(text + ", jx", charge * p.getVx(), jx, ACCURACY_LIMIT);
    assertAlmostEquals(text + ", jy", charge * p.getVy(), jy, ACCURACY_LIMIT);
  }
 
  private void testMove(double x1, double y1, double x2, double y2, double charge, String text) {
    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
View Full Code Here

      testMoveForce(x1, y1, vx, vy, 0.5*Math.random(), 0.5*Math.random(), +1, "random boundary " + i);
    }
  }

  private void testMoveForce(double x1, double y1, double vx, double vy, double ex, double bz, double charge, String text) {
    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
View Full Code Here

  private Grid g;
  private PoissonSolver poisolver;
 
  public PoissonSolverCalculations() {

    Settings stt = new Settings();
    stt.setSimulationWidth(100);
    stt.setSimulationHeight(100);

    stt.setGridCellsX(100);
    stt.setGridCellsY(100);
    stt.setGridSolver(new SimpleSolver());
    stt.setInterpolator(new ChargeConservingCIC());

    this.s = new Simulation(stt);
    this.g = s.grid;
    g.resetCurrent();
   
View Full Code Here

    interpolatorAndPoissonsolver();
  }
 
  public static void interpolatorAndPoissonsolver() {

    Settings stt = new Settings();
    stt.setSimulationWidth(100);
    stt.setSimulationHeight(100);
    stt.setSpeedOfLight(Math.sqrt(stt.getSimulationWidth() * stt.getSimulationWidth() +
        stt.getSimulationHeight() * stt.getSimulationHeight())/5);

    stt.setNumOfParticles(1);
    stt.setParticleRadius(1);
    stt.setParticleMaxSpeed(stt.getSpeedOfLight());

    stt.setGridCellsX(100);
    stt.setGridCellsY(100);
    stt.setGridSolver(new SimpleSolver());
    stt.setInterpolator(new ChargeConservingCIC());

    Simulation s = new Simulation(stt);
    PoissonSolverCalculations.output(s.grid);
  }
View Full Code Here

*/
public class VariousSettings {

  public static Map<String, Settings> getSettingsMap() {
    Map<String, Settings> variousTestSettings = new HashMap<String, Settings>();
    Settings defaultSettings = getDefaultSettings();

    Settings settings = ClassCopier.copy(defaultSettings);
    settings.setNumOfNodes(2);
    variousTestSettings.put("2 nodes - self communication", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setParticleSolver(new Euler());
    variousTestSettings.put("Euler", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setNumOfThreads(5);
    settings.setParticleSolver(new Euler());
    variousTestSettings.put("Threaded version", settings);

    // Fails probably because Boris remembers a lot of information about the force
    // in the particle. This information remembering probably causes problem when particles
    // are transferred from one node to the other.
    // TODO find solution
    settings = ClassCopier.copy(defaultSettings);
    settings.setParticleSolver(new Boris());
    variousTestSettings.put("Boris", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setParticleSolver(new SemiImplicitEulerRelativistic(
        settings.getCellWidth() / settings.getTimeStep()));
    variousTestSettings.put("SemiImplicitEulerRelativistic", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setParticleSolver(new LeapFrogDamped());
    variousTestSettings.put("LeapFrogDamped", settings);

    // Fails because in the distributed version we do additions upon particle's position
    // when it is transferred from one node to another. These additions are cause of the small
    // deviation from the non distributed simulation solution.
    // TODO find solution?
    settings = ClassCopier.copy(defaultSettings);
    settings.setIterations(5000);
    settings.setNumOfParticles(10);
    settings.setParticleSolver(new SemiImplicitEulerRelativistic(
        settings.getCellWidth() / settings.getTimeStep()));
    variousTestSettings.put("5000 iterations", settings);

    // TODO find solution
    settings = ClassCopier.copy(defaultSettings);
    settings.setInterpolator(new ChargeConservingCIC());
    variousTestSettings.put("ChargeConservingCIC", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setInterpolator(new CloudInCell());
    variousTestSettings.put("CloudInCell", settings);

    settings = ClassCopier.copy(defaultSettings);
    settings.setGridSolver(new SimpleSolver());
    variousTestSettings.put("SimpleSolver", settings);

    // Fails because SpringForce uses particle's absolute y position to calculate the force.
    // Since the y position in local and distributed simulation differs,
    // it also has a different effect.
    // TODO find solution
//    settings = ClassCopier.copy(defaultSettings);
//    settings.addForce(new SpringForce());
//    variousTestSettings.put("SpringForce", settings);

    settings = ClassCopier.copy(defaultSettings);
    ConstantForce constantForce = new ConstantForce();
    constantForce.bz = -1;
    settings.addForce(constantForce);
    variousTestSettings.put("MagneticForce", settings);

    return variousTestSettings;
  }
View Full Code Here

    return variousTestSettings;
  }


  public static Settings getDefaultSettings() {
    Settings settings = new Settings();
    settings.setNumOfNodes(16);
    settings.setGridCellsX(64);
    settings.setGridCellsY(128);
    settings.setSimulationWidth(10 * settings.getGridCellsX());
    settings.setSimulationHeight(10 * settings.getGridCellsY());
    settings.setNumOfParticles(100);
    settings.setIterations(100);
    // Ensures that the particles do not get too fast.
    settings.setParticleSolver(new BorisRelativistic(
        settings.getSimulationWidth() / settings.getTimeStep()));
    return settings;
  }
View Full Code Here

TOP

Related Classes of org.openpixi.pixi.physics.Settings

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.