-
Notifications
You must be signed in to change notification settings - Fork 4
/
ConstantBPMWrite.py
70 lines (56 loc) · 3.26 KB
/
ConstantBPMWrite.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
# VSP2WOPWOP Constant BPM Binary Broadband Data File
# Author: Daniel Weitsman
# This function writes out the binary BPM broadband data file for constant cases.
#%%
def ConstantBPMWrite(geomParams,loadParams,dirSaveFile):
#%% imports necessary modules
import os
import struct
import numpy as np
#%% TEflow angle is hard coded to 1 degree
TEflowAngle = np.zeros(len(geomParams['chordDist']))*1*(np.pi/180)
#%%
magic_number = 42 # 4-byte signed
nSect = geomParams['nXsecs'] # Number of bade sections
uniformBlade = 0 # Set equal to '1' if each blade section is uniform and '0' otherwise.
sectChordFlag = 1 # Set equal to '1' if the blade section chord is included,'0' otherwise
sectLengthFlag = 1 # Set equal to '1' if the blade section length is included,'0' otherwise
TEthicknessFlag = 1 # Set equal to '1' if the TE thickness is included,'0' otherwise
TEflowAngleFlag = 1 # Set equal to '1' if the TE flow angle (radians) is included,'0' otherwise
TipLCSFlag = 0 # Set equal to '1' if the blade section lift-curve slope is included,'0' otherwise
SectAOAFlag = 1 # Set equal to '1' if the blade section angle of attack (radians) is included,'0' otherwise
UFlag = 1 # Set equal to '1' if the blade section freestream speed is included,'0' otherwise
timeType = 1 # Set equal to '1' if the data is constant, 2 if periodic, 3 if aperoodic.
#%%
with open(os.path.abspath(os.path.join(dirSaveFile ,'BPM.dat')), 'bw') as f_bin:
f_bin.write(struct.pack('>i', magic_number))
f_bin.write(struct.pack('>i', nSect))
f_bin.write(struct.pack('>i', uniformBlade))
f_bin.write(struct.pack('>i', sectChordFlag))
f_bin.write(struct.pack('>i', sectLengthFlag))
f_bin.write(struct.pack('>i', TEthicknessFlag))
f_bin.write(struct.pack('>i', TEflowAngleFlag))
f_bin.write(struct.pack('>i', TipLCSFlag))
f_bin.write(struct.pack('>i', SectAOAFlag))
f_bin.write(struct.pack('>i', UFlag))
f_bin.write(struct.pack('>i', timeType))
# Constant blade section data
for i in range(0,nSect):
# sectional chord
f_bin.write(struct.pack('>f', geomParams['chordDist'][i]))
# sectional length
f_bin.write(struct.pack('>f', geomParams['sectLen'][i]))
# TE Thickness
f_bin.write(struct.pack('>f', geomParams['TE_thick'][i]))
# TE Flow Angle
f_bin.write(struct.pack('>f', TEflowAngle[i]))
# for i in range(0,nSect):
# Effective sectional AoA
f_bin.write(struct.pack('>'+str(len(loadParams['AoA']))+'f', *loadParams['AoA']))
# f_bin.write(struct.pack('>f', loadParams['AoA'][i]))
# Sectional tip lift-curve slope
# for i in range(nXsecs):
# f_bin.write(struct.pack('<f', loadParams['ClaDist'][i]))
# for i in range(0,nSect):
# Sectional freestream velocity
f_bin.write(struct.pack('>'+str(len(loadParams['U']))+'f', *loadParams['U']))