Skip to content

Commit cd53c27

Browse files
authored
Merge pull request #3149 from bjonkman/b/AeroAcoustics_cleanup
AeroAcoustics cleanup + added driver code
2 parents 69cab72 + 2480d90 commit cd53c27

11 files changed

+1094
-776
lines changed

modules/aerodyn/src/AeroAcoustics.f90

Lines changed: 191 additions & 213 deletions
Large diffs are not rendered by default.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
!**********************************************************************************************************************************
2+
! LICENSING
3+
! Copyright (C) 2015-2016 National Renewable Energy Laboratory
4+
!
5+
! This file is part of AeroDyn.
6+
!
7+
! Licensed under the Apache License, Version 2.0 (the "License");
8+
! you may not use this file except in compliance with the License.
9+
! You may obtain a copy of the License at
10+
!
11+
! http://www.apache.org/licenses/LICENSE-2.0
12+
!
13+
! Unless required by applicable law or agreed to in writing, software
14+
! distributed under the License is distributed on an "AS IS" BASIS,
15+
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
! See the License for the specific language governing permissions and
17+
! limitations under the License.
18+
!
19+
20+
!there will also be various control flags... this may be updated as needed:
21+
!TBLflag = {'BPM','TNO'}
22+
!bluntnessFlag = {'DTU','BPM'}
23+
!BPMBLflag = {'true','false'}
24+
!useOrigModelAtSepOnset = {'true','false'}
25+
26+
27+
28+
29+
30+
!**********************************************************************************************************************************
31+
program AeroAcoustics_Driver
32+
use AeroAcoustics_Driver_Subs
33+
use VersionInfo
34+
implicit none
35+
36+
! Program variables
37+
REAL(ReKi) :: PrevClockTime ! Clock time at start of simulation in seconds [(s)]
38+
REAL(ReKi) :: UsrTime1 ! User CPU time for simulation initialization [(s)]
39+
REAL(ReKi) :: UsrTime2 ! User CPU time for simulation (without initialization) [(s)]
40+
INTEGER(IntKi) , DIMENSION(1:8) :: StrtTime ! Start time of simulation (including initialization) [-]
41+
INTEGER(IntKi) , DIMENSION(1:8) :: SimStrtTime ! Start time of simulation (after initialization) [-]
42+
REAL(DbKi) :: t_global ! global-loop time marker
43+
REAL(DbKi) :: TiLstPrn ! The simulation time of the last print (to file) [(s)]
44+
45+
TYPE(Dvr_Data) :: DriverData
46+
47+
character(1024) :: InputFile
48+
integer :: nt !< loop counter (for time step)
49+
character(20) :: FlagArg ! flag argument from command line
50+
integer(IntKi) :: ErrStat ! status of error message
51+
character(ErrMsgLen) :: ErrMsg !local error message if ErrStat /= ErrID_None
52+
53+
54+
CALL DATE_AND_TIME ( Values=StrtTime ) ! Let's time the whole simulation
55+
CALL CPU_TIME ( UsrTime1 ) ! Initial time (this zeros the start time when used as a MATLAB function)
56+
UsrTime1 = MAX( 0.0_ReKi, UsrTime1 ) ! CPU_TIME: If a meaningful time cannot be returned, a processor-dependent negative value is returned
57+
UsrTime2 = UsrTime1 ! CPU_TIME: Initialize in case of error before getting real data
58+
SimStrtTime = StrtTime ! CPU_TIME: Initialize in case of error before getting real data
59+
nt = 0
60+
61+
! --- Driver initialization
62+
CALL NWTC_Init( ProgNameIN=version%Name )
63+
64+
InputFile = "" ! initialize to empty string to make sure it's input from the command line
65+
CALL CheckArgs( InputFile, Flag=FlagArg )
66+
IF ( LEN( TRIM(FlagArg) ) > 0 ) CALL NormStop()
67+
68+
! Display the copyright notice and compile info:
69+
CALL DispCopyrightLicense( version%Name )
70+
CALL DispCompileRuntimeInfo( version%Name )
71+
72+
73+
! Initialize modules
74+
call ReadDriverInputFile( InputFile, DriverData, ErrStat, ErrMsg ); call CheckError()
75+
call Init_AFI(DriverData%Airfoil_FileName, DriverData%AFInfo, ErrStat, ErrMsg); call CheckError()
76+
call Init_AAmodule(DriverData, ErrStat, ErrMsg); call CheckError()
77+
78+
! Init of time estimator
79+
t_global=0.0_DbKi
80+
call SimStatus_FirstTime( TiLstPrn, PrevClockTime, SimStrtTime, UsrTime2, t_global, DriverData%TMax )
81+
82+
! Time loop
83+
do nt = 1, DriverData%numSteps
84+
! Time update to screen
85+
t_global=nt * DriverData%dt
86+
87+
if (mod( nt + 1, 10 )==0) call SimStatus(TiLstPrn, PrevClockTime, t_global, DriverData%TMax)
88+
89+
! update states and calculate output
90+
call SetInputsForAA(DriverData)
91+
92+
call AA_CalcOutput(t_global, DriverData%u, DriverData%p, DriverData%xd, DriverData%OtherState, DriverData%y, DriverData%m, errStat, errMsg); call CheckError()
93+
call Dvr_WriteOutputs(t_global, nt, DriverData) ! write to file at this step
94+
95+
! Get state variables at next step: INPUT at step nt - 1, OUTPUT at step nt
96+
call AA_UpdateStates(t_global, nt, DriverData%m, DriverData%u, DriverData%p, DriverData%xd, DriverData%OtherState, errStat, errMsg); call CheckError()
97+
98+
end do !nt=1,numSteps
99+
100+
101+
call Dvr_End()
102+
contains
103+
!................................
104+
subroutine CheckError()
105+
if (ErrStat /= ErrID_None) then
106+
call WrScr(TRIM(errMsg))
107+
if (errStat >= AbortErrLev) then
108+
call Dvr_End()
109+
end if
110+
ErrStat = ErrID_None
111+
end if
112+
end subroutine CheckError
113+
!................................
114+
subroutine Dvr_End()
115+
integer(IntKi) :: errStat2 ! local status of error message
116+
character(ErrMsgLen) :: errMsg2 ! local error message if ErrStat /= ErrID_None
117+
118+
call Dvr_EndOutput(DriverData, nt, errStat2, errMsg2)
119+
if (ErrStat2 /= ErrID_None) call WrScr(TRIM(errMsg2))
120+
121+
call RunTimes(StrtTime, UsrTime1, SimStrtTime, UsrTime2, t_global)
122+
123+
if (ErrStat >= AbortErrLev) then
124+
call WrScr('')
125+
CALL ProgAbort( 'AeroAcoustics Driver encountered simulation error level: '&
126+
//TRIM(GetErrStr(ErrStat)), TrapErrors=.FALSE., TimeWait=3._ReKi ) ! wait 3 seconds (in case they double-clicked and got an error)
127+
else
128+
call NormStop()
129+
end if
130+
end subroutine Dvr_End
131+
!................................
132+
end program AeroAcoustics_Driver
133+
134+
135+
136+
!Inputs that will be supplied externally:
137+
!driver%DT
138+
!
139+
!Need to set in InitInput:
140+
! rho [InitInputType%airDens]
141+
! c0 or co [InitInputType%SpdSound]
142+
! L [InitInputType%BlSpn]
143+
! chord [InitInputType%BlChord]
144+
! [driver%DT = Interval]
145+
! visc [InitInputType%KinVisc]
146+
! [InitInputType%HubHeight]
147+
! Airfoil info:
148+
! BlAFID
149+
! AFInfo
150+
!
151+
!Set in AA Input File:
152+
! Lturb (already in AA input file) [InputFileData%Lturb]
153+
! dStarS [m%dstarVar(1), dstarVar1, DSTRS -> interpolated from p%dstarall1 = InputFileData%Suct_DispThick using AoA and Re] meters
154+
! dStarP [m%dstarVar(2), dstarVar2, DSTRP -> interpolated from p%dstarall2 = InputFileData%Pres_DispThick using AoA and Re] meters
155+
! TI [InputFileData%TI]
156+
! cfS [m%CfVar(1), Cfall(1) -> interpolated p%Cfall1=InputFileData%Suct_Cf with Re and AoA]
157+
! cfP [m%CfVar(2), Cfall(2) -> interpolated p%Cfall2=InputFileData%Pres_Cf with Re and AoA]
158+
! deltaS [m%d99Var(1) -> interpolated p%d99all1=InputFileData%Suct_BLThick with Re and AoA]
159+
! deltaP [m%d99Var(2), d99Var2 -> interpolated p%d99all2=InputFileData%Pres_BLThick with Re and AoA ] PRESSURE SIDE BOUNDARY LAYER THICKNESS METERS
160+
! uEdgeS [m%EdgeVelVar(1), EdgeVelAll(2) -> interpolated p%EdgeVelRat1=InputFileData%Suct_EdgeVelRat with Re and AoA]
161+
! uEdgeP [m%EdgeVelVar(2), EdgeVelAll(2) -> interpolated p%EdgeVelRat2=InputFileData%Pres_EdgeVelRat with Re and AoA]
162+
!
163+
!Inputs caluculated in AeroDyn (now set in driver input file?):
164+
! meanWindspeed [u%Inflow]
165+
! AoA [u%AoANoise]
166+
! [u%vRel]
167+
! [AeroCent_G] = u%BladeMotion(j)%Position(:,i) + u%BladeMotion(j)%TranslationDisp(:,i) (global position of the blade node) -> fixed value???
168+
! [RotGtoL] -> set to identity
169+
!
170+
!Inputs calculated
171+
! Ma [M or Mach] : calculated M = U / p%SpdSound ! MACH NUMBER
172+
! Re [RC] : calculated RC = U * C/p%KinVisc ! Reynolds number; C = chord; U=UNoise=sign( max(abs(u%Vrel(J,I)),0.1), u%Vrel(J,I) )
173+
!
174+
!fSep1p0_alpha (new to BPM)
175+
!fSpe0p7_alpha (new to BPM)
176+

0 commit comments

Comments
 (0)