Skip to content

Commit

Permalink
Merge remote-tracking branch 'nja/refactor' into refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Nov 18, 2020
2 parents 28c249d + 578de15 commit 7b5d46e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -37,18 +37,20 @@ 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
```

### 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
Expand Down
1 change: 0 additions & 1 deletion ROSCO_toolbox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ROSCO_toolbox/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'])
Expand Down
Empty file added ofTools/__init__.py
Empty file.
29 changes: 22 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from numpy.distutils.command.build_ext import build_ext
from numpy.distutils.core import setup, Extension

import multiprocessing
import multiprocessing as mp
from distutils.core import run_setup
from setuptools import find_packages
from numpy.distutils.command.build_ext import build_ext
Expand Down Expand Up @@ -65,7 +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):
Expand All @@ -91,12 +91,27 @@ 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)

cmake_args = ['-DBUILD_SHARED_LIBS=OFF']
cmake_args += ['-DCMAKE_Fortran_FLAGS=-ffree-line-length-0']

if platform.system() == 'Windows':
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)
# Need fresh build directory for CMake
os.makedirs(self.build_temp, exist_ok=True)

# Build
self.spawn(['cmake', '-S', ext.sourcedir, '-B', localdir])
self.spawn(['cmake', '--build', localdir])
self.spawn(['cmake', '-S', ext.sourcedir, '-B', self.build_temp] + cmake_args)
self.spawn(['cmake', '--build', self.build_temp, '--target', 'install', '--config', 'Release'])

else:
super().build_extension(ext)
Expand Down Expand Up @@ -168,7 +183,7 @@ def run(self):


metadata = dict(
name = 'ROSCO_toolbox',
name = NAME,
version = about['__version__'],
description = DESCRIPTION,
long_description = long_description,
Expand Down

0 comments on commit 7b5d46e

Please sign in to comment.