OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
675 stars 455 forks source link

Runtime error when linearizing with dev branch #620

Closed dzalkind closed 2 years ago

dzalkind commented 3 years ago

Bug description I get either a segmentation fault or runtime error (depending on compilation) when trying to linearize on the dev branch with

---------------------- FEATURE SWITCHES AND FLAGS ------------------------------
1                      CompElast   - Compute structural dynamics (switch) {1=ElastoDyn; 2=ElastoDyn + BeamDyn for blades}
1                      CompInflow  - Compute inflow wind velocities (switch) {0=still air; 1=InflowWind; 2=external from OpenFOAM}
2                      CompAero    - Compute aerodynamic loads (switch) {0=None; 1=AeroDyn v14; 2=AeroDyn v15}
1                      CompServo   - Compute control and electrical-drive dynamics (switch) {0=None; 1=ServoDyn}
0                      CompHydro   - Compute hydrodynamic loads (switch) {0=None; 1=HydroDyn}
0                      CompSub     - Compute sub-structural dynamics (switch) {0=None; 1=SubDyn; 2=External Platform MCKF}
0                      CompMooring - Compute mooring system (switch) {0=None; 1=MAP++; 2=FEAMooring; 3=MoorDyn; 4=OrcaFlex}
0                      CompIce     - Compute ice loads (switch) {0=None; 1=IceFloe; 2=IceDyn}

and only the GenDOF is enabled in ElastoDyn.

To Reproduce

Steps to reproduce the behavior: 1. Compile dev branch with gfortran 2. Run lin_0.fst case in [iea_semi_lin.zip](https://github.com/OpenFAST/openfast/files/5755902/iea_semi_lin.zip) **Expected behavior** When running this same case (and deleting a line in lin_0_InflowWind.dat) on the master branch, the linearization completes as expected. **Screenshots, if applicable** ![image](https://user-images.githubusercontent.com/65573423/103384320-3c86ca00-4ab3-11eb-85cb-62887e79859a.png) **OpenFAST Version** ``` ************************************************************************************************** OpenFAST Copyright (C) 2020 National Renewable Energy Laboratory Copyright (C) 2020 Envision Energy USA LTD This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY. See the "LICENSE" file distributed with this software for details. ************************************************************************************************** OpenFAST-v2.4.0-133-gb913c945-dirty Compile Info: - Compiler: GCC version 9.3.0 - Architecture: 64 bit - Precision: single - Date: Dec 29 2020 - Time: 12:40:08 Execution Info: - Date: 12/30/2020 - Time: 15:21:40-0700 OpenFAST input file heading: Generated with AeroElasticSE FAST driver Running ElastoDyn. Nodal outputs section of ElastoDyn input file not found or improperly formatted. Running AeroDyn. Nodal output section of AeroDyn input file not found or improperly formatted. Running InflowWind. Running ServoDyn. FAST_InitializeAll:ED_Init:InitBlDefl:Blade 1 initial blade tip displacements are Incompat with enabled DOFs: An approximate characterization of the specified blade deflection will be made. InitBlDefl:Blade 2 initial blade tip displacements are Incompat with enabled DOFs: An approximate characterization of the specified blade deflection will be made. InitBlDefl:Blade 3 initial blade tip displacements are Incompat with enabled DOFs: An approximate characterization of the specified blade deflection will be made. Time: 0 of 600 seconds. At line 6890 of file /Users/dzalkind/Tools/openfast/modules/elastodyn/src/ElastoDyn.f90 Fortran runtime warning: An array temporary was created for argument 'vector2' of procedure 'cross_productr4' At line 6891 of file /Users/dzalkind/Tools/openfast/modules/elastodyn/src/ElastoDyn.f90 Fortran runtime warning: An array temporary was created for argument 'vector2' of procedure 'cross_productr4' At line 6892 of file /Users/dzalkind/Tools/openfast/modules/elastodyn/src/ElastoDyn.f90 Fortran runtime warning: An array temporary was created for argument 'vector2' of procedure 'cross_productr4' At line 6893 of file /Users/dzalkind/Tools/openfast/modules/elastodyn/src/ElastoDyn.f90 Fortran runtime warning: An array temporary was created for argument 'vector2' of procedure 'cross_productr4' At line 6900 of file /Users/dzalkind/Tools/openfast/modules/elastodyn/src/ElastoDyn.f90 ``` **System Information (please complete the following information):** - OS: macOS 10.15.7 - Compiler: GFortran 9.3.0 - Compiler settings: [CMakeCache.txt](https://github.com/OpenFAST/openfast/files/5755923/CMakeCache.txt) **Additional context** It looks like `p%dx` is empty but has a size of 1...that's about as far as I got into debugging. Have a happy new year, OpenFAST team!
jjonkman commented 3 years ago

I haven't tried to test the segmentation fault or runtime error, but I see another issue in this case. ElastoDyn is issuing a warning about the initial blade tip displacements being incompatible with the the enabled DOFs. In @dzalkind's case, all blade DOFs are disabled, and so, all the blade displacements should be zeroed (which is also what ElastoDyn does for the tower--that is, all initial tower displacements are ignored when all tower DOFs are disabled. But instead, based on the error message, it appears that some nonzero edgewise displacement is being set. This suggest a bug in the logic within SUBROUTINE ElastoDyn.f90/InitBlDefl() that should be fixed.

@dzalkind -- To avoid this issue before it is fixed, you could set OoPDefl = IPDefl = 0.0 when FlapDOF1 = FlapDOF2 = EdgeDOF = FALSE.

bjonkman commented 3 years ago

@dzalkind, I didn't run your files, but based on the error in your screenshot, I think the updated code in https://github.com/bjonkman/openfast/tree/b/issue620 will fix the segmentation fault / runtime error issue.

Let us know if that fixes your issue, and I'll submit a pull request to get this fixed on OpenFAST/dev, too.

dzalkind commented 3 years ago

@bjonkman, this fix works! Thank you!

dzalkind commented 3 years ago

@jjonkman, thanks for the explanation! This will save me some time when doing linearizations. I was solving for the steady state deflections and using them as initial conditions because I thought OpenFAST was using them as constant offsets in the simulation when the blade/tower DOFs were disabled.

jjonkman commented 3 years ago

I'm reopening this issue because the second bug--identified in ElastoDyn--has not yet been fixed.

Seager1989 commented 3 years ago

Dear Everyone,

I saw this issue was fixed in the latest dev branch, but I still have similar (segmentation fault) but different errors as below. Do you have any ideas on how to fix this issue? Thank you!

Time: 10 of 20 seconds.  Estimated final completion at 18:23:53.

Performing linearization 1 at simulation time 10 s. (RotSpeed=15.65 rpm, BldPitch1=0 deg)

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f17cdf17d3a
#1  0x7f17cdf16ed5
#2  0x7f17cdb6920f
#3  0x56169ee73fc0
#4  0x56169ece1bb2
#5  0x56169ec80795
#6  0x56169e00e090
#7  0x56169dcf47d5
#8  0x56169dc9e4fb
#9  0x56169dbbccce
#10  0x7f17cdb4a0b2
#11  0x56169dbbcd0d
#12  0xffffffffffffffff
Segmentation fault
andrew-platt commented 3 years ago

@Seager1989, can you compile in debug mode and run the linearization again with the latest dev? That might give an indication of where the segmentation fault is (the stacktrace above is not something I can decipher without more context).

Seager1989 commented 3 years ago

Hi Andy,

I compiled the latest dev in debug mode and run the model again. To save time, I only set 20 s simulation time with the first linearization time at 10 s. The full output with the error is listed below. I do not see much difference but hope you can get useful information.

In addition, I compiled the latest dev with debug mode by (for your reference): cmake .. -DCMAKE_INSTALL_PREFIX="/home/seager/Downloads/openfast-dev/install" -DBUILD_TESTING=off -DBUILD_SHARED_LIBS=off-DCMAKE_BUILD_TYPE=Debug

If you need any other information, please let me know. Thank you!

**************************************************************************************************
 OpenFAST

 Copyright (C) 2021 National Renewable Energy Laboratory
 Copyright (C) 2021 Envision Energy USA LTD

 This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY.
 See the "LICENSE" file distributed with this software for details.
 **************************************************************************************************

 OpenFAST-v2.4.0-112-gd8127649-dirty
 Compile Info:
  - Compiler: GCC version 9.3.0
  - Architecture: 64 bit
  - Precision: double
  - Date: Jan 13 2021
  - Time: 16:24:44
 Execution Info:
  - Date: 01/13/2021
  - Time: 21:02:12-0500

 OpenFAST input file heading:
     FAST Certification Test #24: NREL 5.0 MW Baseline Wind Turbine with OC3 Hywind Configuration,
     for use in offshore analysis

 Running ElastoDyn.
 Nodal outputs section of ElastoDyn input file not found or improperly formatted.
 Running AeroDyn.
 Nodal output section of AeroDyn input file not found or improperly formatted.
 Running InflowWind.
 Running ServoDyn.
 Running HydroDyn.
   Setting WaveTMax to 0.0 since WaveMod = 0
  Reading in WAMIT output with root name "./../5MW_Baseline/HydroData/Spar".
  Computing radiation impulse response functions and wave diffraction forces.

MAP++ environment properties (set externally)...
    Gravity constant          [m/s^2]  : 9.81
    Sea density               [kg/m^3] : 1025.00
    Water depth               [m]      : 320.00
    Vessel reference position [m]      : 0.00 , 0.00 , 0.00
  Time: 0 of 20 seconds.
                                                                                 Time: 1 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 2 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 3 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 4 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 5 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 6 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 7 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 8 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 9 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                 Time: 10 of 20 seconds.  Estimated final completion at 21:02:33.                                                                                                Performing linearization 1 at simulation time 10 s. (RotSpeed=15.65 rpm, BldPitch1=0 deg)        

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f0b12811d3a
#1  0x7f0b12810ed5
#2  0x7f0b1264520f
#3  0x7f0b11532f10
#4  0x7f0b1154a1a2
#5  0x7f0b114d1445
#6  0x7f0b12c25940
#7  0x7f0b12c32135
#8  0x56031936fa2b
#9  0x56031928e1fe
#10  0x7f0b126260b2
#11  0x56031928e23d
#12  0xffffffffffffffff
Segmentation fault (core dumped)
bjonkman commented 3 years ago

You say you have the latest dev branch, but the git hash is from an earlier version from December 11. Could you pull the latest changes from dev and try again? I don't think you have the fix that was merged in #623.

Seager1989 commented 3 years ago

Thank you for pointing this out. I merged the latest update and checked it with the #623 merged. The error is still in there but with some detailed error information. There are many messages so I attached them as a document. Thank you and Andy for your help to fix this problem.

The major error is listed below for your quick review and warnings were reported on the Elastodyn.

               Performing linearization 1 at simulation time 10 s. (RotSpeed=15.65 rpm, BldPitch1=0 deg)        
openfast: ../../../src/libgfortran/generated/matmul_r8.c:98: matmul_r8_avx: Assertion `GFC_DESCRIPTOR_RANK (a) == 2 || GFC_DESCRIPTOR_RANK (b) == 2' failed.

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x7fdfc9196d01 in ???
#1  0x7fdfc9195ed5 in ???
#2  0x7fdfc8e1420f in ???
#3  0x7fdfc8e1418b in ???
#4  0x7fdfc8df3858 in ???
#5  0x7fdfc8df3728 in ???
#6  0x7fdfc8e04f35 in ???
#7  0x7fdfc92922ee in ???
#8  0x5608bb8dc05c in __ss_radiation_MOD_ss_rad_calccontstatederiv
    at /home/seager/Downloads/openfast-dev/openfast/modules/hydrodyn/src/SS_Radiation.f90:480
#9  0x5608bb4d49af in __wamit_MOD_wamit_calccontstatederiv
    at /home/seager/Downloads/openfast-dev/openfast/modules/hydrodyn/src/WAMIT.f90:1649
#10  0x5608bb4074b6 in __hydrodyn_MOD_hydrodyn_calccontstatederiv
    at /home/seager/Downloads/openfast-dev/openfast/modules/hydrodyn/src/HydroDyn.f90:2006
#11  0x5608bb3f0cdd in __hydrodyn_MOD_hd_getop
    at /home/seager/Downloads/openfast-dev/openfast/modules/hydrodyn/src/HydroDyn.f90:3326
#12  0x5608b91f7b20 in __fast_linear_MOD_fast_linearize_op
    at /home/seager/Downloads/openfast-dev/openfast/modules/openfast-library/src/FAST_Lin.f90:905
#13  0x5608b900800a in __fast_subs_MOD_fast_linearize_t
    at /home/seager/Downloads/openfast-dev/openfast/modules/openfast-library/src/FAST_Subs.f90:5816
#14  0x5608b8b4b88a in fast
    at /home/seager/Downloads/openfast-dev/openfast/glue-codes/openfast/src/FAST_Prog.f90:149
#15  0x5608b8b4bcb5 in main
    at /home/seager/Downloads/openfast-dev/openfast/glue-codes/openfast/src/FAST_Prog.f90:34

OpenFastv2.5.0LinError.txt

bjonkman commented 3 years ago

Thanks, That error message helps a lot. I fixed a couple of things in https://github.com/bjonkman/openfast/tree/b/HD_lin. Hopefully that will solve the issue here. I'll create a pull request with this change, too.

Seager1989 commented 3 years ago

Yes, the new branch works well on my side even with some warnings from the Elastodyn. Thank you for your help to fix this problem.

andrew-platt commented 3 years ago

Closing this issue since #634 has been merged to dev.

jjonkman commented 3 years ago

I'm reopening this issue because the second bug--identified in ElastoDyn--has not yet been fixed.

bjonkman commented 3 years ago

There are actually 3 separate issues in this thread, so maybe we should open a new issue for the one that is not yet fixed?

andrew-platt commented 3 years ago

Linearization appears to also be broken in the TCF_mods2 PR #537.

andrew-platt commented 2 years ago

I'm not sure at the moment if this issue should still be open, so I'm going to close it.

One thing to note: I have recently run across a bug where linearization will seg-fault if an invalid channel name was requested AND the LinOutputs is set to 1. This occured during development of the ServoDyn StC linearization (#803) when an invalid channel was selected. This issue may be present in other modules as well, so if you continue getting seg-faults, verifiy that the output file does not show units of (INVALID) for a channel.