From e5b1af5383757f4ad1b98ab36a1e7093b51b8365 Mon Sep 17 00:00:00 2001 From: dzalkind <65573423+dzalkind@users.noreply.github.com> Date: Fri, 9 Jun 2023 14:31:18 -0600 Subject: [PATCH] Yaw Rate Bug Fix (#239) * Add back open loop yaw rate control * Check OL outputs in example * Update CI to use mamba, first attempt * Install extras when environment first set up * Remove potential libpython typo * Remove more potential typos * Use mamba in compile, too * Use environment.yml file * Remove conda installs from rosco-compile * Clean up CI scripts * Update mamba install in CI * Remove petsc and mpi * Revert CI back to conda --- Examples/14_open_loop_control.py | 16 ++++++++++++++++ ROSCO/src/Controllers.f90 | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/Examples/14_open_loop_control.py b/Examples/14_open_loop_control.py index 7ca79462..cbc20f5d 100644 --- a/Examples/14_open_loop_control.py +++ b/Examples/14_open_loop_control.py @@ -145,6 +145,22 @@ fastout = op.load_fast_out(out_file, tmin=0) fig, ax = op.plot_fast_out(cases=cases,showplot=False) +# Check that open loop commands are close to control outputs from OpenFAST +fo = fastout[0] +tt = fo['Time'] +valid_ind = tt > 2 # first few timesteps can differ, depending on OpenFAST solve config + +# Computer errors +nacelle_yaw_diff = fo['NacYaw'][valid_ind] - np.degrees(np.interp(tt[valid_ind],olc.ol_timeseries['time'],olc.ol_timeseries['nacelle_yaw'])) +bld_pitch_diff = fo['BldPitch1'][valid_ind] - np.degrees(np.interp(tt[valid_ind],olc.ol_timeseries['time'],olc.ol_timeseries['blade_pitch'])) +gen_tq_diff = fo['GenTq'][valid_ind] - np.interp(tt[valid_ind],olc.ol_timeseries['time'],olc.ol_timeseries['generator_torque'])/1e3 + +# Check diff timeseries +np.testing.assert_allclose(nacelle_yaw_diff, 0, atol = 1e-1) # yaw has dynamics and integration error, tolerance higher +np.testing.assert_allclose(bld_pitch_diff, 0, atol = 1e-3) +np.testing.assert_allclose(gen_tq_diff, 0, atol = 1e-3) + + if False: plt.show() else: diff --git a/ROSCO/src/Controllers.f90 b/ROSCO/src/Controllers.f90 index 221dd16b..c8a73e35 100644 --- a/ROSCO/src/Controllers.f90 +++ b/ROSCO/src/Controllers.f90 @@ -371,6 +371,14 @@ SUBROUTINE YawRateControl(avrSWAP, CntrPar, LocalVar, objInst, zmqVar, DebugVar, ! Output yaw rate command in rad/s avrSWAP(48) = YawRateCom * D2R + ! If using open loop yaw rate control, overwrite controlled output + ! Open loop torque control + IF ((CntrPar%OL_Mode == 1) .AND. (CntrPar%Ind_YawRate > 0)) THEN + IF (LocalVar%Time >= CntrPar%OL_Breakpoints(1)) THEN + avrSWAP(48) = interp1d(CntrPar%OL_Breakpoints,CntrPar%OL_YawRate,LocalVar%Time, ErrVar) + ENDIF + ENDIF + ! Save for debug DebugVar%YawRateCom = YawRateCom DebugVar%NacHeadingTarget = NacHeadingTarget