Skip to content

Commit

Permalink
Merge remote-tracking branch 'Pietro/noise' into f/noise
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Jul 21, 2020
2 parents 6cedc11 + 91ad82f commit 708ef24
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 130 deletions.
23 changes: 17 additions & 6 deletions modules/aerodyn/src/AeroAcoustics/AeroAcoustics.f90
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,12 @@ subroutine Init_y(y, u, p, errStat, errMsg)
p%numOuts = p%NrObsLoc
p%NumOutsForSep = p%NrObsLoc*size(p%FreqList)*nNoiseMechanism
p%NumOutsForPE = p%NrObsLoc*size(p%Freqlist)
p%NumOutsForNodes = p%NrObsLoc*p%NumBlNds*p%NumBlades
call AllocAry(y%WriteOutput , p%numOuts , 'y%WriteOutput' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%WriteOutputSep , p%NumOutsForSep , 'y%WriteOutputSep' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%WriteOutputForPE , p%numOutsForPE , 'y%WriteOutputForPE' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%DirectiviOutput , p%NrObsLoc , 'y%DirectiviOutput' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%WriteOutputSepFreq , size(y%SumSpecNoiseSep,1)*size(y%SumSpecNoiseSep,2)*size(y%SumSpecNoiseSep,3) , 'y%WriteOutputSepFreq' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%WriteOutputNode , p%NumOutsForNodes , 'y%WriteOutputSepFreq' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%OASPL , p%NrObsLoc , p%NumBlNds , p%NumBlades , 'y%OASPL' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%SumSpecNoise , size(p%FreqList) , p%NrObsLoc , p%NumBlades , 'y%SumSpecNoise' , errStat2 , errMsg2); if(Failed()) return
call AllocAry(y%SumSpecNoiseSep , 7 , p%NrObsLoc , size(p%FreqList) , 'y%SumSpecNoiseSep' , errStat2 , errMsg2); if(Failed()) return
Expand All @@ -491,7 +492,7 @@ subroutine Init_y(y, u, p, errStat, errMsg)
y%WriteOutputSep = 0.0_reki
y%WriteOutputForPE = 0.0_reki
y%DirectiviOutput = 0.0_reki
y%WriteOutputSepFreq = 0.0_reki
y%WriteOutputNode = 0.0_reki
y%OASPL = 0.0_reki
y%OASPL_Mech = 0.0_reki
y%SumSpecNoise = 0.0_reki
Expand Down Expand Up @@ -1214,15 +1215,25 @@ SUBROUTINE CalcAeroAcousticsOutput(u,p,m,xd,y,errStat,errMsg)
y%DirectiviOutput(K) = Ptotal + y%DirectiviOutput(K) ! Assigns Overall Pressure to Appropriate Observer for Directivity
IF (y%DirectiviOutput(K) .EQ. 0.) y%DirectiviOutput(K) = 1 ! Since these will all be converted via LOG10, they will produce an error if .EQ. 0.
! Set .EQ. to 1 instead (LOG10(1)=0)
y%OASPL(K,J,I) = Ptotal + y%OASPL(K,J,I) ! Assigns Overall Pressure to Appropriate Observer/Blade/Node for Directivity
ENDDO ! Loop on observers
ENDDO ! Loop on blade nodes
ENDDO ! Loop on blades

! If any Output file is wanted, convert DirectiviOutput from Directivity Factor to Directivity Index
! Ref: Fundamentals of Acoustics by Colin Hansen (1951)
IF (p%NrOutFile .gt. 0) y%DirectiviOutput = 10.*LOG10(y%DirectiviOutput) !! DirectiviOutput is used as total observer OASPL for Output File 1
! If any Output file is wanted, convert DirectiviOutput from Directivity Factor to Directivity Index
! Ref: Fundamentals of Acoustics by Colin Hansen (1951)
y%DirectiviOutput = 10.*LOG10(y%DirectiviOutput) !! DirectiviOutput is used as total observer OASPL for Output File 1
! Since these will all be converted via LOG10, they will produce an error if .EQ. 0., Set .EQ. to 1 instead (LOG10(1)=0)
DO I = 1,p%numBlades
DO J = 1,p%NumBlNds
DO K = 1,p%NrObsLoc
IF (y%OASPL(K,J,I) .EQ. 0.) y%OASPL(K,J,I) = 1
ENDDO
ENDDO
ENDDO
IF (p%NrOutFile .gt. 0) y%OASPL = 10.*LOG10(y%OASPL) !! OASPL is used as observer/blade/node OASPL for Output File 4

! Procedure for Output file 2
! Procedure for Output file 2
IF (p%NrOutFile .gt. 1) THEN
DO K = 1,p%NrObsLoc
DO III=1,size(p%FreqList)
Expand Down
54 changes: 27 additions & 27 deletions modules/aerodyn/src/AeroAcoustics/AeroAcoustics_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -691,18 +691,19 @@ subroutine AA_SetInitOut(p, InputFileData, InitOut, errStat, errMsg)
enddo
enddo
enddo
! FOURTH FILE HEADER,UNIT - NOT WORKING (MP)
call AllocAry(InitOut%WriteOutputHdrSepFreq,size(p%FreqList)*p%NrObsLoc*7, 'InitOut%WriteOutputHdrSepFreq', errStat2, errMsg2); if(Failed()) return
call AllocAry(InitOut%WriteOutputUntSepFreq,size(p%FreqList)*p%NrObsLoc*7, 'InitOut%WriteOutputUntSepFreq', errStat2, errMsg2); if(Failed()) return

! FOURTH FILE HEADER,UNIT
call AllocAry(InitOut%WriteOutputHdrNodes,p%numBlades*p%NumBlNds*p%NrObsLoc, 'InitOut%WriteOutputHdrNodes', errStat2, errMsg2); if(Failed()) return
call AllocAry(InitOut%WriteOutputUntNodes,p%numBlades*p%NumBlNds*p%NrObsLoc, 'InitOut%WriteOutputUntNodes', errStat2, errMsg2); if(Failed()) return
i=0
do k=1,size(p%FreqList)
do j=1,p%NrObsLoc
do oi=1,7
do oi = 1,p%numBlades
do k = 1,p%NumBlNds
do j = 1,p%NrObsLoc
i=i+1
InitOut%WriteOutputHdrSepFreq(i) = "F"//trim(num2lstr(p%FreqList(k)))//"Obs"//trim(num2lstr(j))//"_Type"//trim(num2lstr(oi))
InitOut%WriteOutputUntSepFreq(i) = "SPL"
end do
end do
InitOut%WriteOutputHdrNodes(i) = "Bld"//trim(num2lstr(oi))//"Node"//trim(num2lstr(k))//"Obs"//trim(num2lstr(j))
InitOut%WriteOutputUntNodes(i) = "SPL"
enddo
enddo
enddo
InitOut%Ver = AA_Ver
InitOut%delim = Tab
Expand Down Expand Up @@ -841,23 +842,22 @@ subroutine AA_InitializeOutputFile(p, InputFileData,InitOut,errStat, errMsg)
write( p%unOutFile4, '(A,I5)' )'Number of blades :', p%numBlades
write( p%unOutFile4, '(A,I5)' )'Number of nodes per blade:', p%NumBlNds
write( p%unOutFile4, '(A,I5)' )'Number of observers :', p%NrObsLoc
numOuts = size(InitOut%WriteOutputHdrSepFreq)
numOuts = size(InitOut%WriteOutputHdrNodes)
!......................................................
! Write the names of the output parameters on one line:
!......................................................
call WrFileNR ( p%unOutFile4, "1-LBL 2-TBLPres 3-TBLSuc 4-Sep 5-BLUNT 6-TIP 7-Inflow")
write (p%unOutFile4,'()')
call WrFileNR ( p%unOutFile4, ' Time ' )
do i=1,NumOuts
call WrFileNR ( p%unOutFile4, InitOut%delim//InitOut%WriteOutputHdrSepFreq(i) )
call WrFileNR ( p%unOutFile4, InitOut%delim//InitOut%WriteOutputHdrNodes(i) )
end do ! i
write (p%unOutFile4,'()')
!......................................................
! Write the units of the output parameters on one line:
!......................................................
call WrFileNR ( p%unOutFile4, ' (s) ' )
do i=1,NumOuts
call WrFileNR ( p%unOutFile4, InitOut%delim//InitOut%WriteOutputUntSepFreq(i) )
call WrFileNR ( p%unOutFile4, InitOut%delim//InitOut%WriteOutputUntNodes(i) )
end do ! i
write (p%unOutFile4,'()')
ENDIF
Expand Down Expand Up @@ -914,12 +914,12 @@ subroutine AA_WriteOutputLine(y, t, p, errStat, errMsg)
ENDIF
! Fourth FILE
IF (p%NrOutFile .gt. 3) THEN
numOuts = size(y%WriteOutputSepFreq)
numOuts = size(y%WriteOutputNode)
frmt = '"'//p%delim//'"'//trim(p%outFmt) ! format for array elements from individual modules
! time
write( tmpStr, '(F15.4)' ) t
call WrFileNR( p%unOutFile4, tmpStr )
call WrNumAryFileNR ( p%unOutFile4, y%WriteOutputSepFreq, frmt, errStat, errMsg )
call WrNumAryFileNR ( p%unOutFile4, y%WriteOutputNode, frmt, errStat, errMsg )
if ( errStat >= AbortErrLev ) return
! write a new line (advance to the next line)
write (p%unOutFile4,'()')
Expand Down Expand Up @@ -971,18 +971,18 @@ SUBROUTINE Calc_WriteOutput( p, u, m, y, ErrStat, ErrMsg )
enddo
ENDIF

! FOR THE FOURTH OUTPUT FILE
IF (p%NrOutFile .gt. 3) THEN
counter=0
DO J = 1, size(p%FreqList)
DO K = 1,p%NrObsLoc
do oi=1,size(y%OASPL_Mech,1)
counter=counter+1
y%WriteOutputSepFreq(counter) = y%SumSpecNoiseSep(oi,K,J)
! FOR THE FOURTH OUTPUT FILE
IF (p%NrOutFile .gt. 3) THEN
counter=0
DO I = 1,p%numBlades
DO J = 1,p%NumBlNds
DO K = 1,p%NrObsLoc
counter=counter+1
y%WriteOutputNode(counter) = y%OASPL(K,J,I)
END DO !
END DO !
END DO !
ENDDO
ENDIF
ENDDO
ENDIF
END SUBROUTINE Calc_WriteOutput
!----------------------------------------------------------------------------------------------------------------------------------
END MODULE AeroAcoustics_IO
8 changes: 4 additions & 4 deletions modules/aerodyn/src/AeroAcoustics_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ typedef ^ InitOutputType CHARACTER(20) WriteOutputH
typedef ^ InitOutputType CHARACTER(20) WriteOutputUntforPE {:} - - "Units of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputHdrSep {:} - - "Names of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputUntSep {:} - - "Units of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputHdrSepFreq {:} - - "Names of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputUntSepFreq {:} - - "Units of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputHdrNodes {:} - - "Names of the output-to-file channels" -
typedef ^ InitOutputType CHARACTER(25) WriteOutputUntNodes {:} - - "Units of the output-to-file channels" -
typedef ^ InitOutputType character(1) delim - - - "column delimiter" "-"
typedef ^ InitOutputType ProgDesc Ver - - - "This module's name, version, and date" -
typedef ^ InitOutputType ReKi AirDens - - - "Air density" kg/m^3
Expand Down Expand Up @@ -196,7 +196,7 @@ typedef ^ ParameterType character(1) delim
typedef ^ ParameterType IntKi NumOuts - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi NumOutsForPE - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi NumOutsForSep - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi NumOutsForSepFreq - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi NumOutsForNodes - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi unOutFile - - - "unit number for writing output file" "-"
typedef ^ ParameterType IntKi unOutFile2 - - - "unit number for writing output file" "-"
typedef ^ ParameterType IntKi unOutFile3 - - - "unit number for writing output file" "-"
Expand Down Expand Up @@ -247,4 +247,4 @@ typedef ^ OutputType ReKi PtotalF
typedef ^ OutputType ReKi WriteOutputForPE {:} - - "Data to be written to an output file: see WriteOutputHdr for names of each variable" "see WriteOutputUnt"
typedef ^ OutputType ReKi WriteOutput {:} - - "Data to be written to an output file: see WriteOutputHdr for names of each variable" "see WriteOutputUnt"
typedef ^ OutputType ReKi WriteOutputSep {:} - - "Data to be written to an output file: see WriteOutputHdr for names of each variable" "see WriteOutputUnt"
typedef ^ OutputType ReKi WriteOutputSepFreq {:} - - "Data to be written to an output file: see WriteOutputHdr for names of each variable" "see WriteOutputUnt"
typedef ^ OutputType ReKi WriteOutputNode {:} - - "Data to be written to an output file: see WriteOutputHdr for names of each variable" "see WriteOutputUnt"
Loading

0 comments on commit 708ef24

Please sign in to comment.