Skip to content

Commit

Permalink
Pointing to watertap 0.11 (watertap-org#91)
Browse files Browse the repository at this point in the history
* setup point to watertap >= 0.10

* modify costing stash

* softening to MCAS try

* pointing to 0.11.0rc1

* black to get tests to run

* fix costing import to get tests to run

* fix costing for watertap == 11

* chem softening working with MCAS

* modify multiperiod

* modify costing_package

* costing pack

* run black

* delete comments

* run black

* clean up setup.py

* change to unit costing with default_costing_method; update solar costing

* trough surrogate tests passing

* add .json to .gitignore

* clean up

* back to skipping trough surrogate tests

* add header

* run black

* Apply suggestions from code review

---------

Co-authored-by: Zhuoran Zhang <[email protected]>
Co-authored-by: Adam Atia <[email protected]>
  • Loading branch information
3 people authored Dec 26, 2023
1 parent b79b007 commit 845f8e7
Show file tree
Hide file tree
Showing 46 changed files with 1,167 additions and 667 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ auto-save-list
# VSCode project file
.vscode
*.code-workspace

# other
*.json
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
author="WaterTAP-REFLO contributors",
python_requires=">=3.8",
install_requires=[
"watertap @ https://github.com/watertap-org/watertap/archive/refs/tags/pr967.zip",
# "watertap @ https://github.com/watertap-org/watertap/archive/main.zip",
# "watertap <= 0.8",
"pyomo <= 6.5",
"pytest >= 7",
"watertap == 0.11.0rc1",
"nrel-pysam == 3.0.2",
],
extras_require={
Expand Down
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

from ._version import __version__
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import pandas as pd
import numpy as np

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

# Pyomo imports
from pyomo.environ import (
ConcreteModel,
Var,
units as pyunits,
)
from pyomo.util.calc_var_value import calculate_variable_from_constraint

# IDAES imports
from idaes.core.util.model_statistics import degrees_of_freedom
import idaes.core.util.scaling as iscale
from idaes.core import FlowsheetBlock
from idaes.core.solvers.get_solver import get_solver
import idaes.logger as idaeslog
from idaes.core.util.scaling import (
calculate_scaling_factors,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import logging
import pandas as pd
import numpy as np
Expand All @@ -7,26 +19,19 @@
Var,
Constraint,
value,
ConcreteModel,
TransformationFactory,
units as pyunits,
)
from pyomo.util.calc_var_value import calculate_variable_from_constraint
from pyomo.common.config import ConfigBlock, ConfigValue, In, PositiveInt
from pyomo.common.config import ConfigBlock, ConfigValue, In

# IDAES imports
from idaes.apps.grid_integration.multiperiod.multiperiod import MultiPeriodModel
from idaes.core.util.model_statistics import degrees_of_freedom
from idaes.core.util.config import is_physical_parameter_block
from idaes.core import (
declare_process_block_class,
UnitModelBlockData,
useDefault,
)
from idaes.core.util.exceptions import (
ConfigurationError,
UserModelError,
InitializationError,
)
import idaes.core.util.scaling as iscale
from idaes.core import UnitModelCostingBlock
Expand Down Expand Up @@ -412,6 +417,18 @@ def create_multiperiod_vagmd_batch_model(

active_blks = mp.get_active_process_blocks()

# Initialize and unfix dof for each period
solver = get_solver()
for blk in active_blks:
fix_dof_and_initialize(
m=blk,
feed_flow_rate=feed_flow_rate,
feed_salinity=feed_salinity,
feed_temp=feed_temp,
)
result = solver.solve(blk)
unfix_dof(m=blk, feed_flow_rate=feed_flow_rate)

# Set-up for the first time period
active_blks[0].fs.vagmd.feed_props[0].conc_mass_phase_comp["Liq", "TDS"].fix(
feed_salinity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import pytest
from pyomo.environ import (
ConcreteModel,
Expand All @@ -7,32 +19,22 @@
)
import re
from pyomo.network import Port
from idaes.core import FlowsheetBlock, UnitModelCostingBlock
from idaes.core import FlowsheetBlock
from watertap_contrib.reflo.analysis.multiperiod.vagmd_batch.VAGMD_batch_flowsheet_multiperiod import (
VAGMDbatchSurrogate,
)

from watertap.property_models.seawater_prop_pack import SeawaterParameterBlock
from watertap_contrib.reflo.costing import REFLOCosting

from idaes.core.util.testing import initialization_tester
from idaes.core.solvers import get_solver
from idaes.core.util.exceptions import (
ConfigurationError,
)
from idaes.core.util.model_statistics import (
degrees_of_freedom,
number_variables,
number_total_constraints,
number_unused_variables,
)
from idaes.core.util.scaling import (
calculate_scaling_factors,
unscaled_variables_generator,
unscaled_constraints_generator,
badly_scaled_var_generator,
)


solver = get_solver()


Expand Down
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/analysis/net_metering/PV_RO.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import os
import numpy as np
from pyomo.environ import (
Expand Down
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/analysis/net_metering/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

from . import util
from .util import *
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/analysis/net_metering/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

from pyomo.environ import value, units as pyunits

__all__ = ["display_ro_pv_results", "display_pv_results"]
Expand Down
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

from .wt_reflo_database import REFLODatabase
from .pysam_watertap import PySAMWaterTAP
from .solar_energy_base import SolarEnergyBase, SolarEnergyBaseData
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/core/pysam_watertap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import json
from os.path import join, dirname
from math import floor, ceil
Expand Down
15 changes: 7 additions & 8 deletions src/watertap_contrib/reflo/core/solar_energy_base.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
###############################################################################
# WaterTAP Copyright (c) 2021, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National
# Laboratory, National Renewable Energy Laboratory, and National Energy
# Technology Laboratory (subject to receipt of any required approvals from
# the U.S. Dept. of Energy). All rights reserved.
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#
###############################################################################
#################################################################################
"""
This module contains a base class for all solar energy unit models.
"""
Expand Down
12 changes: 12 additions & 0 deletions src/watertap_contrib/reflo/core/tests/test_reflo_wt_database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

"""
Tests for WaterTAP-REFLO database wrapper
"""
Expand Down
15 changes: 7 additions & 8 deletions src/watertap_contrib/reflo/core/wt_reflo_database.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
###############################################################################
# WaterTAP Copyright (c) 2021, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National
# Laboratory, National Renewable Energy Laboratory, and National Energy
# Technology Laboratory (subject to receipt of any required approvals from
# the U.S. Dept. of Energy). All rights reserved.
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#
###############################################################################
#################################################################################
"""
This module contains the base class for interacting with WaterTAP data files
with zero-order model parameter data.
Expand Down
13 changes: 13 additions & 0 deletions src/watertap_contrib/reflo/costing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

from .watertap_reflo_costing_package import (
REFLOCosting,
REFLOCostingData,
REFLOSystemCosting,
TreatmentCosting,
EnergyCosting,
Expand Down
13 changes: 13 additions & 0 deletions src/watertap_contrib/reflo/costing/solar/photovoltaic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#################################################################################
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory,
# National Renewable Energy Laboratory, and National Energy Technology
# Laboratory (subject to receipt of any required approvals from the U.S. Dept.
# of Energy). All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################

import pyomo.environ as pyo
from watertap.costing.util import register_costing_parameter_block
from watertap_contrib.reflo.costing.util import (
Expand Down Expand Up @@ -157,6 +169,7 @@ def cost_pv(blk):
expr=blk.sales_tax == blk.direct_cost * global_params.sales_tax_frac
)

blk.costing_package.add_cost_factor(blk, None)
blk.capital_cost_constraint = pyo.Constraint(
expr=blk.capital_cost == blk.direct_cost + blk.indirect_cost + blk.sales_tax
)
Expand Down
Loading

0 comments on commit 845f8e7

Please sign in to comment.