Package hec.rss.model

Class ReservoirElement

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, TSLocation, OperationsElement, PlotVariableConstants, ReleaseElement, AltInputReportInfc, RssModelVariableConstants, RssReturnStatusConstants, RssTSLocation, hec.watershed.res.model.PlottableObject, Serializable, Cloneable, Comparable, Observer, rma.lang.Modifiable

public class ReservoirElement extends Element implements Cloneable, ReleaseElement, AltInputReportInfc, OperationsElement
Composite element that represents a simple reservoir.
See Also:
  • Field Details

  • Constructor Details

    • ReservoirElement

      public ReservoirElement()
    • ReservoirElement

      public ReservoirElement(RssSystem sys, int idx)
  • Method Details

    • initTSVals

      protected void initTSVals(int istep)
      set estimated values for un-initialized time series variables at the given time step
      Overrides:
      initTSVals in class Element
      Parameters:
      istep -
    • setVerticalDatumSettings

      public void setVerticalDatumSettings(VerticalDatumSettings vds)
    • getVerticalDatumSettings

      public VerticalDatumSettings getVerticalDatumSettings()
      Specified by:
      getVerticalDatumSettings in interface OperationsElement
      Returns:
    • getEffectiveElev

      public double getEffectiveElev(RunTimeStep rts)
      returns elevation for the given RunTimeStep at the upstream end of this element. Considers any "forebay" head loss associated with this and all parent elements For the first implementation, this method will only work for reservoirs and their child elements
      Overrides:
      getEffectiveElev in class Element
      Returns:
      double elevation or RMAConst.UNDEF_DOUBLE if elevation data not available
    • getPrevEffectiveElev

      public double getPrevEffectiveElev(RunTimeStep rts)
      returns elevation for one time step prior to the given RunTimeStep at the upstream end of this element. Considers any "forebay" head loss associated with this and all parent elements For the first implementation, this method will only work for reservoirs and their child elements
      Overrides:
      getPrevEffectiveElev in class Element
      Returns:
      double elevation or RMAConst.UNDEF_DOUBLE if elevation data not available
    • getFlowContolTSRecordProxies

      public Vector getFlowContolTSRecordProxies()
      special handling for reservoir element, overrides default implementation in Element.java
      Overrides:
      getFlowContolTSRecordProxies in class Element
    • getReservoirOutletElements

      public List getReservoirOutletElements(List list)
      adds all ReservoirOutletElement children to the given List. If the given list is null, a new ArrayList is created.
      Parameters:
      list -
      Returns:
      the given or newly created list filled with ReservoirOutletElement
    • getPowerPlants

      public PowerPlant[] getPowerPlants()
      Returns a list of power plants attached to this reservoir element. The list is guaranteed to be non null and of size 0 if there are no power plants on this reservoir.
      Returns:
      an array of PowerPlant objects.
    • getPumps

      public Pump[] getPumps()
      Returns a list of pumps attached to this reservoir element. The list is guaranteed to be non null and of size 0 if there are no pumps on this reservoir.
      Returns:
      an array of PowerPlant objects.
    • getRequiredTSRecordProxies

      public Vector getRequiredTSRecordProxies()
      returns the flow TSRecordProxies from upstream nodes on this element and any TSRecordProxies required by active operating rules
      Overrides:
      getRequiredTSRecordProxies in class Element
    • getRuleConnectivityRefs

      public List getRuleConnectivityRefs()
      Returns a List of RuleConnectivityRef objects identifying all rule references to other objects in the network.
      Overrides:
      getRuleConnectivityRefs in class Element
      Returns:
      ArrayList RuleConnectivityRef objects
    • getGuideCurveStorage

      public double getGuideCurveStorage(RunTimeStep rts)
    • saveElementState

      public void saveElementState(int stateid)
      save the current state of the element and its function with the given identifier
      Overrides:
      saveElementState in class Element
      Parameters:
      stateid - identifier for the state
    • restoreElementState

      public void restoreElementState(int stateid)
      Description copied from class: Element
      restore the state of the element and its function matching the given identifier
      Overrides:
      restoreElementState in class Element
      Parameters:
      stateid - identifier for the state
    • createHotstartState

      protected ElementHotstartState createHotstartState()
      Overrides:
      createHotstartState in class Element
    • updateDecisions

      public void updateDecisions(RunTimeStep rts, int iteration)
      make operations decisions for this time step
      Specified by:
      updateDecisions in interface ReleaseElement
      Parameters:
      rts -
      iteration -
    • initForecastOperations

      public int initForecastOperations(RunTimeWindow rtw)
      Initializes adjustable parameter values over forecast time window
      Specified by:
      initForecastOperations in interface ReleaseElement
    • getCompositeRelease

      public PairedValuesExt getCompositeRelease()
      Specified by:
      getCompositeRelease in interface OperationsElement
    • getTotalCompositeRelease

      public double getTotalCompositeRelease(double elev)
      get the total composite release for the elevation
    • getModelVariables

      public Vector getModelVariables(Vector variableList)
      returns a vector of all plottable model variables for reservoirs
      Specified by:
      getModelVariables in interface hec.watershed.res.model.PlottableObject
      Overrides:
      getModelVariables in class Element
    • hasPump

      public boolean hasPump()
      determines whether reservoir has one or more power plants
      Returns:
      true if there is at least one power plant
    • useOverridesForThisReservoir

      public boolean useOverridesForThisReservoir()
      Gets the flag used in the Release Overrides that tells the override options to use another alternative's info to override this reservoir's outlets
      Returns:
      boolean if true, uses overrides on this reservoir
    • setUseOverridesForThisReservoir

      public void setUseOverridesForThisReservoir(boolean set)
      Sets the flag used in the Release Overrides that tells the override options to use another alternative's info to override this reservoir's outlets
      Parameters:
      set - true, uses overrides on this reservoir
    • hasPowerPlant

      public boolean hasPowerPlant()
      determines whether reservoir has one or more power plants
      Returns:
      true if there is at least one power plant
    • hasWaterControlDeviceOnRes

      public boolean hasWaterControlDeviceOnRes()
      determines whether reservoir has one or more WQ Control Devices
      Returns:
      true if there is at least one WQ Control Device
    • getWaterControlDevicesOnRes

      public List<WaterControlDevice> getWaterControlDevicesOnRes()
    • getDefaultModelVariables

      public Vector getDefaultModelVariables()
      Returns a list of Model Variables that are used in the default plot required by PlottableObject interface
      Specified by:
      getDefaultModelVariables in interface hec.watershed.res.model.PlottableObject
      Overrides:
      getDefaultModelVariables in class Element
      Returns:
      list of ModelVariable objects
    • getTSRecords

      public Vector getTSRecords(ModelVariable plotVariable, Vector proxyList, Vector runs)
      gets the TSRecordProxies that match the requested model variables
      Specified by:
      getTSRecords in interface hec.watershed.res.model.PlottableObject
      Overrides:
      getTSRecords in class Element
    • setupForSerialization

      public void setupForSerialization()
      Description copied from class: Element
      called just before ascii serialization
      Overrides:
      setupForSerialization in class Element
    • updateSegments

      public void updateSegments()
      recalculates segments based on associated nodes and current stream alignment
    • getStreamSegmentVector

      public Vector<StreamSegment> getStreamSegmentVector()
      gets the stream segment vector
    • setStreamSegmentVector

      public void setStreamSegmentVector(Vector<StreamSegment> segvec)
      sets the stream segment vector
    • setReservoirProjectId

      public void setReservoirProjectId(long id)
    • getReservoirProjectId

      public long getReservoirProjectId()
    • getNextDivertedOutletName

      public String getNextDivertedOutletName()
    • getNextControlledOutletName

      public String getNextControlledOutletName()
    • getNextUncontrolledOutletName

      public String getNextUncontrolledOutletName()
    • getNextWaterControlDeviceName

      public String getNextWaterControlDeviceName()
    • getNextOutletGroupName

      public String getNextOutletGroupName()
    • getNextPumpName

      public String getNextPumpName()
    • getNextPowerPlantName

      public String getNextPowerPlantName()
    • getNextReversiblePumpName

      public String getNextReversiblePumpName()
    • setDefaultWaterAccount

      public void setDefaultWaterAccount(WaterAccount wa)
    • getDefaultWaterAccount

      public WaterAccount getDefaultWaterAccount()
    • getNextChildName

      public String getNextChildName(String classname, String basename)
      returns the next unique name for the given child element class and base name
    • getDivertedOutlets

      public Vector getDivertedOutlets()
    • createDivertedOutlet

      public DivertedOutletElement createDivertedOutlet(RssNode node0, RssNode node1, Vector ptVec, double tol)
      Adds a new DivertedOutlet to the reservoir
    • reconnectDivertedOutlet

      public void reconnectDivertedOutlet(RssNode node1)
    • clone

      public Object clone()
      Creates a new object of the same class as this object.
      It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No
      constructor is called.
      Overrides:
      clone in class Element
    • copyInto

      public void copyInto(ReservoirElement re)
      Performs a deep copy that clones data of the given ReservoirElement. This method is used by the reservoir editor.
    • initialize

      public boolean initialize(RunTimeWindow rtw)
      initialize prior to a compute
      Overrides:
      initialize in class Element
    • initForPostProcessing

      public boolean initForPostProcessing(RunTimeWindow rtw)
      Prepares this run for post processing in the ResSim Simulation Module. This routing sets up all data model connectivity, but does not load time series arrays.
      Overrides:
      initForPostProcessing in class Element
      Returns:
      RTN_NOPROBLEM if successful
    • prepRegulatedFlowCompute

      public boolean prepRegulatedFlowCompute()
      Set state of elements and nodes in preparation of regulated flow compute. For regulated flow the child elements are used. The nodes computed by the child element functions must be set active.
    • prepCumLocFlowCompute

      public boolean prepCumLocFlowCompute()
      Set state of elements and nodes in preparation of cumulative local flow compute.
    • prepUnregulatedFlowCompute

      public boolean prepUnregulatedFlowCompute(boolean disableDivertedOutlets)
      Set state of elements and nodes in preparation of unregulated flow compute. For unregulated flow the child elements are not used, the reservoir element acts like a junction. The nodes computed by the child element functions must be set inactive.
    • prepHoldoutCompute

      public boolean prepHoldoutCompute()
      sets up reservoir to act as a headwater for holdout flow computations
    • prepPulseRoutingCompute

      public boolean prepPulseRoutingCompute(int outletId)
      sets up reservoir to act as a headwater for pulse routing computations
    • setName

      public void setName()
      over-ride setName to echo rename to child elements - not implemented yet
    • computeHindcast

      public int computeHindcast(RunTimeWindow rtw, int computeFlag)
      Description copied from class: Element
      performs a compute over the runtime window using hindcast logic
      Overrides:
      computeHindcast in class Element
    • computeHindcastStep

      public int computeHindcastStep(RunTimeStep rts)
      Description copied from class: Element
      computes a single hindcast time step
      Overrides:
      computeHindcastStep in class Element
    • computeForecast

      public int computeForecast(RunTimeWindow rtw, int computeFlag)
      Description copied from class: Element
      performs a compute over the runtime window using forecast logic
      Overrides:
      computeForecast in class Element
    • computeForecastStep

      public int computeForecastStep(RunTimeStep rts)
      Description copied from class: Element
      computes a single forecast time step
      Overrides:
      computeForecastStep in class Element
    • initPumpbackStep

      public int initPumpbackStep(RunTimeStep rts)
    • computePumpbackStep

      public int computePumpbackStep(RunTimeStep rts)
      after regular computations are complete for a time step, pumpback operation moves a volume of water from the source reservoir to this reservoir
      Parameters:
      rts -
      Returns:
    • resetOpsIds

      public void resetOpsIds()
    • getResOpName

      public String getResOpName()
      return the name of the ReservoirOp object associated with this element
    • setReservoirOp

      public void setReservoirOp(ReservoirOp resOp)
      Sets a ReservoirOp to the dbf. Removes any ReservoirOp that may exist
    • getReservoirOp

      public ReservoirOp getReservoirOp()
    • getReservoirOpFromDbf

      protected boolean getReservoirOpFromDbf()
      retrieve the reservoir op from the network's dbf file
      Returns:
    • setReservoirSysOp

      public void setReservoirSysOp(ReservoirSysOp resSysOp)
      Sets a ReservoirSysOp
    • getReservoirSysOp

      public ReservoirSysOp getReservoirSysOp()
      returns the reservoir system operations object that is assiciated with this reservoir if one exists.
    • getReservoirSysOpFromDbf

      protected boolean getReservoirSysOpFromDbf()
      retrieve the reservoir sys op from the network's dbf file
      Returns:
    • addNode

      public void addNode(RssNode n, int idir)
      override add node to make connections to child elements
      Overrides:
      addNode in class Element
    • getStorageElement

      public Element getStorageElement()
    • getStorageFunction

      public Storage getStorageFunction()
      Specified by:
      getStorageFunction in interface OperationsElement
      Returns:
    • setStorageFunction

      public void setStorageFunction(Storage storage)
    • setEvaporationTS

      @Deprecated public void setEvaporationTS(boolean useTS)
      Deprecated.
      sets evaporation to time series input if useTS is true
    • getRegion

      public hec.map.WorldRegion getRegion()
      Returns the reservoir region
    • getReferencePt

      public hec.map.WorldPt getReferencePt()
      Returns a reservoir reference point
      Overrides:
      getReferencePt in class Element
    • setReferencePt

      public void setReferencePt(hec.map.WorldPt wpt)
    • setRegion

      public void setRegion(hec.map.WorldRegion reg)
      Sets the reservoir region
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Overrides:
      getFieldObject in class Element
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Overrides:
      setFieldObject in class Element
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful
    • getGatedFlowFunction

      @Deprecated public AdjustableFlow getGatedFlowFunction()
      Deprecated.
      to be removed
    • toString

      public String toString()
      over toString to return name - check if ok to move to namedtype
      Overrides:
      toString in class Element
    • hasDownstreamGoals

      public boolean hasDownstreamGoals(int opid)
      returns true if the current operating rule set has any downstream goals
    • getDownstreamNodes

      public List getDownstreamNodes(List vec)
      returns all downstream nodes in the node list does not recurse through child elements
      Overrides:
      getDownstreamNodes in class Element
    • getDownstreamRuleNodes

      public Hashtable getDownstreamRuleNodes(int opid)
      gets a Hashtable of nodes used by downstream operating ruls for the given OpSet
    • getStorageZones

      public void getStorageZones(int opid, List<StorageZone> zoneList)
      Adds storage zones to the given list
      Parameters:
      opid -
      zoneList -
    • getStorageZone

      public StorageZone getStorageZone(int opid, int zoneid)
      gets a specific storage zone based on the zone id.
      Parameters:
      opid -
      zoneid -
      Returns:
    • getRules

      public void getRules(int opid, List rulevec)
      Adds rule references to the given vector.
    • getConditionalBlockRefs

      public List<ConditionalBlockRef> getConditionalBlockRefs(int opid, List<ConditionalBlockRef> condList)
      Adds all ConditionalBlockRefs utilized by the Operation Set matching the given OpSet Id. This method is intended to provide the list of ConditionalBlockRef that may be utilized during a compute in order to evaluate the logical connectivity within the reservoir network. This method may be called within or outside a compute.
      Parameters:
      opid - id number for an existing OpSet
      condList - list object to hold the set of ConditionalBlockRef objects found by this method
      Returns:
      the list of ConditionalBlockRef objects
    • getDownstreamRules

      public void getDownstreamRules(int opid, List rulevec)
      adds downstream rule references to the given vector
    • getSystemHydropowerOpRules

      public void getSystemHydropowerOpRules(int opid, ArrayList ruleList)
      adds SystemHydropwerOpRule references to the given ArrayList
    • getSystemEnergyGeneration

      protected double getSystemEnergyGeneration(RunTimeStep rts)
      Sums up all energy generation for the given time step that can be used to contribute to system hydropower
      Parameters:
      rts - time step
      Returns:
      energy generated in MWH
    • getSystemGenerationLimits

      protected double getSystemGenerationLimits(RunTimeStep rts, SystemHydropowerRule rule, double[] max, double[] min, int n, int nsteps)
      Calculates the maximum energy this reservoir could generate to satisfy the given system hydropower rule over the given time step.
      Parameters:
      rts - time step
      rule - calling system hydropower rule
      Returns:
      energy generation capacity in MWH
    • getSystemGenerationLimits2

      public double getSystemGenerationLimits2(RunTimeStep rts, OpRule rule, double[] max, double[] min, int istep, int periodSteps)
      temp method called by SystemPowerRule evaluate method to get generation limits
      Parameters:
      rts -
      rule -
      max -
      min -
      istep -
      periodSteps -
      Returns:
    • calcPeriodRelAndGenLimits

      public void calcPeriodRelAndGenLimits(RunTimeStep rts, int istep, int periodSteps, ReservoirLimitSet limitSet, OpRule callingRule)
      Calculate the release, release volume, and energy generation limits for the remaing part of the given period. Results are stored in the given ReleaseLimitSet.
      Parameters:
      rts -
      istep -
      periodSteps -
      callingRule -
    • calcPumpbackVolCap

      public double calcPumpbackVolCap(RunTimeStep rts, int istep, int periodSteps)
      calculates the maximum pump volume for all active pump rules at the given time step and starting elevation over the given period
      Parameters:
      rts -
      istep -
      periodSteps -
      Returns:
      the max pump volume in ac-ft or m^3
    • calcPumpbackVolMin

      public double calcPumpbackVolMin(RunTimeStep rts, int istep, int periodSteps)
    • getExpectedNetInflowVol

      public double getExpectedNetInflowVol(RunTimeStep rts, int steps, OpRule rule)
      compute the expected net inflow volume that will occur between the end of the current time step and the end of number of steps given considering the net inflow as well as expected rule related releases other than the given rule. Net inflow is the net inflow to the reservoir less minimum or specified release from the reservoir.
      Parameters:
      rts - current time step
      steps - number of steps into the future to look
      rule - the rule needing this estimate
      Returns:
      expected volume in acft or m^3
    • clearTSProxyList

      public void clearTSProxyList()
      dumps all ts proxies
      Overrides:
      clearTSProxyList in class Element
    • updateTSProxyList

      public void updateTSProxyList()
      overrides Element.updateTSProxyList to also get proxies from active reservoir operations
      Overrides:
      updateTSProxyList in class Element
    • getActiveTSProxies

      public Vector getActiveTSProxies(Vector vec, int iotype)
      returns a vector of required input, or generated output TSRecordProxies used in the current alternative default implementation elements, assume all records are active
      Overrides:
      getActiveTSProxies in class Element
    • getTSRecordProxies

      public Vector getTSRecordProxies()
      overrides Element.getTSRecordProxies to also get proxies from active reservoir operations
      Overrides:
      getTSRecordProxies in class Element
    • importFrom

      public boolean importFrom(ReservoirImport ri, StringBuffer results)
      import the Physical and Operations elments from ri
      Parameters:
      ri -
      results - put the import results
      Returns:
      true if the import was sucessful
    • setLabelPosition

      public void setLabelPosition(int p)
    • getLabelPosition

      public int getLabelPosition()
    • findRulesFor

      public List<OpRule> findRulesFor(Element elem)
    • findRuleRefsFor

      public List<OpRuleRef> findRuleRefsFor(Element elem)
      find all the OpRuleRefs that have their release element is elem.
      Parameters:
      elem - the release element to look for.
      Returns:
      the list of OpRuleRefs for elem.
    • outputReport

      public void outputReport(AlternativeInputReport report, org.jdom.Element elem)
      Description copied from interface: AltInputReportInfc
      Alternative Input Report Interface for data.
      Specified by:
      outputReport in interface AltInputReportInfc
    • getElementOp

      public ElementOp getElementOp()
      Specified by:
      getElementOp in interface OperationsElement
      Returns:
    • getElementOp

      public ElementOp getElementOp(boolean init)
      Specified by:
      getElementOp in interface OperationsElement