Example #1
0
  public static Simulation initSpring(int count, double radius) {
    Settings stt = new Settings();

    stt.setTimeStep(1);
    stt.setSpeedOfLight(3);
    stt.setSimulationWidth(100);
    stt.setSimulationHeight(100);

    stt.addForce(new ConstantForce());
    stt.addForce(new SpringForce());

    stt.setNumOfParticles(count);
    stt.setParticleRadius(radius);
    stt.setParticleMaxSpeed(stt.getSpeedOfLight());

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

    for (int k = 0; k < count; k++) {
      Particle par = new Particle();
      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;
  }
Example #2
0
  public static Simulation initRandomParticles(int count, double radius) {
    Settings stt = new Settings();

    stt.setTimeStep(1);
    stt.setSpeedOfLight(3);
    stt.setSimulationWidth(100);
    stt.setSimulationHeight(100);

    stt.addForce(new ConstantForce());
    stt.setNumOfParticles(count);
    stt.setParticleRadius(radius);
    stt.setParticleMaxSpeed(stt.getSpeedOfLight());

    stt.setBoundary(GeneralBoundaryType.Hardwall);
    stt.setParticleSolver(new EulerRichardson());
    stt.setParticleSolver(new BorisRelativistic(stt.getCellWidth() / stt.getTimeStep()));

    Simulation simulation = new Simulation(stt);
    return simulation;
  }
Example #3
0
  public static Simulation initMagnetic(int count, double radius) {
    Settings stt = new Settings();

    stt.setTimeStep(1);
    stt.setSpeedOfLight(3);
    stt.setSimulationWidth(100);
    stt.setSimulationHeight(100);

    ConstantForce cf = new ConstantForce();
    cf.bz = -1;
    stt.addForce(cf);
    stt.setNumOfParticles(count);
    stt.setParticleRadius(radius);
    stt.setParticleMaxSpeed(stt.getSpeedOfLight());

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

    Simulation simulation = new Simulation(stt);
    return simulation;
  }