Dear all,
I am trying to implement my Pitch control in Simulink with the 5MW FOWT. But is something that I do not understant why the SFunction works like that:
 The pitch setpoint that I introduce to the SFunction model has a mismatch with the output blade pitch angle at some point. I mean, when it is working in normal operation the input and output pitch value is the same (OK), but when an error ocurs the output signal grows above the maximun pitch angle while the input does not. Why is that? Has not sense higher pitch angle than 1.57rad, rigth?
Thank you so much in advance,
JOE
P.D.: I attach the Simulink scheme, error message and IO signal mismatch.
SFunction input output signal mismatch
Moderator: Bonnie.Jonkman

 Posts: 38
 Joined: Mon Nov 30, 2015 4:13 am
 Organization: IK4Ikerlan
 Location: Spain
SFunction input output signal mismatch
 Attachments

 Scheme.png (47.59 KiB) Viewed 3817 times

 Error.txt
 (541 Bytes) Downloaded 77 times

 IO_Mismatch.png (21.01 KiB) Viewed 3817 times
Joannes Olondriz
Engineer  IK4Ikerlan
Control and Monitoring area, IK4Ikerlan (Olandixo)
20500 ArrasateMondragon (Gipuzkoa). Spain
Paseo J.Mª Arizmendiarrieta, 2
(+34)943 712400  jolondriz@ikerlan.es
Engineer  IK4Ikerlan
Control and Monitoring area, IK4Ikerlan (Olandixo)
20500 ArrasateMondragon (Gipuzkoa). Spain
Paseo J.Mª Arizmendiarrieta, 2
(+34)943 712400  jolondriz@ikerlan.es

 Posts: 3857
 Joined: Thu Nov 03, 2005 4:38 pm
 Location: Boulder, CO
 Contact:
Re: SFunction input output signal mismatch
Dear Joannes,
The FAST v8 SFunction for the MATLAB/Simulink interface is a discretetime block, meaning that inputs go in at time step "n" and outputs come out at time step "n+1". Within the block, the output calculation at n+1 involves an extrapolation of inputs (linear or quadratic), which is normally negligible when the inputs vary slowly in time, but is visible when the inputs vary a lot between time steps.
The error seems to imply that the model has going unstable, with vary large unrealistic displacement.
Best regards,
The FAST v8 SFunction for the MATLAB/Simulink interface is a discretetime block, meaning that inputs go in at time step "n" and outputs come out at time step "n+1". Within the block, the output calculation at n+1 involves an extrapolation of inputs (linear or quadratic), which is normally negligible when the inputs vary slowly in time, but is visible when the inputs vary a lot between time steps.
The error seems to imply that the model has going unstable, with vary large unrealistic displacement.
Best regards,
Jason Jonkman, Ph.D.
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

 Posts: 38
 Joined: Mon Nov 30, 2015 4:13 am
 Organization: IK4Ikerlan
 Location: Spain
Re: SFunction input output signal mismatch
Dear Jason,
Thank you for your fast reply. I agree with you, I think that I need to retun again my control loops.
Best regards,
JOE
Thank you for your fast reply. I agree with you, I think that I need to retun again my control loops.
Best regards,
JOE
Joannes Olondriz
Engineer  IK4Ikerlan
Control and Monitoring area, IK4Ikerlan (Olandixo)
20500 ArrasateMondragon (Gipuzkoa). Spain
Paseo J.Mª Arizmendiarrieta, 2
(+34)943 712400  jolondriz@ikerlan.es
Engineer  IK4Ikerlan
Control and Monitoring area, IK4Ikerlan (Olandixo)
20500 ArrasateMondragon (Gipuzkoa). Spain
Paseo J.Mª Arizmendiarrieta, 2
(+34)943 712400  jolondriz@ikerlan.es

 Posts: 7
 Joined: Mon Jun 04, 2018 2:49 am
 Organization: RWTH Aachen University
 Location: Germany
Re: SFunction input output signal mismatch
Dear all,
is it possible to change the circumstance about output coming out at step "n+1" using a delay or memory block or somethin similar in Simulink?
Also, how does the extrapolation work exaclty? I am trying to set the whole TMD module out to Simulink, so that control or other operations with TMD are possible using Simulink. So far I have seen my model in Simulink works well, when I compare passive TMD forces from FAST with my Simulink model forces calculated in the background. When I want to use the forces calculated in my Simulink model as the actual used TMD forces however, FAST uses different values for TMD forces: In the following I try to phrase the problem using F_Simu as Force calculated by my model and F_FAST as the read in force that is actually applied to the wind turbine:
F_Simu(t=0) = x0 F_FAST(t=0) = 0
F_Simu(t=1) = x1 F_FAST(t=1) = 3*x0
... F_FAST(t=2) = ?? I dont understand what FAST uses here. Probably some result of the extrapolation.
The following time steps seem to work just fine except for some smaller differences which probably result from the extrapolation. The problem is with the initialization using quite high forces in 't=1' the wind turbine is actuated very strongly resulting in divergence problems. I hope to achieve that F_FAST(t=0) is unequal 0 and for the first extrapolation step to be not three times the initial value from Simulink.
I also tried comparing this issue to the external control of Gen Torque and got the same result: When I apply Simulink control of Gen Torque and set that value constant in Simulink, the initial output from FAST is 0, then three times the constant, then 0 again and only in the following time steps the constant value from Simulink is taken as Output in FAST. Is it possible to alternatively turn off the extrapolation from ServoDyn and just take the values from Simulink directly with one time step difference?
I hope I was able to phrase my concern understandable and thank you all for your help.
Best regards
Laurin
is it possible to change the circumstance about output coming out at step "n+1" using a delay or memory block or somethin similar in Simulink?
Also, how does the extrapolation work exaclty? I am trying to set the whole TMD module out to Simulink, so that control or other operations with TMD are possible using Simulink. So far I have seen my model in Simulink works well, when I compare passive TMD forces from FAST with my Simulink model forces calculated in the background. When I want to use the forces calculated in my Simulink model as the actual used TMD forces however, FAST uses different values for TMD forces: In the following I try to phrase the problem using F_Simu as Force calculated by my model and F_FAST as the read in force that is actually applied to the wind turbine:
F_Simu(t=0) = x0 F_FAST(t=0) = 0
F_Simu(t=1) = x1 F_FAST(t=1) = 3*x0
... F_FAST(t=2) = ?? I dont understand what FAST uses here. Probably some result of the extrapolation.
The following time steps seem to work just fine except for some smaller differences which probably result from the extrapolation. The problem is with the initialization using quite high forces in 't=1' the wind turbine is actuated very strongly resulting in divergence problems. I hope to achieve that F_FAST(t=0) is unequal 0 and for the first extrapolation step to be not three times the initial value from Simulink.
I also tried comparing this issue to the external control of Gen Torque and got the same result: When I apply Simulink control of Gen Torque and set that value constant in Simulink, the initial output from FAST is 0, then three times the constant, then 0 again and only in the following time steps the constant value from Simulink is taken as Output in FAST. Is it possible to alternatively turn off the extrapolation from ServoDyn and just take the values from Simulink directly with one time step difference?
I hope I was able to phrase my concern understandable and thank you all for your help.
Best regards
Laurin

 Posts: 3857
 Joined: Thu Nov 03, 2005 4:38 pm
 Location: Boulder, CO
 Contact:
Re: SFunction input output signal mismatch
Dear Laurin,
FAST uses either a linear or quadratic extrapolation depending on the setting of InterpOrder in the FAST primary input file. You cannot eliminate the extrapolation without changing the source code, but I can clarify how the extrapolation works. In linear extrapolation, the values at time n and n1 are used to find the two constants of the linear equation that will yield an extrapolation to the value at n+1. In quadratic extrapolation, the values at n, n1, and n2 are used to find the three constants of the quadratic equation that will yield an extrapolation to the value at n+1. At initialization (time n = 0), the value at time n=0 is used at times n=1 and n=2.
The extrapolation tends to work well for smooth functions, but steps in the function result in an overshoot of the extrapolated value (more so for quadratic than for linear extrapolation). As such, I would always encourage the use of smooth functions. I'm not sure I fully understand what you saying is happening in your simulation at initialization, but you could probably reduce the startup transient by ramping up the force over the first few seconds of simulation.
Best regards,
FAST uses either a linear or quadratic extrapolation depending on the setting of InterpOrder in the FAST primary input file. You cannot eliminate the extrapolation without changing the source code, but I can clarify how the extrapolation works. In linear extrapolation, the values at time n and n1 are used to find the two constants of the linear equation that will yield an extrapolation to the value at n+1. In quadratic extrapolation, the values at n, n1, and n2 are used to find the three constants of the quadratic equation that will yield an extrapolation to the value at n+1. At initialization (time n = 0), the value at time n=0 is used at times n=1 and n=2.
The extrapolation tends to work well for smooth functions, but steps in the function result in an overshoot of the extrapolated value (more so for quadratic than for linear extrapolation). As such, I would always encourage the use of smooth functions. I'm not sure I fully understand what you saying is happening in your simulation at initialization, but you could probably reduce the startup transient by ramping up the force over the first few seconds of simulation.
Best regards,
Jason Jonkman, Ph.D.
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov

 Posts: 7
 Joined: Mon Jun 04, 2018 2:49 am
 Organization: RWTH Aachen University
 Location: Germany
Re: SFunction input output signal mismatch
Dear Jason,
Thank you for your quick reply. I changed the source code in a way so that the TMD forces and moments y%Mesh%Force(:,1) and y%Mesh%Moment(:,1) are read in by the SFunction in Simulink. Afterwards I copied TMD.f90 so that the equations are carried out by Simulink itself. I now ran a Free Decay calculation of the 5MW onshore wind turbine. After I changed the interpolation order from quadratic to linear it seems to work just fine. Thank you very much!
Could you still tell me where in the source code the part with the interpolation is stored? I am not sure I understand why I would prefer to interpolate rather than just take the exact Simulink values from 'n' and let FAST take them as output at 'n+1'. For me no interpolation at all would do as well I guess.
Best regards
Thank you for your quick reply. I changed the source code in a way so that the TMD forces and moments y%Mesh%Force(:,1) and y%Mesh%Moment(:,1) are read in by the SFunction in Simulink. Afterwards I copied TMD.f90 so that the equations are carried out by Simulink itself. I now ran a Free Decay calculation of the 5MW onshore wind turbine. After I changed the interpolation order from quadratic to linear it seems to work just fine. Thank you very much!
Could you still tell me where in the source code the part with the interpolation is stored? I am not sure I understand why I would prefer to interpolate rather than just take the exact Simulink values from 'n' and let FAST take them as output at 'n+1'. For me no interpolation at all would do as well I guess.
Best regards

 Posts: 3857
 Joined: Thu Nov 03, 2005 4:38 pm
 Location: Boulder, CO
 Contact:
Re: SFunction input output signal mismatch
Dear Laurin,
The source code change to eliminate all interpolation and extrapolation is simple. Routine FAST_Subs.f90/ValidateInputData() checks to ensure that FAST primary input parameter InterpOrder is either 1 or 2. All of you to do is change this check so that InterpOrder can be 0, 1, or 2, where InterpOrder=0 corresponds to no interpolation or extrapolation. The interpolation/extrapolation routines already allow for the situation where InterpOrder=0, but we prevented the user from selecting this option because we felt that in general it would be better to have some sort of interpolation/extrapolation.
Best regards,
The source code change to eliminate all interpolation and extrapolation is simple. Routine FAST_Subs.f90/ValidateInputData() checks to ensure that FAST primary input parameter InterpOrder is either 1 or 2. All of you to do is change this check so that InterpOrder can be 0, 1, or 2, where InterpOrder=0 corresponds to no interpolation or extrapolation. The interpolation/extrapolation routines already allow for the situation where InterpOrder=0, but we prevented the user from selecting this option because we felt that in general it would be better to have some sort of interpolation/extrapolation.
Best regards,
Jason Jonkman, Ph.D.
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov
Senior Engineer  National Wind Technology Center (NWTC)
National Renewable Energy Laboratory (NREL)
15013 Denver West Parkway  Golden, CO 80401
+1 (303) 384 – 7026  Fax: +1 (303) 384 – 6901
nwtc.nrel.gov
Who is online
Users browsing this forum: No registered users and 1 guest