Пример #1
0
  @Override
  public void update(double simTime) {

    double dt = simTime - lastUpdateTime;
    lastUpdateTime = simTime;

    // Update the volume stored at the source and destination
    FluidComponent source = sourceInput.getValue();
    FluidComponent destination = destinationInput.getValue();
    double dV = flowRate * dt;
    if (dV > 0.0 && source != null) {
      dV = Math.min(dV, source.getFluidVolume());
    } else if (dV < 0.0 && destination != null) {
      dV = -Math.min(-dV, destination.getFluidVolume());
    }
    if (source != null) {
      source.addVolume(-dV);
    }
    if (destination != null) {
      destination.addVolume(dV);
    }

    // Set the new flow rate
    this.calcFlowRate(source, destination, dt);
  }
Пример #2
0
  @Override
  public void validate() {
    super.validate();

    // Confirm that the fluid has been specified
    if (fluidInput.getValue() == null) {
      throw new InputErrorException("The keyword Fluid must be set.");
    }
  }
Пример #3
0
 protected FluidComponent getDestination() {
   return destinationInput.getValue();
 }
Пример #4
0
 public Fluid getFluid() {
   return fluidInput.getValue();
 }
Пример #5
0
 protected FluidComponent getSource() {
   return sourceInput.getValue();
 }