-
Notifications
You must be signed in to change notification settings - Fork 5
/
HHWind.f90
executable file
·617 lines (455 loc) · 26.6 KB
/
HHWind.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
MODULE HHWind
! This module contains all the data and procedures that define hub-height wind files. This could
! more accurately be called a point wind file since the wind speed at any point is calculated by
! shear applied to the point where wind is defined. It is basically uniform wind over the rotor disk.
! The entire file is read on initialization, then the columns that make up the wind file are
! interpolated to the time requested, and wind is calculated based on the location in space.
!
! the file contains header information (rows that contain "!"), followed by numeric data stored in
! 8 columns: (1) Time [s]
! (2) Horizontal wind speed (V) [m/s]
! (3) Wind direction (Delta) [deg]
! (4) Vertical wind speed (VZ) [m/s]
! (5) Horizontal linear shear (HLinShr) [-]
! (6) Vertical power-law shear (VShr) [-]
! (7) Vertical linear shear (VLinShr) [-]
! (8) Gust (horizontal) velocity (VGust) [m/s]
!
! The horizontal wind speed at (X, Y, Z) is then calculated using the interpolated columns by
! Vh = V * ( Z/RefHt ) ** VShr ! power-law wind shear
! + V * HLinShr/RefWid * ( Y * COS(Delta) + X * SIN(Delta) ) ! horizontal linear shear
! + V * VLinShr/RefWid * ( Z-RefHt ) ! vertical linear shear
! + VGust ! gust speed
!----------------------------------------------------------------------------------------------------
USE NWTC_Library
USE SharedInflowDefns
IMPLICIT NONE
PRIVATE
REAL(ReKi), ALLOCATABLE :: Tdata (:) ! Time array from the HH wind file
REAL(ReKi), ALLOCATABLE :: DELTA (:) ! HH Wind direction (angle)
REAL(ReKi), ALLOCATABLE :: V (:) ! HH horizontal wind speed
REAL(ReKi), ALLOCATABLE :: VZ (:) ! wind, including tower shadow, along the Z axis
REAL(ReKi), ALLOCATABLE :: HSHR (:) ! HH Horizontal linear shear
REAL(ReKi), ALLOCATABLE :: VSHR (:) ! HH vertical shear exponent
REAL(ReKi), ALLOCATABLE :: VLINSHR(:) ! HH vertical linear shear
REAL(ReKi), ALLOCATABLE :: VGUST (:) ! HH wind gust
REAL(ReKi) :: LinearizeDels(7) ! The delta values for linearization -- perhaps at some point, this could be T/F and we determine the deltas by sqrt(eps) or something similar
REAL(ReKi) :: RefHt ! reference height; was HH (hub height); used to center the wind
REAL(ReKi) :: RefWid ! reference width; was 2*R (=rotor diameter); used to scale the linear shear
INTEGER :: NumDataLines
INTEGER, SAVE :: TimeIndx = 0 ! An index into the Tdata array (to allow us faster searching, starting search from previous one)
LOGICAL, SAVE :: Linearize = .FALSE. ! If this is TRUE, we are linearizing
TYPE, PUBLIC :: HH_Info
REAL(ReKi) :: ReferenceHeight
REAL(ReKi) :: Width
END TYPE HH_Info
PUBLIC :: HH_Init
PUBLIC :: HH_GetWindSpeed
PUBLIC :: HH_Terminate
PUBLIC :: HH_SetLinearizeDels
PUBLIC :: HH_Get_ADhack_WindSpeed ! REMOVE THIS!!!!
CONTAINS
!====================================================================================================
SUBROUTINE HH_Init(UnWind, WindFile, WindInfo, ErrStat)
! A subroutine to initialize the HHWind module. It reads the HH file and stores the data in an
! array to use later. It requires an initial reference height (hub height) and width (rotor diameter),
! both in meters, which are used to define the volume where wind velocities will be calculated. This
! information is necessary because of the way the shears are defined.
!----------------------------------------------------------------------------------------------------
! Passed Variables:
INTEGER, INTENT(IN) :: UnWind ! unit number for reading wind files
INTEGER, INTENT(OUT) :: ErrStat ! determines if an error has been encountered
TYPE(HH_Info),INTENT(IN) :: WindInfo ! Additional information needed to initialize this wind type
CHARACTER(*), INTENT(IN) :: WindFile ! Name of the text HH wind file
! local variables
INTEGER, PARAMETER :: NumCols = 8 ! Number of columns in the HH file
REAL(ReKi) :: TmpData(NumCols) ! Temp variable for reading all columns from a line
REAL(ReKi) :: DelDiff ! Temp variable for storing the direction difference
INTEGER :: I
INTEGER :: NumComments
INTEGER :: ILine ! Counts the line number in the file
INTEGER, PARAMETER :: MaxTries = 100
CHARACTER(1024) :: Line ! Temp variable for reading whole line from file
!-------------------------------------------------------------------------------------------------
! Check that it's not already initialized
!-------------------------------------------------------------------------------------------------
IF ( TimeIndx /= 0 ) THEN
CALL WrScr( ' HHWind has already been initialized.' )
ErrStat = 1
RETURN
ELSE
ErrStat = 0
CALL NWTC_Init()
LinearizeDels(:) = 0.0
Linearize = .FALSE.
END IF
!-------------------------------------------------------------------------------------------------
! Open the file for reading
!-------------------------------------------------------------------------------------------------
CALL OpenFInpFile (UnWind, TRIM(WindFile), ErrStat)
IF ( ErrStat /= 0 ) RETURN
!-------------------------------------------------------------------------------------------------
! Find the number of comment lines
!-------------------------------------------------------------------------------------------------
LINE = '!' ! Initialize the line for the DO WHILE LOOP
NumComments = -1
DO WHILE (INDEX( LINE, '!' ) > 0 ) ! Lines containing "!" are treated as comment lines
NumComments = NumComments + 1
READ(UnWind,'( A )',IOSTAT=ErrStat) LINE
IF ( ErrStat /=0 ) THEN
CALL WrScr ( ' Error reading from HH wind file on line '//TRIM(Int2Lstr(NumComments))//'.' )
RETURN
END IF
END DO !WHILE
!-------------------------------------------------------------------------------------------------
! Find the number of data lines
!-------------------------------------------------------------------------------------------------
NumDataLines = 0
READ(LINE,*,IOSTAT=ErrStat) ( TmpData(I), I=1,NumCols )
DO WHILE (ErrStat == 0) ! read the rest of the file (until an error occurs)
NumDataLines = NumDataLines + 1
READ(UnWind,*,IOSTAT=ErrStat) ( TmpData(I), I=1,NumCols )
END DO !WHILE
IF (NumDataLines < 1) THEN
CALL WrScr ( ' Error reading data from HH wind file on line '//TRIM(Int2Lstr(NumDataLines+NumComments))//'.' )
RETURN
ELSE
CALL WrScr ( ' Reading '//TRIM(Int2Lstr(NumDataLines))//' lines of data from the HH wind file.' )
END IF
!-------------------------------------------------------------------------------------------------
! Allocate arrays for the HH data
!-------------------------------------------------------------------------------------------------
! BJJ note: If the subroutine AllocAry() is called, the CVF compiler with A2AD does not work
! properly. The arrays are not properly read even though they've been allocated.
!-------------------------------------------------------------------------------------------------
IF (.NOT. ALLOCATED(Tdata) ) THEN
ALLOCATE ( Tdata(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH time array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(V) ) THEN
ALLOCATE ( V(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH horizontal wind speed array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(Delta) ) THEN
ALLOCATE ( Delta(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH wind direction array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(VZ) ) THEN
ALLOCATE ( VZ(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH vertical wind speed array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(HShr) ) THEN
ALLOCATE ( HShr(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH horizontal linear shear array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(VShr) ) THEN
ALLOCATE ( VShr(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH vertical power-law shear exponent array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(VLinShr) ) THEN
ALLOCATE ( VLinShr(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH vertical linear shear array.' )
RETURN
END IF
END IF
IF (.NOT. ALLOCATED(VGust) ) THEN
ALLOCATE ( VGust(NumDataLines) , STAT=ErrStat )
IF ( ErrStat /=0 ) THEN
CALL WrScr( 'Error allocating memory for the HH gust velocity array.' )
RETURN
END IF
END IF
!-------------------------------------------------------------------------------------------------
! Rewind the file (to the beginning) and skip the comment lines
!-------------------------------------------------------------------------------------------------
REWIND( UnWind )
DO I=1,NumComments
CALL ReadCom( UnWind, TRIM(WindFile), 'Header line #'//TRIM(Int2LStr(I)), ErrStat )
IF ( ErrStat /= 0 ) RETURN
END DO !I
!-------------------------------------------------------------------------------------------------
! Read the data arrays
!-------------------------------------------------------------------------------------------------
DO I=1,NumDataLines
CALL ReadAry( UnWind, TRIM(WindFile), TmpData(1:NumCols), NumCols, 'TmpData', &
'Data from HH line '//TRIM(Int2LStr(NumComments+I)), ErrStat )
IF (ErrStat /= 0) RETURN
Tdata( I) = TmpData(1)
V( I) = TmpData(2)
Delta( I) = TmpData(3)*D2R
VZ( I) = TmpData(4)
HShr( I) = TmpData(5)
VShr( I) = TmpData(6)
VLinSHR(I) = TmpData(7)
VGust( I) = TmpData(8)
END DO !I
!-------------------------------------------------------------------------------------------------
! Make sure the wind direction isn't jumping more than 180 degrees between any 2 consecutive
! input times. (Avoids interpolation errors with modular arithemetic.)
!-------------------------------------------------------------------------------------------------
DO I=2,NumDataLines
ILine = 1
DO WHILE ( ILine < MaxTries )
DelDiff = ( Delta(I) - Delta(I-1) )
IF ( ABS( DelDiff ) < Pi ) EXIT ! exit inner loop
Delta(I) = Delta(I) - SIGN( TwoPi, DelDiff )
ILine = ILine + 1
END DO
IF ( ILine >= MaxTries ) THEN
CALL WrScr( ' Error calculating wind direction from HH file. Delta(' &
// TRIM(Int2LStr(I )) // ') = ' // TRIM(Flt2Lstr(Delta(I))) // '; Delta(' &
// TRIM(Int2LStr(I+1)) // ') = ' // TRIM(Flt2Lstr(Delta(I+1))) )
ErrStat = 1
END IF
END DO !I
!-------------------------------------------------------------------------------------------------
! Close the file
!-------------------------------------------------------------------------------------------------
CLOSE( UnWind )
!-------------------------------------------------------------------------------------------------
! Print warnings and messages
!-------------------------------------------------------------------------------------------------
! CALL WrScr ( ' Processed '//TRIM( Int2LStr( NumDataLines ) )//' records of HH data' )
IF ( Tdata(1) > 0.0 ) THEN
CALL ProgWarn( 'The hub-height wind file : "'//TRIM(ADJUSTL(WindFile))//'" starts at a time '// &
'greater than zero. Interpolation errors may result.')
ENDIF
IF ( NumDataLines == 1 ) THEN
CALL WrScr( ' Only 1 line in HH wind file. Steady, hub-height horizontal wind speed = '//TRIM(Flt2Lstr(V(1)))//' m/s.' )
END IF
!-------------------------------------------------------------------------------------------------
! Set the initial index into the time array (it indicates that we've initialized the module, too)
! and initialize the spatial scaling for the wind calculations
!-------------------------------------------------------------------------------------------------
TimeIndx = 1
RefHt = WindInfo%ReferenceHeight
RefWid = WindInfo%Width
RETURN
END SUBROUTINE HH_Init
!====================================================================================================
FUNCTION HH_GetWindSpeed(Time, InputPosition, ErrStat)
! This subroutine linearly interpolates the columns in the HH input file to get the values for
! the requested time, then uses the interpolated values to calclate the wind speed at a point
! in space represented by InputPosition.
!----------------------------------------------------------------------------------------------------
REAL(ReKi), INTENT(IN) :: Time ! time from the start of the simulation
REAL(ReKi), INTENT(IN) :: InputPosition(3) ! input information: positions X,Y,Z
INTEGER, INTENT(OUT):: ErrStat ! error status
TYPE(InflIntrpOut) :: HH_GetWindSpeed ! return velocities (U,V,W)
REAL(ReKi) :: CosDelta ! cosine of Delta_tmp
REAL(ReKi) :: Delta_tmp ! interpolated Delta at input TIME
REAL(ReKi) :: HShr_tmp ! interpolated HShr at input TIME
REAL(ReKi) :: P ! temporary storage for slope (in time) used in linear interpolation
REAL(ReKi) :: SinDelta ! sine of Delta_tmp
REAL(ReKi) :: V_tmp ! interpolated V at input TIME
REAL(ReKi) :: VGust_tmp ! interpolated VGust at input TIME
REAL(ReKi) :: VLinShr_tmp ! interpolated VLinShr at input TIME
REAL(ReKi) :: VShr_tmp ! interpolated VShr at input TIME
REAL(ReKi) :: VZ_tmp ! interpolated VZ at input TIME
REAL(ReKi) :: V1 ! temporary storage for horizontal velocity
!-------------------------------------------------------------------------------------------------
! verify the module was initialized first
!-------------------------------------------------------------------------------------------------
IF ( TimeIndx == 0 ) THEN
CALL WrScr( ' Error: Call HH_Init() before getting wind speed.')
ErrStat = 1
RETURN
ELSE
ErrStat = 0
END IF
!-------------------------------------------------------------------------------------------------
! Linearly interpolate in time (or used nearest-neighbor to extrapolate)
! (compare with NWTC_Num.f90\InterpStpReal)
!-------------------------------------------------------------------------------------------------
IF ( Linearize ) THEN !get the perturbed wind speed
TimeIndx = 1
V_tmp = V (1) + LinearizeDels(1)
Delta_tmp = Delta (1) + LinearizeDels(2)
VZ_tmp = VZ (1) + LinearizeDels(3)
HShr_tmp = HShr (1) + LinearizeDels(4)
VShr_tmp = VShr (1) + LinearizeDels(5)
VLinShr_tmp = VLinShr(1) + LinearizeDels(6)
VGust_tmp = VGust (1) + LinearizeDels(7)
! Let's check the limits.
ELSE IF ( Time <= Tdata(1) .OR. NumDataLines == 1 ) THEN
TimeIndx = 1
V_tmp = V (1)
Delta_tmp = Delta (1)
VZ_tmp = VZ (1)
HShr_tmp = HShr (1)
VShr_tmp = VShr (1)
VLinShr_tmp = VLinShr(1)
VGust_tmp = VGust (1)
ELSE IF ( Time >= Tdata(NumDataLines) ) THEN
TimeIndx = NumDataLines - 1
V_tmp = V (NumDataLines)
Delta_tmp = Delta (NumDataLines)
VZ_tmp = VZ (NumDataLines)
HShr_tmp = HShr (NumDataLines)
VShr_tmp = VShr (NumDataLines)
VLinShr_tmp = VLinShr(NumDataLines)
VGust_tmp = VGust (NumDataLines)
ELSE
! Let's interpolate!
TimeIndx = MAX( MIN( TimeIndx, NumDataLines-1 ), 1 )
DO
IF ( Time < Tdata(TimeIndx) ) THEN
TimeIndx = TimeIndx - 1
ELSE IF ( Time >= Tdata(TimeIndx+1) ) THEN
TimeIndx = TimeIndx + 1
ELSE
P = ( Time - Tdata(TimeIndx) )/( Tdata(TimeIndx+1) - Tdata(TimeIndx) )
V_tmp = ( V( TimeIndx+1) - V( TimeIndx) )*P + V( TimeIndx)
Delta_tmp = ( Delta( TimeIndx+1) - Delta( TimeIndx) )*P + Delta( TimeIndx)
VZ_tmp = ( VZ( TimeIndx+1) - VZ( TimeIndx) )*P + VZ( TimeIndx)
HShr_tmp = ( HShr( TimeIndx+1) - HShr( TimeIndx) )*P + HShr( TimeIndx)
VShr_tmp = ( VShr( TimeIndx+1) - VShr( TimeIndx) )*P + VShr( TimeIndx)
VLinShr_tmp = ( VLinShr(TimeIndx+1) - VLinShr(TimeIndx) )*P + VLinShr(TimeIndx)
VGust_tmp = ( VGust( TimeIndx+1) - VGust( TimeIndx) )*P + VGust( TimeIndx)
EXIT
END IF
END DO
END IF
!-------------------------------------------------------------------------------------------------
! calculate the wind speed at this time
!-------------------------------------------------------------------------------------------------
CosDelta = COS( Delta_tmp )
SinDelta = SIN( Delta_tmp )
V1 = V_tmp * ( ( InputPosition(3)/RefHt ) ** VShr_tmp & ! power-law wind shear
+ ( HShr_tmp * ( InputPosition(2) * CosDelta + InputPosition(1) * SinDelta ) & ! horizontal linear shear
+ VLinShr_tmp * ( InputPosition(3)-RefHt ) )/RefWid ) & ! vertical linear shear
+ VGUST_tmp ! gust speed
HH_GetWindSpeed%Velocity(1) = V1 * CosDelta
HH_GetWindSpeed%Velocity(2) = -V1 * SinDelta
HH_GetWindSpeed%Velocity(3) = VZ_tmp
RETURN
END FUNCTION HH_GetWindSpeed
!====================================================================================================
FUNCTION HH_Get_ADHack_WindSpeed(Time, InputPosition, ErrStat)
! This subroutine linearly interpolates the columns in the HH input file to get the values for
! the requested time, then uses the interpolated values to calclate the wind speed at a point
! in space represented by InputPosition. THIS FUNCTION SHOULD BE REMOVED!!!!! (used for DISK VEL ONLY)
!----------------------------------------------------------------------------------------------------
REAL(ReKi), INTENT(IN) :: Time ! time from the start of the simulation
REAL(ReKi), INTENT(IN) :: InputPosition(3) ! input information: positions X,Y,Z - NOT USED HERE!!!
INTEGER, INTENT(OUT):: ErrStat ! error status
TYPE(InflIntrpOut) :: HH_Get_ADHack_WindSpeed ! return velocities (U,V,W)
REAL(ReKi) :: Delta_tmp ! interpolated Delta at input TIME
REAL(ReKi) :: P ! temporary storage for slope (in time) used in linear interpolation
REAL(ReKi) :: V_tmp ! interpolated V at input TIME
REAL(ReKi) :: VZ_tmp ! interpolated VZ at input TIME
!-------------------------------------------------------------------------------------------------
! verify the module was initialized first
!-------------------------------------------------------------------------------------------------
IF ( TimeIndx == 0 ) THEN
CALL WrScr( ' Error: Call HH_Init() before getting wind speed.')
ErrStat = 1
RETURN
ELSE
ErrStat = 0
END IF
!-------------------------------------------------------------------------------------------------
! Linearly interpolate in time (or use nearest-neighbor to extrapolate)
! (compare with NWTC_Num.f90\InterpStpReal)
!-------------------------------------------------------------------------------------------------
! Let's check the limits.
IF ( Time <= Tdata(1) .OR. NumDataLines == 1) THEN
TimeIndx = 1
V_tmp = V (1)
Delta_tmp = Delta (1)
VZ_tmp = VZ (1)
ELSE IF ( Time >= Tdata(NumDataLines) ) THEN
TimeIndx = NumDataLines - 1
V_tmp = V (NumDataLines)
Delta_tmp = Delta (NumDataLines)
VZ_tmp = VZ (NumDataLines)
ELSE
! Let's interpolate!
TimeIndx = MAX( MIN( TimeIndx, NumDataLines-1 ), 1 )
DO
IF ( Time < Tdata(TimeIndx) ) THEN
TimeIndx = TimeIndx - 1
ELSE IF ( Time >= Tdata(TimeIndx+1) ) THEN
TimeIndx = TimeIndx + 1
ELSE
P = ( Time - Tdata(TimeIndx) )/( Tdata(TimeIndx+1) - Tdata(TimeIndx) )
V_tmp = ( V( TimeIndx+1) - V( TimeIndx) )*P + V( TimeIndx)
Delta_tmp = ( Delta( TimeIndx+1) - Delta( TimeIndx) )*P + Delta( TimeIndx)
VZ_tmp = ( VZ( TimeIndx+1) - VZ( TimeIndx) )*P + VZ( TimeIndx)
EXIT
END IF
END DO
END IF
!-------------------------------------------------------------------------------------------------
! calculate the wind speed at this time
!-------------------------------------------------------------------------------------------------
HH_Get_ADHack_WindSpeed%Velocity(1) = V_tmp * COS( Delta_tmp )
HH_Get_ADHack_WindSpeed%Velocity(2) = -V_tmp * SIN( Delta_tmp )
HH_Get_ADHack_WindSpeed%Velocity(3) = VZ_tmp
RETURN
END FUNCTION HH_Get_ADHack_WindSpeed
!====================================================================================================
SUBROUTINE HH_SetLinearizeDels( Perturbations, ErrStat )
! This subroutine sets the perturbation values for the linearization scheme.
!----------------------------------------------------------------------------------------------------
REAL(ReKi), INTENT(IN) :: Perturbations(7) ! purturbations for each of the 7 input parameters
INTEGER, INTENT(OUT) :: ErrStat ! time from the start of the simulation
!-------------------------------------------------------------------------------------------------
! verify the module was initialized first
!-------------------------------------------------------------------------------------------------
IF ( TimeIndx == 0 ) THEN
CALL WrScr( ' Error: Call HH_Init() before getting wind speed.')
ErrStat = 1
RETURN
ELSE
ErrStat = 0
END IF
Linearize = .TRUE.
LinearizeDels(:) = Perturbations(:)
RETURN
END SUBROUTINE HH_SetLinearizeDels
!====================================================================================================
SUBROUTINE HH_Terminate(ErrStat)
INTEGER, INTENT(OUT) :: ErrStat ! determines if an error has been encountered
INTEGER :: SumErrs
SumErrs = 0
IF ( ALLOCATED(Tdata ) ) DEALLOCATE( Tdata, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(DELTA ) ) DEALLOCATE( DELTA, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(V ) ) DEALLOCATE( V, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(VZ ) ) DEALLOCATE( VZ, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(HSHR ) ) DEALLOCATE( HSHR, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(VSHR ) ) DEALLOCATE( VSHR, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(VGUST ) ) DEALLOCATE( VGUST, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
IF ( ALLOCATED(VLINSHR) ) DEALLOCATE( VLINSHR, STAT=ErrStat )
SumErrs = SumErrs + ABS(ErrStat)
ErrStat = SumErrs
TimeIndx = 0
END SUBROUTINE HH_Terminate
!====================================================================================================
END MODULE HHWind