From e5b1c57373cee9b48e1d10053fc4bc647c5309fc Mon Sep 17 00:00:00 2001 From: Michael McWilliam Date: Thu, 5 Apr 2018 17:02:04 +0200 Subject: [PATCH] Linux updates to the DLL code --- src/flap_servo/flap_servo.f90 | 8 +++++-- src/generator_servo/generator_servo.f90 | 23 ++++++++++++++------- src/mech_brake/mech_brake.f90 | 4 ++-- src/servo_with_limits/servo_with_limits.f90 | 4 ++-- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/flap_servo/flap_servo.f90 b/src/flap_servo/flap_servo.f90 index 4b4051f..36c419d 100644 --- a/src/flap_servo/flap_servo.f90 +++ b/src/flap_servo/flap_servo.f90 @@ -13,10 +13,12 @@ module flap_servo_mod integer :: stepno = 0 contains !************************************************************************************************** - subroutine init_flap_servo(array1, array2) + subroutine init_flap_servo(array1, array2) bind(c,name="init_flap_servo") ! Initialize Cyclic Flap Controller implicit none + !DEC$ IF .NOT. DEFINED(__LINUX__) !DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'init_flap_servo'::init_flap_servo + !DEC$ END IF real(mk) array1(3), array2(1) ! Input parameters ! 1: constant 1 ; Low-pass filter time constant [s] @@ -36,9 +38,11 @@ subroutine init_flap_servo(array1, array2) return end subroutine init_flap_servo !************************************************************************************************** - subroutine update_flap_servo(array1, array2) + subroutine update_flap_servo(array1, array2) bind(c,name="update_flap_servo") implicit none + !DEC$ IF .NOT. DEFINED(__LINUX__) !DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'update_flap_servo'::update_flap_servo + !DEC$ END IF real(mk) array1(4), array2(3) ! Input array1 must contains ! diff --git a/src/generator_servo/generator_servo.f90 b/src/generator_servo/generator_servo.f90 index 851296f..8350274 100644 --- a/src/generator_servo/generator_servo.f90 +++ b/src/generator_servo/generator_servo.f90 @@ -1,8 +1,9 @@ module generator_servo_mod use generator_servo_fcns + implicit none contains !************************************************************************************************** - subroutine init_generator_servo(array1,array2) + subroutine init_generator_servo(array1,array2) bind(c,name="init_generator_servo") use write_version_mod implicit none !DEC$ IF .NOT. DEFINED(__LINUX__) @@ -41,7 +42,7 @@ subroutine init_generator_servo(array1,array2) array2 = 0.0_mk end subroutine init_generator_servo !************************************************************************************************** - subroutine init_generator_servo_var_eta(array1,array2) + subroutine init_generator_servo_var_eta(array1,array2) bind(c,name="init_generator_servo_var_eta") implicit none !DEC$ IF .NOT. DEFINED(__LINUX__) !DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'init_generator_servo_var_eta'::init_generator_servo_var_eta @@ -107,7 +108,7 @@ subroutine init_generator_servo_var_eta(array1,array2) return end subroutine init_generator_servo_var_eta !************************************************************************************************** - subroutine update_generator_servo(array1, array2) + subroutine update_generator_servo(array1, array2) bind(c,name="update_generator_servo") implicit none !DEC$ IF .NOT. DEFINED(__LINUX__) !DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'update_generator_servo'::update_generator_servo @@ -119,8 +120,7 @@ subroutine update_generator_servo(array1, array2) ! 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 + ! ! Output array2 contains ! ! 1: Generator LSS torque [Nm] ! 2: Electrical generator power [W] @@ -149,7 +149,11 @@ subroutine update_generator_servo(array1, array2) Qshaft = array1(4) omegagen = array1(3) ! Reference mech. torque - mech_Qgref = min(Qgref/generatorvar%eta, generatorvar%max_lss_torque) + if(generatorvar%eta==0.0) then + mech_Qgref = generatorvar%max_lss_torque + else + mech_Qgref = min(Qgref/generatorvar%eta, generatorvar%max_lss_torque) + endif ! Low-pass filter generator speed (LSS) Qgdummy = lowpass2orderfilt(generatorvar%deltat, generatorvar%stepno, lowpass2ordergen, mech_Qgref) mech_Qg = Qgdummy(1) @@ -177,7 +181,12 @@ subroutine update_generator_servo(array1, array2) end select ! Output if ((time.gt.TimeGridLoss).and.(TimeGridLoss.gt.0.d0)) then - array2 = 0.d0 + array2(1) = 0.d0 + array2(2) = 0.d0 + array2(3) = 0.d0 + array2(4) = 0.d0 + array2(5) = 0.d0 + array2(6) = 0.d0 array2(8) = 1.d0 else array2(1) = -mech_Qg diff --git a/src/mech_brake/mech_brake.f90 b/src/mech_brake/mech_brake.f90 index c027793..3e19aa4 100644 --- a/src/mech_brake/mech_brake.f90 +++ b/src/mech_brake/mech_brake.f90 @@ -1,4 +1,4 @@ - subroutine init_mech_brake(array1,array2) + subroutine init_mech_brake(array1,array2) bind(c,name="init_mech_brake") use mech_brake_fcns use write_version_mod implicit none @@ -28,7 +28,7 @@ subroutine init_mech_brake(array1,array2) return end subroutine init_mech_brake !*********************************************************************** - subroutine update_mech_brake(array1,array2) + subroutine update_mech_brake(array1,array2) bind(c,name="update_mech_brake") use mech_brake_fcns ! use imsl implicit none diff --git a/src/servo_with_limits/servo_with_limits.f90 b/src/servo_with_limits/servo_with_limits.f90 index 63ab919..7cff2ea 100644 --- a/src/servo_with_limits/servo_with_limits.f90 +++ b/src/servo_with_limits/servo_with_limits.f90 @@ -1,4 +1,4 @@ - subroutine init_servo_with_limits(array1,array2) + subroutine init_servo_with_limits(array1,array2) bind(c,name="init_servo_with_limits") use servo_with_limits_data use write_version_mod implicit none @@ -49,7 +49,7 @@ subroutine init_servo_with_limits(array1,array2) return end subroutine init_servo_with_limits !*********************************************************************** - subroutine update_servo_with_limits(array1,array2) + subroutine update_servo_with_limits(array1,array2) bind(c,name="update_servo_with_limits") use servo_with_limits_data ! use imsl implicit none