Page 1 of 1

Modifying DISCON.dll

Posted: Fri Jun 19, 2020 8:36 am
by Sandra.Vasquez

I am using the 5MW NREL turbine with the control routine provided in DISCON.dll. Currently, I am trying to simulate sensor and actuator faults on the Blade-Pitch Controller and Generator-Torque Controller loops. For this, I need to do some modifications to the DISCON.f90 code and I will need to access the internal variables of the controllers for implementing fault detection algorithms (I would need some variables included in an output file after the simulation with OpenFast).

I have to say I am not familiar with Fortran. However, from the code I see that there is a 'debugging' option that is enabled with the flag 'PC_DbgOut'. This option seems to print or modify a file by printing a header and some variables values:

Code: Select all

! If we're debugging the pitch controller, open the debug file and write the
   !   header:

   IF ( PC_DbgOut )  THEN

      OPEN ( UnDb, FILE=TRIM( RootName )//'.dbg', STATUS='REPLACE' )

      WRITE (UnDb,'(/////)')
      WRITE (UnDb,'(A)')  'Time '//Tab//'ElapTime'//Tab//'HorWindV'//Tab//'GenSpeed'//Tab//'GenSpeedF'//Tab//'RelSpdErr'//Tab// &
                          'SpdErr '//Tab//'IntSpdErr'//Tab//'GK '//Tab//'PitComP'//Tab//'PitComI'//Tab//'PitComT'//Tab//        &
                          'PitRate1'//Tab//'PitRate2'//Tab//'PitRate3'//Tab//'PitCom1'//Tab//'PitCom2'//Tab//'PitCom3'//Tab// &
      WRITE (UnDb,'(A)')  '(sec)'//Tab//'(sec)   '//Tab//'(m/sec) '//Tab//'(rpm)   '//Tab//'(rpm)    '//Tab//'(%)      '//Tab// &
                          '(rad/s)'//Tab//'(rad)    '//Tab//'(-)'//Tab//'(deg)  '//Tab//'(deg)  '//Tab//'(deg)  '//Tab//        &
                          '(deg/s) '//Tab//'(deg/s) '//Tab//'(deg/s) '//Tab//'(deg)  '//Tab//'(deg)  '//Tab//'(deg)  '//Tab// &
                          '(deg)   '//Tab//'(deg)   '//Tab//'(deg)   '

      OPEN ( UnDb2, FILE=TRIM( RootName )//'.dbg2', STATUS='REPLACE' )
      WRITE (UnDb2,'(/////)')
      WRITE (UnDb2,'(A,85("'//Tab//'AvrSWAP(",I2,")"))')  'Time ', (i,i=1,85)
      WRITE (UnDb2,'(A,85("'//Tab//'(-)"))')  '(s)'

Code: Select all

! Output debugging information if requested:

      IF ( PC_DbgOut )  THEN
                        WRITE (UnDb,FmtDat)  Time, ElapTime, HorWindV, GenSpeed*RPS2RPM, GenSpeedF*RPS2RPM,           &
                                             100.0*SpdErr/PC_RefSpd, SpdErr, IntSpdErr, GK, PitComP*R2D, PitComI*R2D, &
                                             PitComT*R2D, PitRate*R2D, PitCom*R2D, BlPitch*R2D
      END IF


I think I can make use of this debugging option in order to have access to the internal variables of the controllers. I tried to compile DISCON.f90 with 'PC_DbgOut = .TRUE. '. However, once I use the compiled DISCON.dll, I don't see any new file once the simulation with OpenFast is over.

I guess I need to do something in addition for using the debugging option? like maybe create a file '.dbg' with a name coinciding with 'RootName' in a given folder or something? (I don't know what 'RootName' should be equal to, as I mentioned I am not familiar with Fortran).

Could you please help by pointing out how to enable correctly the debugging option?

Best regards,

Sandra Vasquez
PhD student

Re: Modifying DISCON.dll

Posted: Fri Jun 19, 2020 10:43 am
by Jason.Jonkman
Dear Sandra,

All you should need to do is recompile the DISCON.dll after changing PC_DbgOut from .FALSE. to .TRUE. in DISCON.f90. Then running OpenFAST should generate two new files, one named RootName.dbg containing the internal data and one named RootName.dbg2 containing the data in the avrSWAP array, where "RootName" is the name of your OpenFAST primary input file minus the ".fst" extension and with ".SrvD" added, including full path.

If you have done this and you are not seeing these files, are you sure you are calling the correct DLL, which is specified via input parameter DLL_FileName in the ServoDyn input file?

Best regards,

Re: Modifying DISCON.dll

Posted: Mon Jun 22, 2020 10:26 am
by Sandra.Vasquez
Dear Jason,

Thank you very much for your reply. I was compiling wrongly the DISCON.dll. Now the files RootName.dbg and RootName.dbg2 are being generated.

Best regards,

Sandra Vásquez