Package org.openpixi.pixi.physics

Examples of org.openpixi.pixi.physics.Settings


* OpenCL and also sequential simulations and then compares the results.
*/
public class ChargeConservingCICTest extends TestCase {

  public void testParallelSimulation() throws FileNotFoundException {
    Settings defaultSettings = new Settings();
    //defaultSettings.setTimeStep(0.1);
    defaultSettings.setGridCellsX(10);
    defaultSettings.setGridCellsY(10);
    defaultSettings.setNumOfParticles(100);
    defaultSettings.setIterations(100);
    defaultSettings.setParticleSolver(new Boris());
                defaultSettings.setInterpolator(new ChargeConservingCIC());
                defaultSettings.setOCLParticleSolver("boris");
                defaultSettings.setOCLGridInterpolator("charge conserving CIC");
               
    Simulation sequentialSimulation = new Simulation(defaultSettings);

    Settings openCLSettings = ClassCopier.copy(defaultSettings);
    Simulation openCLSimulation = new Simulation(openCLSettings);

    sequentialSimulation.run();
    openCLSimulation.run();

View Full Code Here


    assert iplServer != null: "Ipl server was not specified!";

    Map<String, Settings> settingsMap = VariousSettings.getSettingsMap();
    Map<String, Boolean> resultsMap = new HashMap<String, Boolean>();
    for (String testName: settingsMap.keySet()) {
      Settings stt = settingsMap.get(testName);
      stt.setNumOfNodes(numOfNodes);
      stt.setIplServer(iplServer);

      Node n = new Node(stt);
      n.run();
      try {
        compareResult(stt, n, testName);
View Full Code Here

 
  /**
   * THIS TEST IS CURRENTLY DISABLED! (it does not test the right thing)
   */
  private void testMove(double x1, double y1, double x2, double y2, double charge, String text) {
    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
View Full Code Here

  /**
   * THIS TEST IS CURRENTLY DISABLED! (it does not test the right thing)
   */
  private void testMoveForce(double x1, double y1, double vx, double vy, double ex, double bz, double charge, String text) {
    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
View Full Code Here

* Extends the grid functionality which is required in one or more tests.
*/
public class GridTestCommon {

  public static Settings getCommonSettings() {
    Settings stt = new Settings();

    stt.setSpeedOfLight(0.7);
    stt.setSimulationWidth(10);
    stt.setSimulationHeight(10);
    stt.setParticleSolver(new Boris());
    stt.setBoundary(GeneralBoundaryType.Periodic);

    stt.setGridCellsX(10);
    stt.setGridCellsY(10);

    return stt;
  }
View Full Code Here

* OpenCL and also sequential simulations and then compares the results.
*/
public class LeapFrogDampedTest extends TestCase {

  public void testParallelSimulation() throws FileNotFoundException {
    Settings defaultSettings = new Settings();
    //defaultSettings.setTimeStep(0.1);
    defaultSettings.setGridCellsX(10);
    defaultSettings.setGridCellsY(10);
    defaultSettings.setNumOfParticles(100);
    defaultSettings.setIterations(100);
    defaultSettings.setParticleSolver(new LeapFrogDamped());
                defaultSettings.setInterpolator(new ChargeConservingCIC());
                defaultSettings.setOCLParticleSolver("leap frog damped");
                defaultSettings.setOCLGridInterpolator("charge conserving CIC");
               
    Simulation sequentialSimulation = new Simulation(defaultSettings);

    Settings openCLSettings = ClassCopier.copy(defaultSettings);
    Simulation openCLSimulation = new Simulation(openCLSettings);

    sequentialSimulation.run();
    openCLSimulation.run();

View Full Code Here

* OpenCL and also sequential simulations and then compares the results.
*/
public class EulerTest extends TestCase {

  public void testParallelSimulation() throws FileNotFoundException {
    Settings defaultSettings = new Settings();
    //defaultSettings.setTimeStep(0.1);
    defaultSettings.setGridCellsX(10);
    defaultSettings.setGridCellsY(10);
    defaultSettings.setNumOfParticles(100);
    defaultSettings.setIterations(100);
    defaultSettings.setParticleSolver(new Euler());
                defaultSettings.setInterpolator(new ChargeConservingCIC());
                defaultSettings.setOCLParticleSolver("euler");
                defaultSettings.setOCLGridInterpolator("charge conserving CIC");
               
    Simulation sequentialSimulation = new Simulation(defaultSettings);

    Settings openCLSettings = ClassCopier.copy(defaultSettings);
    Simulation openCLSimulation = new Simulation(openCLSettings);

    sequentialSimulation.run();
    openCLSimulation.run();

View Full Code Here

      }
    }

    assert numOfNodes > 0: "Invalid number of nodes!";

    Settings settings = new Settings();
    settings.setNumOfThreads(1);
    settings.setGridCellsX(16);
    settings.setGridCellsY(16);
    settings.setSimulationWidth(10 * settings.getGridCellsX());
    settings.setSimulationHeight(10 * settings.getGridCellsY());
    settings.setNumOfParticles(10000);
    settings.setIterations(1000);
    settings.setParticleSolver(new Boris());
    settings.setNumOfNodes(numOfNodes);
    settings.setIplServer(iplServer);

    if (numOfNodes == 1) {
      Simulation simulation = new Simulation(settings);
      simulation.run();
      ProfileInfo.printProfileInfo();
    }
    else if (numOfNodes > 1) {
      assert iplServer != null;
      Node node = new Node(settings);
      node.run();
      DistributedProfileInfo.printProfileInfo();
    }

    settings.terminateThreads();
  }
View Full Code Here

   * classes. Except of the interpolator class itself it also relies on the
   * proper functioning of grid accessors as well as on the Cell class.
   */
  public void testChargeInterpolation() {

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

    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).resetCharge();
      }
    }

   
    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);
View Full Code Here

   * the PoissonSolver to the analytic result.
   */
  public PoissonSolverTest(String testName){
    super(testName);

    Settings stt = new Settings();
    stt.setSimulationWidth(10);
    stt.setSimulationHeight(10);
    stt.setGridSolver(new SimpleSolver());
    stt.setInterpolator(new ChargeConservingCIC());
   
    this.s = new Simulation(stt);
    this.g = s.grid;
    this.g.resetCurrent();
   
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.