Skip to content

Commit

Permalink
LD: starting lindyn
Browse files Browse the repository at this point in the history
  • Loading branch information
ebranlard committed Oct 27, 2023
1 parent 889501f commit dbec473
Show file tree
Hide file tree
Showing 10 changed files with 4,249 additions and 19 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ set(OPENFAST_MODULES
icefloe
wakedynamics
awae
lindyn
map
turbsim
supercontroller
Expand Down
2 changes: 1 addition & 1 deletion modules/aerodyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ add_executable(unsteadyaero_driver
src/UnsteadyAero_Driver.f90
src/UA_Dvr_Subs.f90
)
target_link_libraries(unsteadyaero_driver aerodyn_driver_subs)
target_link_libraries(unsteadyaero_driver aerodyn_driver_subs lindynlib)

# AeroDyn-InflowWind c-bindings interface library
add_library(aerodyn_inflow_c_binding SHARED
Expand Down
13 changes: 7 additions & 6 deletions modules/aerodyn/src/UA_Dvr_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module UA_Dvr_Subs

implicit none


type UA_Dvr_InitInput
logical :: Echo
real(ReKi) :: SpdSound
Expand All @@ -30,30 +29,32 @@ module UA_Dvr_Subs
character(1024) :: InputsFile
logical :: SumPrint
logical :: WrAFITables
! Section
real(ReKi) :: MM(3,3)
real(ReKi) :: CC(3,3)
real(ReKi) :: KK(3,3)
logical :: activeDOFs(3)
real(ReKi) :: initPos(3)
real(ReKi) :: initVel(3)
end type UA_Dvr_InitInput

contains

subroutine ReadDriverInputFile( inputFile, InitInp, ErrStat, ErrMsg )

character(1024), intent( in ) :: inputFile
type(UA_Dvr_InitInput), intent( out ) :: InitInp
integer, intent( out ) :: ErrStat ! returns a non-zero value when an error occurs
character(*), intent( out ) :: ErrMsg ! Error message if ErrStat /= ErrID_None

! Local variables
integer :: UnIn ! Unit number for the input file
integer :: UnEchoLocal ! The local unit number for this module's echo file
character(1024) :: EchoFile ! Name of HydroDyn echo file
character(1024) :: FileName ! Name of HydroDyn input file

integer(IntKi) :: errStat2 ! Status of error message
character(1024) :: errMsg2 ! Error message if ErrStat /= ErrID_None
character(*), parameter :: RoutineName = 'ReadDriverInputFile'

character(1024) :: PriPath ! the path to the primary input file
CALL GetPath( inputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located.


! Initialize the echo file unit to -1 which is the default to prevent echoing, we will alter this based on user input
UnEchoLocal = -1
Expand Down
38 changes: 26 additions & 12 deletions modules/aerodyn/src/UnsteadyAero_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
! limitations under the License.
!
!**********************************************************************************************************************************




program UnsteadyAero_Driver

use NWTC_Library
Expand All @@ -31,19 +27,17 @@ program UnsteadyAero_Driver
use UnsteadyAero_Types
use UnsteadyAero
use UA_Dvr_Subs
USE VersionInfo
use VersionInfo

implicit none
use LinDyn





implicit none
! Variables
integer(IntKi), parameter :: NumInp = 2 ! Number of inputs sent to UA_UpdateStates (must be at least 2)

real(DbKi) :: dt, t, uTimes(NumInp)
integer :: i, j, n, iu
! --- UA
type(UA_InitInputType) :: InitInData ! Input data for initialization
type(UA_InitOutputType) :: InitOutData ! Output data from initialization
type(UA_ContinuousStateType) :: x ! Continuous states
Expand All @@ -53,6 +47,19 @@ program UnsteadyAero_Driver
type(UA_ParameterType) :: p ! Parameters
type(UA_InputType) :: u(NumInp) ! System inputs
type(UA_OutputType) :: y ! System outputs
! --- LinDyn
type(LD_InitInputType) :: LD_InitInData ! Input data for initialization
type(LD_InitOutputType) :: LD_InitOutData ! Output data from initialization
type(LD_ContinuousStateType) :: LD_x ! Continuous states
type(LD_DiscreteStateType) :: LD_xd ! Discrete states
type(LD_OtherStateType) :: LD_OtherState ! Other/optimization states
type(LD_MiscVarType) :: LD_m ! Misc/optimization variables
type(LD_ParameterType) :: LD_p ! Parameters
type(LD_InputType) :: LD_u(NumInp) ! System inputs
type(LD_OutputType) :: LD_y ! System outputs



integer(IntKi) :: ErrStat ! Status of error message
character(ErrMsgLen) :: ErrMsg ! Error message if ErrStat /= ErrID_None

Expand Down Expand Up @@ -160,14 +167,21 @@ program UnsteadyAero_Driver

InitInData%WrSum = dvrInitInp%SumPrint ! write all the AFI data

if ( dvrInitInp%SimMod == 3 ) then

print*,'>>>> STopping'

if ( dvrInitInp%SimMod == 1 ) then

call NormStop()


elseif ( dvrInitInp%SimMod == 1 ) then
! Using the frequency and NCycles, determine how long the simulation needs to run
simTime = dvrInitInp%NCycles/dvrInitInp%Frequency
nSimSteps = dvrInitInp%StepsPerCycle*dvrInitInp%NCycles ! we could add 1 here to make this a complete cycle
dt = simTime / nSimSteps

else
else if ( dvrInitInp%SimMod == 2 ) then
! Read time-series data file with a 1 line header and then each row contains time-step data with 4, white-space-separated columns
! time, Angle-of-attack, Vrel, omega
call ReadTimeSeriesData( dvrInitInp%InputsFile, nSimSteps, timeArr, AOAarr, Uarr, OmegaArr, errStat, errMsg )
Expand Down
32 changes: 32 additions & 0 deletions modules/lindyn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright 2016 National Renewable Energy Laboratory
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

if (GENERATE_TYPES)
generate_f90_types(src/LinDyn_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/LinDyn_Types.f90)
endif()

add_library(lindynlib
src/LinDyn.f90
src/LinDyn_Types.f90
)
target_link_libraries(lindynlib nwtclibs)

install(TARGETS lindynlib
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
4 changes: 4 additions & 0 deletions modules/lindyn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# LinDyn Module

## Overview
A module for linear dynamics (m, c, k, f) in OpenFAST
Loading

0 comments on commit dbec473

Please sign in to comment.