Skip to content

Commit

Permalink
Squashed 'ROSCO_toolbox/' changes from 571baad..610755e
Browse files Browse the repository at this point in the history
610755e load aeroelasticse from weis
3584c07 Hardcode debug outname
4b891d8 Revert "Update ROSCO pointer"
008c076 Update ROSCO pointer
fbb5cbc fix previous commit with channel names
457a725 fix previous commit
954ef1e load binaries
b1fe191 Optional wind speed, TMax inputs
12fbbd0 update path
1c4650b check for ROSCO path
17fbb65 Delete old test case run script
bd39933 ROSCO testing as class, rename file
5d61c3c Increment version
46c42f8 Remove GBoxEff from rated torque
0653114 Increment version
37a4a8b More minimum pitch bug fixes
b946e20 Check for spectral in WISDEM
187c2e1 Minimum pitch setting minor bug fix
4892573 typo fixes
d0ee3cd Update requirements
ac712ba move scripts to source folder, typos fixes, cleanup
494a7ab master doc as index
dfc9c2a Standard use descriptions
644861c Compiling and DISCON generation - initial commit
6e2be5a Update project info
616bf27 readthedocs - initial commit
2937b19 Delete old files
b6d4324 Dump outdata to structure and plot
f1de571 formatting
3eb2b90 Load times from input files
057de6d Add checks for optional input files
4159ba5 Update Pl_FastPlots.m
0a03336 Revert examples 6 and 8
077b8d5 Create README.md
3da66f1 Fix some Simulink initial condition issues
4eb6466 Update ROSCO pointer
b29d62b Add ROSCO Simulink Model and simple Matlab/Simulink run case
2866ebd Update ROSCO test, add to gitignore
637c3a1 Increment version
8ff621f Update submodule
bb91651 Rename license file
707e898 Typo
c635f7d Move output variables to init
52b2406 Run Testing - initial commit
edb341f error handling bug fixes
6e6bb66 properly pass desired output channels
078e35f clean up filepaths
bf2a441 6 minute test time for lite testing
5e05be9 ROSCO testing as class, rename file
301a7a3 Create testing suite init
b94be5b Update test cases
913482a Merge remote-tracking branch 'dzalkind/master' into f/testing
REVERT: 571baad Merge branch 'develop' of https://github.com/NREL/ROSCO_toolbox into develop
REVERT: 9f2cf6a Increment version
REVERT: 53cf8c2 Remove GBoxEff from rated torque
REVERT: 4d43650 fix previous commit with channel names
REVERT: 446186d fix previous commit
REVERT: 2bf1888 load binaries
REVERT: ed7f394 Increment version
REVERT: 4e4e3f9 Merge branch 'hotfix/min_pitch'
REVERT: 0a977d9 More minimum pitch bug fixes
REVERT: 8744956 Check for spectral in WISDEM
REVERT: 4351c05 Minimum pitch setting minor bug fix
REVERT: 4ad87a8 typo fixes
REVERT: 5cbcc31 Update requirements
REVERT: de4bee2 move scripts to source folder, typos fixes, cleanup
REVERT: b94f543 master doc as index
REVERT: bb5ded1 Standard use descriptions
REVERT: 9ae9d37 Compiling and DISCON generation - initial commit
REVERT: 391da4a Update project info
REVERT: 117333f readthedocs - initial commit
REVERT: e4b3edb Merge pull request #18 from dzalkind/simulink
REVERT: 5fa1bb9 Delete old files
REVERT: 57196b7 Dump outdata to structure and plot
REVERT: 3203430 formatting
REVERT: 8b77df8 Load times from input files
REVERT: 9424afb Add checks for optional input files
REVERT: 8f0cdb7 Update Pl_FastPlots.m
REVERT: 7122637 Revert examples 6 and 8
REVERT: 877a4b2 Revert "Update ROSCO pointer"
REVERT: cc3b6fd Merge remote-tracking branch 'origin/master' into simulink
REVERT: 2b7ef0e Fix some Simulink initial condition issues
REVERT: a4a3dbe Create README.md
REVERT: 29a1c65 Update ROSCO pointer
REVERT: 76d2189 Increment version
REVERT: bc29969 Increment version
REVERT: 008260e Merge pull request #16 from NREL/develop
REVERT: 963617e Update submodule
REVERT: b0e4aeb Rename license file
REVERT: 457a408 Add ROSCO Simulink Model and simple Matlab/Simulink run case
REVERT: 1cd1bba Update ROSCO test, add to gitignore

git-subtree-dir: ROSCO_toolbox
git-subtree-split: 610755e876c9e942cccc1b1531a7ba6ab0574e0e
  • Loading branch information
nikhar-abbas committed Sep 24, 2020
1 parent df86611 commit 0160654
Show file tree
Hide file tree
Showing 86 changed files with 865 additions and 212,074 deletions.
2 changes: 1 addition & 1 deletion ROSCO
Submodule ROSCO updated 1 files
+2 −11 CMakeLists.txt
445 changes: 445 additions & 0 deletions ROSCO_testing/ROSCO_testing.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ROSCO_testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Testing package for the ROSCO controller."""

__author__ = """Dan Zalkind and Nikhar J. Abbas"""
__email__ = 'daniel.zalkind@nrel.gov'
190 changes: 190 additions & 0 deletions ROSCO_testing/run_Testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@

'''
Run ROSCO lite testing scripts for controller functionality verification
'''
import os
import glob
import ROSCO_testing
import importlib

from wisdem.aeroelasticse.Util import FileTools
from pCrunch import pdTools
from pCrunch import Processing, Analysis

rt = ROSCO_testing.ROSCO_testing()


## =================== INITIALIZATION ===================
turbine2test = 'NREL-5MW' # IEA-15MW
testtype = 'binary-comp' # lite, heavy, binary-comp, discon-comp

# Only fill one of these if comparing controllers
rosco_binaries = [os.path.join(os.getcwd(), glob.glob('../ROSCO/build/libdiscon*')[0]),
os.path.join(os.getcwd(), glob.glob('../ROSCO/build/libdiscon*')[0])]
discon_files = []

# Setup simulation parameters
rt.runDir = 'lite_testing' # directory for FAST simulations
rt.namebase = 'ROSCO_lite_test' # Base name for FAST files
rt.FAST_exe = 'openfast_single' # OpenFAST executable path
rt.Turbsim_exe = 'turbsim_single' # Turbsim executable path
rt.FAST_ver = 'OpenFAST' # FAST version
rt.rosco_path = os.path.join(os.getcwd(), glob.glob('../ROSCO/build/libdiscon*')[0]) # path to compiled ROSCO controller
rt.dev_branch = True # dev branch of Openfast?
rt.debug_level = 2 # debug level. 0 - no outputs, 1 - minimal outputs, 2 - all outputs
rt.overwrite = False # overwite fast sims?
rt.cores = 4 # number of cores if multiprocessings
rt.mpi_run = False # run using mpi
rt.mpi_comm_map_down = [] # core mapping for MPI
rt.outfile_fmt = 2 # 1 = .txt, 2 = binary, 3 = both

# Post Processing Parameters
reCrunch = True # re-run pCrunch?

#### ============================================ ####
# THE ACTION #
# ----- Shouldn't need to change anything here ----- #

# Check validity inputs
if testtype.lower() == 'binary-comp' and len(rosco_binaries) < 2:
raise ValueError('You need at least two binaries to compare for testtype = "binary-comp"!')
if testtype.lower() == 'discon-comp' and len(rosco_binaries) < 2:
raise ValueError('You need at least two discon files to compare for testtype = "binary-comp"!')

# Setup test turbine
if turbine2test == 'NREL-5MW':
rt.Turbine_Class = 'I'
rt.Turbulence_Class = 'A'
rt.FAST_directory = os.path.join(os.getcwd(), '../Test_Cases/NREL-5MW')
rt.FAST_InputFile = 'NREL-5MW.fst'
elif turbine2test == 'IEA-15MW':
rt.Turbine_Class = 'I'
rt.Turbulence_Class = 'B'
rt.FAST_directory = os.path.join(os.getcwd(), '../Test_Cases/IEA-15-240=RWT-UMaineSemi')
rt.FAST_InputFile = 'IEA-15-240=RWT-UMaineSemi.fst'
else:
raise ValueError('{} is not an available turbine to test!'.format(turbine2test))

# Run test
if testtype.lower() == 'lite':
rt.ROSCO_Test_lite()
elif testtype.lower() == 'heavy':
rt.ROSCO_Test_heavy()
elif testtype.lower() == 'binary-comp':
rt.ROSCO_Controller_Comp(rosco_binaries)
elif testtype.lower() == 'discon-comp':
rt.ROSCO_DISCON_Comp(discon_files)
else:
raise ValueError('{} is an invalid test type!'.format(testtype))



# ----------- Post process ----------

# Set up pCrunch
# Initialize processing classes
fp = Processing.FAST_Processing()

if testtype.lower() is any(['lite', 'heavy']):
# Load generated .yaml for outfile names
case_info = FileTools.load_yaml(os.path.join(rt.runDir,'case_matrix.yaml'), package=1)
casenames = case_info['Case_Name']
if rt.outfile_fmt >= 2:
outFileNames = [os.path.join(rt.runDir,fname+'.outb') for fname in casenames]
else:
outFileNames = [os.path.join(rt.runDir,fname+'.out') for fname in casenames]

# Set some processing parameters
fp.OpenFAST_outfile_list = outFileNames
fp.t0 = 0
if rt.cores > 0:
fp.parallel_analysis = True
fp.results_dir = os.path.join(rt.runDir, 'stats')
fp.verbose = True
fp.save_LoadRanking = True
fp.save_SummaryStats = True

# Define load ranking stats
fp.ranking_vars = [['RotSpeed'],
['RootMyb1', 'RootMyb2', 'RootMyb3'],
['TwrBsMyt']]
fp.ranking_stats = ['max',
'max',
'max']
if turbine2test == 'IEA-15MW':
fp.ranking_vars += [['PtfmPitch']]
fp.ranking_stats += ['max']

# Load and save statistics and load rankings
if not os.path.exists(os.path.join(fp.results_dir, 'dataset1_LoadRanking.yaml')) or reCrunch:
stats, load_rankings = fp.batch_processing()

# Print a summary
print('----------------------------------------')
print('\t\t{}'.format(turbine2test))
print('----------------------------------------')
print('\t\t{}'.format('Test Outputs'))
for meas in load_rankings[0].keys():
try:
print('Max {} \t{:1.3e}'.format(meas, load_rankings[0][meas]['max'][0]))
except:
print('{} is not in load rankings'.format(meas))
print('----------------------------------------')

else:
# Save each set of outputs in a list
allstats = []
allrankings = []
for i in range(max(len(discon_files), len(rosco_binaries))):
# Define output file folder
outputDir = os.path.join(os.getcwd(), rt.runDir,'controller_{}'.format(i)) # NJA - this is dependent on the hard-coded folder names in ROSCO_testing.py

# Load output file paths using case matrices
case_info = FileTools.load_yaml(os.path.join(outputDir, 'case_matrix.yaml'), package=1)
casenames = case_info['Case_Name']
if rt.outfile_fmt >= 2:
outFileNames = [os.path.join(outputDir, fname+'.outb') for fname in casenames]
else:
outFileNames = [os.path.join(outputDir, fname+'.out') for fname in casenames]

# Set some processing parameters
fp.OpenFAST_outfile_list = outFileNames
fp.t0 = 0
if rt.cores > 0:
fp.parallel_analysis = True
fp.results_dir = os.path.join(outputDir, 'stats')
fp.verbose = True
fp.save_LoadRanking = True
fp.save_SummaryStats = True

# Define load ranking stats
fp.ranking_vars = [['RotSpeed'],
['RootMyb1', 'RootMyb2', 'RootMyb3'],
['TwrBsMyt']]
fp.ranking_stats = ['max',
'max',
'max']
if turbine2test == 'IEA-15MW':
fp.ranking_vars += [['PtfmPitch']]
fp.ranking_stats += ['max']

# Load and save statistics and load rankings
if not os.path.exists(os.path.join(fp.results_dir, 'dataset1_LoadRanking.yaml')) or reCrunch:
stats, load_rankings = fp.batch_processing()

# Save all outputs
allstats.append(stats)
allrankings.append(load_rankings[0])

# Print a summary
print('----------------------------------------')
print('\t\t{}'.format(turbine2test))
print('----------------------------------------')
print('\t\t{}\t{}'.format('Controller1', 'Controller2'))
for meas in allrankings[0].keys():
try:
print('Max {} \t{:1.3e}\t{:1.3e}'.format(
meas, allrankings[0][meas]['max'][0], allrankings[1][meas]['max'][0]))
except:
print('{} is not in load rankings'.format(meas))
print('----------------------------------------')
15 changes: 7 additions & 8 deletions ROSCO_testing/test_ROSCO.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
'''

import numpy as np
# from wisdem.aeroelasticse.CaseLibrary import ROSCO_Test
import os

from wisdem.aeroelasticse.FAST_reader import InputReader_Common, InputReader_OpenFAST, InputReader_FAST7
from wisdem.aeroelasticse.FAST_writer import InputWriter_Common, InputWriter_OpenFAST, InputWriter_FAST7
from wisdem.aeroelasticse.runFAST_pywrapper import runFAST_pywrapper_batch
from wisdem.aeroelasticse.CaseGen_General import CaseGen_General
from wisdem.aeroelasticse.CaseGen_IEC import CaseGen_IEC
from weis.aeroelasticse.FAST_reader import InputReader_Common, InputReader_OpenFAST, InputReader_FAST7
from weis.aeroelasticse.FAST_writer import InputWriter_Common, InputWriter_OpenFAST, InputWriter_FAST7
from weis.aeroelasticse.runFAST_pywrapper import runFAST_pywrapper_batch
from weis.aeroelasticse.CaseGen_General import CaseGen_General
from weis.aeroelasticse.CaseGen_IEC import CaseGen_IEC
from pCrunch import pdTools
from pCrunch import Processing, Analysis
from wisdem.aeroelasticse.Util import FileTools
from weis.aeroelasticse.Util import FileTools
import pandas as pd

# Moved ROSCO_Test into toolbox so that it doesn't rely on my fork of aeroelasticse
Expand Down Expand Up @@ -183,4 +182,4 @@ def ROSCO_Test(fst_vt, runDir, namebase, TMax, turbine_class, turbulence_class,





3 changes: 2 additions & 1 deletion ROSCO_toolbox/control_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def __init__(self, lib_name, param_filename='DISCON.IN'):
# Initialize DISCON and related
self.aviFAIL = c_int32() # 1
self.accINFILE = self.param_name.encode('utf-8')
self.avcOUTNAME = create_string_buffer(1000) # 'DEMO'.encode('utf-8')
# self.avcOUTNAME = create_string_buffer(1000) # 'DEMO'.encode('utf-8')
self.avcOUTNAME = 'simDEBUG.dbg'.encode('utf-8')
self.avcMSG = create_string_buffer(1000)
self.discon.DISCON.argtypes = [POINTER(c_float), POINTER(c_int32), c_char_p, c_char_p, c_char_p] # (all defined by ctypes)

Expand Down
10 changes: 5 additions & 5 deletions ROSCO_toolbox/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def load_from_fast(self, FAST_InputFile,FAST_directory, FAST_ver='OpenFAST',dev_
txt_filename: str, optional
filename for *.txt, only used if rot_source='txt'
"""
from wisdem.aeroelasticse.FAST_reader import InputReader_OpenFAST
from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST

print('Loading FAST model: %s ' % FAST_InputFile)
self.TurbineName = FAST_InputFile.strip('.fst')
Expand Down Expand Up @@ -355,9 +355,9 @@ def generate_rotperf_fast(self, openfast_path, FAST_runDirectory=None, run_BeamD
'mpi' - run using mpi tools
'''

# Load additional WISDEM tools
from wisdem.aeroelasticse import runFAST_pywrapper, CaseGen_General
from wisdem.aeroelasticse.Util import FileTools
# Load additional WEIS tools
from weis.aeroelasticse import runFAST_pywrapper, CaseGen_General
from weis.aeroelasticse.Util import FileTools
# Load pCrunch tools
from pCrunch import pdTools, Processing

Expand Down Expand Up @@ -537,7 +537,7 @@ def load_blade_info(self):
-----------
self - note: needs to contain fast input file info provided by load_from_fast.
'''
from wisdem.aeroelasticse.FAST_reader import InputReader_OpenFAST
from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST

# Load Fast input deck
# self.TurbineName = FAST_InputFile.strip('.fst')
Expand Down
2 changes: 1 addition & 1 deletion ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import struct

try:
from wisdem.aeroelasticse.Util import spectral
from weis.aeroelasticse.Util import spectral
except:
pass

Expand Down
Loading

0 comments on commit 0160654

Please sign in to comment.