Commit e16d1b5d authored by mikf's avatar mikf

initial commit

parents
/source/.vs
/source/*.u2d
/source/x64
/source/Win32
/source/version.inc
/source/git_version.h
# GeneratorServo
MODULE BuildInfo
IMPLICIT NONE
!
type tbuildinfo
character*255 :: git_tag = ""
character*255 :: builder = ""
character*255 :: computer_name = ""
character*255 :: build_time = ""
character*255 :: build_date = ""
end type
!
CONTAINS
!
SUBROUTINE BuildInfo_initialise(b)
type (tbuildinfo) :: b
!
include 'version.inc'
END SUBROUTINE
!
SUBROUTINE BuildInfo_echo(b,fin)
type (tbuildinfo) :: b
integer, optional :: fin
integer :: fid
!
if (present(fin)) then
fid = fin
else
fid = 6 ! use stdout if not specified in input
endif
!
WRITE(fid,*) "***********************************************************************"
WRITE(fid,*) "* Build information for HAWC2MB.exe (GIT)"
!DEC$ IF DEFINED(_WIN32)
!DEC$ IF DEFINED(_M_X64)
WRITE(fid,*) "* WINDOWS 64-bit"
!DEC$ ELSE
WRITE(fid,*) "* WINDOWS 32-bit"
!DEC$ ENDIF
!DEC$ ENDIF
!DEC$ IF DEFINED(_DEBUG)
WRITE(fid,*) "* DEBUG version"
!DEC$ ENDIF
!DEC$ IF DEFINED(CLUSTER)
WRITE(fid,*) "* CLUSTER version"
!DEC$ ENDIF
WRITE(fid,*) "***********************************************************************"
WRITE(fid,*) "* GIT-TAG = ", trim(b%git_tag)
WRITE(fid,*) "* BUILDER = ", trim(b%builder)
WRITE(fid,*) "* COMPUTER_NAME = ", trim(b%computer_name)
WRITE(fid,*) "* BUILD_TIME = ", trim(b%build_time)
WRITE(fid,*) "* BUILD_DATE = ", trim(b%build_date)
WRITE(fid,*) "***********************************************************************"
!
END SUBROUTINE
!
END MODULE
module generator_servo_mod
use generator_servo_fcns
contains
!**************************************************************************************************
subroutine init_generator_servo(array1,array2)
use write_version_mod
implicit none
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'init_generator_servo'::init_generator_servo
!DEC$ END IF
real(mk) array1(100), array2(1)
! Input array1 must contain
!
! 1: constant 1 ; Frequency of 2nd order servo model of generator-converter system [Hz]
! 2: constant 2 ; Damping ratio 2nd order servo model of generator-converter system [-]
! 3: constant 3 ; Maximum allowable LSS torque (pull-out torque) [Nm]
! 4: constant 4 ; Generator efficiency [-]
! 5: constant 5 ; Gearratio [-]
! 6: constant 6 ; Time for half value in softstart of torque [s]
! 7: constant 7 ; Time for grid loss [s]
!
! Output array2 contains nothing
!
call write_textversion
write(6, *) 'Gen. torque Servo ' //trim(adjustl(TextVersion))// ' loaded...'
! Save parameters
lowpass2ordergen%f0 = array1(1)*2.0_mk*pi
lowpass2ordergen%zeta = array1(2)
generatorvar%max_lss_torque = array1(3)
generatorvar%n_eta = 1
allocate(generatorvar%p_eta(1))
generatorvar%p_eta = array1(4)
generatorvar%nom_eta_x = 1.0_mk
generatorvar%gearratio = array1(5)
TimeGridLoss = array1(7)
! Initiate the dynamic variables
generatorvar%stepno = 0
generatorvar%time_old = 0.0_mk
generatorvar%eta = 1.0_mk
! Zero output
array2 = 0.0_mk
end subroutine init_generator_servo
!**************************************************************************************************
subroutine init_generator_servo_var_eta(array1,array2)
implicit none
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'init_generator_servo_var_eta'::init_generator_servo_var_eta
!DEC$ END IF
real*8 array1(100), array2(1)
!
! Input array1 must contain
!
! 1: constant 1 ; Frequency of genertor 2nd order control model [Hz]
! 2: constant 2 ; Damping ratio of genertor 2nd order control model [-]
! 3: constant 3 ; Maximum allowable LSS torque (pull-out torque) [Nm]
! 4: constant 4 ; N_eta - No. of efficiency factors [-]
! 5: constant 5 ; Gearratio [-]
! 6: constant 6 ; Time for half value in softstart of torque [s]
! 7: constant 7 ; Time for grid loss [s]
! 8: constant 8 ; unit conversion factor
! 9: constant 9 ; Efficiency dependance: (1) LSS speed, (2) LSS mech torque, (3) mech. power
! 10: constant 10 ; Nominal LSS speed/LSS torque/mech. power [rad/s / Nm / W]
! 11: constant 11 ; Efficiency at 0/N_eta percent nominal speed/torque/power [-]
! 12: constant 12 ; Efficiency at 1/N_eta percent nominal speed/torque/power [-]
! 13: constant 13 ; Efficiency at 2/N_eta percent nominal speed/torque/power [-]
!
! Output array2 contains nothing
!
! Local vars
real(mk), allocatable :: y_eta(:)
integer i, j, n_eta
! Save parameters
call init_generator_servo(array1, array2)
n_eta = array1(4)
generatorvar%n_eta = n_eta
allocate(y_eta(n_eta))
deallocate(generatorvar%p_eta)
allocate(generatorvar%p_eta(n_eta))
generatorvar%eta_dependance = array1(9)
generatorvar%nom_eta_x = array1(10)
do i = 1, n_eta
y_eta(i) = array1(10 + i)
enddo
select case (n_eta)
case (1)
generatorvar%p_eta(1) = y_eta(1)
case (2)
generatorvar%p_eta(1) = y_eta(1)
generatorvar%p_eta(2) = y_eta(2) - y_eta(1)
case (3)
generatorvar%p_eta(1) = y_eta(1)
generatorvar%p_eta(3) = (y_eta(3) - 2.0_mk*y_eta(2) + y_eta(1))*2.0_mk
generatorvar%p_eta(2) = (y_eta(2) - generatorvar%p_eta(3)/4.0_mk - y_eta(1))*2.0_mk
case (4)
generatorvar%p_eta(1) = y_eta(1)
generatorvar%p_eta(3) = y_eta(3) - y_eta(1)
generatorvar%p_eta(2) = 1.0_mk/sqrt(0.5_mk)*atanh((y_eta(2) - y_eta(1))/generatorvar%p_eta(3))
case default
write (0,*) 'Error: n_eta should be between 1,2 or 3'
end select
! Initiate the dynamic variables
generatorvar%stepno = 0
generatorvar%time_old = 0.0_mk
! Zero output
array2 = 0.0_mk
return
end subroutine init_generator_servo_var_eta
!**************************************************************************************************
subroutine update_generator_servo(array1, array2)
implicit none
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'update_generator_servo'::update_generator_servo
!DEC$ END IF
real*8 array1(100), array2(100)
! Input array1 must contain
!
! 1: general time ; Time [s]
! 2: dll inpvec 1 1 ; Electrical torque reference [Nm]
! 3: constraint bearing1 shaft_rot 1 only 2 ; Generator LSS speed [rad/s]
!....4: mbdy momentvec shaft 1 1 shaft # only 3;
!
! Output array2 contains
!
! 1: Generator LSS torque [Nm]
! 2: Electrical generator power [W]
! 3: Gearbox reaction tower top LSS [Nm]
! 4: Generator reaction tower top HSS [Nm]
! 5: Mechanical generator power [kW]
! 6: mbdy moment_ext towertop 2 3 shaft
! 7: Resulting efficiency
! 8: Grid flag [1=no grid,0=grid]
!
! Local vars
real(mk) time, omegagen, Qgref, mech_Qgref, mech_Qg, Qg, softstart_torque
real(mk) Qshaft
real(mk) Qgdummy(2)
integer i
real(mk) eta_x
! New step?
time = array1(1)
if (time .gt. generatorvar%time_old) then
generatorvar%deltat = time - generatorvar%time_old
generatorvar%time_old = time
generatorvar%stepno = generatorvar%stepno + 1
endif
! Save input
Qgref = array1(2)
Qshaft = array1(4)
omegagen = array1(3)
! Reference mech. torque
mech_Qgref = min(Qgref/generatorvar%eta, generatorvar%max_lss_torque)
! Low-pass filter generator speed (LSS)
Qgdummy = lowpass2orderfilt(generatorvar%deltat, generatorvar%stepno, lowpass2ordergen, mech_Qgref)
mech_Qg = Qgdummy(1)
! Loss
select case (generatorvar%eta_dependance)
case (1)
eta_x = omegagen
case (2)
eta_x = mech_Qg
case (3)
eta_x = mech_Qg*omegagen
end select
eta_x = max(min(eta_x/generatorvar%nom_eta_x, 1.0_mk), 0.0_mk)
select case(generatorvar%n_eta)
case (1)
generatorvar%eta = generatorvar%p_eta(1)
case (2)
generatorvar%eta = generatorvar%p_eta(2)*eta_x + generatorvar%p_eta(1)
case (3)
generatorvar%eta = generatorvar%p_eta(3)*eta_x**2 + generatorvar%p_eta(2)*eta_x + generatorvar%p_eta(1)
case (4)
generatorvar%eta = generatorvar%p_eta(3)*tanh(sqrt(eta_x)*generatorvar%p_eta(2)) + generatorvar%p_eta(1)
end select
! Output
if ((time.gt.TimeGridLoss).and.(TimeGridLoss.gt.0.d0)) then
array2 = 0.d0
array2(8) = 1.d0
else
array2(1) = -mech_Qg
array2(2) = mech_Qg*omegagen*generatorvar%eta
array2(3) = -mech_Qg + mech_Qg/generatorvar%gearratio
array2(4) = -mech_Qg/generatorvar%gearratio
array2(5) = mech_Qg*omegagen*1.e-3_mk
array2(6) = -Qshaft*1.e3_mk
array2(8) = 0.0_mk
endif
array2(7) = generatorvar%eta
return
end subroutine update_generator_servo
!**************************************************************************************************
end module generator_servo_mod
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject ProjectType="typeDynamicLibrary" ProjectCreator="Intel Fortran" Keyword="Dll" Version="11.0" ProjectIdGuid="{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}">
<Platforms>
<Platform Name="Win32"/></Platforms>
<Configurations>
<Configuration Name="Debug|Win32" OutputDirectory="..\$(ConfigurationName)" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" WarnInterfaces="true" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" GenerateDebugInformation="true" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="Release|Win32" OutputDirectory="..\$(ConfigurationName)" DeleteExtensionsOnClean="*.cod;*__genmod.*;*.obj;*.mod;*.pdb;*.asm;*.lst;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;*.lib;$(TargetPath);*.htm;$(IntDir)" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true" ManifestFile="$(IntDir).intermediate.manifest" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true" ResourceFile="$(IntDir).embed.manifest.res"/></Configuration></Configurations>
<Files>
<Filter Name="Header Files" Filter="fi;fd"/>
<Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/>
<Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
<File RelativePath=".\generator_servo.f90"/>
<File RelativePath=".\generator_servo_fcns.f90"/>
<File RelativePath="..\misc_mod.f90"/>
<File RelativePath="..\write_version.f90"/></Filter></Files>
<Globals/></VisualStudioProject>
module generator_servo_fcns
use misc_mod
! Types
type Tgenerator
real*8,allocatable::p_eta(:)
real*8 nom_eta_x
real*8 eta,gearratio,mgenwa1,mgenera1,max_lss_torque
integer*4 stepno,n_eta,eta_dependance
real*8 deltat,outputvektor_old(15),time_old
end type Tgenerator
! Variables
type(Tgenerator) generatorvar
type(Tlowpass2order) lowpass2ordergen
real*8 TimeGridLoss
!*****************************************************************************************
contains
!*****************************************************************************************
end module generator_servo_fcns
\ No newline at end of file
@echo off
pushd %~dp0
for /f %%i in ('git describe --tags --dirty --always') do set GIT_ID=%%i
for /f %%i in ('git tag') do set GIT_VERSION=%%i
set psign=%%
echo b%psign%git_tag = "%GIT_ID%" > version.inc
echo b%psign%builder = "%USERNAME%" >> version.inc
echo b%psign%computer_name= "%COMPUTERNAME%" >> version.inc
echo b%psign%build_time = "%TIME%" >> version.inc
echo b%psign%build_date = "%DATE%" >> version.inc
REM
set S=#define GIT_ID "%GIT_ID%"
echo %S% > git_version.h
set GIT_VERSION=%GIT_VERSION: =%
echo %GIT_ID%
echo %GIT_VERSION%
IF not "%GIT_ID%"=="%GIT_VERSION%" (
set GIT_VERSION=%GIT_VERSION%,-1
)
set S=#define GIT_VERSION %GIT_VERSION:.=,%
echo %S% >> git_version.h
type version.inc
echo ----------------------
type git_version.h
popd
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by version.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// Microsoft Visual C++ generated resource script.
//
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#include "winver.h"
#include "git_version.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION GIT_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040604b0"
BEGIN
VALUE "CompanyName", "DTU Wind Energy"
VALUE "FileDescription", "Generator Servo"
VALUE "InternalName", "GeneratorServo"
VALUE "LegalCopyright", "DTU Wind Energy"
VALUE "OriginalFilename", "generator_servo.dll"
VALUE "ProductName", "Generator Servo"
VALUE "FileVersion", GIT_ID
VALUE "ProductVersion", GIT_ID
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x406, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment