Skip to content
Snippets Groups Projects
Commit 685c8566 authored by Witold Skrzypiński's avatar Witold Skrzypiński Committed by Mikkel Friis-Møller
Browse files

Inputs for calculate_devex and calculate_capex converted from lists to np...

Inputs for calculate_devex and calculate_capex converted from lists to np arrays within the methods.
parent 66b26908
No related branches found
No related tags found
1 merge request!135Dtu cost model
Pipeline #11559 passed
......@@ -10,6 +10,7 @@ API Reference
api_reference/topfarmproblem
api_reference/cost
api_reference/dtucost
api_reference/constraints
api_reference/drivers
api_reference/plotcomp
......
DTU Cost Model
====================
.. autoclass:: topfarm.cost_models.dtu_wind_cm.dtu_wind_cm_main.economic_evaluation
.. autosummary::
__init__
calculate_npv
calculate_irr
calculate_cash_flow
calculate_expenditures
calculate_devex
calculate_capex
calculate_opex
calculate_abex
calculate_turbine
calculate_foundation
high_speed_drivetrain
medium_speed_drivetrain
direct_drive_drivetrain
......@@ -20,6 +20,8 @@ import os
import sys
sys.path.insert(0, os.path.join(os.path.abspath('.'), '..', '..'))
nbsphinx_allow_errors = True
from topfarm import __version__
from topfarm import __release__
......
......@@ -38,7 +38,7 @@ Design Variables
These are the variables that should be changed during the optimization. Common
options include wind turbine positions and/or turbine types.
Cost Component
----------------
......@@ -51,7 +51,19 @@ Cost Component
``topfarm.cost_models.cost_model_wrappers``. TOPFARM also contains a wrapper
for PyWake's AEP calculator, which can be used with a variety of wake models.
DTU Cost Model
----------------
This is the DTU offshore cost model. The class includes methods for simple calculations
of the Internal Rate of Return (IRR) and Net Present Value (NPV). Further, it breaks up
the project costs into DEVEX, CAPEX, OPEX and ABEX within seperate methods, which may be
called individually. It generally relies on curve fitting using input parameters such as
rated power or water depth, and was tuned using data obtained from the
industry. It supports three types of drivetrains: high-speed, medium-speed and direct-drive.
It also supports two types of offshore foundations: monopile and jacket.
Drivers
----------
......
......@@ -37,7 +37,9 @@ def main():
return AEPCalc.calculate_AEP(x_i=x, y_i=y).sum(-1).sum(-1)*10**6
def irr_func(aep, **kwargs):
return economic_evaluation(Drotor_vector, power_rated_vector, hub_height_vector, aep).calculate_irr()
my_irr = economic_evaluation(Drotor_vector, power_rated_vector, hub_height_vector, aep).calculate_irr()
print(my_irr)
return my_irr
aep_comp = CostModelComponent(input_keys=['x','y'], n_wt=n_wt, cost_function=aep_func, output_key="aep", output_unit="GWh", objective=False, output_val=np.zeros(n_wt))
irr_comp = CostModelComponent(input_keys=['aep'], n_wt=n_wt, cost_function=irr_func, output_key="irr", output_unit="%", objective=True, income_model=True)
......
import numpy as np
from openmdao.api import view_model
from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines, IEA37Site
from py_wake.wake_models.gaussian import IEA37SimpleBastankhahGaussian
from py_wake.aep_calculator import AEPCalculator
from topfarm.cost_models.economic_models.dtu_wind_cm_main import economic_evaluation
from topfarm.cost_models.cost_model_wrappers import CostModelComponent
from topfarm import TopFarmGroup, TopFarmProblem
from topfarm.easy_drivers import EasyRandomSearchDriver
from topfarm.drivers.random_search_driver import RandomizeTurbinePosition_Circle
from topfarm.constraint_components.boundary import CircleBoundaryConstraint
from topfarm.plotting import XYPlotComp, NoPlot
from topfarm.constraint_components.spacing import SpacingConstraint
def main():
if __name__ == '__main__':
try:
import matplotlib.pyplot as plt
plt.gcf()
plot_comp = XYPlotComp()
plot = True
except RuntimeError:
plot_comp = NoPlot()
plot = False
n_wt = 16
site = IEA37Site(n_wt)
windTurbines = IEA37_WindTurbines()
wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines)
Drotor_vector = [windTurbines.diameter()] * n_wt
power_rated_vector = [float(windTurbines.power(20))*1e-6] * n_wt
hub_height_vector = [windTurbines.hub_height()] * n_wt
AEPCalc = AEPCalculator(wake_model)
distance_from_shore = 10 # [km]
energy_price = 0.1 # [Euro/kWh] What we get per kWh
project_duration = 20 # [years]
rated_rpm_array = [12] * n_wt # [rpm]
water_depth_array = [15] * n_wt # [m]
eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)
def aep_func(x, y, **kwargs):
return AEPCalc.calculate_AEP(x_i=x, y_i=y).sum(-1).sum(-1)*10**6
def irr_func(aep, **kwargs):
eco_eval.calculate_irr(rated_rpm_array, Drotor_vector, power_rated_vector, hub_height_vector, water_depth_array, aep)
print(eco_eval.IRR)
return eco_eval.IRR
aep_comp = CostModelComponent(input_keys=['x','y'], n_wt=n_wt, cost_function=aep_func, output_key="aep", output_unit="kWh", objective=False, output_val=np.zeros(n_wt))
irr_comp = CostModelComponent(input_keys=['aep'], n_wt=n_wt, cost_function=irr_func, output_key="irr", output_unit="%", objective=True, income_model=True)
group = TopFarmGroup([aep_comp, irr_comp])
problem = TopFarmProblem(
design_vars=dict(zip('xy', site.initial_position.T)),
cost_comp=group,
driver=EasyRandomSearchDriver(randomize_func=RandomizeTurbinePosition_Circle(), max_iter=50),
constraints=[SpacingConstraint(200),
CircleBoundaryConstraint([0, 0], 1300.1)],
plot_comp=plot_comp)
cost, state, recorder = problem.optimize()
# problem.evaluate()
# view_model(problem, outfile='example_4_integrated_optimization_aep_and_irr_n2.html', show_browser=False)
main()
This diff is collapsed.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 13 13:20:09 2019
Full set of dtu cost model tests
"""
from topfarm.cost_models.economic_models.dtu_wind_cm_main import economic_evaluation
from topfarm.tests import npt
import warnings
def test_dtu_cm_capex():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
distance_from_shore = 10 # [km]
energy_price = 0.2 # [Euro/kWh]
project_duration = 20 # [years]
eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)
number_of_turbines = 10
rated_rpm_vector = [10.0] * number_of_turbines # [RPM]
rotor_diameter_vector = [100.0] * number_of_turbines # [m]
rated_power_vector = [10.0] * number_of_turbines # [MW]
hub_height_vector = [100.0] * number_of_turbines # [m]
water_depth_vector = [15.0] * number_of_turbines # [m]
eco_eval.calculate_capex(rated_rpm_vector, rotor_diameter_vector, rated_power_vector,
hub_height_vector, water_depth_vector)
npt.assert_almost_equal(eco_eval.project_costs_sums['CAPEX'] * 1.0E-6, 93.6938301) # [M Euro]
def test_dtu_cm_devex():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
distance_from_shore = 10 # [km]
energy_price = 0.2 # [Euro/kWh]
project_duration = 20 # [years]
eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)
number_of_turbines = 10
rated_power_vector = [10.0] * number_of_turbines # [MW]
eco_eval.calculate_devex(rated_power_vector)
npt.assert_almost_equal(eco_eval.project_costs_sums['DEVEX'] * 1.0E-6, 12.3461538) # [M Euro]
def test_dtu_cm_opex():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
distance_from_shore = 10 # [km]
energy_price = 0.2 # [Euro/kWh]
project_duration = 20 # [years]
eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)
number_of_turbines = 10
rated_power_vector = [10.0] * number_of_turbines # [MW]
eco_eval.calculate_opex(rated_power_vector)
npt.assert_almost_equal(eco_eval.project_costs_sums['OPEX'] * 1.0E-6, 6.465) # [M Euro / year]
def test_dtu_cm_irr():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
distance_from_shore = 10 # [km]
energy_price = 0.2 # [Euro/kWh]
project_duration = 20 # [years]
eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)
number_of_turbines = 10
rated_rpm_vector = [10.0] * number_of_turbines # [RPM]
rotor_diameter_vector = [100.0] * number_of_turbines # [m]
rated_power_vector = [10.0] * number_of_turbines # [MW]
hub_height_vector = [100.0] * number_of_turbines # [m]
water_depth_vector = [15.0] * number_of_turbines # [m]
aep_vector = [8.0e6] * number_of_turbines # [kWh]
eco_eval.calculate_irr(rated_rpm_vector, rotor_diameter_vector, rated_power_vector,
hub_height_vector, water_depth_vector, aep_vector)
npt.assert_almost_equal(eco_eval.IRR, 6.2860816) # [%]
def test_dtu_cm_npv():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
distance_from_shore = 10 # [km]
energy_price = 0.2 # [Euro/kWh]
project_duration = 20 # [years]
discount_rate = 0.062860816 # [-]
eco_eval = economic_evaluation(distance_from_shore, energy_price,
project_duration, discount_rate)
number_of_turbines = 10
rated_rpm_vector = [10.0] * number_of_turbines # [RPM]
rotor_diameter_vector = [100.0] * number_of_turbines # [m]
rated_power_vector = [10.0] * number_of_turbines # [MW]
hub_height_vector = [100.0] * number_of_turbines # [m]
water_depth_vector = [15.0] * number_of_turbines # [m]
aep_vector = [8.0e6] * number_of_turbines # [kWh]
eco_eval.calculate_npv(rated_rpm_vector, rotor_diameter_vector, rated_power_vector,
hub_height_vector, water_depth_vector, aep_vector)
npt.assert_almost_equal(eco_eval.NPV, 0.0437686) # [Euro]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment