Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #96

Merged
merged 27 commits into from
Mar 19, 2021
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
20 changes: 10 additions & 10 deletions .github/workflows/CI_WEIS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,47 @@ jobs:
# Install dependencies of WEIS specific to ubuntu
- name: Add dependencies ubuntu specific
if: false == contains( matrix.os, 'windows')
shell: pwsh
shell: bash
# (if you use the shell here, cannot use 'compiler' package otherwise get link problems to system libraries
# Mpi only seems to work with the shell command though, so instead rely on system compilers
run: |
conda install -y petsc4py mpi4py openmpi==4.0.5
conda install -y petsc4py mpi4py openmpi
python -c "import platform; print(platform.node())"

# Install dependencies of WISDEM specific to windows
- name: Add dependencies windows specific
if: contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython

# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

# Install WISDEM
- name: Install WEIS
shell: pwsh
shell: bash
run: |
python setup.py develop

# List the collected tests for debugging purposes
- name: List tests
shell: pwsh
shell: bash
run: |
pytest weis --collect-only

# Run all tests within WEIS, but not computationally expensive examples
- name: Run tests within WEIS
shell: pwsh
shell: bash
run: |
pytest weis --cov-config=.coverageac --cov=weis

# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

# Run coveralls
- name: Run coveralls
if: contains( matrix.os, 'ubuntu')
# This also works, https://github.com/AndreMiras/coveralls-python-action
#uses: AndreMiras/coveralls-python-action@develop
shell: pwsh
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/run_exhaustive_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
# Install dependencies of WEIS specific to ubuntu
- name: Add dependencies ubuntu specific
if: false == contains( matrix.os, 'windows')
shell: pwsh
shell: bash
# (if you use the shell here, cannot use 'compiler' package otherwise get link problems to system libraries
# Mpi only seems to work with the shell command though, so instead rely on system compilers
run: |
conda install -y petsc4py mpi4py openmpi==4.0.5
conda install -y petsc4py mpi4py openmpi
python -c "import platform; print(platform.node())"

# Install dependencies of WISDEM specific to windows
Expand All @@ -59,26 +59,26 @@ jobs:
run: |
conda install -y m2w64-toolchain libpython

# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

# Install WISDEM
- name: Install WEIS
shell: pwsh
shell: bash
run: |
python setup.py develop

# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

# Run all examples
- name: Run tests within WEIS
shell: pwsh
shell: bash
run: |
cd weis/test
pytest run_examples.py
python run_examples.py

# Run scripts within rotor_opt folder with MPI
- name: Run parallel examples rotor optimization
shell: pwsh
shell: bash
run: |
cd examples/05_IEA-3.4-130-RWT
mpirun -np 2 python weis_driver.py
Expand All @@ -91,7 +91,7 @@ jobs:

# Run scripts within design of experiments folder
- name: Run examples design of experiments
shell: pwsh
shell: bash
run: |
cd examples/09_design_of_experiments
mpirun -np 2 python DOE_openfast.py
Expand Down
8 changes: 8 additions & 0 deletions ROSCO/src/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)
! WE_Mode = 0, Filter hub height wind speed as passed from servodyn using first order low pass filter with 1Hz cornering frequency
! WE_Mode = 1, Use Inversion and Inveriance filter as defined by Ortege et. al.
USE ROSCO_Types, ONLY : LocalVariables, ControlParameters, ObjectInstances, PerformanceData, DebugVariables
use ieee_arithmetic
IMPLICIT NONE

! Inputs
Expand Down Expand Up @@ -179,6 +180,13 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)
Cp_op = 0.25 ! initialize so debug output doesn't give *****

ELSE
IF (ieee_is_nan(v_h)) THEN
om_r = LocalVar%RotSpeedF
v_t = 0.0
v_m = LocalVar%HorWindV
v_h = LocalVar%HorWindV
ENDIF

! Find estimated operating Cp and system pole
A_op = interp1d(CntrPar%WE_FOPoles_v,CntrPar%WE_FOPoles,v_h)

Expand Down
7 changes: 4 additions & 3 deletions ROSCO/src/Functions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ REAL FUNCTION interp2d(xData, yData, zData, xq, yq)
! 5| d e f
! 6| g H i

use ieee_arithmetic
IMPLICIT NONE
! Inputs
REAL(8), DIMENSION(:), INTENT(IN) :: xData ! Provided x data (vector), to find query point (should be monotonically increasing)
Expand All @@ -215,7 +216,7 @@ REAL FUNCTION interp2d(xData, yData, zData, xq, yq)

! ---- Find corner indices surrounding desired interpolation point -----
! x-direction
IF (xq <= MINVAL(xData)) THEN ! On lower x-bound, just need to find zData(yq)
IF (xq <= MINVAL(xData) .OR. (ieee_is_nan(xq))) THEN ! On lower x-bound, just need to find zData(yq)
j = 1
jj = 1
interp2d = interp1d(yData,zData(:,j),yq)
Expand All @@ -241,7 +242,7 @@ REAL FUNCTION interp2d(xData, yData, zData, xq, yq)
ENDIF
j = j-1 ! Move j back one
! y-direction
IF (yq <= MINVAL(yData)) THEN ! On lower y-bound, just need to find zData(xq)
IF (yq <= MINVAL(yData) .OR. (ieee_is_nan(yq))) THEN ! On lower y-bound, just need to find zData(xq)
i = 1
ii = 1
interp2d = interp1d(xData,zData(i,:),xq)
Expand All @@ -266,7 +267,7 @@ REAL FUNCTION interp2d(xData, yData, zData, xq, yq)
END DO
ENDIF
i = i-1 ! move i back one

! ---- Do bilinear interpolation ----
! Find values at corners
fQ(1,1) = zData(i,j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ False Echo - Echo the input file data (flag)
1 WaveNDir - Number of wave directions (-) [only used when WaveMod=2,3, or 4 and WaveDirMod=1; odd number only]
90 WaveDirRange - Range of wave directions (full range: WaveDir +/- 1/2*WaveDirRange) (degrees) [only used when WaveMod=2,3,or 4 and WaveDirMod=1]
123456789 WaveSeed(1) - First random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
1011121314 WaveSeed(2) - Second random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
RANLUX WaveSeed(2) - Second random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
TRUE WaveNDAmp - Flag for normally distributed amplitudes (flag) [only used when WaveMod=2, 3, or 4]
"" WvKinFile - Root name of externally generated wave data file(s) (quoted string) [used only when WaveMod=5 or 6]
1 NWaveElev - Number of points where the incident wave elevations can be computed (-) [maximum of 9 output locations]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ False Echo - Echo the input file data (flag)
1 WaveNDir - Number of wave directions (-) [only used when WaveMod=2,3, or 4 and WaveDirMod=1; odd number only]
90 WaveDirRange - Range of wave directions (full range: WaveDir +/- 1/2*WaveDirRange) (degrees) [only used when WaveMod=2,3,or 4 and WaveDirMod=1]
-561580799 WaveSeed(1) - First random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
-1669871451 WaveSeed(2) - Second random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
RANLUX WaveSeed(2) - Second random seed of incident waves [-2147483648 to 2147483647] (-) [unused when WaveMod=0, 5, or 6]
TRUE WaveNDAmp - Flag for normally distributed amplitudes (flag) [only used when WaveMod=2, 3, or 4]
"none" WvKinFile - Root name of externally generated wave data file(s) (quoted string) [used only when WaveMod=5 or 6]
1 NWaveElev - Number of points where the incident wave elevations can be computed (-) [maximum of 9 output locations]
Expand Down
1 change: 0 additions & 1 deletion examples/03_NREL5MW_OC3_spar/modeling_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Level3: # Options for WEIS fidelity level 3 = nonlinear time domain
WvLowCOff: 0.15708
WvHiCOff: 3.2
WaveSeed1: 123456789
WaveSeed2: 1011121314
AddBLin3: [0.0, 0.0, 4389794.6, 0.0, 0.0, 0.0]
ROSCO:
flag: True
Expand Down
1 change: 0 additions & 1 deletion examples/04_NREL5MW_OC4_semi/modeling_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Level3: # Options for WEIS fidelity level 3 = nonlinear time domain
WvLowCOff: 0.15708
WvHiCOff: 3.2
WaveSeed1: 123456789
WaveSeed2: 1011121314
AddBLin3: [0.0, 0.0, 4389794.6, 0.0, 0.0, 0.0]
ROSCO:
flag: True
Expand Down
1 change: 0 additions & 1 deletion examples/06_IEA-15-240-RWT/modeling_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Level3: # Options for WEIS fidelity level 3 = nonlinear time domain
WvLowCOffD: 0.0
WvHiCOffD: 3.04292
WaveSeed1: 123456789
WaveSeed2: 1011121314
AddBLin3: [0.0, 0.0, 4389794.6, 0.0, 0.0, 0.0]
ROSCO:
flag: True
Expand Down
3 changes: 1 addition & 2 deletions examples/09_design_of_experiments/modeling_options_OF.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Level3: # Options for WEIS fidelity level 3 = nonlinear time domain
WvLowCOff: 0.15708
WvHiCOff: 3.2
WaveSeed1: 123456789
WaveSeed2: 1011121314
AddBLin3: [0.0, 0.0, 4389794.6, 0.0, 0.0, 0.0]
ROSCO:
flag: True
Expand All @@ -71,4 +70,4 @@ openfast:
IEC: # Currently supported: 1.1, 1.3, 1.4, 1.5, 5.1, 6.1, 6.3
- DLC: 1.1
U: [5., 13.]
Seeds: [1]
Seeds: [1]
34 changes: 17 additions & 17 deletions pCrunch/pCrunch/io/openfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def dataproperty(f):
@property
def wrapper(self, *args, **kwargs):
if getattr(self, "_data", None) is None:
if getattr(self, "data", None) is None:
raise AttributeError("Output has not been read yet.")
return f(self, *args, **kwargs)

Expand All @@ -27,7 +27,7 @@ class OpenFASTBase:
def __getitem__(self, chan):
try:
idx = np.where(self.channels == chan)[0][0]

except IndexError:
raise IndexError(f"Channel '{chan}' not found.")

Expand All @@ -54,22 +54,22 @@ def trim_data(self, tmin=0, tmax=np.inf):
Ending time.
"""

idx = np.where((self.time >= tmin) & (self.time <= tmax))
if tmin > max(self.time):
idx = np.where((self.time >= tmin) & (self.time <= tmax))[0]
if tmin > self.time.max():
raise ValueError(
f"Initial time '{tmin}' is after the end of the simulation."
)

self.data = self.data[idx]

@dataproperty
def data(self):
"""Returns output data at `self._data`."""
return self._data
self.data = self.data[idx,:]
#@dataproperty
#def data(self):
# """Returns output data at `self.data`."""
# return self.data

@data.setter
def data(self, data):
self._data = data
#@data.setter
#def data(self, data):
# self.data = data

@dataproperty
def time(self):
Expand All @@ -78,10 +78,10 @@ def time(self):
@time.setter
def time(self, time):
if "Time" in self.channels:
raise ValueError(f"'Time' channel already exists in output data.")
raise ValueError("'Time' channel already exists in output data.")

self.data = np.append(time, self.data, axis=1)
self.channels = np.append("Time", self.channels)
self.data = np.append(self.data, time, axis=1)
self.channels = np.append(self.channels, "Time")

def append_magnitude_channels(self):
"""
Expand Down Expand Up @@ -256,7 +256,7 @@ def __init__(self, data, channels, dlc, **kwargs):
data : np.ndarray
"""

self._data = data
self.data = data

if isinstance(channels, list):
self.channels = np.array(channels)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def build_extension(self, ext):
# Custom tuning
mycompiler = self.compiler.compiler[0]
if ci_flag:
tune = '-O0'
tune = '-O0 -g' #-ffpe-trap=invalid,zero,overflow,underflow

elif eagle_flag:
tune = '-xSKYLAKE-AVX512'
Expand Down
Loading