@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); }
@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."); } }
protected FluidComponent getDestination() { return destinationInput.getValue(); }
public Fluid getFluid() { return fluidInput.getValue(); }
protected FluidComponent getSource() { return sourceInput.getValue(); }