forked from kshaler/python-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_CPLambdaPitch.py
More file actions
48 lines (38 loc) · 1.8 KB
/
Example_CPLambdaPitch.py
File metadata and controls
48 lines (38 loc) · 1.8 KB
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
import numpy as np
import os
import matplotlib.pyplot as plt
import pyFAST.case_generation.case_gen as case_gen
import pyFAST.input_output.postpro as postpro
# Get current directory so this script can be called from any location
MyDir=os.path.dirname(__file__)
def CPLambdaExample():
""" Example to determine the CP-CT Lambda Pitch matrices of a turbine.
This script uses the function CPCT_LambdaPitch which basically does the same as Parametric Examples given in this folder
"""
FAST_EXE = os.path.join(MyDir, '../../../data/openfast.exe') # Location of a FAST exe (and dll)
ref_dir = os.path.join(MyDir, '../../../data/NREL5MW/') # Folder where the fast input files are located (will be copied)
main_file = 'Main_Onshore_OF2.fst' # Main file in ref_dir, used as a template
# --- Computing CP and CT matrices for range of lambda and pitches
Lambda = np.linspace(0.1,10,3)
Pitch = np.linspace(-10,10,4)
CP,CT,Lambda,Pitch,MaxVal,result = case_gen.CPCT_LambdaPitch(ref_dir,main_file,Lambda,Pitch,fastExe=FAST_EXE,showOutputs=False,nCores=4,TMax=10)
print('CP max',MaxVal)
# --- Plotting matrix of CP values
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
LAMBDA, PITCH = np.meshgrid(Lambda, Pitch)
CP[CP<0]=0
surf = ax.plot_surface(LAMBDA, PITCH, np.transpose(CP), cmap=cm.coolwarm, linewidth=0, antialiased=True,alpha=0.8)
ax.scatter(MaxVal['lambda_opt'],MaxVal['pitch_opt'],MaxVal['CP_max'],c='k',marker='o',s=20)
ax.set_xlabel('lambda')
ax.set_ylabel('pitch')
ax.set_zlabel('CP')
fig.colorbar(surf, shrink=0.5, aspect=5)
if __name__=='__main__':
CPLambdaExample()
plt.show()
if __name__=='__test__':
# Need openfast.exe, doing nothing
pass