-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsmSensDemo.py
147 lines (111 loc) · 3.41 KB
/
csmSensDemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# csmSensDemo.py
# 2013 01 24
''' demonstrate sensitivity of LCOE to different parameters using OpenMDAO
Author: G. Scott, NREL, Jan 2013
'''
import sys, os, fileinput
from lcoe_csm_assembly import lcoe_csm_assembly
global doplot
doplot = True
try:
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
except:
doplot = False
sys.stderr.write("Couldn't find matplotlib - no plots will be generated\n")
#-----------------------------------------
def lcoePlot(x,y,xname,subplt=111, lcoe=None):
global doplot
if not doplot:
return
if subplt==111:
fig = plt.figure()
plt.subplot(subplt)
plt.plot(x,y)
plt.plot(x,y,'b+')
if lcoe is not None:
ymin = 0.90*lcoe
ymax = 1.10*lcoe
plt.ylim(ymin,ymax)
plt.ylabel('LCOE')
plt.xlabel(xname)
plt.title('LCOE vs. {:}'.format(xname))
plt.grid()
if subplt==111:
plt.show()
#-----------------------------------------
def main():
global doplot
lcoe = lcoe_csm_assembly()
lcoe.advancedBlade = True
lcoe.execute()
#lcoe.printResults()
lcoe.printShortHeader()
lcoe.printShortResults()
lcoe.advancedBlade = False
lcoe.execute()
#lcoe.printResults()
lcoe.printShortResults()
#-------------- Sensitivity analysis --------------
import numpy as np
# keep default values so we can reset
hhDefault = lcoe.hubHeight
tsDefault = lcoe.maxTipSpeed
rdDefault = lcoe.rotorDiameter
rpDefault = lcoe.ratedPower
lcoe_start = lcoe.lcoe
# sweep over hubht (hubHeight = 90.0)
x = []
y = []
for hubht in np.arange(70.0,121.0,10.0):
lcoe.hubHeight = hubht
lcoe.execute()
print '{:4.0f}m '.format(hubht),
lcoe.printShortResults()
x.append(hubht)
y.append(lcoe.lcoe)
lcoe.hubHeight = hhDefault
lcoePlot(x,y,'HubHeight (m)', 221, lcoe_start)
# sweep over rotor diameter (rotorDiameter=126.0)
x = []
y = []
for rotorDiameter in np.arange(112.0,141.0,2.0):
lcoe.rotorDiameter = rotorDiameter
lcoe.execute()
print '{:4.0f}m '.format(rotorDiameter),
lcoe.printShortResults()
x.append(rotorDiameter)
y.append(lcoe.lcoe)
lcoe.rotorDiameter = rdDefault
lcoePlot(x,y,'Rotor Diameter (m)', 222, lcoe_start)
# sweep over tip speed (maxTipSpeed = 80.0)
x = []
y = []
for maxTipSpeed in np.arange(70.0,101.0,2.0):
lcoe.maxTipSpeed = maxTipSpeed
lcoe.execute()
print '{:4.0f}mps '.format(maxTipSpeed),
lcoe.printShortResults()
x.append(maxTipSpeed)
y.append(lcoe.lcoe)
lcoe.maxTipSpeed = tsDefault
lcoePlot(x,y,'Max Tip Speed (m/s)', 223, lcoe_start)
# sweep over rated power (ratedPower = 5000.0)
x = []
y = []
for ratedPower in np.arange(4500.0,5501.0,100.0):
lcoe.ratedPower = ratedPower
lcoe.execute()
print '{:4.0f}kW '.format(ratedPower),
lcoe.printShortResults()
x.append(ratedPower)
y.append(lcoe.lcoe)
lcoe.ratedPower = rpDefault
lcoePlot(x,y,'Rated Power (kW)', 224, lcoe_start)
if doplot:
plt.tight_layout()
plt.savefig('csmdemo.png')
plt.show()
if __name__=="__main__":
main()