Skip to content

Commit

Permalink
Fix the usecase
Browse files Browse the repository at this point in the history
If the age of an asset is such that it should be replaced on
the project's last year, we do not take it into account as the
resell price would be deduced anyway
  • Loading branch information
Bachibouzouk committed Sep 25, 2023
1 parent 6740cd0 commit f2b665d
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/multi_vector_simulator/C2_economic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,11 @@ def get_replacement_costs(
)

replacement_costs = 0

# Latest investment is first investment
latest_investment = first_time_investment
# Starting from first investment (in the past for installed capacities)
year = -age_of_asset
if abs(year) >= asset_lifetime:
if abs(year) > asset_lifetime:
logging.error(
f"The age of the asset `{asset_label}` ({age_of_asset} years) is lower or equal than "
f"the asset lifetime ({asset_lifetime} years). This does not make sense, as a "
Expand All @@ -222,16 +221,24 @@ def get_replacement_costs(
for count_of_replacements in range(1, number_of_investments):
# replacements taking place after an asset ends its lifetime
year += asset_lifetime

# Update latest_investment (to be used for residual value)
latest_investment = first_time_investment / ((1 + discount_factor) ** (year))
# Add latest investment to replacement costs
replacement_costs += latest_investment
# Update cash flow projection (specific)
present_value_of_capital_expenditures.loc[year] = latest_investment
if year < project_lifetime:
# Update latest_investment (to be used for residual value)
latest_investment = first_time_investment / (
(1 + discount_factor) ** (year)
)
# Add latest investment to replacement costs
replacement_costs += latest_investment
# Update cash flow projection (specific)
present_value_of_capital_expenditures.loc[year] = latest_investment
elif year == project_lifetime:
logging.warning(
f"No asset `{asset_label}` replacement costs are computed for the project's "
f"last year as the asset reach its end-of-life exactly on that year"
)

# Calculation of residual value / value at project end
year += asset_lifetime
if year != project_lifetime:
year += asset_lifetime
if year > project_lifetime:
# the residual of the capex at the end of the simulation time takes into
linear_depreciation_last_investment = latest_investment / asset_lifetime
Expand Down

0 comments on commit f2b665d

Please sign in to comment.