-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Costing docs- initial template rollout #1361
Changes from all commits
a18fc07
49046e6
22ab641
0ca6d91
5b06d5d
485a2cc
cc9cb3a
3fb3491
b16235c
017706e
7b74a5e
f7ead45
bfc1296
fe183b2
46e2afa
951f1ed
1786b10
d73251e
74bb7cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name,unit | ||
anaerobic digester,anaerobic_digester | ||
clarifier,clarifier | ||
compressor,compressor | ||
crystallizer,crystallizer | ||
cstr injection,cstr_injection | ||
cstr,cstr | ||
dewatering,dewatering | ||
electrodialysis,electrodialysis | ||
electrolyzer,electrolyzer | ||
electroNP,electroNP | ||
energy recovery device,energy_recovery_device | ||
evaporator,evaporator | ||
gac,gac | ||
heat exchanger,heat_exchanger | ||
heater chiller,heater_chiller | ||
ion exchange,ion_exchange | ||
membrane distillation,membrane_distillation | ||
mixer,mixer | ||
nanofiltration,nanofiltration | ||
osmotically assisted reverse osmosis,osmotically_assisted_reverse_osmosis | ||
pressure exchanger,pressure_exchanger | ||
pump,pump | ||
reverse osmosis,reverse_osmosis | ||
stoichiometric reactor,stoichiometric_reactor | ||
thickener,thickener | ||
uv aop,uv_aop |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Anaerobic Digester Costing Method | ||
================================== | ||
|
||
Costing Method Parameters | ||
+++++++++++++++++++++++++ | ||
|
||
The following parameters are constructed for the unit on the FlowsheetCostingBlock (e.g., `m.fs.costing.anaerobic_digester`) when applying the `cost_anaerobic_digester` costing method in the ``watertap_costing_package``: | ||
|
||
.. csv-table:: | ||
:header: "Description", "Symbol", "Parameter Name", "Default Value", "Units" | ||
|
||
"description", ":math:`Symbol_{example}`", "parameter_name", "1", ":math:`\text{dimensionless}`" | ||
|
||
Costing Method Variables | ||
++++++++++++++++++++++++ | ||
|
||
The following variables are constructed on the unit block (e.g., m.fs.unit.costing) when applying the `cost_anaerobic_digester` costing method in the ``watertap_costing_package``: | ||
|
||
.. csv-table:: | ||
:header: "Description", "Symbol", "Variable Name", "Default Value", "Units" | ||
|
||
"description", ":math:`Symbol_{example}`", "variable_name", "1", ":math:`\text{dimensionless}`" | ||
|
||
Capital Cost Calculations | ||
+++++++++++++++++++++++++ | ||
|
||
Describe capital costs..keep it concise where possible | ||
|
||
.. math:: | ||
|
||
C_{cap,tot} = C_{cap,example1}+C_{cap,example2}+C_{cap,other} | ||
|
||
.. math:: | ||
|
||
C_{cap,example1} = fill in equation for each component in total capex equation | ||
|
||
|
||
Operating Cost Calculations | ||
+++++++++++++++++++++++++++ | ||
|
||
Describe operating/maintenance costs..keep it concise where possible | ||
|
||
.. math:: | ||
|
||
C_{op,tot} = C_{op,example1}+C_{op,example2}+C_{op,other} | ||
|
||
.. math:: | ||
|
||
C_{op,example1} = fill in equation for each component in total opex equation | ||
|
||
|
||
Code Documentation | ||
------------------ | ||
|
||
* :mod:`watertap.costing.unit_models.anaerobic_digester` | ||
|
||
References | ||
---------- | ||
Aim to include at least one reference in most cases, but delete this section if no references used for cost relationships/default values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
################################################################################# | ||
# WaterTAP Copyright (c) 2020-2024, 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/" | ||
################################################################################# | ||
|
||
__author__ = "Adam Atia" | ||
|
||
import pandas as pd | ||
|
||
df = pd.read_csv("WT_unit_costing_for_docs.csv") | ||
|
||
|
||
unit_title_list = [i.title() for i in df["name"]] | ||
|
||
unit_name_list = list(df["unit"]) | ||
|
||
title_exceptions = { | ||
"cstr_injection": "Completely Stirred Tank Reactor w/Injection Stream", | ||
"cstr": "Completely Stirred Tank Reactor", | ||
"dewatering": "Dewatering Unit", | ||
"electroNP": "ElectroN-P", | ||
"gac": "Granular Activated Carbon", | ||
"heater_chiller": "Heater/Chiller", | ||
"uv_aop": "UV with Advanced Oxidation Processes", | ||
} | ||
|
||
|
||
if __name__ == "__main__": | ||
hunterbarber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Toggle OVERWRITE to True to overwrite unit model costing rst files | ||
OVERWRITE = False | ||
# Specify unit model costing filenames (e.g., "ion_exchange") that you want to overwrite | ||
# Otherwise, if list left empty, the default is to overwrite all files | ||
OVERWRITE_LIST = [] | ||
try: | ||
with open("detailed_unit_model_costing.rst", "r") as f: | ||
lines = f.readlines() | ||
except: | ||
|
||
# Create index file for all unit model costing docs | ||
with open("detailed_unit_model_costing.rst", "w") as f: | ||
f.write("Detailed Unit Model Costing\n") | ||
f.write("=" * len("Detailed Unit Model Costing")) | ||
f.write("\n") | ||
f.write( | ||
"Default costing methods are provided for the unit models listed below. However, users should supply their own cost relationship, if possible, instead of relying completely on the defaults.\n\n" | ||
) | ||
f.write(".. toctree::\n") | ||
f.write(" :maxdepth: 1\n\n") | ||
with open("detailed_unit_model_costing.rst", "r") as f: | ||
lines = f.readlines() | ||
|
||
for i, unit_title in enumerate(unit_title_list): | ||
for l, line in enumerate(lines): | ||
# set on_list flag to False if unit name not found in landing page list | ||
if unit_name_list[i] != line.strip(): | ||
on_list = False | ||
# set on_list flag to True if unit name is on landing page list and break inner loop | ||
else: | ||
on_list = True | ||
line_index = l | ||
break | ||
|
||
# if new entry or if overwriting existing entry | ||
if (not on_list) or (OVERWRITE and (on_list)): | ||
|
||
# check that entries in OVERWRITE_LIST are valid | ||
if OVERWRITE and len(OVERWRITE_LIST): | ||
if all( | ||
overwrite_item not in unit_name_list | ||
for overwrite_item in OVERWRITE_LIST | ||
): | ||
raise ValueError( | ||
"Entries provided in OVERWRITE_LIST are invalid.\nOVERWRITE_LIST should be empty or contain a list of valid unit names (e.g., 'ion_exchange')" | ||
) | ||
|
||
# if this is a new entry, append the unit name to the landing page for all unit costing | ||
if not on_list: | ||
# append unit doc to index | ||
with open("detailed_unit_model_costing.rst", "a") as f: | ||
f.write(f" {unit_name_list[i]}\n") | ||
else: | ||
# either overwrite all units in the landing page OR overwrite specific units specified on OVERWRITE_LIST | ||
if (not len(OVERWRITE_LIST)) or ( | ||
any(item == unit_name_list[i] for item in OVERWRITE_LIST) | ||
): | ||
lines[line_index] = f" {unit_name_list[i]}\n" | ||
with open("detailed_unit_model_costing.rst", "w") as f: | ||
f.writelines(lines) | ||
else: | ||
pass | ||
|
||
if ( | ||
(not on_list) | ||
or (not len(OVERWRITE_LIST)) | ||
or (any(item == unit_name_list[i] for item in OVERWRITE_LIST)) | ||
): | ||
with open(f"{unit_name_list[i]}.rst", "w") as f: | ||
|
||
# write doc title based on unit name | ||
if unit_name_list[i] in title_exceptions: | ||
f.write(f"{title_exceptions[unit_name_list[i]]} Costing Method") | ||
f.write("\n") | ||
f.write( | ||
"=" | ||
* len( | ||
f"{title_exceptions[unit_name_list[i]]} Costing Method\n" | ||
) | ||
) | ||
else: | ||
f.write(f"{unit_title} Costing Method") | ||
f.write("\n") | ||
f.write("=" * len(f"{unit_title} Costing Method\n")) | ||
|
||
# TODO: add parameter tables | ||
f.write("\n\nCosting Method Parameters\n") | ||
f.write("+" * len("Costing Method Parameters")) | ||
f.write( | ||
f"\n\nThe following parameters are constructed for the unit on the FlowsheetCostingBlock (e.g., `m.fs.costing.{unit_name_list[i]}`) when applying the `cost_{unit_name_list[i]}` costing method in the ``watertap_costing_package``:\n\n" | ||
) | ||
f.write(".. csv-table::\n") | ||
f.write( | ||
' :header: "Description", "Symbol", "Parameter Name", "Default Value", "Units"\n\n' | ||
) | ||
f.write( | ||
' "description", ":math:`Symbol_{example}`", "parameter_name", "1", ":math:`\\text{dimensionless}`"\n' | ||
) | ||
|
||
# TODO: add var tables | ||
f.write("\nCosting Method Variables\n") | ||
f.write("+" * len("Costing Method Variables")) | ||
f.write( | ||
f"\n\nThe following variables are constructed on the unit block (e.g., m.fs.unit.costing) when applying the `cost_{unit_name_list[i]}` costing method in the ``watertap_costing_package``:\n\n" | ||
) | ||
f.write(".. csv-table::\n") | ||
f.write( | ||
' :header: "Description", "Symbol", "Variable Name", "Default Value", "Units"\n\n' | ||
) | ||
f.write( | ||
' "description", ":math:`Symbol_{example}`", "variable_name", "1", ":math:`\\text{dimensionless}`"\n' | ||
) | ||
|
||
# TODO: add capex eqs | ||
f.write("\nCapital Cost Calculations\n") | ||
f.write("+" * len("Capital Cost Calculations")) | ||
f.write( | ||
"\n\nDescribe capital costs..keep it concise where possible\n\n" | ||
) | ||
f.write(" .. math::\n\n") | ||
f.write( | ||
" C_{cap,tot} = C_{cap,example1}+C_{cap,example2}+C_{cap,other}" | ||
) | ||
f.write("\n\n .. math::\n\n") | ||
f.write( | ||
" C_{cap,example1} = fill in equation for each component in total capex equation\n\n " | ||
) | ||
|
||
# TODO: add opex eqs | ||
f.write("\nOperating Cost Calculations\n") | ||
f.write("+" * len("Operating Cost Calculations")) | ||
f.write( | ||
"\n\nDescribe operating/maintenance costs..keep it concise where possible\n\n" | ||
) | ||
f.write(" .. math::\n\n") | ||
f.write( | ||
" C_{op,tot} = C_{op,example1}+C_{op,example2}+C_{op,other}" | ||
) | ||
f.write("\n\n .. math::\n\n") | ||
f.write( | ||
" C_{op,example1} = fill in equation for each component in total opex equation\n\n " | ||
) | ||
|
||
# TODO: add module directives to unit and cost method | ||
f.write("\nCode Documentation\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming the author can should just include both the 0D and 1D models here, or other instances where unit_model:cost_model aren't 1:1. Say the some units having more dependencies on rectifier, heat exchanger, pumps, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of that, I don't know if it makes sense to have once section as the model directly using the method/class and an optional section for other costing dependencies. Just a thought. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So instead of including any link to unit models here, I can just include the cost method, and later, within unit model tech refs, we can point to the relevant default costing method for the unit at hand. For example, in the tech ref for GAC, under costing section, We would just have a sentence pointing to the default costing method used and its tech ref (or something like that). |
||
f.write("-" * len("Code Documentation")) | ||
f.write( | ||
f"\n\n* :mod:`watertap.costing.unit_models.{unit_name_list[i]}`" | ||
) | ||
|
||
f.write("\n\nReferences\n") | ||
f.write("-" * len("References")) | ||
f.write( | ||
"\nAim to include at least one reference in most cases, but delete this section if no references used for cost relationships/default values" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A disclaimer that the default values of parameters (say unit cost) correspond to the dollar value of the year of the reference (e.g. USD2020). Not necessarily saying this should go in the references, but if supplying units of default parameters should $ be listed as USDYYYY in all of these docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a link to other docs on costing, wherever currency units are explained, with a brief description on the fact that we can resolve variations in defaults (or provided values) with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything would be converted to base flowsheet currency when solving, so that link probably should exist at a higher level documentation like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if reporting default parameters, makes sense to report the currency year. |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Clarifier Costing Method | ||
========================= | ||
|
||
Costing Method Parameters | ||
+++++++++++++++++++++++++ | ||
|
||
The following parameters are constructed for the unit on the FlowsheetCostingBlock (e.g., `m.fs.costing.clarifier`) when applying the `cost_clarifier` costing method in the ``watertap_costing_package``: | ||
|
||
.. csv-table:: | ||
:header: "Description", "Symbol", "Parameter Name", "Default Value", "Units" | ||
|
||
"description", ":math:`Symbol_{example}`", "parameter_name", "1", ":math:`\text{dimensionless}`" | ||
|
||
Costing Method Variables | ||
++++++++++++++++++++++++ | ||
|
||
The following variables are constructed on the unit block (e.g., m.fs.unit.costing) when applying the `cost_clarifier` costing method in the ``watertap_costing_package``: | ||
|
||
.. csv-table:: | ||
:header: "Description", "Symbol", "Variable Name", "Default Value", "Units" | ||
|
||
"description", ":math:`Symbol_{example}`", "variable_name", "1", ":math:`\text{dimensionless}`" | ||
|
||
Capital Cost Calculations | ||
+++++++++++++++++++++++++ | ||
|
||
Describe capital costs..keep it concise where possible | ||
|
||
.. math:: | ||
|
||
C_{cap,tot} = C_{cap,example1}+C_{cap,example2}+C_{cap,other} | ||
|
||
.. math:: | ||
|
||
C_{cap,example1} = fill in equation for each component in total capex equation | ||
|
||
|
||
Operating Cost Calculations | ||
+++++++++++++++++++++++++++ | ||
|
||
Describe operating/maintenance costs..keep it concise where possible | ||
|
||
.. math:: | ||
|
||
C_{op,tot} = C_{op,example1}+C_{op,example2}+C_{op,other} | ||
|
||
.. math:: | ||
|
||
C_{op,example1} = fill in equation for each component in total opex equation | ||
|
||
|
||
Code Documentation | ||
------------------ | ||
|
||
* :mod:`watertap.costing.unit_models.clarifier` | ||
|
||
References | ||
---------- | ||
Aim to include at least one reference in most cases, but delete this section if no references used for cost relationships/default values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could probably get rid of this csv and just read filenames from costing/unit_models, but isn't necessary to make that change yet.