Esempio n. 1
0
  /** Test of propagateSingle method, of class DiffusionEngine. */
  @Test
  public void testPropagateSingle() {
    BufferedWriter out = null;
    try {
      String path = "./test/testInputFiles/test_diffusionEngine/";
      String singleOutFileName = path + "DiffusionEngineTest_single.txt";
      out = new BufferedWriter(new FileWriter(singleOutFileName));

      IParticleAllAccess p = new Particle(0, 0, new double[] {15, 5, 5});
      AdvancedSystemOut.println("p1 new coords a", p.get_coords(), "");
      double[] newCoords = new double[p.get_coords().length];
      newCoords = p.get_coords();
      int nSteps = nIntegrationSteps;
      out.write("{");
      for (int i = 0; i < nSteps; i++) {
        newCoords = DoubleArrays.add(newCoords, diffusionEngine.propagateSingle(p));
        AdvancedSystemOut.println("p1 new coords aa", newCoords, "");
        out.write("{");
        for (int j = 0; j < newCoords.length; j++) {
          if (j == newCoords.length - 1) {
            out.write(Double.toString(newCoords[j]));
          } else {
            out.write(Double.toString(newCoords[j]) + ",");
          }
        }
        p.set_coords(newCoords);
        if (i == nSteps - 1) {
          out.write("}\n");
        } else {
          out.write("},\n");
        }
      }
      out.write("}\n");

    } catch (IOException ex) {
      Logger.getLogger(DiffusionEngineTest.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      try {
        out.close();
      } catch (IOException ex) {
        Logger.getLogger(DiffusionEngineTest.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }
Esempio n. 2
0
  /** Test of propagatePair method, of class DiffusionEngine. */
  @Test
  public void testPropagatePair() {
    BufferedWriter out = null;
    try {
      String path = "./test/testInputFiles/test_diffusionEngine/";
      String singleOutFileName = path + "DiffusionEngineTest_pair.txt";
      out = new BufferedWriter(new FileWriter(singleOutFileName));

      System.out.println("propagatePair");
      IParticleAllAccess p1 = new Particle(10, 0, new double[] {5, 5, 5});
      IParticleAllAccess p2 = new Particle(11, 0, new double[] {5.1, 5.1, 5.1});
      double dist;

      double[][] newCoords = new double[2][3];
      newCoords[0] = p1.get_coords();
      newCoords[1] = p2.get_coords();
      int nSteps = nIntegrationSteps;

      out.write("{\n");
      for (int i = 0; i < nSteps; i++) {
        dist = DoubleArrays.distance(p1.get_coords(), p2.get_coords());
        System.out.println("dist: " + dist);
        double[][] cumulatedDisplacement = diffusionEngine.propagatePair(p1, p2, dist);

        newCoords[0] = DoubleArrays.add(newCoords[0], cumulatedDisplacement[0]);
        newCoords[1] = DoubleArrays.add(newCoords[1], cumulatedDisplacement[1]);

        // add a little noise:

        out.write("{");
        for (int j = 0; j < newCoords.length; j++) {

          out.write("{");
          for (int k = 0; k < newCoords[j].length; k++) {
            if (k == newCoords[j].length - 1) {
              out.write(Double.toString(newCoords[j][k]));
            } else {
              out.write(Double.toString(newCoords[j][k]) + ",");
            }
          }
          if (j == newCoords.length - 1) {
            out.write("}");
          } else {
            out.write("},\n");
          }
        }
        if (i == nSteps - 1) {
          out.write("}\n");
        } else {
          out.write("},\n");
        }

        // add a little noise
        newCoords[0] = DoubleArrays.add(newCoords[0], diffusionEngine.propagateSingle(p1));
        newCoords[1] = DoubleArrays.add(newCoords[1], diffusionEngine.propagateSingle(p2));

        p1.set_coords(newCoords[0]);
        p2.set_coords(newCoords[1]);
      }
      out.write("}");
    } catch (IOException ex) {
      Logger.getLogger(DiffusionEngineTest.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      try {
        out.close();
      } catch (IOException ex) {
        Logger.getLogger(DiffusionEngineTest.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }