Skip to content

Commit 4e489f2

Browse files
Fix Bond Financing Start Year off-by-one index implementation error. Treat bond financing start years prior to construction as equivalent to the first construction year.
1 parent b4b77b8 commit 4e489f2

File tree

7 files changed

+248
-206
lines changed

7 files changed

+248
-206
lines changed

src/geophires_x/Economics.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,9 @@ def __init__(self, model: Model):
11851185
f'and normalized to sum to 1.0.'
11861186
)
11871187

1188-
default_bond_financing_start_year = 0
1189-
latest_allowed_bond_financing_start_year_index = 0
11901188
bond_financing_start_year_name = 'Bond Financing Start Year'
1189+
default_bond_financing_start_year = -1*(MAX_CONSTRUCTION_YEARS - 1)
1190+
latest_allowed_bond_financing_start_year_index = 0
11911191
self.bond_financing_start_year = self.ParameterDict[self.bond_financing_start_year.Name] = intParameter(
11921192
bond_financing_start_year_name,
11931193
DefaultValue=default_bond_financing_start_year,
@@ -1201,15 +1201,15 @@ def __init__(self, model: Model):
12011201
ToolTipText=f'Project year index when bond financing (debt/loans) starts '
12021202
f'(if {self.FIB.Name} is >0). '
12031203
f'Prior years will be financed with equity only. '
1204-
f'By default, bond financing starts during the first construction year '
1204+
f'By default, bond financing starts during the first construction year ' # TODO lead with this
12051205
f'which has year index {{({model.surfaceplant.construction_years.Name} - 1) * -1}}. '
1206-
f'For example, a project with 4 '
1207-
# f'{model.surfaceplant.construction_years.Name} '
1208-
'construction years '
1209-
f'where bond '
1210-
f'financing starts on the third {model.surfaceplant.construction_years.Name[:-1]} would have '
1211-
f'a {bond_financing_start_year_name} value of -1; construction starts in Year -3, the second'
1212-
f'year is Year -2, and the final 2 bond-financed construction years are Year -1 and Year 0.'
1206+
f'For example, a project with 4 construction years '
1207+
f'where bond financing starts on the third {model.surfaceplant.construction_years.Name[:-1]} '
1208+
f'would have a {bond_financing_start_year_name} value of -1; construction starts in Year -3, '
1209+
f'the second year is Year -2, and the final 2 bond-financed construction years are Year -1 '
1210+
f'and Year 0. '
1211+
f'Bond financing will start on the first construction year if the specified year index is '
1212+
f'prior to the first construction year.'
12131213
)
12141214

12151215
self.contingency_percentage = self.ParameterDict[self.contingency_percentage.Name] = floatParameter(

src/geophires_x/EconomicsSam.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def _inv_msg(param_name: str, invalid_value: Any, supported_description: str) ->
204204

205205
construction_years = model.surfaceplant.construction_years.value
206206
if abs(econ.bond_financing_start_year.value) >= construction_years:
207-
raise ValueError(
208-
f'{econ.bond_financing_start_year.Name} ({econ.bond_financing_start_year.value}) may not be earlier than '
209-
f'first {model.surfaceplant.construction_years.Name[:-1]} ({-1*(construction_years-1)}). '
207+
model.logger.debug(
208+
f'{econ.bond_financing_start_year.Name} ({econ.bond_financing_start_year.value}) is earlier than '
209+
f'first {model.surfaceplant.construction_years.Name[:-1]} ({-1 * (construction_years - 1)}). (OK)'
210210
)
211211

212212

src/geophires_x/EconomicsSamPreRevenue.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def calculate_pre_revenue_costs_and_cashflow(model: 'Model') -> PreRevenueCostsA
6868
construction_years: int = model.surfaceplant.construction_years.value
6969

7070
# Translate from negative year index input value to start-year-0-indexed calculation value
71-
debt_financing_start_year: int = (
72-
construction_years - abs(econ.bond_financing_start_year.value) if econ.bond_financing_start_year.Provided else 0
71+
debt_financing_start_year: int = max(
72+
construction_years - abs(econ.bond_financing_start_year.value) - 1,
73+
0, # Treat bond financing years prior to construction as starting in the first year of construction
7374
)
7475

7576
return _calculate_pre_revenue_costs_and_cashflow(

src/geophires_x_schema_generator/geophires-request.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,11 +1785,11 @@
17851785
"maximum": 1.0
17861786
},
17871787
"Bond Financing Start Year": {
1788-
"description": "Project year index when bond financing (debt/loans) starts (if Fraction of Investment in Bonds is >0). Prior years will be financed with equity only. By default, bond financing starts during the first construction year which has year index {(Construction Years - 1) * -1}. For example, a project with 4 construction years where bond financing starts on the third Construction Year would have a Bond Financing Start Year value of -1; construction starts in Year -3, the secondyear is Year -2, and the final 2 bond-financed construction years are Year -1 and Year 0.",
1788+
"description": "Project year index when bond financing (debt/loans) starts (if Fraction of Investment in Bonds is >0). Prior years will be financed with equity only. By default, bond financing starts during the first construction year which has year index {(Construction Years - 1) * -1}. For example, a project with 4 construction years where bond financing starts on the third Construction Year would have a Bond Financing Start Year value of -1; construction starts in Year -3, the second year is Year -2, and the final 2 bond-financed construction years are Year -1 and Year 0. Bond financing will start on the first construction year if the specified year index is prior to the first construction year.",
17891789
"type": "integer",
17901790
"units": "yr",
17911791
"category": "Economics",
1792-
"default": 0,
1792+
"default": -14,
17931793
"minimum": -14,
17941794
"maximum": 0
17951795
},

0 commit comments

Comments
 (0)