Skip to content

Commit 6a42696

Browse files
Merge pull request #13 from softwareengineerprogrammer/irr-percent-fix
IRR percent fix
2 parents 94df90b + f5d05e3 commit 6a42696

14 files changed

+101
-62
lines changed

src/geophires_x/Economics.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ def CalculateRevenue(plantlifetime: int, ConstructionYears: int, CAPEX: float, O
8181
return CashFlow, CummCashFlow
8282

8383

84-
def CalculateFinancialPerformance(plantlifetime: int, FixedInternalRate: float, TotalRevenue, TotalCummRevenue,
85-
CAPEX: float, OPEX: float):
84+
def CalculateFinancialPerformance(plantlifetime: int,
85+
FixedInternalRate: float,
86+
TotalRevenue: list,
87+
TotalCummRevenue: list,
88+
CAPEX: float,
89+
OPEX: float):
8690
"""
8791
CalculateFinancialPerformance calculates the financial performance of the project. It is used to calculate the
8892
financial performance of the project. It is used to calculate the revenue stream for the project.
@@ -113,6 +117,8 @@ def CalculateFinancialPerformance(plantlifetime: int, FixedInternalRate: float,
113117
IRR = npf.irr(TotalRevenue)
114118
if math.isnan(IRR):
115119
IRR = 0.0
120+
else:
121+
IRR *= 100. # convert from decimal to percent
116122
VIR = 1.0 + (NPV / CAPEX)
117123

118124
# Calculate MOIC which depends on CumCashFlow
@@ -417,7 +423,6 @@ def __init__(self, model: Model):
417423
)
418424
self.ccwellfixed = self.ParameterDict[self.ccwellfixed.Name] = floatParameter(
419425
"Well Drilling and Completion Capital Cost",
420-
value=-1.0,
421426
DefaultValue=-1.0,
422427
Min=0,
423428
Max=200,
@@ -743,7 +748,6 @@ def __init__(self, model: Model):
743748
)
744749
self.wellcorrelation = self.ParameterDict[self.wellcorrelation.Name] = intParameter(
745750
"Well Drilling Cost Correlation",
746-
value=WellDrillingCostCorrelation.VERTICAL_SMALL,
747751
DefaultValue=WellDrillingCostCorrelation.VERTICAL_SMALL,
748752
AllowableRange=[1, 2, 3, 4, 5],
749753
UnitType=Units.NONE,
@@ -1323,8 +1327,8 @@ def __init__(self, model: Model):
13231327
self.ProjectIRR = self.OutputParameterDict[self.ProjectIRR.Name] = OutputParameter(
13241328
"Project Internal Rate of Return",
13251329
UnitType=Units.PERCENT,
1330+
CurrentUnits=PercentUnit.PERCENT,
13261331
PreferredUnits=PercentUnit.PERCENT,
1327-
CurrentUnits=PercentUnit.PERCENT
13281332
)
13291333
self.ProjectVIR = self.OutputParameterDict[self.ProjectVIR.Name] = OutputParameter(
13301334
"Project Value Investment Ratio",
@@ -1767,10 +1771,11 @@ def Calculate(self, model: Model) -> None:
17671771
else:
17681772
# if depth is > 7000 m, we don't have a correlation for it, so we must use the SIMPLE logic
17691773
checkdepth = model.reserv.depth.quantity().to('m').magnitude
1770-
if (
1771-
checkdepth > 7000.0 or checkdepth < 500) and not self.wellcorrelation.value == WellDrillingCostCorrelation.SIMPLE:
1772-
msg = f'Simple user-specified cost per meter used for drilling depth <500 or >7000 m ({checkdepth}m)'
1773-
print(f'Warning: {msg}')
1774+
if ((checkdepth > 7000.0 or checkdepth < 500) and
1775+
not self.wellcorrelation.value == WellDrillingCostCorrelation.SIMPLE):
1776+
msg = (f'Invalid cost correlation specified for drilling depth <500 or >7000 m ({checkdepth}m), '
1777+
f'falling back to simple user-specified cost '
1778+
f'({self.Vertical_drilling_cost_per_m.value} per meter)')
17741779
model.logger.warning(msg)
17751780
self.wellcorrelation.value = WellDrillingCostCorrelation.SIMPLE
17761781

@@ -1804,13 +1809,18 @@ def Calculate(self, model: Model) -> None:
18041809
else:
18051810
self.C1well = self.Vertical_drilling_cost_per_m.value * model.reserv.depth.quantity().to(
18061811
'm').magnitude * 1E-6
1812+
18071813
elif self.wellcorrelation.value == WellDrillingCostCorrelation.VERTICAL_SMALL:
1808-
self.C1well = (
1809-
0.3021 * checkdepth ** 2 + 584.9112 * checkdepth + 751368.) * 1E-6 # well drilling and completion cost in M$/well
1814+
self.C1well = ((0.3021 * checkdepth ** 2 + 584.9112 * checkdepth + 751368.)
1815+
* 1E-6) # well drilling and completion cost in M$/well
1816+
18101817
elif self.wellcorrelation.value == WellDrillingCostCorrelation.DEVIATED_SMALL:
18111818
self.C1well = (0.2898 * checkdepth ** 2 + 822.1507 * checkdepth + 680563.) * 1E-6
1819+
18121820
elif self.wellcorrelation.value == WellDrillingCostCorrelation.VERTICAL_LARGE:
1821+
18131822
self.C1well = (0.2818 * checkdepth ** 2 + 1275.5213 * checkdepth + 632315.) * 1E-6
1823+
18141824
elif self.wellcorrelation.value == WellDrillingCostCorrelation.DEVIATED_LARGE:
18151825
self.C1well = (0.2553 * checkdepth ** 2 + 1716.7157 * checkdepth + 500867.) * 1E-6
18161826

src/geophires_x/SurfacePlantDoubleFlash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def Calculate(self, model: Model) -> None:
122122
self.NetElectricityProduced.value = self.ElectricityProduced.value - model.wellbores.PumpingPower.value
123123
self.FirstLawEfficiency.value = self.NetElectricityProduced.value/HeatExtractedTowardsElectricity
124124

125-
# Calculate annual electricity, pum;ping, and heat production
125+
# Calculate annual electricity, pumping, and heat production
126126
self.HeatkWhExtracted.value, self.PumpingkWh.value, self.TotalkWhProduced.value, self.NetkWhProduced.value, self.HeatkWhProduced.value = \
127127
SurfacePlant.annual_electricity_pumping_power(self, self.plant_lifetime.value, self.enduse_option.value,
128128
self.HeatExtracted.value, model.economics.timestepsperyear.value, self.utilization_factor.value,

tests/example1_addons.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ECONOMIC PARAMETERS,Accrued financing during construction,,0.0,
1111
ECONOMIC PARAMETERS,Project lifetime,,30,yr
1212
ECONOMIC PARAMETERS,Capacity factor,,90.0,%
1313
ECONOMIC PARAMETERS,Project NPV,,-6.29,MUSD
14-
ECONOMIC PARAMETERS,Project IRR,,0.04,%
14+
ECONOMIC PARAMETERS,Project IRR,,4.48,%
1515
ECONOMIC PARAMETERS,Project VIR=PI=PIR,,0.81,
1616
ECONOMIC PARAMETERS,Project MOIC,,3.47,
1717
ECONOMIC PARAMETERS,Fixed Charge Rate (FCR),,5.0,

tests/examples/example10_HP.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.3
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-18
10-
Simulation Time: 09:03
11-
Calculation Time: 0.143 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:32
11+
Calculation Time: 0.142 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -30,7 +30,7 @@ Simulation Metadata
3030
Project lifetime: 30 yr
3131
Capacity factor: 90.0 %
3232
Project NPV: 4.04 MUSD
33-
Project IRR: 0.07 %
33+
Project IRR: 7.45 %
3434
Project VIR=PI=PIR: 1.13
3535
Project MOIC: 0.92
3636

tests/examples/example11_AC.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.3
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-18
10-
Simulation Time: 09:03
11-
Calculation Time: 0.154 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:33
11+
Calculation Time: 0.143 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -31,7 +31,7 @@ Simulation Metadata
3131
Project lifetime: 30 yr
3232
Capacity factor: 90.0 %
3333
Project NPV: -15.88 MUSD
34-
Project IRR: 0.00 %
34+
Project IRR: 0.34 %
3535
Project VIR=PI=PIR: 0.48
3636
Project MOIC: 0.03
3737

tests/examples/example12_DH.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.3
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-18
10-
Simulation Time: 09:03
11-
Calculation Time: 0.132 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:33
11+
Calculation Time: 0.127 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -33,7 +33,7 @@ Simulation Metadata
3333
Project lifetime: 30 yr
3434
Capacity factor: 86.3 %
3535
Project NPV: -19.42 MUSD
36-
Project IRR: 0.02 %
36+
Project IRR: 1.73 %
3737
Project VIR=PI=PIR: 0.59
3838
Project MOIC: 0.14
3939

tests/examples/example1_addons.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.3
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-18
10-
Simulation Time: 09:03
11-
Calculation Time: 0.613 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:31
11+
Calculation Time: 0.616 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -30,7 +30,7 @@ Simulation Metadata
3030
Project lifetime: 30 yr
3131
Capacity factor: 90.0 %
3232
Project NPV: -6.29 MUSD
33-
Project IRR: 0.04 %
33+
Project IRR: 4.48 %
3434
Project VIR=PI=PIR: 0.81
3535
Project MOIC: 3.47
3636

tests/examples/example2.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.0
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-13
10-
Simulation Time: 09:44
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:31
1111
Calculation Time: 0.215 sec
1212

1313
***SUMMARY OF RESULTS***
@@ -30,7 +30,7 @@ Simulation Metadata
3030
Project lifetime: 25 yr
3131
Capacity factor: 90.0 %
3232
Project NPV: -1.73 MUSD
33-
Project IRR: 0.06 %
33+
Project IRR: 5.77 %
3434
Project VIR=PI=PIR: 0.96
3535
Project MOIC: 0.51
3636

tests/examples/example3.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.3
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-18
10-
Simulation Time: 08:28
11-
Calculation Time: 0.168 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:31
11+
Calculation Time: 0.169 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -30,7 +30,7 @@ Simulation Metadata
3030
Project lifetime: 35 yr
3131
Capacity factor: 90.0 %
3232
Project NPV: -2.89 MUSD
33-
Project IRR: 0.06 %
33+
Project IRR: 6.01 %
3434
Project VIR=PI=PIR: 0.97
3535
Project MOIC: 0.65
3636

tests/examples/example5.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Simulation Metadata
66
----------------------
7-
GEOPHIRES Version: 3.4.0
7+
GEOPHIRES Version: 3.4.11
88
GEOPHIRES Build Date: 2022-06-30
9-
Simulation Date: 2024-02-13
10-
Simulation Time: 09:44
11-
Calculation Time: 0.064 sec
9+
Simulation Date: 2024-03-01
10+
Simulation Time: 12:31
11+
Calculation Time: 0.062 sec
1212

1313
***SUMMARY OF RESULTS***
1414

@@ -29,7 +29,7 @@ Simulation Metadata
2929
Project lifetime: 30 yr
3030
Capacity factor: 90.0 %
3131
Project NPV: -2.25 MUSD
32-
Project IRR: 0.06 %
32+
Project IRR: 5.64 %
3333
Project VIR=PI=PIR: 0.95
3434
Project MOIC: 0.47
3535

0 commit comments

Comments
 (0)