Skip to content

Commit 8eaa89a

Browse files
authored
Merge pull request #2584 from andrew-platt/f/MD_shared_example
F/md shared example
2 parents bc6c481 + 2d9edde commit 8eaa89a

File tree

10 files changed

+103
-28
lines changed

10 files changed

+103
-28
lines changed

docs/source/user/api_change.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ SubDyn 56\*
3838
SubDyn 57\* NSpringPropSets 0 - Number of spring properties
3939
SubDyn 58\* PropSetID k11 k12 k13 k14 k15 k16 k22 k23 k24 k25 k26 k33 k34 k35 k36 k44 k45 k46 k55 k56 k66
4040
SubDyn 59\* (-) (N/m) (N/m) (N/m) (N/rad) (N/rad) (N/rad) (N/m) (N/m) (N/rad) (N/rad) (N/rad) (N/m) (N/rad) (N/rad) (N/rad) (Nm/rad) (Nm/rad) (Nm/rad) (Nm/rad) (Nm/rad) (Nm/rad)
41-
FAST.Farm 47 RotorDiamRef 125 RotorDiamRef - Reference turbine rotor diameter for wake calculations (m) [>0.0]
42-
FAST.Farm 57 k_vAmb DEFAULT k_vAmb - Calibrated parameters for the influence of the ambient turbulence in the eddy viscosity (set of 5 parameters: k, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=0.05, 1.0, 0.0, 1.0, 0.01]
43-
FAST.Farm 58 kvShr DEFAULT k_vShr - Calibrated parameters for the influence of the shear layer in the eddy viscosity (set of 5 parameters: k, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=0.016, 0.2, 3.0, 25.0, 0.1]
44-
FAST.Farm 59-66 --removed--
45-
FAST.Farm 71 --- WAKE-ADDED TURBULENCE ---
46-
FAST.Farm 72 WAT 2 WAT - Switch between wake-added turbulence box options {0: no wake added turbulence, 1: predefined turbulence box, 2: user defined turbulence box} (switch)
47-
FAST.Farm 73 WAT_BoxFile "../WAT_MannBoxDB/FFDB_D100_512x512x64.u" WAT_BoxFile - Filepath to the file containing the u-component of the turbulence box (either predefined or user-defined) (quoted string)
48-
FAST.Farm 74 WAT_NxNyNz 512, 512, 64 WAT_NxNyNz - Number of points in the x, y, and z directions of the WAT_BoxFile [used only if WAT=2, derived value if WAT=1] (-)
49-
FAST.Farm 75 WAT_DxDyDz 5.0, 5.0, 5.0 WAT_DxDyDz - Distance (in meters) between points in the x, y, and z directions of the WAT_BoxFile [used only if WAT=2, derived value if WAT=1] (m)
50-
FAST.Farm 76 WAT_ScaleBox default WAT_ScaleBox - Flag to scale the input turbulence box to zero mean and unit standard deviation at every node [DEFAULT=False] (flag)
51-
FAST.Farm 77 WAT_k_Def default WAT_k_Def - Calibrated parameters for the influence of the maximum wake deficit on wake-added turbulence (set of 5 parameters: k_Def, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=[0.6, 0.0, 0.0, 2.0, 1.0 ]]
52-
FAST.Farm 78 WAT_k_Grad default WAT_k_Grad - Calibrated parameters for the influence of the radial velocity gradient of the wake deficit on wake-added turbulence (set of 5 parameters: k_Grad, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=[3.0, 0.0, 0.0, 12.0, 0.65]
41+
FAST.Farm 16 WrMooringVis true WrMooringVis - Write shared mooring visualization, at DT_Mooring timestep (-) [only used for Mod_SharedMooring=3]
42+
FAST.Farm 48 RotorDiamRef 125 RotorDiamRef - Reference turbine rotor diameter for wake calculations (m) [>0.0]
43+
FAST.Farm 58 k_vAmb DEFAULT k_vAmb - Calibrated parameters for the influence of the ambient turbulence in the eddy viscosity (set of 5 parameters: k, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=0.05, 1.0, 0.0, 1.0, 0.01]
44+
FAST.Farm 59 kvShr DEFAULT k_vShr - Calibrated parameters for the influence of the shear layer in the eddy viscosity (set of 5 parameters: k, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=0.016, 0.2, 3.0, 25.0, 0.1]
45+
FAST.Farm 60-66 --removed--
46+
FAST.Farm 72 --- WAKE-ADDED TURBULENCE ---
47+
FAST.Farm 73 WAT 2 WAT - Switch between wake-added turbulence box options {0: no wake added turbulence, 1: predefined turbulence box, 2: user defined turbulence box} (switch)
48+
FAST.Farm 74 WAT_BoxFile "../WAT_MannBoxDB/FFDB_D100_512x512x64.u" WAT_BoxFile - Filepath to the file containing the u-component of the turbulence box (either predefined or user-defined) (quoted string)
49+
FAST.Farm 75 WAT_NxNyNz 512, 512, 64 WAT_NxNyNz - Number of points in the x, y, and z directions of the WAT_BoxFile [used only if WAT=2, derived value if WAT=1] (-)
50+
FAST.Farm 76 WAT_DxDyDz 5.0, 5.0, 5.0 WAT_DxDyDz - Distance (in meters) between points in the x, y, and z directions of the WAT_BoxFile [used only if WAT=2, derived value if WAT=1] (m)
51+
FAST.Farm 77 WAT_ScaleBox default WAT_ScaleBox - Flag to scale the input turbulence box to zero mean and unit standard deviation at every node [DEFAULT=False] (flag)
52+
FAST.Farm 78 WAT_k_Def default WAT_k_Def - Calibrated parameters for the influence of the maximum wake deficit on wake-added turbulence (set of 5 parameters: k_Def, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=[0.6, 0.0, 0.0, 2.0, 1.0 ]]
53+
FAST.Farm 79 WAT_k_Grad default WAT_k_Grad - Calibrated parameters for the influence of the radial velocity gradient of the wake deficit on wake-added turbulence (set of 5 parameters: k_Grad, FMin, DMin, DMax, Exp) (-) [>=0.0, >=0.0 and <=1.0, >=0.0, >DMin, >0.0] or DEFAULT [DEFAULT=[3.0, 0.0, 0.0, 12.0, 0.65]
5354
AeroDyn 80\* NacArea 0, 0, 0 NacArea - Projected area of the nacelle in X, Y, Z in the nacelle coordinate system (m^2)
5455
AeroDyn 81\* NacCd 0, 0, 0 NacCd - Drag coefficient for the nacelle areas defined above (-)
5556
AeroDyn 82\* NacDragAC 0, 0, 0 NacDragAC - Position of aerodynamic center of nacelle drag in nacelle coordinates (m)

docs/source/user/fast.farm/InputFiles.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ documentation for details on the input file at the farm level.
138138
**DT_Mooring** (sec) sets the timestep for the shared mooring connections with
139139
MoorDyn.
140140

141+
**WrMooringVis** [swithch] Write shared mooring line visualization, at
142+
the global FAST.Farm time step
143+
144+
141145
.. _FF:Input:VTK:
142146

143147
Ambient Wind: Precursor in Visualization Toolkit Format

glue-codes/fast-farm/src/FAST_Farm_IO.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ SUBROUTINE Farm_ReadPrimaryFile( InputFile, p, WD_InitInp, AWAE_InitInp, SC_Init
643643
CALL ReadVar( UnIn, InputFile, p%MD_FileName, "MD_FileName", "Name/location of the dynamic library {.dll [Windows] or .so [Linux]} containing the Super Controller algorithms (quoated string)", ErrStat2, ErrMsg2, UnEc); if (Failed()) return
644644
IF ( PathIsRelative( p%MD_FileName ) ) p%MD_FileName = TRIM(PriPath)//TRIM(p%MD_FileName)
645645
CALL ReadVar( UnIn, InputFile, p%DT_mooring, "DT_Mooring", "Time step for farm-levem mooring coupling with each turbine [used only when Mod_SharedMooring > 0] (s) [>0.0]", ErrStat2, ErrMsg2, UnEc); if (Failed()) return
646+
CALL ReadVar( UnIn, InputFile, p%WrMooringVis, "MooringVis","Write shared mooring visualization, at DT_Mooring timestep (-) [only used for Mod_SharedMooring=3]", ErrStat2, ErrMsg2, UnEc); if (Failed()) return
646647

647648
!---------------------- AMBIENT WIND: PRECURSOR IN VTK FORMAT ---------------------------------------------
648649
CALL ReadCom( UnIn, InputFile, 'Section Header: Ambient Wind: Precursor in VTK Format', ErrStat2, ErrMsg2, UnEc ); if (Failed()) return

glue-codes/fast-farm/src/FAST_Farm_Registry.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef ^ ParameterType LOGICAL UseSC -
4141
typedef ^ ParameterType ReKi WT_Position {:}{:} - - "X-Y-Z position of each wind turbine; index 1 = XYZ; index 2 = turbine number" meters
4242
typedef ^ ParameterType IntKi WaveFieldMod - - - "Wave field handling (-) (switch) {0: use individual HydroDyn inputs without adjustment, 1: adjust wave phases based on turbine offsets from farm origin}" -
4343
typedef ^ ParameterType IntKi MooringMod - - - "Mod_SharedMooring is a flag for array-level mooring. (switch) {0: none, 3: yes/MoorDyn}" -
44+
typedef ^ ParameterType logical WrMooringVis - - - "Write shared mooring visualization (-) [only used for Mod_SharedMooring=3]" -
4445
typedef ^ ParameterType CHARACTER(1024) MD_FileName - - - "Name/location of the farm-level MoorDyn input file" -
4546
typedef ^ ParameterType DbKi DT_mooring - - - "Time step for farm-levem mooring coupling with each turbine [used only when Mod_SharedMooring > 0]" seconds
4647
typedef ^ ParameterType IntKi n_mooring - - - "Number of FAST and MoorDyn time steps per FAST.Farm timestep when mooring > 0" -
@@ -157,6 +158,9 @@ typedef ^ ^ DbKi InputTimes {:} -
157158
typedef ^ ^ MD_OutputType y - - - "System outputs"
158159
typedef ^ ^ MD_MiscVarType m - - - "Misc/optimization variables"
159160
typedef ^ ^ logical IsInitialized - .FALSE. - "Has MD_Init been called"
161+
typedef ^ ^ IntKi VTK_count - 0 - "Counter for VTK output of shared moorings"
162+
typedef ^ ^ IntKi VTK_TWidth - - - "width for VTK_count field in output name"
163+
typedef ^ ^ character(1024) VTK_OutFileRoot - - - "Rootfilename for VTK output"
160164
# ..... WAT InflowWind data ............................................................................................
161165
typedef ^ WAT_IfW_data InflowWind_ContinuousStateType x - - - "Continuous states"
162166
typedef ^ ^ InflowWind_DiscreteStateType xd - - - "Discrete states"

glue-codes/fast-farm/src/FAST_Farm_Subs.f90

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ SUBROUTINE Farm_InitMD( farm, ErrStat, ErrMsg )
783783
type(MD_InitInputType) :: MD_InitInp
784784
type(MD_InitOutputType) :: MD_InitOut
785785

786+
character(1025) :: Path, FileRoot ! for vtk outputs
786787
INTEGER(IntKi) :: nt ! loop counter for rotor number
787788
INTEGER(IntKi) :: ErrStat2 ! Temporary Error status
788789
CHARACTER(ErrMsgLen) :: ErrMsg2 ! Temporary Error message
@@ -844,6 +845,14 @@ SUBROUTINE Farm_InitMD( farm, ErrStat, ErrMsg )
844845
MD_InitInp%rhoW = 1025.0
845846
MD_InitInp%WtrDepth = 0.0 !TODO: eventually connect this to a global depth input variable <<<
846847

848+
! Visualization of shared moorings
849+
if (farm%p%WrMooringVis) then
850+
MD_InitInp%VisMeshes=.true.
851+
farm%MD%VTK_Count = 0
852+
call GetPath ( MD_InitInp%RootName, Path, FileRoot ) ! the returned DVR_Outs%VTK_OutFileRoot includes a file separator character at the end
853+
farm%MD%VTK_OutFileRoot = trim(Path)//PathSep//'vtk'//PathSep//trim(FileRoot)
854+
farm%MD%VTK_TWidth = 5 !FIXME: this should be set based on sim length
855+
endif
847856

848857
! allocate MoorDyn inputs (assuming size 2 for linear interpolation/extrapolation... >
849858
ALLOCATE( farm%MD%Input( 2 ), farm%MD%InputTimes( 2 ), STAT = ErrStat2 )
@@ -1006,7 +1015,7 @@ subroutine FARM_MD_Increment(t, n, farm, ErrStat, ErrMsg)
10061015

10071016
end if
10081017
end do
1009-
1018+
10101019

10111020
contains
10121021
logical function Failed()
@@ -1657,7 +1666,7 @@ subroutine FARM_CalcOutput(t, farm, ErrStat, ErrMsg)
16571666
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status
16581667
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message
16591668

1660-
INTEGER(IntKi) :: nt
1669+
INTEGER(IntKi) :: nt,j
16611670
INTEGER(IntKi) :: ErrStat2 ! Temporary Error status
16621671
CHARACTER(ErrMsgLen) :: ErrMsg2 ! Temporary Error message
16631672
CHARACTER(*), PARAMETER :: RoutineName = 'FARM_CalcOutput'
@@ -1755,6 +1764,31 @@ subroutine FARM_CalcOutput(t, farm, ErrStat, ErrMsg)
17551764
call Farm_WriteOutput(n, t, farm, ErrStat2, ErrMsg2)
17561765
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
17571766

1767+
!.......................................................................................
1768+
! Write shared moorings visualization
1769+
!.......................................................................................
1770+
1771+
! Write visualization meshes
1772+
if (farm%p%MooringMod == 3) then
1773+
if (farm%MD%p%VisMeshes) then
1774+
if (allocated(farm%MD%y%VisLinesMesh)) then
1775+
do j=1,size(farm%MD%y%VisLinesMesh)
1776+
if (farm%MD%y%VisLinesMesh(j)%Committed) then
1777+
call MeshWrVTK((/0.0_SiKi,0.0_SiKi,0.0_SiKi/), farm%MD%y%VisLinesMesh(j), trim(farm%MD%VTK_OutFileRoot)//'.MD_Line'//trim(Num2LStr(j)), farm%MD%VTK_count, .false., ErrSTat2, ErrMsg2, farm%MD%VTK_tWidth )
1778+
endif
1779+
enddo
1780+
endif
1781+
if (allocated(farm%MD%y%VisRodsMesh)) then
1782+
do j=1,size(farm%MD%y%VisRodsMesh)
1783+
if (farm%MD%y%VisRodsMesh(j)%Committed) then
1784+
call MeshWrVTK((/0.0_SiKi,0.0_SiKi,0.0_SiKi/), farm%MD%y%VisRodsMesh(j), trim(farm%MD%VTK_OutFileRoot)//'.MD_Rod'//trim(Num2LStr(j)), farm%MD%VTK_count, .false., ErrSTat2, ErrMsg2, farm%MD%VTK_tWidth )
1785+
endif
1786+
enddo
1787+
endif
1788+
farm%MD%VTK_Count = farm%MD%VTK_Count + 1
1789+
endif
1790+
endif
1791+
17581792
! write(*,*) 'Total Farm_CO-serial took '//trim(num2lstr(omp_get_wtime()-tm1))//' seconds.'
17591793

17601794
end subroutine FARM_CalcOutput
@@ -1841,7 +1875,7 @@ subroutine FARM_End(farm, ErrStat, ErrMsg)
18411875

18421876
!--------------
18431877
! 6. End farm-level MoorDyn
1844-
if (farm%p%MooringMod == 3) then
1878+
if (farm%p%MooringMod == 3 .and. allocated(farm%MD%Input)) then
18451879
call MD_End(farm%MD%Input(1), farm%MD%p, farm%MD%x, farm%MD%xd, farm%MD%z, farm%MD%OtherSt, farm%MD%y, farm%MD%m, ErrStat2, ErrMsg2)
18461880
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
18471881
!TODO: any related items need to be cleared?

0 commit comments

Comments
 (0)