Skip to content

Commit

Permalink
Merge pull request #303 from softwareengineerprogrammer/main
Browse files Browse the repository at this point in the history
Disable Forex API; Set FIR=DR in relevant examples
  • Loading branch information
softwareengineerprogrammer authored Oct 16, 2024
2 parents beb8738 + eccce2f commit c976107
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.6.1
current_version = 3.6.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion .cookiecutterrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ default_context:
sphinx_doctest: "no"
sphinx_theme: "sphinx-py3doc-enhanced-theme"
test_matrix_separate_coverage: "no"
version: 3.6.1
version: 3.6.2
version_manager: "bump2version"
website: "https://github.com/NREL"
year_from: "2023"
Expand Down
12 changes: 10 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ Free software: `MIT license <LICENSE>`__
:alt: Supported implementations
:target: https://pypi.org/project/geophires-x

.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.6.1.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.6.2.svg
:alt: Commits since latest release
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.6.1...main
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.6.2...main

.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
:target: https://nrel.github.io/GEOPHIRES-X
Expand Down Expand Up @@ -357,6 +357,14 @@ Example-specific web interface deeplinks are listed in the Link column.
- `Fervo_Project_Cape.txt <tests/examples/Fervo_Project_Cape.txt>`__
- `.out <tests/examples/Fervo_Project_Cape.out>`__
- `link <https://gtp.scientificwebservices.com/geophires?geophires-example-id=Fervo_Project_Cape>`__
* - Fervo Project Cape 2
- `Fervo_Project_Cape-2.txt <tests/examples/Fervo_Project_Cape-2.txt>`__
- `.out <tests/examples/Fervo_Project_Cape-2.out>`__
- `link <https://gtp.scientificwebservices.com/geophires?geophires-example-id=Fervo_Project_Cape-2>`__
* - Fervo Project Cape 3
- `Fervo_Project_Cape-3.txt <tests/examples/Fervo_Project_Cape-3.txt>`__
- `.out <tests/examples/Fervo_Project_Cape-3.out>`__
- `link <https://gtp.scientificwebservices.com/geophires?geophires-example-id=Fervo_Project_Cape-3>`__
* - Superhot Rock (SHR) Example 1
- `example_SHR-1.txt <tests/examples/example_SHR-1.txt>`__
- `.out <tests/examples/example_SHR-1.out>`__
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
year = '2024'
author = 'NREL'
copyright = f'{year}, {author}'
version = release = '3.6.1'
version = release = '3.6.2'

pygments_style = 'trac'
templates_path = ['./templates']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read(*names, **kwargs):

setup(
name='geophires-x',
version='3.6.1',
version='3.6.2',
license='MIT',
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
long_description='{}\n{}'.format(
Expand Down
19 changes: 15 additions & 4 deletions src/geophires_x/Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from geophires_x.Units import *

_ureg = get_unit_registry()
_DISABLE_FOREX_API = True # See https://github.com/NREL/GEOPHIRES-X/issues/236#issuecomment-2414681434

class HasQuantity(ABC):

Expand Down Expand Up @@ -500,15 +501,19 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str:

try:
# if we come here, we have a currency conversion to do (USD->EUR, etc.).

if _DISABLE_FOREX_API:
raise RuntimeError('Forex API disabled')

cr = CurrencyRates()
conv_rate = cr.get_rate(currShort, prefShort)
except BaseException as ex:
print(str(ex))
msg = (
f'Error: GEOPHIRES failed to convert your currency for {ParamToModify.Name} to something it '
f'understands. You gave {strUnit} - Are these currency units defined for forex-python? or perhaps the '
f'currency server is down? Please change your units to {ParamToModify.PreferredUnits.value} to '
f'continue. Cannot continue unless you do. Exiting.'
f'Error: GEOPHIRES failed to convert your currency for {ParamToModify.Name} to something it understands. '
f'You gave {strUnit} - conversion may be affected by https://github.com/NREL/GEOPHIRES-X/issues/236. '
f'Please change your units to {ParamToModify.PreferredUnits.value} '
f'to continue. Cannot continue unless you do. Exiting.'
)
print(msg)
model.logger.critical(str(ex))
Expand Down Expand Up @@ -710,6 +715,9 @@ def _parameter_with_currency_units_converted_back_to_preferred_units(param: Para
# start the currency conversion process
cc = CurrencyCodes()
try:
if _DISABLE_FOREX_API:
raise RuntimeError('Forex API disabled')

cr = CurrencyRates()
conv_rate = cr.get_rate(currType, prefType)
except BaseException as ex:
Expand Down Expand Up @@ -966,6 +974,9 @@ def ConvertOutputUnits(oparam: OutputParameter, newUnit: Units, model):

raise RuntimeError(msg)
try:
if _DISABLE_FOREX_API:
raise RuntimeError('Forex API disabled')

cr = CurrencyRates()
conv_rate = cr.get_rate(prefShort, currShort)
except BaseException as ex:
Expand Down
2 changes: 1 addition & 1 deletion src/geophires_x/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.6.1'
__version__ = '3.6.2'
10 changes: 5 additions & 5 deletions tests/examples/example10_HP.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
GEOPHIRES Version: 3.6.2
Simulation Date: 2024-10-15
Simulation Time: 13:08
Calculation Time: 0.104 sec
Simulation Time: 15:20
Calculation Time: 0.100 sec

***SUMMARY OF RESULTS***

Expand All @@ -29,9 +29,9 @@ Simulation Metadata
Accrued financing during construction: 5.00
Project lifetime: 30 yr
Capacity factor: 90.0 %
Project NPV: 3.32 MUSD
Project NPV: 11.28 MUSD
Project IRR: 8.07 %
Project VIR=PI=PIR: 1.11
Project VIR=PI=PIR: 1.36
Project MOIC: 1.01
Project Payback Period: 11.96 yr

Expand Down
1 change: 1 addition & 0 deletions tests/examples/example10_HP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Heat Pump COP, 2.8, --- [-]
Plant Lifetime,30, ---[years]
Economic Model,2, ---BICYCLE Levelized Cost Model
Discount Rate, 0.05, --- [-] Required if Standard LCOE/LCOH model is selected. See manual for details.
Fixed Internal Rate, 5, -- matches Discount Rate
Inflation Rate During Construction,0.05, ---[-]

# ***Capital and O&M Cost Parameters***
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/example11_AC.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
GEOPHIRES Version: 3.6.2
Simulation Date: 2024-10-15
Simulation Time: 13:07
Calculation Time: 0.104 sec
Simulation Time: 15:20
Calculation Time: 0.099 sec

***SUMMARY OF RESULTS***

Expand All @@ -30,9 +30,9 @@ Simulation Metadata
Accrued financing during construction: 5.00
Project lifetime: 30 yr
Capacity factor: 90.0 %
Project NPV: -0.53 MUSD
Project NPV: 6.22 MUSD
Project IRR: 6.82 %
Project VIR=PI=PIR: 0.98
Project VIR=PI=PIR: 1.21
Project MOIC: 0.83
Project Payback Period: 13.36 yr

Expand Down
1 change: 1 addition & 0 deletions tests/examples/example11_AC.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Absorption Chiller COP, 0.72, --- [-]
Plant Lifetime,30, ---[years]
Economic Model,2, ---BICYCLE Levelized Cost Model
Discount Rate, 0.05, --- [-] Required if Standard LCOE/LCOH model is selected. See manual for details.
Fixed Internal Rate, 5, -- matches Discount Rate
Inflation Rate During Construction,0.05, ---[-]

# ***Capital and O&M Cost Parameters***
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/example13.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
GEOPHIRES Version: 3.6.2
Simulation Date: 2024-10-15
Simulation Time: 13:07
Simulation Time: 15:20
Calculation Time: 0.035 sec

***SUMMARY OF RESULTS***
Expand All @@ -30,9 +30,9 @@ Simulation Metadata
Accrued financing during construction: 0.00
Project lifetime: 30 yr
Capacity factor: 80.0 %
Project NPV: -45.14 MUSD
Project NPV: -43.00 MUSD
Project IRR: -5.99 %
Project VIR=PI=PIR: 0.20
Project VIR=PI=PIR: 0.24
Project MOIC: -0.22
Project Payback Period: N/A
CHP: Percent cost allocation for electrical plant: 60.28 %
Expand Down
1 change: 1 addition & 0 deletions tests/examples/example13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ District Heating Road Length,3, ---[km] supersedes model option 2 if any val
Plant Lifetime,30, --- [years]
Economic Model,2, --- Should be 1 (FCR model), 2 (Standard LCOE/LCOH model), or 3 (Bicycle model).
Discount Rate,0.05,
Fixed Internal Rate,5, -- matches Discount Rate
Inflation Rate During Construction,0, --- [-]
Well Drilling and Completion Capital Cost Adjustment Factor,1, --- [-] Use built-in well cost correlation as is
Well Drilling Cost Correlation,1, --- [-] Use built-in well drilling cost correlation #1
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/example2.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
GEOPHIRES Version: 3.6.2
Simulation Date: 2024-10-15
Simulation Time: 13:07
Calculation Time: 0.208 sec
Simulation Time: 15:20
Calculation Time: 0.209 sec

***SUMMARY OF RESULTS***

Expand All @@ -28,9 +28,9 @@ Simulation Metadata
Accrued financing during construction: 0.00
Project lifetime: 25 yr
Capacity factor: 90.0 %
Project NPV: -3.54 MUSD
Project NPV: 3.83 MUSD
Project IRR: 5.97 %
Project VIR=PI=PIR: 0.91
Project VIR=PI=PIR: 1.09
Project MOIC: 0.52
Project Payback Period: 13.21 yr

Expand Down
1 change: 1 addition & 0 deletions tests/examples/example2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Surface Temperature,15, ---[deg.C]
Plant Lifetime,25, ---[years]
Economic Model,2, ---Standard Levelized Cost Model
Discount Rate,.05, ---[-]
Fixed Internal Rate,5, -- matches Discount Rate
Inflation Rate During Construction,0, ---[-]

# ***Capital and O&M Cost Parameters***
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/example_SHR-2.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
GEOPHIRES Version: 3.6.2
Simulation Date: 2024-10-15
Simulation Time: 13:08
Calculation Time: 0.528 sec
Simulation Time: 15:20
Calculation Time: 0.530 sec

***SUMMARY OF RESULTS***

Expand All @@ -29,9 +29,9 @@ Simulation Metadata
Accrued financing during construction: 0.00
Project lifetime: 20 yr
Capacity factor: 95.0 %
Project NPV: 334.92 MUSD
Project NPV: 402.91 MUSD
Project IRR: 15.06 %
Project VIR=PI=PIR: 1.80
Project VIR=PI=PIR: 1.97
Project MOIC: 2.00
Project Payback Period: 7.61 yr
Estimated Jobs Created: 221
Expand Down
1 change: 1 addition & 0 deletions tests/examples/example_SHR-2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Tax Relief Per Year, 2.212
Do Carbon Price Calculations, True
Time steps per year, 6
Discount Rate, 0.06
Fixed Internal Rate, 6, -- matches Discount Rate
Reservoir Stimulation Capital Cost, 18
Well Drilling and Completion Capital Cost Adjustment Factor, 2
Injection Well Drilling and Completion Capital Cost Adjustment Factor, 2
Expand Down

0 comments on commit c976107

Please sign in to comment.