-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAeroSubs.f90
executable file
·5283 lines (3892 loc) · 172 KB
/
AeroSubs.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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MODULE AeroSubs
USE NWTC_Library
USE InflowWind
USE SharedInflowDefns
IMPLICIT NONE
CONTAINS
! ************************************************
! AeroDyn Subroutines for YawDyn, ADAMS,
! SymDyn and FAST.
! ************************************************
! UNIVERSITY OF UTAH, MECHANICAL ENGINEERING DEPARTMENT
!====================================================================================================
SUBROUTINE AD_GetInput(UnIn, AeroInFile, WindFileName, Title, ErrStat )
!====================================================================================================
USE AeroGenSubs, ONLY: AllocArrays
USE AD_IOParams
USE AeroTime
USE ElOutParams
USE Airfoil
USE Blade
USE Element
USE InducedVel
USE Rotor
USE Switch
USE TwrProps
USE Wind
IMPLICIT NONE
! Passed Variables:
INTEGER, INTENT(IN) :: UnIn
CHARACTER(*), INTENT(IN) :: AeroInFile
CHARACTER(*), INTENT(OUT) :: WindFileName
CHARACTER(*), INTENT(OUT) :: Title ! used for ADOUT() -- bjj: get rid of this when ADOUT is gone!!!!
INTEGER, INTENT(OUT) :: ErrStat
! Local Variables:
INTEGER :: ElIndex
INTEGER :: IELM
INTEGER :: IndPrint
INTEGER :: K
CHARACTER(1024) :: LINE
CHARACTER(1024) :: FilePath ! The path name of the AeroDyn input file (so files listed in it can be defined relative to the main input file location)
!-------------------------------------------------------------------------------------------------
! Open the AeroDyn input file
!-------------------------------------------------------------------------------------------------
CALL OpenFInpFile(UnIn, TRIM(AeroInFile), ErrStat)
IF (ErrStat /= 0 ) RETURN
CALL GetPath( AeroInFile, FilePath )
!-------------------------------------------------------------------------------------------------
! If the echo file is open, write the header...
!-------------------------------------------------------------------------------------------------
IF ( Echo ) THEN
WRITE( UnEc, '(// A /)' ) 'AeroDyn input data from file "'//TRIM( AeroInFile )//'":'
END IF
!-------------------------------------------------------------------------------------------------
! Read the AeroDyn input file
!-------------------------------------------------------------------------------------------------
! Read in the title line
CALL ReadStr( UnIn, AeroInFile, Title, 'Title', 'File title', ErrStat)
IF ( ErrStat /= 0 ) RETURN
CALL WrScr( ' Heading of the AeroDyn input file: '//TRIM(Title) )
! Read in the units specifier - REMOVE SOON!!!!!
CALL ReadVar( UnIn, AeroInFile, LINE, 'Units', 'Units option', ErrStat)
IF ( ErrStat /= 0 ) RETURN
LINE = ADJUSTL( LINE )
CALL Conv2UC(LINE(1:3))
IF (LINE(1:2) /= 'SI') THEN
CALL ProgWarn( 'English units are no longer allowed in AeroDyn. Please modify your input files to use the metric system.')
ErrStat = 1
RETURN
END IF
SIunit = .TRUE.
! Read in the stall model
CALL ReadVar( UnIn, AeroInFile, LINE, 'DStall', 'Stall model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
CALL Conv2UC(LINE(1:7))
SELECT CASE ( TRIM(Line) )
CASE ('STEADY')
DStall = .FALSE.
CASE ('BEDDOES')
DStall = .TRUE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "STEADY" or "BEDDOES" stall model option.')
ErrStat = 1
RETURN
END SELECT
! Read in the CM option
CALL ReadVar( UnIn, AeroInFile, LINE, 'PMoment', 'Pitching moment option', ErrStat)
IF ( ErrStat /= 0 ) RETURN
CALL Conv2UC(LINE(1:6))
SELECT CASE ( TRIM(Line) )
CASE ('USE_CM')
PMoment = .TRUE.
CASE ('NO_CM')
PMoment = .FALSE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "USE_CM" or "NO_CM" pitching moment option.')
ErrStat = 1
RETURN
END SELECT
! Read in the inflow model option
CALL ReadVar( UnIn, AeroInFile, LINE, 'DynInfl', 'Inflow model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
CALL Conv2UC(LINE(1:7))
SELECT CASE ( Line(1:5) )
CASE ('EQUIL')
DynInfl = .FALSE.
DynInit = .FALSE.
IF (Line(6:7) == 'DA') THEN
EqAIDmult = 1.0
EquilDA = .TRUE.
EquilDT = .FALSE.
ELSEIF (LINE(6:7) == 'DB') THEN
EqAIDmult = 1.0
EquilDA = .TRUE.
EquilDT = .TRUE.
ELSEIF (LINE(6:7) == 'DT') THEN
EqAIDmult = 0.0
EquilDA = .FALSE.
EquilDT = .TRUE.
ELSE
EqAIDmult = 0.0
EquilDA = .FALSE.
EquilDT = .FALSE.
ENDIF
CASE ('DYNIN')
DynInfl = .TRUE.
DynInit = .TRUE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "EQUIL" or "DYNIN" inflow model option.')
ErrStat = 1
RETURN
END SELECT
! Read in the wake model
CALL ReadVar( UnIn, AeroInFile, LINE, 'Wake', 'Wake model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
CALL Conv2UC(LINE(1:5))
SELECT CASE ( TRIM(Line) )
CASE ('NONE')
Wake = .FALSE.
Swirl = .FALSE.
CALL ProgWarn( ' All wake calculations are turned off! This option is recommended only '// &
'in high winds or for debugging.' )
CASE ('WAKE')
Wake = .TRUE.
Swirl = .FALSE.
CASE ('SWIRL')
Wake = .TRUE.
Swirl = .TRUE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "NONE", "WAKE", or "SWIRL" wake model option.')
ErrStat = 1
RETURN
END SELECT
! Read in the tolerance for the wake model
CALL ReadVar( UnIn, AeroInFile, AToler, 'AToler', 'Induction factor tolerance', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read in the tip-loss model for EQUIL inflow
CALL ReadVar( UnIn, AeroInFile, LINE, 'TLoss', 'Tip-loss model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( DynInfl ) THEN ! Initialize these variables, though they shouldn't be used
TLoss = .FALSE.
GTech = .FALSE.
ELSE
CALL Conv2UC(LINE(1:5))
SELECT CASE ( LINE(1:5) )
CASE ('NONE ')
TLoss = .FALSE.
GTech = .FALSE.
CASE ('PRAND')
TLoss = .TRUE.
GTech = .FALSE.
CASE ('GTECH')
TLoss = .TRUE.
GTech = .TRUE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "NONE", "PRAND", or "GTECH" tip-loss model option.')
ErrStat = 1
RETURN
END SELECT
END IF
! Read in the hub-loss model for EQUIL inflow
CALL ReadVar( UnIn, AeroInFile, LINE, 'HLoss', 'Hub-loss model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( DynInfl ) THEN ! Initialize these variables, though they shouldn't be used
HLoss = .FALSE.
ELSE
CALL Conv2UC( LINE(1:5) )
SELECT CASE ( LINE(1:5) )
CASE ('NONE')
HLoss = .FALSE.
CASE ('PRAND')
HLoss = .TRUE.
CASE DEFAULT
CALL ProgWarn( ' Error: Expecting "NONE" or "PRAND" hub-loss model option.')
ErrStat = 1
RETURN
END SELECT
END IF
! Read in the wind file name
CALL ReadVar( UnIn, AeroInFile, WindFileName, 'WindFileName', 'Name of the wind file', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( PathIsRelative( WindFileName ) ) WindFileName = TRIM(FilePath)//TRIM(WindFileName)
! Read in the wind reference (hub) height above ground
CALL ReadVar( UnIn, AeroInFile, HH, 'RefHt', 'Wind reference height', ErrStat)
IF ( ErrStat /= 0 ) RETURN
!bjj: this is a hack job to allow both the new tower influence and the old tower wake models to be used
CALL ReadStr( UnIn, AeroInFile, Line, 'NewTowerModel?', 'Check for tower influence model', ErrStat )
IF ( ErrStat /= 0 ) RETURN
! Check if this is the "special string" to indicate the new tower influence model
CALL Conv2UC( Line )
IF ( INDEX(Line, "NEWTOWER" ) > 0 ) THEN
!----------------------------------------------------------------------------------------------
! New tower influence model, as implemented by PJM
!----------------------------------------------------------------------------------------------
PJM_Version = .TRUE.
! Read in the tower potential flow switch
CALL ReadVar( UnIn, AeroInFile, TwrPotent, 'TwrPotent', 'Tower influence model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read in the tower shadow switch
CALL ReadVar( UnIn, AeroInFile, TwrShadow, 'TwrShadow', 'Tower shadow model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read in the tower drag file name
CALL ReadVar( UnIn, AeroInFile, TwrFile, 'TwrFile', 'Tower data file name', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( PathIsRelative( TwrFile ) ) TwrFile = TRIM(FilePath)//TRIM(TwrFile)
ELSE
!----------------------------------------------------------------------------------------------
! Old tower influence model, read TwrShad from Line for now
!----------------------------------------------------------------------------------------------
PJM_Version = .FALSE.
TwrPotent = .FALSE. ! We don't want to read the tower file!
TwrShadow = .FALSE. ! We don't want to read the tower file!
! Read in the tower shadow deficit
IF ( INDEX( 'FTft', Line(:1) ) > 0 ) THEN
CALL ProgWarn( ' Invalid numeric input. "'//TRIM( Line )//'" found when trying to read TwrShad.' )
ErrStat = 1
RETURN
ELSE
READ (Line,*,IOSTAT=ErrStat) TwrShad
CALL CheckIOS ( ErrStat, AeroInFile, 'TwrShad', NumType, .TRUE. )
IF ( Echo ) THEN
WRITE (UnEc,"( 2X, ES11.4e2, 2X, A, T30, ' - ', A )") TwrShad, "TwrShad", 'Tower shadow deficit'
END IF
END IF
!----------------
IF ( TwrShad >= 1.0 ) THEN
CALL ProgWarn( ' Tower shadow deficit cannot be >= 1. Setting default deficit = 0.3' )
TwrShad = 0.3
END IF
! Read in the tower shadow width
CALL ReadVar( UnIn, AeroInFile, ShadHWid, 'ShadHWid', 'Tower shadow half width', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( ShadHWid <= 0.0 ) THEN
CALL ProgWarn( ' Tower shadow width cannot be <= zero. Setting default half width = 1.0' )
ShadHWid = 1.0
END IF
! Read in the tower shadow reference point (distance from yaw axis to hub)
CALL ReadVar( UnIn, AeroInFile, T_Shad_Refpt, 'T_Shad_Refpt', 'Tower shadow reference point', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Constants used in tower shadow calculations
TShadC1 = ShadHWid / SQRT ( ABS( T_Shad_Refpt ) )
TShadC2 = TwrShad * SQRT ( ABS( T_Shad_Refpt ) )
END IF
! Read in the air density
CALL ReadVar( UnIn, AeroInFile, Rho, 'Rho', 'Air density', ErrStat)
IF ( ErrStat /= 0 ) RETURN
!bjj do we need to check the the air density is non-negative?
IF ( Rho == 0.0 .AND. DynInfl ) THEN ! Turn off the GDW if RHO = 0. It will crash
CALL ProgWarn( 'Air density is zero. Dynamic Inflow will be turned off to avoid program crash.' )
DynInfl = .FALSE.
ENDIF
! Read in the kinematic viscosity
CALL ReadVar( UnIn, AeroInFile, KinVisc, 'KinVisc', 'Kinematic viscosity', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Aero calculation time interval
CALL ReadVar( UnIn, AeroInFile, DtAero, 'DtAero', 'Aero calculation time step', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read the number of airfoil files
CALL ReadVar( UnIn, AeroInFile, NumFoil, 'NumFoil', 'Number of airfoil files', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( NumFoil < 1 ) THEN
CALL ProgWarn( ' Error: Number of airfoil files must be a positive integer.')
ErrStat = 1
RETURN
END IF
!..............................................................................................
! Allocate space for the airfoil data file name(s), then read them
!..............................................................................................
IF (.NOT. ALLOCATED(FoilNm)) THEN
ALLOCATE ( FoilNm( NumFoil ) , STAT=ErrStat )
IF ( ErrStat /= 0 ) THEN
CALL ProgWarn(' Error allocating space for the FoilNm array.')
RETURN
END IF
END IF
CALL ReadAryLines( UnIn, AeroInFile, FoilNm(1:NumFoil), NumFoil, 'FoilNm', 'Airfoil file names', ErrStat )
IF ( ErrStat /= 0 ) RETURN
DO K=1,NumFoil
IF ( PathIsRelative( FoilNm(K) ) ) FoilNm(K) = TRIM(FilePath)//TRIM( FoilNm(K) )
END DO
! Read in the number of blade elements
CALL ReadVar( UnIn, AeroInFile, NElm, 'NElm', 'Number of blade elements', ErrStat)
IF ( ErrStat /= 0 ) RETURN
!..............................................................................................
! Allocate space for blade element data and read the arrays
! Read blade element data, check some inputs, convert twist to radians
!..............................................................................................
CALL AllocArrays ('Element')
NumElOut = 0 ! Initialize the element print array index
NumWndElOut = 0
CALL ReadCom( UnIn, AeroInFile, 'Element table headers', ErrStat)
IF ( ErrStat /= 0 ) RETURN
DO IElm = 1, NElm
READ(UnIn,'(A)',IOSTAT=ErrStat) Line !read into a line to see if print/no print is enabled
IF (ErrStat == 0) THEN
READ(Line,*,IOSTAT=ErrStat) RElm(IElm), Twist(IElm), DR(IElm), C(IElm), NFoil(IElm)
END IF
IF ( ErrStat == 0 ) THEN
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
! Check if AeroDyn will print out the element and/or wind data
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CALL Conv2UC(LINE)
ElPrList(IElm) = 0 ! INITIALIZE
IndPrint = INDEX(LINE,"PRINT")
IF (IndPrint > 0) THEN
IF (LINE(IndPrint-2:IndPrint+4) /= "NOPRINT") THEN
NumElOut = NumElOut + 1
ElPrList(IElm) = NumElOut
END IF
ENDIF
WndElPrList(IElm) = 0 ! INITIALIZE
IndPrint = INDEX(LINE,"WIND")
IF (IndPrint > 0) THEN
IF (LINE(IndPrint-2:IndPrint-1) /= "NO") THEN
NumWndElOut = NumWndElOut + 1
WndElPrList(IElm) = NumWndElOut
END IF
ENDIF
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
! Echo data to the file NWTC_Library echo file, if requested
!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
IF ( Echo ) THEN ! NWTC_Library echo file
WRITE (UnEc,'(4(2X,ES11.4e2),2X,I11,1(2X,L11))') RElm(IElm), Twist(IElm), DR(IElm), C(IElm), NFoil(IElm), &
ElPrList(IElm) /= 0 !, WndElPrList(IElm) == 0
END IF
ELSE IF ( ErrStat < 0 ) THEN
CALL ProgWarn(' Error reading from line '//TRIM(Int2Lstr(IElm))//' of the AeroDyn element table.' )
CALL ProgWarn( ' Premature end of file while reading line '//TRIM(Int2Lstr(IElm))// &
' of the AeroDyn element table in file "'//TRIM(AeroInFile)//'."' )
RETURN
ELSE
CALL ProgWarn(' Error reading from line '//TRIM(Int2Lstr(IElm))// &
' of the AeroDyn element table in file "'//TRIM(AeroInFile)//'."' )
RETURN
END IF
! Check for valid data:
IF( C(IElm) <= 0.0 ) THEN
CALL ProgWarn(' Error reading from line '//TRIM(Int2Lstr(IElm))//' of the AeroDyn element table.'// &
' Chord length must be larger than 0.' )
ErrStat = 1
RETURN
ENDIF
IF (NFoil(IElm) < 1 .OR. NFoil(IElm) > NumFoil) THEN
CALL ProgWarn(' Error reading from line '//TRIM(Int2Lstr(IElm))//' of the AeroDyn element table.'// &
' Airfoil file ID must be a number between 1 and '//TRIM(Int2Lstr(NumFoil))//'.' )
ErrStat = 1
RETURN
END IF
! Convert Twist to radians:
Twist(IElm) = Twist(IElm)*D2R
ENDDO ! IELM
!..............................................................................................
! Read multiple airfoil table option
!..............................................................................................
!bjj, this would be ideal, but it's annoying to read EOF for all these files...
! CALL ReadVar( UnIn, AeroInFile, Line, 'MultiTab', 'Multiple airfoil table option', ErrStat)
! IF ( ErrStat > 0 ) RETURN
READ(UnIn,*,IOSTAT=ErrStat) Line !read MultiTab -- it may not exist
IF (ErrStat > 0 ) THEN
CALL WrScr1 ( ' Invalid character input for file "'//TRIM( AeroInFile )//'".' )
CALL ProgWarn ( ' The error occurred while trying to read "MultiTab".' )
RETURN
ELSE IF (ErrStat == 0) THEN
IF ( Echo ) THEN
WRITE (UnEc, "( 15X, A, T30, ' - ', A, /, 2X, A )" ) &
'MultiTab', 'Multiple airfoil table option', '"'//TRIM( Line )//'"'
END IF
ELSE
MultiTab = .FALSE.
Reynolds = .FALSE.
! CALL PremEOF ( TRIM( Fil ), Variable, TrapThisError )
END IF
!-------------------------------------------------------------------------------------------------
! Close AeroDyn input file
!-------------------------------------------------------------------------------------------------
CLOSE(UnIn)
!-------------------------------------------------------------------------------------------------
! Read airfoil data and check for MultiTab values using LINE, which was read above
!-------------------------------------------------------------------------------------------------
CALL READFL() ! Read airfoil files; bjj: make sure there isn't a conflict with ErrStat when this gets rewritten; also make it use the same UnIn
MulTabLoc = 0.0 ! Initialize this value
! Read in the type of airfoil data table in each file
IF ( ErrStat < 0 ) THEN ! If we hit the end of the file without MultiTab, use only 1 airfoil table
IF ( ANY( NTables(1:NumFoil) > 1 ) ) THEN
CALL ProgWarn( ' Error reading multiple airfoil table option. Only one table for each file will be used.' )
END IF
MultiTab = .FALSE.
Reynolds = .FALSE.
ErrStat = 0
ELSE ! ErrStat = 0
IF ( ANY( NTables(1:NumFoil) > 1 ) ) THEN
CALL Conv2UC(LINE(1:6))
SELECT CASE ( TRIM(Line) )
CASE ( 'USER' )
MultiTab = .TRUE.
Reynolds = .FALSE.
DO K = 1, NumFoil
IF ( NTables(K) > 1 ) THEN
IF ( ( MulTabLoc < MulTabMet(K,1) ) .OR. ( MulTabLoc > MulTabMet(K,NTables(K) ) ))THEN !bjj: why don't we have this error elsewhere??? can't MulTabLoc change?
CALL ProgWarn( 'Error interpolating between airfoil tables. '// &
' Initial interpolation value = '//TRIM(Flt2LStr(MulTabLoc))// &
' is outside table range of '//TRIM(Flt2LStr(MulTabMet(K,1)))// &
' to '//TRIM(Flt2LStr(MulTabMet(K,NTables(K))))// &
' in airfoil file #'//TRIM(Int2LStr(K))//'.' )
ErrStat = 1
RETURN
END IF
END IF ! NTables(K) > 1
ENDDO ! K
CASE ( 'RENUM' )
MultiTab = .TRUE.
Reynolds = .TRUE.
CASE ( 'SINGLE' )
MultiTab = .FALSE.
Reynolds = .FALSE.
CASE DEFAULT
CALL WrScr( ' Error: control model option must be "SINGLE" or "MULTI".' )
END SELECT
ELSE
MultiTab = .FALSE.
Reynolds = .FALSE.
END IF
ENDIF
!-------------------------------------------------------------------------------------------------
! Read tower drag input file, if necessary
!-------------------------------------------------------------------------------------------------
IF (TwrPotent .OR. TwrShadow) THEN ! Read in the tower drag file
CALL READTwr(UnIn, TwrFile, ErrStat)
IF (ErrStat /= 0) RETURN
END IF
!-------------------------------------------------------------------------------------------------
! Initialize variables for printing
!-------------------------------------------------------------------------------------------------
IF ( NumElOut > 0 .OR. NumWndElOut > 0 ) THEN
ElemPrn = .TRUE.
CALL AllocArrays ('ElPrint') ! Allocate arrays with dimension NumElOut
ElIndex = 0 ! Re-Initialize the element print array index for wind
DO IElm = 1, NElm
IF (WndElPrList(IElm) > 0) THEN
ElIndex = ElIndex + 1
WndElPrNum(ElIndex) = IElm
END IF
END DO ! IELM
ElIndex = 0 ! Re-Initialize the element print array index
DO IElm = 1, NElm
IF (ElPrList(IElm) > 0) THEN
ElIndex = ElIndex + 1
ElPrNum(ElIndex) = IElm
END IF
END DO ! IELM
ELSE
ElemPrn = .FALSE.
END IF
!-------------------------------------------------------------------------------------------------
! Initialize BEDDOES dynamic stall data
!-------------------------------------------------------------------------------------------------
IF ( DStall ) CALL BEDDAT()
RETURN
END SUBROUTINE AD_GetInput
!====================================================================================================
SUBROUTINE ADOut ( TITLE, HubRad, WindFileName )
! used to output data pertinent
! to the yaw dynamics routines
! *****************************************************
USE AD_IOParams
USE ElOutParams
USE AeroTime
USE Airfoil
USE Blade
USE Element
USE InducedVel
USE Rotor
USE Switch
USE Wind
USE TwrProps
IMPLICIT NONE
! Passed Variables:
CHARACTER(*), INTENT(IN):: TITLE
REAL(ReKi), INTENT(IN):: HubRad
CHARACTER(*), INTENT(IN):: WindFileName
! Local Variables:
INTEGER :: IElm
INTEGER :: IFoil
CHARACTER( 2) :: Dst_Unit
CHARACTER(150) :: Frmt
CHARACTER( 4) :: Mass_Unit
CHARACTER( 35) :: MESAGE
CHARACTER( 3) :: Vel_Unit
CHARACTER(1) :: Delim
IF (SIUNIT) THEN
Dst_Unit = 'm'
Mass_Unit = 'kg'
Vel_Unit = 'mps'
ELSE
Dst_Unit = 'ft'
Mass_Unit = 'slug'
Vel_Unit = 'fps'
ENDIF
! Reiterate the input file
WRITE(UnADopt,'(/A)') 'Inputs read in from the AeroDyn input file:'
WRITE(UnADopt,'(A/)') TRIM(TITLE)
MESAGE = 'Units for input and output'
IF ( SIUNIT ) THEN
WRITE(UnADopt,'(A)') 'SI'//TAB//MESAGE
ELSE
WRITE(UnADopt,'(A)') 'ENGLISH'//TAB//MESAGE
ENDIF
MESAGE = 'Dynamic stall model'
IF ( DSTALL ) THEN
WRITE(UnADopt,'(A)') 'BEDDOES'//TAB//MESAGE//' [Beddoes]'
ELSE
WRITE(UnADopt,'(A)') 'STEADY'//TAB//MESAGE//' [NO Dynamic stall]'
ENDIF
MESAGE = 'Aerodynamic pitching moment model'
IF ( PMOMENT ) THEN
WRITE(UnADopt,'(A)') 'USE_CM'//TAB//MESAGE//' [Pitching Moments calculated]'
ELSE
WRITE(UnADopt,'(A)') 'NO_CM'//TAB//MESAGE//' [NO Pitching Moments calculated]'
ENDIF
MESAGE = 'Inflow model'
IF ( DYNINFL ) THEN
WRITE(UnADopt,'(A)') 'DYNIN'//TAB//MESAGE//' [Dynamic Inflow]'
ELSE
IF ( EquilDA .AND. EquilDT ) THEN
WRITE(UnADopt,'(A)') 'EQUILDB'//TAB//MESAGE//' [Equilibrium w/ axial and tangential drag]'
ELSEIF ( EquilDA ) THEN
WRITE(UnADopt,'(A)') 'EQUILDA'//TAB//MESAGE//' [Equilibrium w/ axial drag]'
ELSEIF ( EquilDT ) THEN
WRITE(UnADopt,'(A)') 'EQUILDA'//TAB//MESAGE//' [Equilibrium w/ tangential drag]'
ELSE
WRITE(UnADopt,'(A)') 'EQUIL'//TAB//MESAGE//' [Equilibrium]'
ENDIF
ENDIF
MESAGE = 'Induction factor model'
IF ( WAKE ) THEN
IF (SWIRL) THEN
WRITE(UnADopt,'(A)') 'SWIRL'//TAB//MESAGE//' [Normal and Radial flow induction factors calculated]'
ELSE
WRITE(UnADopt,'(A)') 'WAKE'//TAB//MESAGE//' [Normal flow induction factors calculated]'
ENDIF
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(ATOLER))//TAB// 'Convergence tolerance for induction factor'
ELSE
WRITE(UnADopt,'(A)') 'NONE'//TAB//MESAGE//' [NO induction factors calculated]'
WRITE(UnADopt,'(A)') '[Not Used]'//TAB//'Convergence tolerance for induction factor'
ENDIF
MESAGE = 'Tip-loss model'
IF (.NOT. DYNINFL) THEN
IF ( TLOSS ) THEN
IF (GTECH) THEN
WRITE(UnADopt,'(A)') 'GTECH'//TAB//MESAGE//' [Georgia Tech correction to Prandtl model]'
ELSE
WRITE(UnADopt,'(A)') 'PRAND'//TAB//MESAGE//' [Prandtl model]'
ENDIF
ELSE
WRITE(UnADopt,'(A)') 'NONE'//TAB//MESAGE//' [NO tip-loss calculated]'
ENDIF
ELSE
WRITE(UnADopt,'(A)') '[Not Used]'//TAB//MESAGE
ENDIF
MESAGE = 'Hub-loss model'
IF (.NOT. DYNINFL) THEN
IF ( HLOSS ) THEN
WRITE(UnADopt,'(A)') 'PRAND'//TAB//MESAGE//' [Prandtl model]'
ELSE
WRITE(UnADopt,'(A)') 'NONE'//TAB//MESAGE//' [NO hub-loss calculated]'
ENDIF
ELSE
WRITE(UnADopt,'(A)') '[Not Used]'//TAB//MESAGE
ENDIF
WRITE(UnADopt, '(A)') '"'//TRIM(WindFileName)//'"'//TAB//' Wind file name'
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(HH))//TAB// 'Wind reference (hub) height, '//TRIM(Dst_Unit)
IF ( PJM_Version ) THEN
WRITE(UnADopt,'(L2, A)') TwrPotent, TAB//'Calculate tower potential flow [T or F]'
WRITE(UnADopt,'(L2, A)') TwrShadow, TAB//'Calculate tower shadow [T or F]'
IF ( TwrPotent .OR. TwrShadow ) THEN
WRITE(UnADopt,'(A)') '"'//TRIM( TwrFile )//'"'//TAB//'Tower drag file name'
ELSE
WRITE(UnADopt,'(A)') '[none]'//TAB//'No tower drag properties file'
ENDIF
ELSE
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(TwrShad))//TAB// 'Tower shadow centerline velocity deficit'
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(ShadHWid))//TAB// 'Tower shadow half width, '//TRIM(Dst_Unit)
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(T_Shad_Refpt))//TAB// 'Tower shadow reference point, '//TRIM(Dst_Unit)
END IF
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(RHO))//TAB// 'Air density, '//TRIM(Mass_Unit)//'/'//TRIM(Dst_Unit)//'^3'
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(KinVisc))//TAB// 'Kinematic air viscosity, '//TRIM(Dst_Unit)//'^2/sec'
WRITE(UnADopt,'(A)') TRIM(Flt2LStr(DTAERO))//TAB// 'Time interval for aerodynamic calculations, sec'
WRITE(UnADopt,'(A)') TRIM(Int2LStr(NUMFOIL))//TAB// 'Number of airfoil files used. Files listed below:'
DO IFoil = 1, NUMFOIL
WRITE(UnADopt,'(A)') '"'//TRIM(FOILNM(IFoil))//'"'
END DO ! IFoil
WRITE(UnADopt,'(A)') TRIM(Int2LStr(NELM))//TAB// 'Number of blade elements per blade'
Delim = ' ' !or Delim = TAB
!-------------------------------------------------------------------------------------------------
! write out element information
!-------------------------------------------------------------------------------------------------
Frmt = '(3X,A10,8("'//Delim//'",A10))'
WRITE(UnADopt,'( )')
! column names
WRITE(UnADopt,Frmt) ' Element ', &
' RELM ', &
' Twist ', &
' DR ', &
' Chord ', &
' NFoil ', &
' Print? ', &
' Tip-loss ', &
' Hub-loss '
! column units
WRITE(UnADopt,Frmt) ' (-) ', &
' (m) ', &
' (deg) ', &
' (m) ', &
' (m) ', &
' (-) ', &
' (Yes/No) ', &
' constant ', &
' constant '
WRITE(UnADopt,Frmt) '----------', &
'----------', &
'----------', &
'----------', &
'----------', &
'----------', &
'----------', &
'----------', &
'----------'
! column data
Frmt = '(3X, I10, 4("'//Delim//'",F10.5),"'//Delim//'",I10,"'//Delim//'",A10, 2("'//Delim//'",F10.5) )'
DO IElm = 1, NELM
IF (ElPrList(IElm) /= 0) THEN
MESAGE = 'Yes'
ELSE
MESAGE = 'No'
ENDIF
WRITE(UnADopt, Frmt) IElm, RELM(IElm), TWIST(IElm)*R2D, DR(IElm), C(IElm), &
NFOIL(IElm), TRIM(Mesage), TLCNST(IElm), HLCNST(IElm)
END DO
IF ( MultiTab ) THEN
WRITE(UnADopt,'(A)') 'MULTI Multiple airfoil tables used'
ELSE
WRITE(UnADopt,'( )')
ENDIF
WRITE(UnADopt,"(/' Rotor radius = ',F7.3,' m')") R
WRITE(UnADopt,"( ' Hub radius = ',F7.3,' m')") HubRad
WRITE(UnADopt,"( ' Number of blades = ',I3 )") NB
IF ( DSTALL ) CALL BEDWRT
IF ( ELEMPRN ) WRITE(UnADopt,'(/A/)')'Blade element aerodynamic time series data written to file.' !bjj: what? isn't that what "Print? Y/N" is for?
CLOSE (UnADopt )
RETURN
END SUBROUTINE ADOut
! ****************************************************
SUBROUTINE READFL
! Reads a data file containing airfoil angle of attack,
! CL and CD, and dynamic stall parameters
! ****************************************************
USE AD_IOParams
USE Airfoil
USE Bedoes
USE AeroGenSubs, ONLY: AllocArrays
USE Switch
IMPLICIT NONE
! Local Variables:
REAL(ReKi), ALLOCATABLE :: CDNegPI(:)
REAL(ReKi), ALLOCATABLE :: CDPosPI(:)
REAL(ReKi), ALLOCATABLE :: CLNegPI(:)
REAL(ReKi), ALLOCATABLE :: CLPosPI(:)
REAL(ReKi), ALLOCATABLE :: CMNegPI(:)
REAL(ReKi), ALLOCATABLE :: CMPosPI(:)
INTEGER :: IPHI
INTEGER :: I
INTEGER :: K
INTEGER :: Sttus
INTEGER :: NFOILID
INTEGER :: NumLines
INTEGER :: NUNIT
INTEGER :: IOS
LOGICAL :: ALPosPI
LOGICAL :: ALNegPI
CHARACTER( 40) :: TITLE (2)
CHARACTER(1024) :: LINE
NUNIT = UnAirfl
NumCL = 0
! The first loop checks existence and file length to set NumCL
DO NFOILID = 1, NUMFOIL
! Open the file for reading # of lines
CALL OpenFInpFile (NUNIT, TRIM(FOILNM(NFOILID)))
! Determine the maximum number of aerodata points in all files
NumLines = 0
IOS = 0
DO WHILE (IOS == 0)
READ ( NUNIT, '()', IOSTAT=IOS )
NumLines = NumLines + 1
END DO
NumCL = MAX(NumLines - 14, NumCL)
CLOSE (NUNIT)
END DO ! NFOILID
! Allocate the arrays
Call AllocArrays ('Aerodata')
! The second loop reads the files
DO NFOILID = 1, NUMFOIL
! Open the file for reading inputs
CALL OpenFInpFile (NUNIT, TRIM(Adjustl(FOILNM(NFOILID))) )
! Set up the file to read the aerodata
READ(NUNIT,'( A )') TITLE(1)
READ(NUNIT,'( A )') TITLE(2)
! Read in airfoil table dimension parameters:
! NTables = number of airfoil data tables
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , '# of tables' )
READ(LINE,*,ERR=205) NTables( NFOILID )
! Allocate local arrays with NTables dimension
Sttus = 0
IF (.NOT. ALLOCATED(CLPosPI)) ALLOCATE ( CLPosPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CLPosPI array.' )
IF (.NOT. ALLOCATED(CDPosPI)) ALLOCATE ( CDPosPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CDPosPI array.' )
IF (.NOT. ALLOCATED(CMPosPI)) ALLOCATE ( CMPosPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CMPosPI array.' )
IF (.NOT. ALLOCATED(CLNegPI)) ALLOCATE ( CLNegPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CLNegPI array.' )
IF (.NOT. ALLOCATED(CDNegPI)) ALLOCATE ( CDNegPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CDNegPI array.' )
IF (.NOT. ALLOCATED(CMNegPI)) ALLOCATE ( CMNegPI(NTables(NFOILID)) , STAT=Sttus )
IF ( Sttus /= 0 ) CALL ProgAbort ( ' Error allocating memory for CMNegPI array.' )
! Read in airfoil data table identification array
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , 'multi-table metric' )
READ(LINE,*,ERR=205) (MulTabMet ( NFOILID, K ), K = 1, NTables(NFOILID))
! Read in four lines that are no longer used
! These are retained for future USE and backwards compatibility only
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , '5th line' )
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , '6th line' )
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , '7th line' )
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , '8th line' )
! Read Beddoes stall parameters
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , 'Angle of zero lift (AOL)' )
IF (DSTALL) READ(LINE,*,ERR=205) (AOL( NFOILID, K ), K = 1, NTables(NFOILID))
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , 'CNA' )
IF (DSTALL) READ(LINE,*,ERR=205) (CNA ( NFOILID, K ), K = 1, NTables(NFOILID))
READ(NUNIT,'( A )',IOSTAT=IOS) LINE
IF ( IOS < 0 ) CALL PremEOF ( Trim(FOILNM(NFOILID)) , 'CNS' )
IF (DSTALL) READ(LINE,*,ERR=205) (CNS ( NFOILID, K ), K = 1, NTables(NFOILID))
READ(NUNIT,'( A )',IOSTAT=IOS) LINE