From be59f685a883abc679ca660275903a24caced644 Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Thu, 12 Nov 2020 16:10:07 -0700 Subject: [PATCH 1/8] cleanup --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7f1c35081..43f9f259b 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,11 @@ Here is a short (but _hopefully_ sweet) installation and run process for basic c ### Installing the complete ROSCO Toolbox In order to fully leverage the controller tuning capabilities, [WISDEM](https://github.com/WISDEM/WISDEM) is used. This is made available through installation via [Anaconda](https://www.anaconda.com/). If you do not already have Anaconda installed on your machine, it is recommended that you install it to install WISDEM. Alternatively, you can install wisdem following the ``for developer'' instructions on the WISDEM home page and skip to step 2 here. -If you do not have WISDEM or the ROSCO toolbox installed and would like to install WISDEM, the ROSCO toolbox, and compile the controller on your unix machine please do the following: open your terminal, navigate to the folder of your choosing, and copy and paste the below text into the command line. This code block is broken up in a piece-wise description in the following sections. +If you do not have WISDEM or the ROSCO toolbox installed and would like to install WISDEM, the ROSCO toolbox, and compile the controller please do the following: open your terminal or command prompt, navigate to the folder of your choosing, and enter the below text into the command line. This code block is broken up in a piece-wise description in the following sections. 1. #### Install WISDEM ``` conda config --add channels conda-forge - conda create -y --name rosco-env python=3.7 + conda create -y --name rosco-env python=3.8 conda activate rosco-env conda install -y wisdem ``` @@ -41,14 +41,14 @@ If you do not have WISDEM or the ROSCO toolbox installed and would like to insta ``` ### Alternatively... -If you wish to write your own scripts to leaverage the ROSCO toolbox tools, but do not necessarily need the source code or to run any of the examples, the ROSCO toolbox is available via PyPi: +If you wish to write your own scripts to leverage the ROSCO toolbox tools, but do not necessarily need the source code or to run any of the examples, the ROSCO toolbox is available via PyPi: ``` pip install rosco_toolbox ``` Note that if you do choose to install the ROSCO Toolbox this way, you will not have the source code. Additionally, you will need to download WISDEM and the ROSCO controller separately if you wish to use any of the ROSCO toolbox functionalities that need those software packages. #### Compiling ROSCO -The controller itself is installed as a submodule in the ROSCO toolbox. For further information on compiling and running ROSCO itself, especially if you are on a Windows machine, we point you to the [ROSCO github page](https://github.com/NREL/ROSCO_toolbox.git). If you wish to re-compile the ROSOCO toolbox, cmake provides easy to compiling on Unix based systems. In order to compile the controller, you should run the following commands from the ROSCO_toolbox folder. +The controller itself is installed as a submodule in the ROSCO toolbox. For further information on compiling and running ROSCO itself, or to download the release binaries directly, we point you to the [ROSCO github page](https://github.com/NREL/ROSCO_toolbox.git). If you wish to re-compile the ROSOCO toolbox, cmake provides easy to compiling on Unix based systems. In order to compile the controller, you should run the following commands from the ROSCO_toolbox folder. ``` cd ROSCO mkdir build From 0f5a8dfa5e357a0849de9b3ee9386105bacef670 Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Thu, 12 Nov 2020 16:10:16 -0700 Subject: [PATCH 2/8] Update for ROSCO on windows --- setup.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/setup.py b/setup.py index f4290791d..d0cec7031 100644 --- a/setup.py +++ b/setup.py @@ -98,6 +98,23 @@ def build_extension(self, ext): self.spawn(['cmake', '-S', ext.sourcedir, '-B', localdir]) self.spawn(['cmake', '--build', localdir]) + + if platform.system() == 'Windows': + cmake_args += ['-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE'] + + if self.compiler.compiler_type == 'msvc': + cmake_args += ['-DCMAKE_GENERATOR_PLATFORM=x64'] + else: + cmake_args += ['-G', 'MinGW Makefiles'] + + self.build_temp += '_'+ext.name + os.makedirs(localdir, exist_ok=True) + # Need fresh build directory for CMake + os.makedirs(self.build_temp, exist_ok=True) + + self.spawn(['cmake', '-S', ext.sourcedir, '-B', self.build_temp] + cmake_args) + self.spawn(['cmake', '--build', self.build_temp, '-j', str(ncpus), '--target', 'install', '--config', 'Release']) + else: super().build_extension(ext) From 45ceb01ebf63b4bfed3afef43940dc983f9f7898 Mon Sep 17 00:00:00 2001 From: nikhar-abbas Date: Thu, 12 Nov 2020 20:09:05 -0700 Subject: [PATCH 3/8] Fix ROSCO compiling bugs on windows --- setup.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index d0cec7031..12f682776 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,6 @@ from numpy.distutils.command.build_ext import build_ext from numpy.distutils.core import setup, Extension -import multiprocessing from distutils.core import run_setup from setuptools import find_packages from numpy.distutils.command.build_ext import build_ext @@ -65,7 +64,6 @@ # For the CMake Extensions this_directory = os.path.abspath(os.path.dirname(__file__)) - class CMakeExtension(Extension): def __init__(self, name, sourcedir='', **kwa): @@ -91,21 +89,19 @@ def build_extension(self, ext): raise RuntimeError('Cannot find CMake executable') # Refresh build directory - localdir = os.path.join(this_directory, 'ROSCO','build') + localdir = os.path.join(this_directory, 'ROSCO','install') os.makedirs(localdir, exist_ok=True) - # Build - self.spawn(['cmake', '-S', ext.sourcedir, '-B', localdir]) - self.spawn(['cmake', '--build', localdir]) - + cmake_args = ['-DBUILD_SHARED_LIBS=OFF'] + cmake_args += ['-DCMAKE_Fortran_FLAGS=-ffree-line-length-0'] if platform.system() == 'Windows': - cmake_args += ['-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE'] - + cmake_args += ['-DCMAKE_INSTALL_PREFIX={}'.format(localdir)] if self.compiler.compiler_type == 'msvc': cmake_args += ['-DCMAKE_GENERATOR_PLATFORM=x64'] else: cmake_args += ['-G', 'MinGW Makefiles'] + cmake_args += ['-D', 'CMAKE_Fortran_COMPILER=gfortran'] self.build_temp += '_'+ext.name os.makedirs(localdir, exist_ok=True) @@ -113,7 +109,7 @@ def build_extension(self, ext): os.makedirs(self.build_temp, exist_ok=True) self.spawn(['cmake', '-S', ext.sourcedir, '-B', self.build_temp] + cmake_args) - self.spawn(['cmake', '--build', self.build_temp, '-j', str(ncpus), '--target', 'install', '--config', 'Release']) + self.spawn(['cmake', '--build', self.build_temp, '--target', 'install', '--config', 'Release']) else: super().build_extension(ext) @@ -185,7 +181,7 @@ def run(self): metadata = dict( - name = 'NAME', + name = NAME, version = about['__version__'], description = DESCRIPTION, long_description = long_description, From 21acfd64847b1df905bd451af4ea775713bf9aa9 Mon Sep 17 00:00:00 2001 From: nikhar-abbas Date: Thu, 12 Nov 2020 20:41:10 -0700 Subject: [PATCH 4/8] remove multiprocessing --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 12f682776..6873e7f95 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ from numpy.distutils.command.build_ext import build_ext from numpy.distutils.core import setup, Extension +import multiprocessing as mp from distutils.core import run_setup from setuptools import find_packages from numpy.distutils.command.build_ext import build_ext @@ -64,6 +65,7 @@ # For the CMake Extensions this_directory = os.path.abspath(os.path.dirname(__file__)) +ncpus = mp.cpu_count() class CMakeExtension(Extension): def __init__(self, name, sourcedir='', **kwa): From f9e356a246cae46da22e9b0ac2e53453ddc7dd23 Mon Sep 17 00:00:00 2001 From: nikhar-abbas Date: Thu, 12 Nov 2020 20:41:28 -0700 Subject: [PATCH 5/8] add compiler install instructions --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 43f9f259b..5f4dd9d18 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ If you do not have WISDEM or the ROSCO toolbox installed and would like to insta cd ROSCO_toolbox git submodule init git submodule update + conda install compilers # (Mac/Linux only) + conda install m2w64-toolchain libpython # (Windows only) python setup.py install ``` From 873108c2b25d943b664c423f47e6c7324281375f Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Fri, 13 Nov 2020 13:01:48 -0700 Subject: [PATCH 6/8] add init --- ofTools/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ofTools/__init__.py diff --git a/ofTools/__init__.py b/ofTools/__init__.py new file mode 100644 index 000000000..e69de29bb From abf83fc0694b45577a9879fd7f6fd0892956d3cc Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Fri, 13 Nov 2020 13:46:10 -0700 Subject: [PATCH 7/8] Remove wisdem import --- ROSCO_toolbox/controller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ROSCO_toolbox/controller.py b/ROSCO_toolbox/controller.py index 64b473221..ebafca715 100644 --- a/ROSCO_toolbox/controller.py +++ b/ROSCO_toolbox/controller.py @@ -12,7 +12,6 @@ import numpy as np import sys import datetime -from wisdem.ccblade import CCAirfoil, CCBlade from scipy import interpolate, gradient, integrate # Some useful constants From 578de15ad668d463c584fec2808641292f98df94 Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Fri, 13 Nov 2020 13:46:20 -0700 Subject: [PATCH 8/8] Only load ccblade if needed --- ROSCO_toolbox/turbine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ROSCO_toolbox/turbine.py b/ROSCO_toolbox/turbine.py index 91de9ab92..696705e65 100644 --- a/ROSCO_toolbox/turbine.py +++ b/ROSCO_toolbox/turbine.py @@ -12,7 +12,6 @@ import os import numpy as np import datetime -from wisdem.ccblade import CCAirfoil, CCBlade from scipy import interpolate from numpy import gradient import pickle @@ -249,6 +248,8 @@ def load_from_ccblade(self): Dictionary containing fast model details - defined using from InputReader_OpenFAST (distributed as a part of AeroelasticSE) ''' + from wisdem.ccblade import CCAirfoil, CCBlade + print('Loading rotor performance data from CC-Blade.') # Load blade information if it isn't already @@ -499,6 +500,7 @@ def load_blade_info(self): self - note: needs to contain fast input file info provided by load_from_fast. ''' from ofTools.fast_io.FAST_reader import InputReader_OpenFAST + from wisdem.ccblade import CCAirfoil, CCBlade # Create CC-Blade Rotor r0 = np.array(self.fast.fst_vt['AeroDynBlade']['BlSpn'])