Пример #1
0
  @Override
  public double calcOutletPressure(double inletPres, double flowAccel) {

    double dyn =
        this.getDynamicPressure(); // Note that dynamic pressure is negative for negative velocities
    double pres = inletPres;
    pres -= this.getFluid().getDensityxGravity() * heightChangeInput.getValue();
    if (Math.abs(dyn) > 0.0 && this.getFluid().getViscosity() > 0.0) {
      this.setDarcyFrictionFactor();
      pres -= darcyFrictionFactor * dyn * this.getLength() / this.getDiameter();
    } else {
      darcyFrictionFactor = 0.0;
    }
    pres -= pressureLossCoefficientInput.getValue() * dyn;
    pres -= flowAccel * this.getFluid().getDensity() * lengthInput.getValue() / this.getFlowArea();
    return pres;
  }
Пример #2
0
  @Override
  protected double getNextSample() {
    double u2, b, sample;

    // Case 1 - Shape parameter < 1
    if (shapeInput.getValue() < 1.0) {
      double threshold;
      b = 1.0 + (shapeInput.getValue() / Math.E);
      do {
        double p = b * rng2.nextUniform();
        u2 = rng1.nextUniform();

        if (p <= 1.0) {
          sample = Math.pow(p, 1.0 / shapeInput.getValue());
          threshold = Math.exp(-sample);
        } else {
          sample = -Math.log((b - p) / shapeInput.getValue());
          threshold = Math.pow(sample, shapeInput.getValue() - 1.0);
        }
      } while (u2 > threshold);
    }

    // Case 2 - Shape parameter >= 1
    else {
      double u1, w, z;
      double a = 1.0 / Math.sqrt((2.0 * shapeInput.getValue()) - 1.0);
      b = shapeInput.getValue() - Math.log(4.0);
      double q = shapeInput.getValue() + (1.0 / a);
      double d = 1.0 + Math.log(4.5);
      do {
        u1 = rng1.nextUniform();
        u2 = rng2.nextUniform();
        double v = a * Math.log(u1 / (1.0 - u1));
        sample = shapeInput.getValue() * Math.exp(v);
        z = u1 * u1 * u2;
        w = b + q * v - sample;
      } while ((w + d - 4.5 * z < 0.0) && (w < Math.log(z)));
    }

    // Scale the sample by the desired mean value
    return sample * meanInput.getValue() / shapeInput.getValue();
  }
Пример #3
0
  @Override
  public HasScreenPoints.PointsInfo[] getScreenPoints() {
    synchronized (screenPointLock) {
      if (cachedPointInfo == null) {
        cachedPointInfo = new HasScreenPoints.PointsInfo[1];
        HasScreenPoints.PointsInfo pi = new HasScreenPoints.PointsInfo();
        cachedPointInfo[0] = pi;

        pi.points = pointsInput.getValue();
        pi.color = colourInput.getValue();
        pi.width = widthInput.getValue().intValue();
        if (pi.width < 1) pi.width = 1;
      }
      return cachedPointInfo;
    }
  }
Пример #4
0
  /*
   * Return the Darcy Friction Factor for a turbulent flow.
   */
  private double getTurbulentFrictionFactor(double reynoldsNumber) {
    double x = 1.0; // The present value for x = 1 / sqrt( frictionfactor ).
    double lastx = 0.0;

    double a = (roughnessInput.getValue() / this.getDiameter()) / 3.7;
    double b = 2.51 / reynoldsNumber;

    int n = 0;
    while (Math.abs(x - lastx) / lastx > 1.0e-10 && n < 20) {
      lastx = x;
      x = -2.0 * Math.log10(a + b * lastx);
      n++;
    }

    if (n >= 20) {
      error(
          "Darcy Friction Factor iterations did not converge: lastx = %f  x = %f  n = %d",
          lastx, x, n);
    }

    return 1.0 / (x * x);
  }
Пример #5
0
 @Override
 protected double getStandardDeviation() {
   return meanInput.getValue() / Math.sqrt(shapeInput.getValue());
 }
Пример #6
0
 @Override
 protected double getMeanValue() {
   return meanInput.getValue();
 }
Пример #7
0
 @Override
 protected double getStandardDeviation() {
   return meanInput.getValue();
 }
Пример #8
0
  @Override
  protected double getNextSample() {

    // Inverse transform method
    return (-meanInput.getValue() * Math.log(rng.nextUniform()));
  }
Пример #9
0
 @Override
 public double getLength() {
   return lengthInput.getValue();
 }