WaterSources Module

The WaterSources module contains classes and functions related defining the components of the water system that supply water. This module is a submodule of the SystemComponents module.

API Reference

Below is the API reference for the WaterSources submodule. Documentation is automatically extracted from the header files.

Base Components

AllocatedIntake.h

class AllocatedIntake : public WaterSource
#include <AllocatedIntake.h>

The AllocatedIntake is a subclass of the main WaterSource class that represents a raw water intake from upstream catchments with allocations associated to utilities.

Created by dgorelic on 3/2/2020.

Public Functions

AllocatedIntake(const char *name, const int id, const vector<Catchment*> &catchments, vector<int> connected_sources, vector<int> &partner_utilities, const double total_raw_water_capacity, vector<double> &raw_water_capacity_allocation_fractions, const double total_treatment_capacity, vector<double> &treatment_capacity_allocation_fractions)

Constructor for creating an AllocatedIntake object.

This constructor initializes an AllocatedIntake object, which represents a intake that has allocated raw water and treatment capacities, as well as associated utilities and catchments. It initializes various properties by invoking the base class constructor (WaterSource) and setting additional member variables such as allocated_demands.

Parameters:
  • name – The name of the intake.

  • id – The unique identifier for the intake.

  • catchments – A vector of pointers to the catchments associated with this intake.

  • connected_sources – A vector of IDs for the connected sources of the intake.

  • partner_utilities – A vector of IDs for the partner utilities associated with this intake.

  • total_raw_water_capacity – The total raw water capacity of the intake.

  • raw_water_capacity_allocation_fractions – A vector of fractions representing the allocation of raw water capacity to different utilities.

  • total_treatment_capacity – The total treatment capacity of the intake.

  • treatment_capacity_allocation_fractions – A vector of fractions representing the allocation of treatment capacity to different utilities.

Returns:

A fully constructed AllocatedIntake object.

AllocatedIntake(const AllocatedIntake &intake)

Copy constructor for creating a new AllocatedIntake object by copying another AllocatedIntake object.

This constructor initializes a new AllocatedIntake object by copying the values from an existing AllocatedIntake object. It delegates the initialization of the base class (WaterSource) to the base class copy constructor and copies the allocated_demands vector from the intake object.

Parameters:

intake – The AllocatedIntake object to copy from.

Returns:

A new AllocatedIntake object that is a copy of the provided intake object.

AllocatedIntake &operator=(const AllocatedIntake &intake)

Assignment operator for copying the contents of one AllocatedIntake object to another.

This operator allows for the assignment of one AllocatedIntake object to another, copying the values of the base class (WaterSource) and the allocated_demands vector from the source object to the target object.

Parameters:

intake – The AllocatedIntake object to assign from.

Returns:

A reference to the target AllocatedIntake object (*this).

~AllocatedIntake() override

Destructor for the AllocatedIntake class.

This destructor is responsible for cleaning up the resources used by the AllocatedIntake object. It clears the catchments vector to free any associated memory when the object is destroyed.

This destructor overrides the base class destructor (WaterSource) to ensure proper cleanup.

Returns:

void

virtual void applyContinuity(int week, double upstream_source_min_env_flow, double wastewater_inflow, vector<double> &demand) override

Applies the continuity equation to update water availability, demand, and allocations for the current time step.

This function updates various properties related to water inflow, outflow, and demand based on the continuity equation. It computes the total upstream inflows, allocates available volumes to utilities based on their allocations, and updates the outflows and demands for the current week.

This function overrides the base class method applyContinuity to provide specific implementation for AllocatedIntake.

Parameters:
  • week – The current week for which the continuity equation is being applied.

  • upstream_source_min_env_flow – The minimum environmental flow from upstream sources.

  • wastewater_inflow – The inflow of wastewater.

  • demand – A fraction of supply allocated to demands from each utility.

Returns:

void

virtual void setRealization(unsigned long r, vector<double> &rdm_factors) override

Sets the realization for the AllocatedIntake object and updates water demand and availability.

This function sets the realization for the AllocatedIntake object by calling the base class’s setRealization method. It then updates the total demand and available volume based on the current upstream catchment inflow and the minimum environmental outflow.

This function overrides the base class method setRealization to provide specific implementation for AllocatedIntake.

Parameters:
  • r – The realization index (e.g., representing a specific scenario or time step).

  • rdm_factors – A vector of random distribution factors used in the realization process.

Returns:

void

virtual double getPrioritySourcePotentialVolume(int utility_id) const override

Calculates the priority source potential volume for a given utility.

This function calculates the potential volume of water available to a utility based on its allocated treatment capacity, current demand, environmental requirements, and upstream catchment inflow. The result is the maximum available volume that can be allocated to the utility, considering the constraints set by treatment capacities and environmental flows.

This function overrides the base class method getPrioritySourcePotentialVolume to provide specific implementation for AllocatedIntake.

Parameters:

utility_id – The ID of the utility for which the priority source potential volume is being calculated.

Returns:

The calculated priority source potential volume for the specified utility.

vector<double> getAllocatedDemands() const

Retrieves the allocated demands for all utilities.

This function returns a vector containing the allocated demands for all utilities associated with the AllocatedIntake object. The demands are represented by the allocated_demands vector, which is updated based on the current inflows and allocations.

Returns:

A vector of double representing the allocated demands for each utility.

virtual void addCapacity(double capacity, int utility_id)

Adds capacity to the AllocatedIntake object and updates utility allocations.

This function adds the specified capacity to both the total capacity of the AllocatedIntake object and the allocated capacity for a specific utility. It also ensures that the allocation fractions for all utilities are updated to reflect the new capacity.

Parameters:
  • capacity – The amount of capacity to add to the AllocatedIntake.

  • utility_id – The ID of the utility for which the capacity is being added.

Returns:

void

virtual void addTreatmentCapacity(const double added_treatment_capacity, int utility_id)

Adds treatment capacity to the AllocatedIntake object and updates utility allocations.

This function adds the specified treatment capacity to both the total treatment capacity of the AllocatedIntake object and the allocated treatment capacity for a specific utility. It also ensures that the allocation fractions for all utilities are updated to reflect the new treatment capacity.

Parameters:
  • added_treatment_capacity – The amount of treatment capacity to add to the AllocatedIntake.

  • utility_id – The ID of the utility for which the treatment capacity is being added.

Returns:

void

virtual double getAvailableAllocatedVolume(int utility_id) override

Retrieves the available allocated volume for a specific utility.

This function returns the available allocated volume for a given utility. The available volume is determined based on the current allocation and environmental conditions. This function overrides the base class method getAvailableAllocatedVolume to provide specific implementation for AllocatedIntake.

Parameters:

utility_id – The ID of the utility for which the available allocated volume is being retrieved.

Returns:

The available allocated volume for the specified utility.

Public Members

double next_upstream_catchment_inflow = 0

The inflow from the adjacent upstream catchment.

vector<double> allocated_demands

The demands allocated to each utility to be fulfiled by this intake.

AllocatedIntakeExpansion.h

class AllocatedIntakeExpansion : public WaterSource
#include <AllocatedIntakeExpansion.h>

The AllocatedIntakeExpansion is a subclass of the main WaterSource class that represents a raw water intake from upstream catchments with allocations associated to utilities.

Created by dgorelic on 3/2/2020.

Public Functions

AllocatedIntakeExpansion(const char *name, const int id, const unsigned int parent_intake_ID, const double total_supply_capacity_added, double total_treatment_capacity_added, vector<int> &partner_utility_ids, vector<double> &supply_capacity_allocations_added, vector<double> &treatment_capacity_allocations_added, const vector<double> &construction_time_range, vector<int> connected_sources, double permitting_period, vector<Bond*> &bonds)

Constructor for creating an AllocatedIntakeExpansion object.

This constructor initializes an AllocatedIntakeExpansion object by calling the base class’s WaterSource constructor and setting additional specific attributes for the expansion, such as supply and treatment capacities, construction time range, and partner utilities. It also stores the parent intake ID and updates the relevant capacities for the expansion.

Parameters:
  • name – The name of the intake expansion.

  • id – The unique identifier for the intake expansion.

  • parent_intake_ID – The ID of the parent intake to which this expansion is associated.

  • total_supply_capacity_added – The total additional supply capacity for the expansion.

  • total_treatment_capacity_added – The total additional treatment capacity for the expansion.

  • partner_utility_ids – A vector of IDs representing the utilities involved with this expansion.

  • supply_capacity_allocations_added – A vector of allocation fractions for the added supply capacity.

  • treatment_capacity_allocations_added – A vector of allocation fractions for the added treatment capacity.

  • construction_time_range – A vector containing the range of possible construction times for the expansion.

  • connected_sources – A vector of water source IDs connected to the intake expansion.

  • permitting_period – The permitting period for the expansion.

  • bonds – A vector of Bond objects associated with the intake expansion.

Returns:

An AllocatedIntakeExpansion object initialized with the provided parameters.

AllocatedIntakeExpansion(const AllocatedIntakeExpansion &intake_expansion)

Copy constructor for creating a copy of an AllocatedIntakeExpansion object.

This constructor creates a new AllocatedIntakeExpansion object by copying the values from another AllocatedIntakeExpansion object. It calls the base class’s copy constructor to copy common attributes and also copies the specific attributes related to the intake expansion, such as the parent_intake_ID, supply_capacity_added, and treatment_capacity_added.

Parameters:

intake_expansion – The AllocatedIntakeExpansion object to copy.

Returns:

A new AllocatedIntakeExpansion object that is a copy of the provided intake_expansion.

AllocatedIntakeExpansion &operator=(const AllocatedIntakeExpansion &intake_expansion)

Assignment operator for copying an AllocatedIntakeExpansion object.

This operator assigns the values from one AllocatedIntakeExpansion object to another, ensuring that all attributes are copied. It calls the base class’s assignment operator to copy common attributes and handles the assignment of specific attributes related to the intake expansion.

Parameters:

intake_expansion – The AllocatedIntakeExpansion object to assign to the current object.

Returns:

A reference to the current AllocatedIntakeExpansion object after the assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the intake expansion, updating the available flow and demand outflows.

This function computes the continuity for the intake expansion based on the current week’s inflows, wastewater discharge, and the demand outflows. It updates the relevant internal variables to ensure the system’s water balance is maintained. This function does not have a specific implementation in this subclass, inheriting its behavior from the base class.

Parameters:
  • week – The week for which the continuity is being applied.

  • upstream_source_inflow – The inflow into the intake from the upstream source.

  • wastewater_discharge – The volume of wasterwater discharged by the intake.

  • demand_outflow – A vector containing the demand outflows for each associated utility.

Returns:

None

virtual double getAllocatedCapacity(int utility_id) override

Retrieves the allocated supply capacity for a specific utility.

This function locates the utility within the allocation list and returns the allocated supply capacity for the given utility. This function overrides the base class implementation to handle the specific allocation structure of the intake expansion.

Parameters:

utility_id – The ID of the utility whose allocated supply capacity is being requested.

Throws:

logic_error – If the utility ID cannot be found in the allocation list.

Returns:

The allocated supply capacity for the specified utility.

virtual double getAllocatedTreatmentCapacity(int utility_id) const override

Retrieves the allocated treatment capacity for a specific utility.

This function locates the utility within the allocation list and returns the allocated treatment capacity for the given utility. If the utility ID cannot be found, a logic error is thrown. This function overrides the base class implementation to handle the specific allocation structure of the intake expansion.

Parameters:

utility_id – The ID of the utility whose allocated treatment capacity is being requested.

Throws:

logic_error – If the utility ID cannot be found in the allocation list.

Returns:

The allocated treatment capacity for the specified utility.

virtual Bond &getBond(int utility_id) override

Retrieves the bond associated with a specific utility.

This function locates the utility within the allocation list and retrieves the corresponding bond object. If the utility ID cannot be found, a logic error is thrown. This function overrides the base class implementation to handle the specific allocation structure of the intake expansion.

Parameters:

utility_id – The ID of the utility whose bond is being requested.

Throws:

logic_error – If the utility ID cannot be found in the allocation list or if no bond is associated with the utility.

Returns:

A reference to the Bond object associated with the specified utility.

Public Members

const unsigned int parent_intake_ID

The water source ID of the parent intake object.

const vector<double> supply_capacity_added

A vector of the supply capacity added to the intake for each utility with allocation to this intake.

const vector<double> treatment_capacity_added

A vector of the treatment capacity added to the intake for each utility with allocation to this intake.

AllocatedReservoir.h

class AllocatedReservoir : public Reservoir
#include <AllocatedReservoir.h>

The AllocatedReservoir is a subclass of the Reservoir class, which in turn is a subclass of the main WaterSource class. It represents a reservoir with allocations associated to utilities.

Created by bernardoct on 7/9/17.

Public Functions

AllocatedReservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, vector<int> *utilities_with_allocations, vector<double> *allocated_fractions, vector<double> *allocated_treatment_fractions)

Constructor for the AllocatedReservoir class.

This function initializes an AllocatedReservoir object with the specified parameters. It sets up the reservoir’s name, ID, catchments, capacities, and various allocation fractions. Additionally, it checks if the water quality pool is initialized.

Parameters:
  • name – The name of the reservoir.

  • id – The unique identifier for the reservoir.

  • catchments – A vector of pointers to catchment objects associated with the reservoir.

  • capacity – The total capacity of the reservoir.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir.

  • evaporation_series – The evaporation series object associated with the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities with allocations.

  • allocated_fractions – A pointer to a vector of doubles representing the allocated fractions of the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of doubles representing the allocated treatment fractions.

Returns:

void

AllocatedReservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, const vector<double> &construction_time_range, double permitting_period, Bond &bond, vector<int> *utilities_with_allocations, vector<double> *allocated_fractions, vector<double> *allocated_treatment_fractions)

Constructor for the AllocatedReservoir class.

This function initializes an AllocatedReservoir object with the specified parameters. It sets up additional attributes including construction time, permitting period, and bond information. Additionally, it checks if the water quality pool is initialized.

Parameters:
  • name – The name of the reservoir.

  • id – The unique identifier for the reservoir.

  • catchments – A vector of pointers to catchment objects associated with the reservoir.

  • capacity – The total capacity of the reservoir.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir.

  • evaporation_series – The evaporation series associated with the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve.

  • construction_time_range – A vector of doubles representing the range of construction times for the reservoir.

  • permitting_period – The permitting period for the reservoir.

  • bond – The Bond object associated with the reservoir.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities with allocations.

  • allocated_fractions – A pointer to a vector of doubles representing the allocated fractions of the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of doubles representing the allocated treatment fractions.

Returns:

void

AllocatedReservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, vector<int> *utilities_with_allocations, vector<double> *allocated_fractions, vector<double> *allocated_treatment_fractions)

Constructor for the AllocatedReservoir class.

This function initializes an AllocatedReservoir object with the specified parameters. It sets up a reservoir with a fixed storage area instead of a storage area curve. Additionally, it checks if the water quality pool is initialized.

Parameters:
  • name – The name of the reservoir.

  • id – The unique identifier for the reservoir.

  • catchments – A vector of pointers to catchment objects associated with the reservoir.

  • capacity – The total capacity of the reservoir.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir.

  • evaporation_series – The evaporation series object associated with the reservoir.

  • storage_area – The storage area of the reservoir.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities with allocations.

  • allocated_fractions – A pointer to a vector of doubles representing the allocated fractions of the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of doubles representing the allocated treatment fractions.

Returns:

void

AllocatedReservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, const vector<double> &construction_time_range, double permitting_period, Bond &bond, vector<int> *utilities_with_allocations, vector<double> *allocated_fractions, vector<double> *allocated_treatment_fractions)

Constructor for the AllocatedReservoir class.

This function initializes an AllocatedReservoir object with the specified parameters. It sets up additional attributes including construction time, permitting period, and bond information. It sets up a reservoir with a fixed storage area instead of a storage area curve. Additionally, it checks if the water quality pool is initialized.

Parameters:
  • name – The name of the reservoir.

  • id – The unique identifier for the reservoir.

  • catchments – A vector of pointers to catchment objects associated with the reservoir.

  • capacity – The total capacity of the reservoir.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir.

  • evaporation_series – The evaporation series associated with the reservoir.

  • storage_area – The storage area of the reservoir.

  • construction_time_range – A vector of doubles representing the range of construction times for the reservoir.

  • permitting_period – The permitting period for the reservoir.

  • bond – The Bond object associated with the reservoir.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities with allocations.

  • allocated_fractions – A pointer to a vector of doubles representing the allocated fractions of the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of doubles representing the allocated treatment fractions.

Returns:

void

AllocatedReservoir(const AllocatedReservoir &allocated_reservoir)

Copy constructor for the AllocatedReservoir class.

This function creates a new AllocatedReservoir object as a copy of an existing one. It initializes the new object by copying the data members from the provided allocated_reservoir, including the base class Reservoir and the has_water_quality_pool member.

Parameters:

allocated_reservoir – The AllocatedReservoir object to be copied.

Returns:

void

AllocatedReservoir &operator=(const AllocatedReservoir &allocated_reservoir)

Assignment operator for the AllocatedReservoir class.

This function assigns the state of one AllocatedReservoir object to another using the assignment operator. It copies the data members from the provided allocated_reservoir object to the current object (*this), including the base class Reservoir and the has_water_quality_pool member.

Parameters:

allocated_reservoir – The AllocatedReservoir object to be assigned.

Returns:

A reference to the current AllocatedReservoir object (*this).

~AllocatedReservoir()

Destructor for the AllocatedReservoir class.

This function cleans up the AllocatedReservoir object when it goes out of scope. As it is defaulted, it relies on the compiler-generated destructor to handle cleanup.

Returns:

void

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_inflow, vector<double> &demand_outflow) override

Updates reservoir state by applying water balance equations for a given week.

This function calculates the reservoir’s continuity, accounting for inflows, outflows, evaporation, and demand, and updates the state of the reservoir accordingly. This function overrides the base class Reservoir function to include continuity calculations.

Parameters:
  • week – The current week for which continuity is calculated.

  • upstream_source_inflow – The inflow from upstream water sources.

  • wastewater_inflow – The inflow from wastewater sources.

  • demand_outflow – A vector representing the water demands of different utilities.

Throws:

runtime_error – If the continuity error exceeds acceptable limits or allocated volumes do not match the available volume.

Returns:

void

virtual void setFull() override

Sets the reservoir and all allocated volumes to full capacity.

This function marks the reservoir as full by setting its state to maximum capacity. Additionally, it ensures that all allocations for utilities are set to their respective maximum capacities. This function overrides the base class Reservoir function to include continuity calculations.

Returns:

void

virtual double getAvailableAllocatedVolume(int utility_id) override

Retrieves the available allocated volume for a specific utility.

This function returns the current available volume of water allocated to the specified utility. It retrieves the allocated volume from the available_allocated_volumes vector using the utility_id. This function overrides the base class Reservoir function to include continuity calculations.

Parameters:

utility_id – The identifier of the utility for which the allocated volume is retrieved.

Returns:

double The available allocated volume for the specified utility.

virtual void removeWater(int allocation_id, double volume) override

Removes a utility’s allocated volume of water from the reservoir updates the reservoir state.

This function reduces the allocated volume for a specific utility by the given amount, adjusts the total available volume of the reservoir, and updates the total demand and policy-added demand. This function overrides the base class Reservoir function to include continuity calculations.

Parameters:
  • allocation_id – The identifier of the allocation (utility) from which water is to be removed.

  • volume – The volume of water to be removed.

Returns:

void

virtual double getAllocatedCapacity(int utility_id) override

Retrieves the allocated capacity for a specific utility.

This function overrides the base class Reservoir function to allow specific utility-related information to be retrieved.

Parameters:

utility_id – The identifier of the utility for which the allocated capacity is retrieved.

Returns:

double The allocated capacity for the specified utility.

virtual double getAllocatedFraction(int utility_id) override

Retrieves the allocated fraction of capacity for a specific utility.

This function returns the fraction of the reservoir’s total capacity that is allocated to a specific utility. This function overrides the base class Reservoir function to allow specific utility-related information to be retrieved.

Parameters:

utility_id – The identifier of the utility for which the allocated fraction is retrieved.

Returns:

double The allocated fraction for the specified utility (unitless, typically between 0 and 1).

virtual void addCapacity(double capacity, int utility_id) override

Adds capacity to the reservoir and adjusts allocations for each utility.

This function increases the reservoir’s total capacity and redistributes the added capacity among utilities based on their allocated fractions. This function overrides the base class Reservoir function to include continuity calculations.

Parameters:
  • capacity – The additional capacity to be added to the reservoir.

  • utility_id – The identifier of the utility initiating the capacity increase.

Returns:

void

virtual void addTreatmentCapacity(const double added_plant_treatment_capacity, int utility_id) override

Adds treatment capacity to the reservoir for a specific utility and updates allocation fractions. This function increases the plant’s treatment capacity for a specified utility and recalculates the treatment allocation fractions for all utilities.

Both the total treatment capacity of the new plant and the fraction of the treatment capacity allocated to a given utility allow for joint treatment plants. To have one utility only building an exclusive plant, the fraction will be 1.

This function overrides the base class Reservoir function to include continuity calculations.

Parameters:
  • added_plant_treatment_capacity – The additional treatment capacity to be added.

  • utility_id – The identifier of the utility receiving the additional treatment capacity.

Returns:

void

virtual double getAllocatedTreatmentCapacity(int utility_id) const override

Retrieves the allocated treatment capacity for a specific utility.

This function returns the treatment capacity allocated to the specified utility. If the utility ID corresponds to the water quality allocation, an exception is thrown as it does not have an allocated treatment capacity. This function overrides the base class Reservoir function to reference a specific utility.

Parameters:

utility_id – The identifier of the utility whose treatment capacity is being queried.

Throws:

std::invalid_argument – If utility_id corresponds to the water quality allocation.

Returns:

double The allocated treatment capacity (m³/day) for the specified utility.

virtual double getSupplyAllocatedFraction(int utility_id) override

Retrieves the supply allocated fraction for a specific utility.

This function returns the supply allocated fraction for the specified utility. If the utility ID corresponds to the water quality allocation, an exception is thrown because water quality allocation cannot be used for supply. This function overrides the base class Reservoir function to reference a specific utility.

Parameters:

utility_id – The identifier of the utility whose supply allocation fraction is being queried.

Throws:

std::invalid_argument – If utility_id corresponds to the water quality allocation.

Returns:

double The supply allocated fraction for the specified utility.

bool mass_balance_with_wq_pool(double net_inflow, vector<double> &demand_outflow)

Performs the mass balance calculation for the reservoir with the water quality (WQ) pool.

This function calculates the mass balance for the reservoir by considering both the allocations for utilities and the water quality pool. It splits the incoming net inflow among the utilities, subtracts their respective demands, and handles cases where the allocated volume goes negative by charging the water quality pool. The function also flags when an allocation exceeds its capacity.

Parameters:
  • net_inflow – The net inflow into the reservoir (inflow minus outflow from upstream sources).

  • demand_outflow – A vector containing the demand outflows for each utility.

Returns:

bool Returns true if overallocation occurs (i.e., any allocation exceeds its capacity), false otherwise.

bool mass_balance_without_wq_pool(double net_inflow, vector<double> &demand_outflow)

Performs the mass balance calculation for the reservoir without considering the water quality (WQ) pool.

This function calculates the mass balance for the reservoir when there is no water quality pool. It splits the incoming net inflow among the utilities based on their allocation fractions, subtracts their respective demands, and checks if any allocation exceeds its capacity.

Parameters:
  • net_inflow – The net inflow into the reservoir (inflow minus outflow from upstream sources).

  • demand_outflow – A vector containing the demand outflows for each utility.

Returns:

bool Returns true if overallocation occurs (i.e., any allocation exceeds its capacity), false otherwise.

virtual void setOnline() override

Sets the reservoir online, initializing available volume and allocated volumes.

This function sets the reservoir’s state to “online” by initializing its available volume to zero and setting all allocated volumes to zero for each utility with allocations. This represents the transition from an offline state to an active state where the reservoir is ready to receive inflows. This function overrides the base class Reservoir function to include continuity calculations.

Returns:

void

Protected Attributes

const bool has_water_quality_pool

A flag to indicate if the reservoir has a water quality pool.

double continuity_error

The error in calculating inflow continuity. Calculated as the total_outflow of the reservoir + available_allocated_volumes to a specific utility. Should be zero.

FixedJointWTP.h

class FixedJointWTP : public JointWTP
#include <FixedJointWTP.h>

The FixedJointWTP is a subclass of the JointWTP class, which in turn is a subclass of the main WaterSource class. This subclass represents the Joint WTP with fixed treatment capacity allocations to utilities.

Created by dgorelic on 10/28/2019.

Public Functions

FixedJointWTP(const char *name, const int id, const int parent_reservoir_ID, const int expansion_sequence_id, const double total_treatment_capacity, vector<int> connected_sources, vector<int> &agreement_utility_ids, vector<double> &fixed_treatment_capacity_allocations, vector<Bond*> &bonds, const vector<double> &construction_time_range, double permitting_period)

Constructs a FixedJointWTP object.

This constructor initializes an instance of the FixedJointWTP class, which represents a fixed allocation water treatment plant with a specified treatment capacity, parent reservoir, and various other parameters. It calls the base class JointWTP constructor and sets the permanent_treatment_allocations pointer.

Parameters:
  • name – The name of the water treatment plant.

  • id – The unique identifier for the water treatment plant.

  • parent_reservoir_ID – The ID of the parent reservoir.

  • expansion_sequence_id – The ID representing the expansion sequence of the plant.

  • total_treatment_capacity – The total treatment capacity of the water treatment plant.

  • connected_sources – A vector of integers representing the connected water sources to the treatment plant.

  • agreement_utility_ids – A vector of integers representing the utility IDs associated with agreements for treatment capacity.

  • fixed_treatment_capacity_allocations – A vector of doubles representing the fixed treatment capacity allocations for each utility.

  • bonds – A vector of pointers to Bond objects representing the associated bonds with the treatment plant.

  • construction_time_range – A vector of doubles representing the construction time range for the treatment plant.

  • permitting_period – The permitting period for the plant.

Returns:

A FixedJointWTP object initialized with the specified parameters.

FixedJointWTP(const FixedJointWTP &fixed_joint_water_treatment_plant)

Copy constructor for the FixedJointWTP class.

This constructor creates a new FixedJointWTP object as a copy of the provided FixedJointWTP object. It copies all member variables from the given instance, including the permanent_treatment_allocations pointer.

Parameters:

fixed_joint_water_treatment_plant – The FixedJointWTP object to copy.

Returns:

A new FixedJointWTP object that is a copy of the provided object.

~FixedJointWTP() override

Destructor for the FixedJointWTP class.

This destructor is the default destructor for the FixedJointWTP class and ensures proper cleanup of resources when an object of this class is destroyed. Since the class does not manage any dynamic memory or resources directly, the destructor simply calls the default destructor of its base class (JointWTP).

Returns:

None

FixedJointWTP &operator=(const FixedJointWTP &fixed_joint_water_treatment_plant)

Assignment operator for the FixedJointWTP class.

This operator allows for assignment of one FixedJointWTP object to another. It ensures that the base class (JointWTP) assignment operator is properly invoked and then returns the current object for chained assignments.

Parameters:

fixed_joint_water_treatment_plant – The FixedJointWTP object to be assigned to the current object.

Returns:

A reference to the current FixedJointWTP object after the assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the FixedJointWTP class.

This function calls the base class (JointWTP) implementation of applyContinuity to perform the necessary continuity checks and calculations for water treatment. It handles the inflows and outflows, ensuring the consistency of water volumes in the treatment process. This function overrides the virtual method in the base Reservoir class.

Parameters:
  • week – The week for which continuity is being applied.

  • upstream_source_inflow – The volume of water inflow from upstream sources.

  • wastewater_discharge – The volume of water from wastewater discharge.

  • demand_outflow – A reference to a vector of water demand outflows for each utility.

Returns:

None.

virtual double implementInitialTreatmentCapacity(int utility_id) override

Implements the initial treatment capacity for a specific utility.

This function retrieves the initial treatment capacity allocated to a utility from the permanent treatment allocations. It assumes that the indices in the permanent_treatment_allocations vector correspond to the order of utility IDs in the agreement_utility_ids vector. If the indices do not match, the returned value may be incorrect. This function overrides the virtual method in the base Reservoir class.

Parameters:

utility_id – The ID of the utility for which the initial treatment capacity is being retrieved.

Returns:

The initial treatment capacity allocated to the specified utility.

Private Members

vector<double> *permanent_treatment_allocations

Permanent treatment allocations for utilities.

Intake.h

class Intake : public WaterSource
#include <Intake.h>

The Intake is a subclass of the main WaterSource class that represents a pipeline that draws water from a surface water source.

Created by bernardo on 2/10/17.

Public Functions

Intake(const char *name, const int id, const vector<Catchment*> &catchments, const double max_treatment_capacity)

Constructs an Intake object with the specified properties.

This constructor initializes an Intake object, which represents a water source typically used for the intake of water for treatment. It inherits from the WaterSource class, setting up the properties of the intake such as name, ID, associated catchments, and maximum treatment capacity.

Parameters:
  • name – The name of the intake.

  • id – The unique identifier for the intake.

  • catchments – A vector of pointers to Catchment objects associated with this intake.

  • max_treatment_capacity – The maximum treatment capacity of the intake.

Returns:

A constructed Intake object with the provided properties.

Intake(const char *name, const int id, const vector<Catchment*> &catchments, const double raw_water_capacity, const double max_treatment_capacity)

Constructs an Intake object with the specified properties, including raw water capacity.

This constructor initializes an Intake object, which represents a water source typically used for the intake of raw water for treatment. It inherits from the WaterSource class, setting up the properties of the intake such as name, ID, associated catchments, raw water capacity, and maximum treatment capacity.

Parameters:
  • name – The name of the intake.

  • id – The unique identifier for the intake.

  • catchments – A vector of pointers to Catchment objects associated with this intake.

  • raw_water_capacity – The raw water intake capacity of the intake.

  • max_treatment_capacity – The maximum treatment capacity of the intake.

Returns:

A constructed Intake object with the provided properties.

Intake(const char *name, const int id, const vector<Catchment*> &catchments, vector<int> connected_sources, const double raw_water_main_capacity, const vector<double> construction_time_range, double permitting_period, Bond &bond)

Constructor for the Intake class.

This function initializes the Intake class with the details on construction, permitting, and financing.

Parameters:
  • name – The name of the intake.

  • id – The ID of the intake.

  • catchments – A vector of Catchment objects associated with this intake.

  • connected_sources – A vector of integers representing the connected water sources.

  • raw_water_main_capacity – The capacity for raw water intake.

  • construction_time_range – A vector containing the time range for construction.

  • permitting_period – The permitting period for the intake.

  • bond – The Bond object associated with the intake.

Returns:

A new instance of the Intake class initialized with the provided values.

Intake(const Intake &intake)

Copy constructor for the Intake class.

This constructor initializes a new Intake object as a copy of an existing Intake object.

Parameters:

intake – The Intake object to copy.

Returns:

A new instance of the Intake class that is a copy of the provided Intake.

Intake &operator=(const Intake &intake)

Assignment operator for the Intake class.

This operator assigns the values of an existing Intake object to the current object.

Parameters:

intake – The Intake object to assign from.

Returns:

A reference to the current Intake object after the assignment.

~Intake() override

Destructor for the Intake class.

This destructor clears the list of catchments associated with the Intake object. This destructor overrides the default destructor for the WaterSource class.

Returns:

None

virtual void applyContinuity(int week, double upstream_source_min_env_flow, double wastewater_inflow, vector<double> &demand) override

Applies continuity to update the water availability and demand for the Intake system.

This function calculates the total upstream inflow, downstream demand, and the water availability for the next time step. It also computes the total outflow based on the given upstream source inflow, wastewater inflow, and demand outflow. This function overrides the applyContinuity function in the WaterSource class.

FIXME: WHEN IMPLEMENTING RESERVOIR RULES, ADD A “BANK” OF WATER OVER AND UNDERUSE TO BE ADDED/SUBTRACTED FROM THE AVAILABLE VOLUME FOR THE NEXT REALIZATION.

Parameters:
  • week – The current week for which continuity is being applied.

  • upstream_source_inflow – The upstream source inflow during the current week.

  • wastewater_inflow – The wastewater inflow during the current week.

  • demand – The demand for water for each connected utility or system during the current week.

Returns:

None

virtual void setRealization(unsigned long r, vector<double> &rdm_factors) override

Sets the realization for the Intake system based on random factors.

This function updates the total demand and available volume for the Intake system based on a new realization and corresponding random factors. Thid function overrides the setRealization function in the WaterSource class.

Parameters:
  • r – The realization index, used to set the state for the given realization.

  • rdm_factors – The random factors that influence the realization.

Returns:

None

virtual double getPrioritySourcePotentialVolume(int utility_id) const override

Gets the potential volume available from the priority source.

This function calculates the remaining “storage” capacity after accounting for weekly demands and environmental flows. The volume is based on the treatment capacity and inflows. This function overrides the getPrioritySourcePotentialVolume function in the WaterSource class.

Parameters:

utility_id – The utility identifier. Currently unused in this method but kept for consistency.

Returns:

The remaining potential volume available from the priority source.

Public Members

double next_upstream_catchment_inflow = 0

The inflow to the intake from the adjacent upstream catchment.

IntakeExpansion.h

class IntakeExpansion : public WaterSource
#include <IntakeExpansion.h>

The IntakeExpansion is a subclass of the main WaterSource class that represents a pipeline scheduled for expansion.

Created by dgorelic on 7/8/2019.

Public Functions

IntakeExpansion(const char *name, const int id, const unsigned int parent_intake_ID, const double capacity_added, const double treatment_capacity_added, const vector<double> &construction_time_range, vector<int> connected_sources, double permitting_period, Bond &bond)

Constructs an IntakeExpansion object.

This constructor initializes the IntakeExpansion object, which represents the expansion of an existing intake system by adding extra capacity and treatment capacity.

Parameters:
  • name – The name of the intake expansion.

  • id – The unique identifier for the intake expansion.

  • parent_intake_ID – The ID of the parent intake from which this expansion is derived.

  • capacity_added – The additional capacity added to the intake.

  • treatment_capacity_added – The additional treatment capacity added to the intake.

  • construction_time_range – The time range for the construction of the expansion.

  • connected_sources – The list of connected sources to the intake expansion.

  • permitting_period – The permitting period for the expansion.

  • bond – The bond associated with the intake expansion.

Returns:

A new IntakeExpansion object.

IntakeExpansion(const IntakeExpansion &intake_expansion)

Copy constructor for the IntakeExpansion class.

This constructor creates a new IntakeExpansion object by copying the properties of an existing one. It ensures that both the WaterSource and parent_intake_ID are properly copied.

Parameters:

intake_expansion – The IntakeExpansion object to copy.

Returns:

A new IntakeExpansion object with the same properties as intake_expansion.

IntakeExpansion &operator=(const IntakeExpansion &intake_expansion)

Assignment operator for the IntakeExpansion class.

This operator assigns the properties of one IntakeExpansion object to another. It ensures that both the WaterSource and parent_intake_ID are correctly assigned.

Parameters:

intake_expansion – The IntakeExpansion object to assign from.

Returns:

A reference to the current IntakeExpansion object after the assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the IntakeExpansion class.

This function applies the continuity equation for the intake expansion process. This function does not have a specific implementation, taking on the behavior from the parent WaterSource class.

Parameters:
  • week – The current week for which continuity is applied.

  • upstream_source_inflow – The inflow from upstream sources.

  • wastewater_discharge – The discharge from wastewater sources.

  • demand_outflow – A vector containing the outflows of water demands.

Returns:

void

Public Members

const unsigned int parent_intake_ID

The ID of the parent intake.

JointWTP.h

class JointWTP : public WaterSource
#include <JointWTP.h>

The JointWTP is a subclass of the main WaterSource class. This subclass represents the joint Jordan Lake Water Treatment Plant.

Created by dgorelic on 10/28/2019.

Subclassed by FixedJointWTP, VariableJointWTP

Public Functions

JointWTP(const char *name, const int id, const int agreement_type, const int parent_reservoir_ID, const int expansion_sequence_id, const double total_treatment_capacity, vector<int> connected_sources, vector<int> &agreement_utility_ids, vector<double> &agreement_utility_treatment_capacities, vector<Bond*> &bonds, const vector<double> &construction_time_range, double permitting_period)

Constructor for the JointWTP class.

This constructor initializes a Joint Water Treatment Plant (WTP) with the given parameters, including the name, ID, agreement type, parent reservoir ID, expansion sequence, treatment capacity, connected sources, and various other settings. It also initializes the associated bonds and construction time range.

Parameters:
  • name – The name of the JointWTP.

  • id – The unique identifier of the JointWTP.

  • agreement_type – The agreement type for the JointWTP (e.g., shared, private).

  • parent_reservoir_ID – The ID of the parent reservoir associated with the JointWTP.

  • expansion_sequence_id – The ID that defines the sequence of expansion for the JointWTP (low/high).

  • total_treatment_capacity – The total treatment capacity of the JointWTP.

  • connected_sources – A vector containing the IDs of sources connected to the JointWTP.

  • agreement_utility_ids – A vector containing the IDs of utilities involved in the agreement.

  • agreement_utility_treatment_capacities – A vector containing the treatment capacities allocated to the utilities in the agreement.

  • bonds – A vector containing bonds related to the JointWTP.

  • construction_time_range – A vector specifying the construction time range for the JointWTP.

  • permitting_period – The permitting period for the JointWTP.

Returns:

A new instance of the JointWTP class.

JointWTP(const JointWTP &joint_water_treatment_plant)

Copy constructor for the JointWTP class.

This constructor creates a new instance of the JointWTP class by copying the data from an existing joint_water_treatment_plant object. It initializes the new instance by copying the base class (WaterSource) data and the specific attributes of the JointWTP class.

Parameters:

joint_water_treatment_plant – The JointWTP instance to copy from.

Returns:

A new instance of the JointWTP class, with data copied from the given joint_water_treatment_plant.

~JointWTP() override

Destructor for the JointWTP class.

This destructor is automatically invoked when an instance of the JointWTP class goes out of scope or is deleted. It performs any necessary cleanup, but in this case, the destructor is defaulted and doesn’t perform any custom actions.

Returns:

None

JointWTP &operator=(const JointWTP &joint_water_treatment_plant)

Assignment operator for the JointWTP class.

This operator allows for assignment of one JointWTP object to another.

Parameters:

joint_water_treatment_plant[in] The JointWTP object to be assigned to the current object.

Returns:

A reference to the current JointWTP object after the assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the JointWTP class.

This function is called to apply the continuity of the water treatment process. However, it is not designed to be called on a JointWTP instance. It throws a logic_error to indicate that continuity should be applied only to the associated reservoir being expanded, not the JointWTP itself. This function overrides the applyContinuity function in the base class WaterSource.

Parameters:
  • week – The current week in the simulation (used for inflow and outflow calculations).

  • upstream_source_inflow – The volume of water inflow from upstream sources for the given week.

  • wastewater_discharge – The volume of wastewater being discharged into the system.

  • demand_outflow – A vector representing the water demand outflow for each utility or demand point.

Throws:

logic_error – If called on a JointWTP instance, throws an error indicating that continuity should be applied to the reservoir being expanded, not the JointWTP.

Returns:

None

virtual double implementInitialTreatmentCapacity(int utility_id)

Implements the initial treatment capacity for the JointWTP class.

This function is intended to be overridden in child classes of JointWTP to define how the initial treatment capacity is implemented. When called on a JointWTP instance, it throws a logic_error because treatment capacity should be specified in the derived class.

Parameters:

utility_id – The ID of the utility for which the treatment capacity is being implemented.

Throws:

logic_error – If called on a JointWTP instance, throws an error indicating that the function should be overridden in a derived class to handle the implementation of treatment capacity.

Returns:

Returns 0 as a placeholder, but an exception will be thrown before this value is returned.

virtual int getAgreementType() const override

Retrieves the agreement type of the JointWTP.

This function returns the type of the agreement associated with the JointWTP instance. This function overrides the getAgreementType function in the base class WaterSource.

Returns:

The agreement type as an integer.

virtual int getParentWaterSourceID() const override

Retrieves the parent reservoir ID associated with the JointWTP.

This function returns the ID of the reservoir that the JointWTP is associated with. This function overrides the getParentWaterSourceID function in the base class WaterSource.

Returns:

The parent reservoir ID as an integer.

virtual double getAllocatedTreatmentFraction(int utility_id) const override

Calculates the allocated treatment fraction for a given utility.

This function computes the fraction of the total allocated treatment capacity for a specific utility relative to the total fraction allocated across all utilities. This function overrides the getAllocatedTreatmentFraction function in the base class WaterSource.

Parameters:

utility_id – The ID of the utility for which the allocated treatment fraction is requested.

Returns:

The allocated treatment fraction for the specified utility.

Public Members

const int expansion_sequence_id

The low or high expansion ID of the JointWTP object.

const unsigned int parent_reservoir_ID

The ID of the parent reservoir.

const int joint_agreement_type

The type of agreement for the JointWTP.

Quarry.h

class Quarry : public Reservoir
#include <Quarry.h>

The Quarry is a subclass of the Reservoir class, which in turn is a subclass of the main WaterSource class. It represents a quarry reservoir that diverts water from upstream catchments.

Created by bernardoct on 5/3/17.

Public Functions

Quarry(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, double max_diversion)

Constructs a Quarry object. This function initializes a quarry reservoir with specified parameters such as name, ID, catchments, capacity, treatment capacity, evaporation data, and more.

Parameters:
  • name – The name of the quarry as a C-style string.

  • id – The unique identifier of the quarry as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the quarry.

  • capacity – The total storage capacity of the quarry in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the quarry.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the quarry.

  • storage_area_curve – A pointer to a DataSeries object defining the relationship between storage and surface area of the quarry. Can be null.

  • max_diversion – The maximum diversion flow rate allowed from the quarry.

Quarry(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, const vector<double> &construction_time_range, double permitting_period, Bond &bond, double max_diversion)

Constructs a Quarry object. This function initializes a quarry reservoir with specified parameters such as name, ID, catchments, capacity, treatment capacity, evaporation data. It also includes additional parameters that define the construction timeline, and financial bond details.

Parameters:
  • name – The name of the quarry as a C-style string.

  • id – The unique identifier of the quarry as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the quarry.

  • capacity – The total storage capacity of the quarry in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the quarry.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the quarry.

  • storage_area_curve – A pointer to a DataSeries object defining the relationship between storage and surface area of the quarry. Can be null.

  • construction_time_range – A vector of doubles representing the start and end times of the quarry’s construction period.

  • permitting_period – The permitting period for the quarry in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the quarry.

  • max_diversion – The maximum diversion flow rate allowed from the quarry.

Quarry(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, double max_diversion)

Constructs a Quarry object. This function initializes a quarry reservoir with specified parameters such as name, ID, catchments, capacity, treatment capacity, evaporation data. It specifies a fixed storage area instead of a storage area curve.

Parameters:
  • name – The name of the quarry as a C-style string.

  • id – The unique identifier of the quarry as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the quarry.

  • capacity – The total storage capacity of the quarry in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the quarry .

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the quarry.

  • storage_area – The surface area of the quarry in square units.

  • max_diversion – The maximum diversion flow rate allowed from the quarry.

Quarry(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, const vector<double> &construction_time_range, double permitting_period, Bond &bond, double max_diversion)

Constructs a Quarry object. This function initializes a quarry reservoir with specified parameters such as name, ID, catchments, capacity, treatment capacity, evaporation data. It also includes additional parameters that define the construction timeline, and financial bond details. It specifies a fixed storage area instead of a storage area curve.

Parameters:
  • name – The name of the quarry as a C-style string.

  • id – The unique identifier of the quarry as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the quarry.

  • capacity – The total storage capacity of the quarry in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the quarry.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the quarry.

  • storage_area – The surface area of the quarry in square units.

  • construction_time_range – A vector of doubles representing the start and end times of the quarry’s construction period.

  • permitting_period – The permitting period for the quarry in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the quarry.

  • max_diversion – The maximum diversion flow rate allowed from the quarry.

Quarry(const Quarry &quarry, const double max_diversion)

Constructs a Quarry object as a copy of an existing Quarry object, with an option to set a new maximum diversion rate by overriding the max diversion of the original Quarry object.

Parameters:
  • quarry – A reference to the existing Quarry object to copy.

  • max_diversion – The maximum diversion flow rate allowed through the new quarry. This overrides the value from the copied Quarry object.

Quarry &operator=(const Quarry &quarry)

Overloads the assignment operator for the Quarry class, allowing one Quarry object to be assigned to another.

This function copies the properties of an existing Quarry object, including the maximum diversion rate, to the current Quarry object.

Parameters:

quarry – A reference to the existing Quarry object to copy.

Returns:

A reference to the current Quarry object after assignment.

~Quarry()

Destructor for the Quarry class.

This function cleans up resources used by the Quarry object. Since the class does not dynamically allocate resources directly, the destructor relies on the base class (Reservoir) and standard cleanup mechanisms.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_inflow, vector<double> &demand_outflow) override

Applies the continuity equation to update the Quarry’s inflows, outflows, and available volume based on weekly data.

This function performs reservoir mass balance by using the total inflow, demand outflow, and updates the available volume and total outflow based on inflows from upstream sources, wastewater, combining them with catchment inflows. The function also ensures that the quarry maintains its capacity limits and adjusts outflows accordingly.

Parameters:
  • week – The week number for which the continuity equation is applied.

  • upstream_source_inflow – The inflow from the upstream source in cubic units.

  • wastewater_inflow – The inflow from wastewater in cubic units.

  • demand_outflow – A vector representing the demand outflow for the week.

virtual void setOnline() override

Sets the Quarry object to an online state.

This function transitions the Quarry to an operational state by marking it as online. The available volume is initially set to NONE, simulating an empty reservoir that begins to fill as inflows occur.

Private Members

double max_diversion = NON_INITIALIZED

The maximum volume of water that can be diverted through the quarry.

double diverted_flow = NON_INITIALIZED

The volume of water diverted through the quarry.

Relocation.h

class Relocation : public WaterSource
#include <Relocation.h>

This subclass of WaterSource represents a relocation (reallocation) of water between utilities. This subclass does not have any water directly routed through it. Continuity equations therefore do not apply to it. It can only change allocated fractions in the reservoir/water source it is assigned to.

FIXME: Change name of class to reallocation.

Created by bernardoct on 7/25/17.

Public Functions

Relocation(const char *name, const int id, unsigned long parent_reservoir_ID, vector<double> *allocated_fractions, vector<int> *utilities_with_allocations, const vector<double> &construction_time_range, double permitting_period, Bond &bond)

Constructs a Relocation object, initializing a water source linked to a parent reservoir with specified allocations and construction details.

Parameters:
  • name – The name of the relocation water source as a C-style string.

  • id – The unique identifier of the relocation water source as an integer.

  • parent_reservoir_ID – The ID of the parent reservoir associated with this relocation.

  • allocated_fractions – A pointer to a vector of fractions allocated to utilities.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities that have allocations.

  • construction_time_range – A vector of doubles representing the start and end times of the construction period.

  • permitting_period – The permitting period for the relocation in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the relocation.

Relocation(const Relocation &relocation)

Constructs a Relocation object as a copy of an existing Relocation object.

Parameters:

relocation – A reference to the existing Relocation object to copy.

Returns:

A new Relocation object that is a copy of the provided relocation.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Throws an exception when the applyContinuity function is called on a Relocation object.

This function indicates that the applyContinuity method is not applicable to Relocation objects, as they only change allocated fractions in the source they are assigned to. Continuity calculations should be applied only to the source being relocated.

Parameters:
  • week – The week number for which the continuity equation would be applied (if applicable).

  • upstream_source_inflow – The inflow from the upstream source in cubic units.

  • wastewater_discharge – The discharge from wastewater in cubic units.

  • demand_outflow – A vector representing the demand outflow for the week.

Throws:

logic_error – This function throws a logic_error exception, as continuity cannot be applied directly to a Relocation object.

unsigned long getParent_reservoir_ID() const

Retrieves the ID of the parent reservoir associated with the Relocation object.

Returns:

The unique ID of the parent reservoir.

Public Members

const unsigned long parent_reservoir_ID

The unique water source ID of the parent reservoir assigned to this relocation.

const vector<double> *new_allocated_fractions

The new allocated fractions for connected utilities.

const vector<int> *utilities_with_allocations

A list of the IDs of the utilities with allocations to the water source.

Reservoir.h

class Reservoir : public WaterSource
#include <Reservoir.h>

The Reservoir class is a subclass of the main WaterSource class. It represents a general reservoir object with a fixed or variable storage area curve.

Created by bernardoct on 1/12/17.

Subclassed by AllocatedReservoir, Quarry

Public Functions

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, int source_type = RESERVOIR)

Constructs a basic Reservoir object with a storage area curve. It also ensures that the last storage value in the storage area curve matches the reservoir’s capacity.

Called for a reservoir that is already built and operational.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve for the reservoir.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, const vector<double> &construction_time_range, double permitting_period, Bond &bond, int source_type = RESERVOIR)

Constructs a Reservoir object with a storage area curve, treatment capacity. Also includes financing, construction, and permitting information.

Called when the reservoir does not yet exist at the beginning of the simulation.

This function initializes a Reservoir object with parameters such as the name, ID, catchments, capacity, maximum treatment capacity, evaporation series, storage area curve, and other construction and permitting details. It also ensures that the last storage value in the storage area curve matches the reservoir’s capacity.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve for the reservoir.

  • construction_time_range – A vector of doubles representing the start and end times of the construction period.

  • permitting_period – The permitting period for the reservoir in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the reservoir.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, int source_type = RESERVOIR)

Constructs a Reservoir object with a fixed storage area, treatment capacity, and evaporation data.

Called for a reservoir that is already built and operational.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area – The area of the reservoir in square units.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, const vector<double> &construction_time_range, double permitting_period, Bond &bond, int source_type = RESERVOIR)

Constructs a Reservoir object with a fixed storage area, treatment capacity. Also includes financing, construction, and permitting information.

Called when the reservoir does not yet exist at the beginning of the simulation.

This function initializes a Reservoir object with parameters such as the name, ID, catchments, capacity, maximum treatment capacity, evaporation series, storage area curve, and other construction and permitting details. It also ensures that the last storage value in the storage area curve matches the reservoir’s capacity.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve for the reservoir.

  • construction_time_range – A vector of doubles representing the start and end times of the construction period.

  • permitting_period – The permitting period for the reservoir in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the reservoir.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, vector<double> *allocated_treatment_fractions, vector<double> *allocated_fractions, vector<int> *utilities_with_allocations, int source_type = RESERVOIR)

Constructs a Reservoir object with specified storage area curve. Includes additional details like treatment fractions and allocation details to connected utilities.

Called for a reservoir that is already built and operational.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve for the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of treatment fractions allocated to utilities.

  • allocated_fractions – A pointer to a vector of fractions allocated to utilities.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities that have allocations.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, vector<double> *allocated_treatment_fractions, vector<double> *allocated_fractions, vector<int> *utilities_with_allocations, int source_type = RESERVOIR)

Constructs a Reservoir object with specified storage area curve. Includes additional details like treatment fractions and allocation details to connected utilities.

Called for a reservoir that is already built and operational.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area – The area of the reservoir in square units.

  • allocated_treatment_fractions – A pointer to a vector of treatment fractions allocated to utilities.

  • allocated_fractions – A pointer to a vector of fractions allocated to utilities.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities that have allocations.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, DataSeries *storage_area_curve, vector<double> *allocated_treatment_fractions, vector<double> *allocated_fractions, vector<int> *utilities_with_allocations, const vector<double> &construction_time_range, double permitting_period, Bond &bond, int source_type = RESERVOIR)

Constructs a Reservoir object with specified storage area curve. Includes additional details like treatment fractions and allocation details to connected utilities. Also includes financing, construction, and permitting information.

Called when the reservoir does not yet exist at the beginning of the simulation.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area_curve – A pointer to a DataSeries object representing the storage area curve for the reservoir.

  • allocated_treatment_fractions – A pointer to a vector of treatment fractions allocated to utilities.

  • allocated_fractions – A pointer to a vector of fractions allocated to utilities.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities that have allocations.

  • construction_time_range – A vector of doubles representing the start and end times of the construction period.

  • permitting_period – The permitting period for the reservoir in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the reservoir.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const char *name, const int id, const vector<Catchment*> &catchments, const double capacity, const double max_treatment_capacity, EvaporationSeries &evaporation_series, double storage_area, vector<double> *allocated_treatment_fractions, vector<double> *allocated_fractions, vector<int> *utilities_with_allocations, const vector<double> &construction_time_range, double permitting_period, Bond &bond, int source_type = RESERVOIR)

Constructs a Reservoir object with fixed storage area. Includes additional details like treatment fractions and allocation details to connected utilities. Also includes financing, construction, and permitting information.

Called when the reservoir does not yet exist at the beginning of the simulation.

Parameters:
  • name – The name of the reservoir as a C-style string.

  • id – The unique identifier of the reservoir as an integer.

  • catchments – A vector of pointers to Catchment objects representing the catchments linked to the reservoir.

  • capacity – The total storage capacity of the reservoir in cubic units.

  • max_treatment_capacity – The maximum treatment capacity of the reservoir in cubic units per time unit.

  • evaporation_series – A reference to an EvaporationSeries object containing evaporation data for the reservoir.

  • storage_area – The area of the reservoir in square units.

  • allocated_treatment_fractions – A pointer to a vector of treatment fractions allocated to utilities.

  • allocated_fractions – A pointer to a vector of fractions allocated to utilities.

  • utilities_with_allocations – A pointer to a vector of integers representing the utilities that have allocations.

  • construction_time_range – A vector of doubles representing the start and end times of the construction period.

  • permitting_period – The permitting period for the reservoir in time units.

  • bond – A reference to a Bond object representing the financial bond associated with the reservoir.

  • source_type – The type of the source (e.g., a constant or specific reservoir type).

Throws:

invalid_argument – If the last storage value in the storage area curve does not match the reservoir’s capacity.

Reservoir(const Reservoir &reservoir)

Copy constructor for creating a copy of an existing Reservoir object. A new EvaporationSeries is created to ensure deep copying of the evaporation data.

Parameters:

reservoir – The Reservoir object to copy.

Reservoir &operator=(const Reservoir &reservoir)

Assignment operator for copying data from another Reservoir object.

This operator assigns the values from another Reservoir object to the current object, copying the storage area curve and performing a deep copy of the evaporation series. The base class WaterSource’s assignment operator is also called to copy its attributes.

Parameters:

reservoir – The Reservoir object to copy data from.

Returns:

A reference to the current Reservoir object after assignment.

~Reservoir() override

Destructor for the Reservoir class.

This destructor is the default destructor for the Reservoir class and overrides the corresponding function in the base class. It ensures proper cleanup of any dynamically allocated resources when a Reservoir object is destroyed.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity calculations for the reservoir over a given week.

This function calculates the new stored volume and outflow for the reservoir based on the continuity equation, taking into account inflows, demand outflows, evaporation, and spillage. It also updates various internal state variables like total demand, available volume, and total outflow.

This function overrides the applyContinuity function in the base class WaterSource.

Parameters:
  • week – The week for which continuity calculations are performed.

  • upstream_source_inflow – The inflow from upstream sources.

  • wastewater_inflow – The inflow from wastewater sources.

  • demand_outflow – A vector of demand outflows for the week.

virtual void setOnline() override

Marks the reservoir as online and initializes available volume.

This function sets the reservoir to an online state, where it begins accepting inflows. It also sets the available_volume to NONE, indicating that the reservoir starts empty and will gradually fill as inflows start coming in.

This function overrides the setOnline function in the base class WaterSource.

virtual void setRealization(unsigned long r, vector<double> &rdm_factors) override

Sets the realization for the reservoir and updates the evaporation series.

This function sets the realization for the Reservoir object, which may include applying random decision-making (RDM) factors to the reservoir’s behavior. It also updates the evaporation_series by setting its realization based on the provided factors.

This function overrides the setRealization function in the base class WaterSource.

Parameters:
  • r – The realization index or identifier.

  • rdm_factors – A reference to a vector of RDM factors to apply during the realization.

double getArea() const

Returns the area of the reservoir.

This function retrieves the area of the reservoir, which is used to calculate various hydrological properties related to the reservoir’s size.

Returns:

The area of the reservoir as a double.

Public Members

const bool fixed_area

The fixed area of the reservoir.

EvaporationSeries evaporation_series

The EvaporationSeries object representing the evaporation series of the reservoir.

Protected Attributes

DataSeries *storage_area_curve

The DataSeries object representing the storage area curve of the reservoir.

double area = NON_INITIALIZED

The area of the reservoir.

ReservoirExpansion.h

class ReservoirExpansion : public WaterSource
#include <ReservoirExpansion.h>

The ReservoirExpansion class is a subclass of the main WaterSource class. It represents a general reservoir object scheduled for expansion.

Created by bernardoct on 5/3/17.

Public Functions

ReservoirExpansion(const char *name, const int id, const unsigned int parent_reservoir_ID, const double capacity, const vector<double> &construction_time_range, double permitting_period, Bond &bond)

Constructor for creating a ReservoirExpansion object.

This constructor initializes a ReservoirExpansion object with the specified parameters and sets the parent reservoir ID. It also calls the constructor of the base class WaterSource to initialize the shared attributes.

Parameters:
  • name – The name of the reservoir expansion.

  • id – The unique identifier for the reservoir expansion.

  • parent_reservoir_ID – The ID of the parent reservoir.

  • capacity – The capacity of the reservoir expansion.

  • construction_time_range – The time range for construction of the reservoir expansion.

  • permitting_period – The permitting period for the reservoir expansion.

  • bond – A reference to the bond object associated with the reservoir expansion.

ReservoirExpansion(const ReservoirExpansion &reservoir_expansion)

Copy constructor for the ReservoirExpansion class.

This constructor creates a copy of an existing ReservoirExpansion object by copying the values of its attributes, including calling the copy constructor of the base class WaterSource.

Parameters:

reservoir_expansion – The ReservoirExpansion object to copy.

ReservoirExpansion &operator=(const ReservoirExpansion &reservoir_expansion)

Assignment operator for the ReservoirExpansion class.

This operator assigns the values of one ReservoirExpansion object to another.

Parameters:

reservoir_expansion – The ReservoirExpansion object to assign from.

Returns:

A reference to the current ReservoirExpansion object after assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Throws an error indicating that continuity cannot be applied to a reservoir expansion.

This function throws a logic_error because a reservoir expansion only adds storage volume to the reservoir it is assigned to. Continuity calculations should be applied to the reservoir being expanded, not the expansion itself.

Parameters:
  • week – The week for which continuity would be applied.

  • upstream_source_inflow – The inflow from upstream sources (not used).

  • wastewater_discharge – The inflow from wastewater discharge (not used).

  • demand_outflow – A vector of demand outflows (not used).

Throws:

logic_error – This function always throws a logic_error because continuity cannot be applied to a reservoir expansion.

Public Members

const unsigned int parent_reservoir_ID

The ID of the parent reservoir that is being expanded.

SequentialJointTreatmentExpansion.h

class SequentialJointTreatmentExpansion : public WaterSource
#include <SequentialJointTreatmentExpansion.h>

The SequentialJointTreatmentExpansion class is a subclass of the main WaterSource class. It represents the Joint WTP with a scheduled expansion sequence.

Created by bernardoct on 7/18/17.

Public Functions

SequentialJointTreatmentExpansion(const char *name, const int id, const int parent_reservoir_ID, const int expansion_sequence_id, vector<int> connected_sources, vector<double> &sequential_treatment_capacity, vector<Bond*> &bonds, const vector<double> &construction_time_range, double permitting_period)

Constructor for creating a SequentialJointTreatmentExpansion object.

This constructor initializes a SequentialJointTreatmentExpansion object with the specified parameters and sets various attributes including the treatment capacities, expansion sequence ID, and parent reservoir ID. It also calls the constructor of the base class WaterSource to initialize shared attributes.

Parameters:
  • name – The name of the sequential joint treatment expansion.

  • id – The unique identifier for the expansion.

  • parent_reservoir_ID – The ID of the parent reservoir to which the expansion is associated.

  • expansion_sequence_id – The ID that represents the sequence in which this expansion is applied.

  • connected_sources – A list of sources connected to this expansion.

  • sequential_treatment_capacity – The capacities of the sequential treatment process.

  • bonds – A vector of bonds associated with the expansion.

  • construction_time_range – The time range for constructing the expansion.

  • permitting_period – The permitting period for the expansion.

Throws:

invalid_argument – If the sequential_treatment_capacity vector is not empty when initialized.

SequentialJointTreatmentExpansion(const SequentialJointTreatmentExpansion &joint_water_treatment_plant)

Copy constructor for creating a copy of a SequentialJointTreatmentExpansion object.

This constructor initializes a new SequentialJointTreatmentExpansion object by copying the values from an existing SequentialJointTreatmentExpansion object. It also calls the base class copy constructor.

Parameters:

joint_water_treatment_plant – The SequentialJointTreatmentExpansion object to copy from.

~SequentialJointTreatmentExpansion() override

Destructor for the SequentialJointTreatmentExpansion class.

This destructor is the default destructor, which ensures proper cleanup of resources when a SequentialJointTreatmentExpansion object is destroyed.

SequentialJointTreatmentExpansion &operator=(const SequentialJointTreatmentExpansion &joint_water_treatment_plant)

Assignment operator for assigning one SequentialJointTreatmentExpansion object to another.

This operator assigns the values from one SequentialJointTreatmentExpansion object to another, using the base class assignment operator for common attributes.

Parameters:

joint_water_treatment_plant – The SequentialJointTreatmentExpansion object to assign from.

Returns:

A reference to the current SequentialJointTreatmentExpansion object.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the SequentialJointTreatmentExpansion object.

This method throws a logic_error because SequentialJointTreatmentExpansion only adds storage volume to the reservoir it’s assigned to, and continuity cannot be applied to it directly. Continuity must be applied to the reservoir it expands.

Parameters:
  • week – The week for which the continuity is applied.

  • upstream_source_inflow – The amount of water inflow from upstream sources.

  • wastewater_discharge – The amount of wastewater discharged.

  • demand_outflow – A vector representing the demand outflow.

Throws:

logic_error – This function throws a logic_error indicating that continuity cannot be applied directly to a SequentialJointTreatmentExpansion.

double implementTreatmentCapacity(int utility_id)

Returns the treatment capacity added for a specific utility.

This fuynction returns the capacity to be installed for a given utility and deducts it from maximum planned expansion.

Parameters:

utility_id – The ID of the utility for which the treatment capacity is requested.

Returns:

The added treatment capacity for the specified utility.

Public Members

const int expansion_sequence_id

The ID of the expansion sequence to which this expansion belongs.

const unsigned int parent_reservoir_ID

The ID of the parent reservoir to which this expansion is associated.

Private Members

double total_treatment_capacity

The total treatment capacity of the joint treatment plant.

vector<double> &added_treatment_capacities

The treatment capacity added at each expansion.

VariableJointWTP.h

class VariableJointWTP : public JointWTP
#include <VariableJointWTP.h>

The VariableJointWTP class is a subclass of JointWTP, which in turn is a subclass of the main WaterSource class. It allows for variable allocations of treatment capacity to utilities.

Created by dgorelic on 10/29/2019.

FIXME: Unclear what the purpose of this class is and how it differs from JointWTP.

Public Functions

VariableJointWTP(const char *name, const int id, const int parent_reservoir_ID, const int expansion_sequence_id, const double total_treatment_capacity, vector<int> connected_sources, vector<int> &agreement_utility_ids, vector<double> &initial_treatment_capacity_allocations, vector<Bond*> &bonds, const vector<double> &construction_time_range, double permitting_period)

Constructs a VariableJointWTP object with the specified parameters.

This constructor initializes a VariableJointWTP object, which represents a joint water treatment plant with variable treatment capacity allocations, and associates it with a specific parent reservoir.

Parameters:
  • name – The name of the joint water treatment plant.

  • id – The ID of the joint water treatment plant.

  • parent_reservoir_ID – The ID of the parent reservoir for the joint water treatment plant.

  • expansion_sequence_id – The expansion sequence ID for the joint water treatment plant.

  • total_treatment_capacity – The total treatment capacity of the plant.

  • connected_sources – A list of source IDs connected to the plant.

  • agreement_utility_ids – A list of utility IDs that have agreements with the plant.

  • initial_treatment_capacity_allocations – A list of initial treatment capacity allocations for each utility.

  • bonds – A list of bonds associated with the plant.

  • construction_time_range – A vector specifying the time range for construction.

  • permitting_period – The permitting period for the plant.

VariableJointWTP(const VariableJointWTP &variable_joint_water_treatment_plant)

Copy constructor for the VariableJointWTP class.

This constructor creates a new VariableJointWTP object as a copy of an existing one, inheriting the properties and treatment capacity allocations from the original plant.

Parameters:

variable_joint_water_treatment_plant – The VariableJointWTP object to copy from.

~VariableJointWTP() override

Destructor for the VariableJointWTP class.

This function cleans up resources used by the Quarry object. Since the class does not dynamically allocate resources directly, the destructor relies on the base class (WaterSource) and standard cleanup mechanisms.

VariableJointWTP &operator=(const VariableJointWTP &variable_joint_water_treatment_plant)

Assignment operator for copying data for another VariableJointWTP object.

This operator assigns the values from another VariableJointWTP object to the current object, copying the storage area curve and performing a deep copy of the evaporation series. The base class WaterSource’s assignment operator is also called to copy its attributes.

Parameters:

variable_joint_water_treatment_plant – The VariableJointWTP object to copy data from.

Returns:

A reference to the current VariableJointWTP object after assignment.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity for the VariableJointWTP class.

This function calls the base class JointWTP’s applyContinuity method to perform the continuity calculations for the water treatment plant, considering the upstream inflow, wastewater discharge, and demand outflow.

Parameters:
  • week – The week for which the continuity is applied.

  • upstream_source_inflow – The inflow from the upstream source.

  • wastewater_discharge – The discharge of wastewater into the plant.

  • demand_outflow – A vector containing the demand outflow for each utility.

virtual double implementInitialTreatmentCapacity(int utility_id) override

Implements the initial treatment capacity for a specific utility.

This function returns the treatment capacity allocated to a utility based on the initial treatment allocations.

Parameters:

utility_id – The ID of the utility for which the treatment capacity is retrieved.

Returns:

The initial treatment capacity allocated to the specified utility.

virtual void resetAllocations(const vector<double> *demand_ratios) override

Resets the treatment allocations based on demand deltas for the utilities.

This function updates the treatment capacity allocations for each utility based on changes in demand. It adjusts the treatment allocations for the current year based on the estimated future demand deltas. If the allocations exceed the total treatment capacity, the fractions and capacities are adjusted accordingly to ensure proper allocation.

Parameters:

demand_deltas – A vector containing the estimated demand changes for each utility.

Private Members

vector<double> initial_treatment_allocations

The initial allocations for the treatment capacity of this JointWTP.

WaterReuse.h

class WaterReuse : public WaterSource
#include <WaterReuse.h>

The WaterReuse class is a subclass of the main WaterSource class. It represents the a water reuse project as a potential new water source.

Created by bernardoct on 5/3/17.

Public Functions

WaterReuse(const char *name, const int id, const double capacity)

Constructs a WaterReuse object.

Initializes a WaterReuse instance, setting its name, ID, capacity, and source type. The available volume is initialized to the specified capacity.

Parameters:
  • name – The name of the water reuse source.

  • id – The ID of the water reuse source.

  • capacity – The total capacity of the water reuse source.

WaterReuse(const char *name, const int id, const double treatment_capacity, const vector<double> &construction_time_range, double permitting_period, Bond &bond)

Constructs a WaterReuse object with treatment capacity and additional attributes.

Initializes a WaterReuse instance specifically for types requiring a treatment capacity. Also includes details on construction time range, permitting period, and bond. The available volume is initialized to the treatment capacity, and treated volume is also set to the treatment capacity.

Parameters:
  • name – The name of the water reuse source.

  • id – The ID of the water reuse source.

  • treatment_capacity – The treatment capacity of the water reuse source.

  • construction_time_range – The construction time range for the water reuse source.

  • permitting_period – The permitting period for the water reuse source.

  • bond – The bond associated with the water reuse source.

WaterReuse(const WaterReuse &reuse)

Copy constructor for the WaterReuse class.

Creates a new WaterReuse object by copying the attributes from an existing one. This includes copying the base WaterSource attributes and the treated volume.

Parameters:

reuse – The WaterReuse object to copy from.

WaterReuse &operator=(const WaterReuse &water_reuse)

Assignment operator for the WaterReuse class.

This operator assigns the values from another WaterReuse object to the current one, copying the available_volume and the state from the WaterSource base class.

Parameters:

water_reuse – The WaterReuse object to copy values from.

virtual void applyContinuity(int week, double upstream_source_inflow, double wastewater_discharge, vector<double> &demand_outflow) override

Applies continuity calculations for the WaterReuse system.

This function calculates the total demand and updates the treated volume for the WaterReuse system based on the minimum of total demand and total treatment capacity.

Parameters:
  • week – The current week of the simulation.

  • upstream_source_inflow – The inflow from upstream sources to the system.

  • wastewater_discharge – The amount of wastewater being discharged into the system.

  • demand_outflow – A vector representing the demand outflows for the system.

double getReused_volume() const

Retrieves the volume of water that has been reused.

This function returns the volume of water that has been treated and reused by the WaterReuse object, based on the current treatment capacity and demand.

Returns:

The volume of water that has been reused.

Private Members

double treated_volume = NON_INITIALIZED

The volume of water to be treated through the water reuse facility.