Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

IO: adding excel file, hawcstab2 cmb, and misc updates from weio/welib #31

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ False Echo - Echo input data to <RootName>.ech (flag)
0 CompSub - Compute sub-structural dynamics (switch) {0=None; 1=SubDyn}
0 CompMooring - Compute mooring system (switch) {0=None; 1=MAP++; 2=FEAMooring; 3=MoorDyn; 4=OrcaFlex}
0 CompIce - Compute ice loads (switch) {0=None; 1=IceFloe; 2=IceDyn}
0 MHK - MHK turbine type (switch) {0=Not an MHK turbine; 1=Fixed MHK turbine; 2=Floating MHK turbine}
---------------------- ENVIRONMENTAL CONDITIONS --------------------------------
9.80665 Gravity - Gravitational acceleration (m/s^2)
1.225 AirDens - Air density (kg/m^3)
0 WtrDens - Water density (kg/m^3)
1.464e-05 KinVisc - Kinematic viscosity of working fluid (m^2/s)
335 SpdSound - Speed of sound in working fluid (m/s)
103500 Patm - Atmospheric pressure (Pa) [used only for an MHK turbine cavitation check]
1700 Pvap - Vapour pressure of working fluid (Pa) [used only for an MHK turbine cavitation check]
0 WtrDpth - Water depth (m)
0 MSL2SWL - Offset between still-water level and mean sea level (m) [positive upward]
---------------------- INPUT FILES ---------------------------------------------
"onshore/NREL5MW_ED_Onshore.dat" EDFile - Name of file containing ElastoDyn input parameters (quoted string)
"NA" BDBldFile(1) - Name of file containing BeamDyn input parameters for blade 1 (quoted string)
"5MW_Baseline/NRELOffshrBsline5MW_BeamDyn.dat" BDBldFile(1) - Name of file containing BeamDyn input parameters for blade 1 (quoted string)
"NA" BDBldFile(2) - Name of file containing BeamDyn input parameters for blade 2 (quoted string)
"NA" BDBldFile(3) - Name of file containing BeamDyn input parameters for blade 3 (quoted string)
"onshore/NREL5MW_IW.dat" InflowFile - Name of file containing inflow wind input parameters (quoted string)
Expand Down
35 changes: 17 additions & 18 deletions data/NREL5MW/onshore/NREL5MW_AD.dat
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,28 @@ False CavitCheck - Perform cavitation check? (flag) [AFAeroMod m
False CompAA - Flag to compute AeroAcoustics calculation [used only when WakeMod = 1 or 2]
"unused" AA_InputFile - AeroAcoustics input file [used only when CompAA=true]
====== Environmental Conditions ===================================================================
1.225 AirDens - Air density (kg/m^3)
1.464E-05 KinVisc - Kinematic air viscosity (m^2/s)
335 SpdSound - Speed of sound (m/s)
103500 Patm - Atmospheric pressure (Pa) [used only when CavitCheck=True]
1700 Pvap - Vapour pressure of fluid (Pa) [used only when CavitCheck=True]
0.5 FluidDepth - Water depth above mid-hub height (m) [used only when CavitCheck=True]
====== Blade-Element/Momentum Theory Options ====================================================== [unused when WakeMod=0 or 3]
2 SkewMod - Type of skewed-wake correction model (switch) {1=uncoupled, 2=Pitt/Peters, 3=coupled} [unused when WakeMod=0 or 3]
"default" SkewModFactor - Constant used in Pitt/Peters skewed wake model {or "default" is 15/32*pi} (-) [used only when SkewMod=2; unused when WakeMod=0 or 3]
True TipLoss - Use the Prandtl tip-loss model? (flag) [unused when WakeMod=0 or 3]
True HubLoss - Use the Prandtl hub-loss model? (flag) [unused when WakeMod=0 or 3]
True TanInd - Include tangential induction in BEMT calculations? (flag) [unused when WakeMod=0 or 3]
False AIDrag - Include the drag term in the axial-induction calculation? (flag) [unused when WakeMod=0 or 3]
False TIDrag - Include the drag term in the tangential-induction calculation? (flag) [unused when WakeMod=0,3 or TanInd=FALSE]
"Default" IndToler - Convergence tolerance for BEMT nonlinear solve residual equation {or "default"} (-) [unused when WakeMod=0 or 3]
100 MaxIter - Maximum number of iteration steps (-) [unused when WakeMod=0]
default AirDens - Air density (kg/m^3)
default KinVisc - Kinematic air viscosity (m^2/s)
default SpdSound - Speed of sound (m/s)
default Patm - Atmospheric pressure (Pa) [used only when CavitCheck=True]
default Pvap - Vapour pressure of fluid (Pa) [used only when CavitCheck=True]
====== Blade-Element/Momentum Theory Options ====================================================== [used only when WakeMod=1]
2 SkewMod - Type of skewed-wake correction model (switch) {1=uncoupled, 2=Pitt/Peters, 3=coupled} [used only when WakeMod=1]
"default" SkewModFactor - Constant used in Pitt/Peters skewed wake model {or "default" is 15/32*pi} (-) [used only when SkewMod=2; unused when WakeMod=0]
True TipLoss - Use the Prandtl tip-loss model? (flag) [used only when WakeMod=1]
False HubLoss - Use the Prandtl hub-loss model? (flag) [used only when WakeMod=1]
True TanInd - Include tangential induction in BEMT calculations? (flag) [used only when WakeMod=1]
False AIDrag - Include the drag term in the axial-induction calculation? (flag) [used only when WakeMod=1]
False TIDrag - Include the drag term in the tangential-induction calculation? (flag) [used only when WakeMod=1 and TanInd=TRUE]
"default" IndToler - Convergence tolerance for BEMT nonlinear solve residual equation {or "default"} (-) [used only when WakeMod=1]
100 MaxIter - Maximum number of iteration steps (-) [used only when WakeMod=1]
====== Dynamic Blade-Element/Momentum Theory Options ============================================== [used only when WakeMod=2]
2 DBEMT_Mod - Type of dynamic BEMT (DBEMT) model {1=constant tau1, 2=time-dependent tau1} (-) [used only when WakeMod=2]
4 tau1_const - Time constant for DBEMT (s) [used only when WakeMod=2 and DBEMT_Mod=1]
====== OLAF -- cOnvecting LAgrangian Filaments (Free Vortex Wake) Theory Options ================== [used only when WakeMod=3]
"unused" OLAFInputFileName - Input file for OLAF [used only when WakeMod=3]
"unused" OLAFInputFileName - Input file for OLAF [used only when WakeMod=3]
====== Beddoes-Leishman Unsteady Airfoil Aerodynamics Options ===================================== [used only when AFAeroMod=2]
3 UAMod - Unsteady Aero Model Switch (switch) {1=Baseline model (Original), 2=Gonzalez's variant (changes in Cn,Cc,Cm), 3=Minnema/Pierce variant (changes in Cc and Cm)} [used only when AFAeroMod=2]
3 UAMod - Unsteady Aero Model Switch (switch) {1=Baseline model (Original), 2=Gonzalezs variant (changes in Cn,Cc,Cm), 3=Minemma/Pierce variant (changes in Cc and Cm)} [used only when AFAeroMod=2]
True FLookup - Flag to indicate whether a lookup for f' will be calculated (TRUE) or whether best-fit exponential equations will be used (FALSE); if FALSE S1-S4 must be provided in airfoil input files (flag) [used only when AFAeroMod=2]
====== Airfoil Information =========================================================================
1 AFTabMod - Interpolation method for multiple airfoil tables {1=1D interpolation on AoA (first table only); 2=2D interpolation on AoA and Re; 3=2D interpolation on AoA and UserProp} (-)
Expand Down
8 changes: 5 additions & 3 deletions data/NREL5MW/onshore/NREL5MW_ED_Onshore.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ NREL 5.0 MW Baseline Wind Turbine for Use in Offshore Analysis. Properties from
False Echo - Echo input data to "<RootName>.ech" (flag)
3 Method - Integration method: {1: RK4, 2: AB4, or 3: ABM4} (-)
"default" DT - Integration time step (s)
---------------------- ENVIRONMENTAL CONDITION ---------------------------------
9.80665 Gravity - Gravitational acceleration (m/s^2)
---------------------- DEGREES OF FREEDOM --------------------------------------
True FlapDOF1 - First flapwise blade mode DOF (flag)
True FlapDOF2 - Second flapwise blade mode DOF (flag)
Expand All @@ -32,7 +30,7 @@ False PtfmYDOF - Platform yaw rotation DOF (flag)
0 BlPitch(3) - Blade 3 initial pitch (degrees) [unused for 2 blades]
0 TeetDefl - Initial or fixed teeter angle (degrees) [unused for 3 blades]
0 Azimuth - Initial azimuth angle for blade 1 (degrees)
0.0 RotSpeed - Initial or fixed rotor speed (rpm)
10.0 RotSpeed - Initial or fixed rotor speed (rpm)
0 NacYaw - Initial or fixed nacelle-yaw angle (degrees)
0 TTDspFA - Initial fore-aft tower-top displacement (meters)
0 TTDspSS - Initial side-to-side tower-top displacement (meters)
Expand Down Expand Up @@ -210,6 +208,10 @@ True TabDelim - Use tab delimiters in text tabular output file? (fla
"TwrBsMzt" - Side-to-side bending, fore-aft bending, and yaw moments at the base of the tower (platform)
"RootMyb1"
"NcIMUTVxs"
"Q_DrTr" Displacement of drivetrain rotational-flexibility DOF
"Q_GeAz" Displacement of variable speed generator DOF
"QD_DrTr" Velocity of drivetrain rotational-flexibility DOF
"QD_GeAz" Velocity of variable speed generator DOF
END of input file (the word "END" must appear in the first 3 columns of this last OutList line)
---------------------- NODE OUTPUTS --------------------------------------------
1 BldNd_BladesOut - Blades to output
Expand Down
6 changes: 3 additions & 3 deletions pyFAST/case_generation/case_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def paramsStiff(p=None):
p['EDFile|PtfmYDOF'] = 'False'
return p

def paramsWS_RPM_Pitch(WS, RPM, Pitch, baseDict=None, FlatInputs=False):
def paramsWS_RPM_Pitch(WS, RPM, Pitch, baseDict=None, flatInputs=False):
"""
Generate OpenFAST "parameters" (list of dictionaries with "address")
chaing the inputs in ElastoDyn, InflowWind for different wind speed, RPM and Pitch
Expand Down Expand Up @@ -470,8 +470,8 @@ def createStepWind(filename,WSstep=1,WSmin=3,WSmax=25,tstep=100,dt=0.5,tmin=0,tm

#print(f.toDataFrame())
#pass
#createStepWind('tests.wnd',tstep=200,WSmax=28)
# createStepWind('tests.wnd',tstep=200,WSmin=5,WSmax=7,WSstep=2)
#createStepWind('test.wnd',tstep=200,WSmax=28)
# createStepWind('test.wnd',tstep=200,WSmin=5,WSmax=7,WSstep=2)



Expand Down
8 changes: 4 additions & 4 deletions pyFAST/case_generation/examples/Example_CPLambdaPitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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, "../../../../openfast/build/bin/openfast_x64.exe") # Location of a FAST exe (and dll)
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_OF.fst' # Main file in ref_dir, used as a template
main_file = 'Main_Onshore.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,20)
Pitch = np.linspace(-2,10,20)
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)

Expand Down
4 changes: 2 additions & 2 deletions pyFAST/case_generation/examples/Example_ExcelFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
def main():
# --- Main Parameters
ref_dir = os.path.join(MyDir, '../../../data/NREL5MW/') # Folder where the fast input files are located (will be copied)
FAST_EXE = FAST_EXE = os.path.join(MyDir, '../../../../openfast/build/bin/openfast_x64.exe') # Location of a FAST exe (and dll)
main_file = 'Main_Onshore_OF.fst' # Main file in ref_dir, used as a template
FAST_EXE = os.path.join(MyDir, '../../../data/openfast.exe') # Location of a FAST exe (and dll)
main_file = 'Main_Onshore.fst' # Main file in ref_dir, used as a template
work_dir = os.path.join(MyDir, '_NREL5MW_ParametricExcel/') # Output folder (will be created)
parametricFile = 'ParametricExcel.xlsx' # Excel file containing set of parameters

Expand Down
4 changes: 2 additions & 2 deletions pyFAST/case_generation/examples/Example_Parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def ParametricExample():

"""
# --- Parameters for this script
FAST_EXE = FAST_EXE = os.path.join(MyDir, '../../../../openfast/build/bin/openfast_x64.exe') # Location of a FAST exe (and dll)
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_OF.fst' # Main file in ref_dir, used as a template
main_file = 'Main_Onshore.fst' # Main file in ref_dir, used as a template
work_dir = '_NREL5MW_Parametric/' # Output folder (will be created)

# --- Defining the parametric study (list of dictionnaries with keys as FAST parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def PowerCurveParametricExample1():
- they values are the values corresponding to this parameter
"""
# --- Parameters for this script
FAST_EXE = os.path.join(MyDir, '../../../../openfast/build/bin/openfast_x64.exe') # Location of a FAST exe (and dll)
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_OF.fst' # Main file in ref_dir, used as a template
main_file = 'Main_Onshore.fst' # Main file in ref_dir, used as a template
work_dir = '_NREL5MW_PowerCurveParametric/' # Output folder (will be created)

# --- Defining the parametric study (list of dictionnaries with keys as FAST parameters)
Expand Down Expand Up @@ -82,9 +82,9 @@ def PowerCurveParametricExample2():
- they values are the values corresponding to this parameter
"""
# --- Parameters for this script
FAST_EXE = FAST_EXE = os.path.join(MyDir, '../../../../openfast/build/bin/openfast_x64.exe') # Location of a FAST exe (and dll)
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_OF.fst' # Main file in ref_dir, used as a template
main_file = 'Main_Onshore.fst' # Main file in ref_dir, used as a template
work_dir = '_NREL5MW_PowerCurveParametric2/' # Output folder (will be created)
out_Ext = '.outb' # Output extension

Expand Down
32 changes: 19 additions & 13 deletions pyFAST/case_generation/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# --- Tools for executing FAST
# --------------------------------------------------------------------------------{
# --- START cmd.py
def run_cmds(inputfiles, exe, parallel=True, showOutputs=True, nCores=None, showCommand=True):
def run_cmds(inputfiles, exe, parallel=True, showOutputs=True, nCores=None, showCommand=True, verbose=True):
""" Run a set of simple commands of the form `exe input_file`
By default, the commands are run in "parallel" (though the method needs to be improved)
The stdout and stderr may be displayed on screen (`showOutputs`) or hidden.
Expand All @@ -31,13 +31,15 @@ def run_cmds(inputfiles, exe, parallel=True, showOutputs=True, nCores=None, show
Failed=[]
def _report(p):
if p.returncode==0:
print('[ OK ] Input : ',p.input_file)
if verbose:
print('[ OK ] Input : ',p.input_file)
else:
Failed.append(p)
print('[FAIL] Input : ',p.input_file)
print(' Directory: '+os.getcwd())
print(' Command : '+p.cmd)
print(' Use `showOutputs=True` to debug, or run the command above.')
if verbose:
print('[FAIL] Input : ',p.input_file)
print(' Directory: '+os.getcwd())
print(' Command : '+p.cmd)
print(' Use `showOutputs=True` to debug, or run the command above.')
#out, err = p.communicate()
#print('StdOut:\n'+out)
#print('StdErr:\n'+err)
Expand Down Expand Up @@ -68,13 +70,14 @@ def _report(p):
_report(p)
# --- Giving a summary
if len(Failed)==0:
print('[ OK ] All simulations run successfully.')
return True
if verbose:
print('[ OK ] All simulations run successfully.')
return True, Failed
else:
print('[FAIL] {}/{} simulations failed:'.format(len(Failed),len(inputfiles)))
for p in Failed:
print(' ',p.input_file)
return False
return False, Failed

def run_cmd(input_file_or_arglist, exe, wait=True, showOutputs=False, showCommand=True):
""" Run a simple command of the form `exe input_file` or `exe arg1 arg2` """
Expand Down Expand Up @@ -116,7 +119,7 @@ class Dummy():
return p
# --- END cmd.py

def run_fastfiles(fastfiles, fastExe=None, parallel=True, showOutputs=True, nCores=None, showCommand=True, reRun=True):
def run_fastfiles(fastfiles, fastExe=None, parallel=True, showOutputs=True, nCores=None, showCommand=True, reRun=True, verbose=True):
if fastExe is None:
fastExe=FAST_EXE
if not reRun:
Expand All @@ -131,15 +134,15 @@ def run_fastfiles(fastfiles, fastExe=None, parallel=True, showOutputs=True, nCor
newfiles.append(f)
fastfiles=newfiles

return run_cmds(fastfiles, fastExe, parallel=parallel, showOutputs=showOutputs, nCores=nCores, showCommand=showCommand)
return run_cmds(fastfiles, fastExe, parallel=parallel, showOutputs=showOutputs, nCores=nCores, showCommand=showCommand, verbose=verbose)

def run_fast(input_file, fastExe=None, wait=True, showOutputs=False, showCommand=True):
if fastExe is None:
fastExe=FAST_EXE
return run_cmd(input_file, fastExe, wait=wait, showOutputs=showOutputs, showCommand=showCommand)


def writeBatch(batchfile, fastfiles, fastExe=None, nBatches=1):
def writeBatch(batchfile, fastfiles, fastExe=None, nBatches=1, pause=False):
""" Write batch file, everything is written relative to the batch file"""
if fastExe is None:
fastExe=FAST_EXE
Expand All @@ -154,6 +157,9 @@ def writeb(batchfile, fastfiles):
ff_rel = os.path.relpath(ff_abs, batchdir)
l = fastExe_rel + ' '+ ff_rel
f.write("%s\n" % l)
if pause:
f.write("pause\n") # windows only..

if nBatches==1:
writeb(batchfile, fastfiles)
else:
Expand All @@ -167,7 +173,7 @@ def writeb(batchfile, fastfiles):



def removeFASTOutputs(workDir):
def removeFASTOuputs(workDir):
# Cleaning folder
for f in glob.glob(os.path.join(workDir,'*.out')):
os.remove(f)
Expand Down
2 changes: 1 addition & 1 deletion pyFAST/case_generation/tests/test_run_Examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def test_run_examples(self):
MyDir=os.path.dirname(__file__)
files = glob.glob(os.path.join(MyDir,'../examples/[a-zA-Z]*.py'))
import matplotlib.pyplot as plt
plt.close('all')
print('\n--------------------------------------------------------------')
for f in files:
print('Running example script: {}'.format(f))
if hasattr(self,'subTest'):
with self.subTest(filename=os.path.basename(f)):
execfile(f, {'__name__': '__test__', 'print': lambda *_:None})
plt.close('all')


if __name__ == '__main__':
Expand Down
Loading