Skip to content

Commit f6d3279

Browse files
committed
Isolate neural net, make running optional
1 parent eef6bdd commit f6d3279

File tree

9 files changed

+67
-52
lines changed

9 files changed

+67
-52
lines changed

Examples/34_AEPS_Simulation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def main():
5252

5353
# Input yaml and output directory
5454
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW_AEPS.yaml')
55-
run_dir = os.path.join(example_out_dir,'34_AEPS_Simulation/4_name_changes')
55+
run_dir = os.path.join(example_out_dir,'34_AEPS_Simulation/9_sweep_lim')
5656
os.makedirs(run_dir,exist_ok=True)
5757

5858
# Read initial input file
@@ -67,9 +67,12 @@ def main():
6767
# Set DISCON input dynamically through yaml/dict
6868
controller_params = {}
6969
# controller_params['PS_Mode'] = 3 # review this
70+
controller_params['ps_percent'] = .95
7071
controller_params['ASO_Mode'] = 1
7172
controller_params['PA_Mode'] = 2
72-
controller_params['VS_ControlMode'] = 2.
73+
controller_params['VS_ControlMode'] = 2
74+
controller_params['DISCON'] = {}
75+
controller_params['DISCON']['ASO_ThrustGain'] = 0.4
7376

7477
# simulation set up
7578
r = run_FAST_ROSCO()
@@ -85,16 +88,16 @@ def main():
8588
# Run with and without AEPS algorithm
8689
r.control_sweep_fcn = cl.sweep_yaml_input
8790
r.control_sweep_opts = {
88-
'control_param':'ASO_Mode',
89-
'param_values': [0,1] #Run with ASO mode equal to 0 and 1, respectively.
91+
'control_param':'eps_percent',
92+
'param_values': [0.7, 0.8, 0.9, 1.0] #Run with ASO mode equal to 0 and 1, respectively.
9093
}
9194

9295
r.controller_params = controller_params
9396
r.save_dir = run_dir
9497
r.rosco_dir = rosco_dir
9598
r.case_inputs = {}
9699
# r.rosco_dll = "C:/Users/musah/ROSCO/rosco/controller/build/libdiscon.dll"
97-
r.n_cores = 2
100+
r.n_cores = 4
98101
r.run_FAST()
99102

100103

rosco/controller/rosco_registry/rosco_types.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ ControlParameters:
635635
ASO_ThrustLim:
636636
<<: *real
637637
description: AEPS Pre-Defined Thrust Limit [MN]
638+
ASO_UseNN:
639+
<<: *integer
640+
description: AEPS Use Neural Network for thrust estimation {0- No, 1- Yes}
638641

639642
# Open-loop Control
640643
OL_Filename:

rosco/controller/src/ControllerBlocks.f90

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,15 @@ SUBROUTINE AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData
248248

249249
ENDIF
250250

251-
! NOTE: Calculation of the Thrust (Estimate) of the controlled turbine is realized under the subroutine of WindSpeedEstimator
251+
! NOTE: Calculation of the Thrust (Estimate) of the controlled turbine is realized under the subroutine of WindSpeedEstimator
252252

253-
! Adaptive EPS Algorithm Starts from Here
253+
! Adaptive EPS Algorithm Starts from Here
254254

255-
P = 0.5 / CntrPar%Kc ! Solution of Lyapunov Equation (-K)'*P+P*(-K)=-I
255+
LocalVar%ASO_PitchOffset = 0.0_DbKi ! Initialize the extra pitch angle output
256+
257+
if (CntrPar%ASO_UseNN > 0) THEN
258+
259+
P = 0.5 / CntrPar%Kc ! Solution of Lyapunov Equation (-K)'*P+P*(-K)=-I
256260

257261
! Kronecker product calculation (del = D1 ⊗ D2)
258262
bias = 1.0
@@ -272,7 +276,7 @@ SUBROUTINE AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData
272276
del((i-1)*2 + j) = 1.0_DbKi / (1.0_DbKi + exp(-del((i-1)*2 + j)))
273277
end do
274278
end do
275-
279+
276280
! Compute the Derivative of Weight
277281
do i = 1, n
278282
dWeght_dt(i) = CntrPar%gamma * (del(i) * LocalVar%T_err * P - CntrPar%ke * Weght(i) * abs(LocalVar%T_err))
@@ -288,7 +292,7 @@ SUBROUTINE AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData
288292

289293
! Compute the Derivative of Thrust estimate (ASO_ThrustNN)
290294
Thrst_es_dt = a_s * LocalVar%ASO_ThrustNN + b_s * LocalVar%We_Vw + LocalVar%Delta + CntrPar%Kc * LocalVar%T_err
291-
295+
292296
! Update ASO_ThrustNN using Euler's method
293297
LocalVar%ASO_ThrustNN = LocalVar%ASO_ThrustNN + Thrst_es_dt * LocalVar%DT !ASO_ThrustNN in Mega Newton
294298
LocalVar%Thrst_esN=LocalVar%ASO_ThrustNN * (10**6) !ASO_ThrustNN in Newton
@@ -298,40 +302,11 @@ SUBROUTINE AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData
298302

299303
! Calculate the Adaptation
300304
LocalVar%Adp = LocalVar%Delta + CntrPar%Kc * LocalVar%T_err
301-
305+
302306
! Calculate the Derivative of Thrust Estimate
303307
Pre_Thrst_es = LocalVar%ASO_ThrustNN - Thrst_es_dt * LocalVar%DT
304308
LocalVar%Tdot = (LocalVar%ASO_ThrustNN - Pre_Thrst_es) / LocalVar%DT
305309

306-
if (CntrPar%ASO_Mode == 0) then
307-
LocalVar%ASO_PitchOffset = 0
308-
309-
else if (CntrPar%ASO_Mode == 1 .and. LocalVar%time >= CntrPar%ASO_StartTime) then
310-
311-
! Detecting the Excessive Thrust Force and Generating Extra Blade Pitch Output
312-
!if (LocalVar%We_Vw - LocalVar%Uenv >= 0) then
313-
if (LocalVar%We_Vw - LocalVar%Uenv >= -CntrPar%Um) then
314-
!LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * (LocalVar%We_Vw - LocalVar%Uenv)
315-
LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * abs(LocalVar%We_Vw - (LocalVar%Uenv-CntrPar%Um))
316-
317-
else
318-
LocalVar%ASO_PitchOffset = 0
319-
end if
320-
321-
else if (CntrPar%ASO_Mode == 2) then
322-
323-
if (LocalVar%ASO_ThrustEst - CntrPar%ASO_ThrustLim >= -CntrPar%Tm*CntrPar%ASO_ThrustLim) then
324-
LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * abs(LocalVar%ASO_ThrustEst - (CntrPar%ASO_ThrustLim-CntrPar%Tm*CntrPar%ASO_ThrustLim))
325-
else
326-
LocalVar%ASO_PitchOffset = 0
327-
end if
328-
329-
else if (CntrPar%ASO_Mode == 3) then
330-
331-
print *, "Design ASCOS system"
332-
333-
end if
334-
335310
! Envelope wind speed calculation
336311
Es = 0.01 ! Uenv tolerance
337312
LocalVar%Uold = LocalVar%Uenv
@@ -345,7 +320,30 @@ SUBROUTINE AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData
345320
LocalVar%Uold = LocalVar%Uenv
346321
m = m + 1
347322

348-
end do
323+
end do
324+
325+
if (LocalVar%time >= CntrPar%ASO_StartTime) then
326+
327+
! Detecting the Excessive Thrust Force and Generating Extra Blade Pitch Output
328+
!if (LocalVar%We_Vw - LocalVar%Uenv >= 0) then
329+
if (LocalVar%We_Vw - LocalVar%Uenv >= -CntrPar%Um) then
330+
!LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * (LocalVar%We_Vw - LocalVar%Uenv)
331+
LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * abs(LocalVar%We_Vw - (LocalVar%Uenv-CntrPar%Um))
332+
333+
endif
334+
endif
335+
336+
else ! Use plain thrust esimate from WSE
337+
338+
if ((LocalVar%time >= CntrPar%ASO_StartTime) .AND. (LocalVar%ASO_ThrustEst > CntrPar%ASO_ThrustLim * (1 - CntrPar%Tm))) then
339+
LocalVar%ASO_PitchOffset = CntrPar%ASO_ThrustGain * abs(LocalVar%ASO_ThrustEst - (CntrPar%ASO_ThrustLim-CntrPar%Tm*CntrPar%ASO_ThrustLim))
340+
else
341+
LocalVar%ASO_PitchOffset = 0
342+
end if
343+
344+
endif
345+
346+
349347

350348
! Adaptive EPS Algorithm Ends Here
351349

rosco/controller/src/DISCON.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,16 @@ SUBROUTINE DISCON(avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG) BIND (C, NAME
107107
CALL Shutdown(LocalVar, CntrPar, objInst,ErrVar)
108108
ENDIF
109109
CALL WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar, ErrVar)
110+
IF (CntrPar%ASO_Mode > 0) THEN
111+
CALL AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData, DebugVar, ErrVar)
112+
END IF
110113
CALL PowerControlSetpoints(CntrPar, LocalVar, objInst, DebugVar, ErrVar) ! Everything before the pitch, torque set points are computeed
111114
IF (CntrPar%SU_Mode > 0) THEN
112115
CALL Startup(LocalVar, CntrPar, objInst,ErrVar)
113116
ENDIF
114117
CALL ComputeVariablesSetpoints(CntrPar, LocalVar, objInst, DebugVar, ErrVar)
115118
CALL StateMachine(CntrPar, LocalVar)
116119
CALL SetpointSmoother(LocalVar, CntrPar, objInst)
117-
CALL AdaptiveEnvelopeProtectionSystem(LocalVar, CntrPar, objInst, PerfData, DebugVar, ErrVar)
118120
CALL VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst, ErrVar)
119121
IF (CntrPar%PC_ControlMode > 0) THEN
120122
CALL PitchControl(avrSWAP, CntrPar, LocalVar, objInst, DebugVar, ErrVar)

rosco/controller/src/ROSCO_IO.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! ROSCO IO
2-
! This file is automatically generated by write_registry.py using ROSCO v2.9.7
2+
! This file is automatically generated by write_registry.py using ROSCO v2.10.1
33
! For any modification to the registry, please edit the rosco_types.yaml accordingly
44

55
MODULE ROSCO_IO

rosco/controller/src/ROSCO_Types.f90

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
! ROSCO Registry
2-
! This file is automatically generated by write_registry.py using ROSCO v2.9.7
2+
! This file is automatically generated by write_registry.py using ROSCO v2.10.1
33
! For any modification to the registry, please edit the rosco_types.yaml accordingly
44

55
MODULE ROSCO_Types
66
USE, INTRINSIC :: ISO_C_Binding
77
USE Constants
88
IMPLICIT NONE
99

10-
Character(*), PARAMETER :: rosco_version = '2.9.7' ! ROSCO version
10+
Character(*), PARAMETER :: rosco_version = '2.10.1' ! ROSCO version
1111

1212
TYPE, PUBLIC :: ControlParameters
1313
INTEGER(IntKi) :: ZMQ_ID ! 0000 - 9999, Identifier of the rosco, used for zeromq interface only
@@ -169,9 +169,10 @@ MODULE ROSCO_Types
169169
REAL(DbKi) :: ke ! AEPS e-modification term gain
170170
REAL(DbKi) :: Um ! Wind margin for AEPS avoidance
171171
REAL(DbKi) :: Tm ! Thrust margin for BEBS avoidance [%]
172-
REAL(DbKi) :: ASO_ThrustGain ! AEPS/BEPS design parameter for effective avoidance
173-
REAL(DbKi) :: ASO_StartTime ! AEPS activation time for avoidance
174-
REAL(DbKi) :: ASO_ThrustLim ! AEPS Pre-Defined Thrust Limit [MN]
172+
REAL(DbKi) :: ASO_ThrustGain ! AEPS/BEPS design parameter for effective avoidance
173+
REAL(DbKi) :: ASO_StartTime ! AEPS activation time for avoidance
174+
REAL(DbKi) :: ASO_ThrustLim ! AEPS Pre-Defined Thrust Limit [MN]
175+
INTEGER(IntKi) :: ASO_UseNN ! AEPS Use Neural Network for thrust estimation {0- No, 1- Yes}
175176
CHARACTER(1024) :: OL_Filename ! Input file with open loop timeseries
176177
INTEGER(IntKi) :: OL_Mode ! Open loop control mode {0 - no open loop control, 1 - open loop control vs. time, 2 - open loop control vs. wind speed}
177178
INTEGER(IntKi) :: OL_BP_Mode ! Open loop control mode {0 - no open loop control, 1 - open loop control vs. time, 2 - open loop control vs. wind speed}
@@ -332,17 +333,17 @@ MODULE ROSCO_Types
332333
REAL(DbKi) :: HorWindV_F ! Filtered hub height wind speed m/s
333334
REAL(DbKi) :: rootMOOP(3) ! Blade root bending moment [Nm]
334335
REAL(DbKi) :: rootMOOPF(3) ! Filtered Blade root bending moment [Nm]
335-
REAL(DbKi) :: ASO_ThrustEst ! Turbine Thrust Force [MN]
336+
REAL(DbKi) :: ASO_ThrustEst ! Turbine Thrust Force [MN]
336337
REAL(DbKi) :: ThrstN ! Turbine Thrust Force [N]
337-
REAL(DbKi) :: ASO_ThrustNN ! Estimated Turbine Thrust Force by Adaptive EPS System [MN]
338+
REAL(DbKi) :: ASO_ThrustNN ! Estimated Turbine Thrust Force by Adaptive EPS System [MN]
338339
REAL(DbKi) :: Thrst_esN ! Estimated Turbine Thrust Force by Adaptive EPS System [N]
339340
REAL(DbKi) :: T_err ! Error between Thrust Force and Its Estimation
340341
REAL(DbKi) :: Tdot ! Thrust Derivative
341342
REAL(DbKi) :: Adp ! Adaptation
342343
REAL(DbKi) :: Uenv ! Envelope Wind Speed [m/s]
343344
REAL(DbKi) :: Uold ! Previous Envelope Wind Speed [m/s]
344345
REAL(DbKi) :: Delta ! Delta
345-
REAL(DbKi) :: ASO_PitchOffset ! Extra Blade Pitch Angle, an Avoidance Signal generated by Adaptive EPS System
346+
REAL(DbKi) :: ASO_PitchOffset ! Extra Blade Pitch Angle, an Avoidance Signal generated by Adaptive EPS System
346347
REAL(DbKi) :: BlPitch(3) ! Blade pitch [rad]
347348
REAL(DbKi) :: BlPitchCMeas ! Mean (collective) blade pitch [rad]
348349
REAL(DbKi) :: Azimuth ! Rotor aziumuth angle [rad]

rosco/controller/src/ReadSetParameters.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ SUBROUTINE ReadControlParameterFileSub(CntrPar, LocalVar, accINFILE, accINFILE_s
508508
CALL ParseInput(FileLines, 'ke', CntrPar%ke, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
509509
CALL ParseInput(FileLines, 'Um', CntrPar%Um, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
510510
CALL ParseInput(FileLines, 'Tm', CntrPar%Tm, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
511+
CALL ParseInput(FileLines, 'ASO_UseNN', CntrPar%ASO_UseNN, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
511512
CALL ParseInput(FileLines, 'ASO_ThrustGain', CntrPar%ASO_ThrustGain, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
512513
CALL ParseInput(FileLines, 'ASO_StartTime', CntrPar%ASO_StartTime, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)
513514
CALL ParseInput(FileLines, 'ASO_ThrustLim', CntrPar%ASO_ThrustLim, accINFILE(1), ErrVar, CntrPar%ASO_Mode == 0, UnEc)

rosco/toolbox/inputs/toolbox_schema.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,12 @@ properties:
13771377
type: string
13781378
description: Name of procedure in DLL to be called
13791379
default: DISCON
1380+
ASO_UseNN:
1381+
type: number
1382+
description: Use neural net to estimate thrust (0 - no, 1 - yes)
1383+
minimum: 0
1384+
maximum: 1
1385+
default: 0
13801386
PF_Offsets:
13811387
type: array
13821388
items:

rosco/toolbox/utilities.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
212212
file.write('{:<14.5e} ! gamma - AEPS Learning Rate\n'.format(rosco_vt['gamma']))
213213
file.write('{:<14.5e} ! ke - AEPS e-modification term gain\n'.format(rosco_vt['ke']))
214214
file.write('{:<14.5e} ! Um - Wind margin for AEPS avoidance\n'.format(rosco_vt['Um']))
215-
file.write('{:<14.5e} ! Tm - Thrust margin for BEBS avoidance [%]\n'.format(rosco_vt['Tm']))
215+
file.write('{:<14.5f} ! Tm - Fraction to reduce thrust margin [-]\n'.format(rosco_vt['Tm']))
216+
file.write('{:<11d} ! ASO_UseNN - {}\n'.format(rosco_vt['ASO_UseNN'], input_descriptions['ASO_UseNN']))
216217
file.write('{:<14.5e} ! ASO_ThrustGain - AEPS/BEPS design parameter for effective avoidance\n'.format(rosco_vt['ASO_ThrustGain']))
217218
file.write('{:<14.5e} ! ASO_StartTime - AEPS activation time for avoidance\n'.format(rosco_vt['ASO_StartTime']))
218219
file.write('{:<14.5e} ! ASO_ThrustLim - Pre-Defined Thrust Limit [MN]\n'.format(rosco_vt['ASO_ThrustLim']))

0 commit comments

Comments
 (0)