Question about running FAST 8 in Simulink

Dear Jason

I am running the FAST 8 in Simulink and encountered the following problem. I modified the source code to allow two extra inputs from Simulink to S-function. the dynamic library has been compiled successfully. Now when I begin to run the Simulink. The first time is totally fine. But when I stopped the simulation and started again. The following error occurred.

Capture3.JPG

I have changed the S function name to FAST_SFun_s and it worked very well before I did the modification of source code. It should not be the problem of linking S-function and dynamic library. When I started the simulation the second time, the following error occurred and continued to occur when I start the simulation again and again.

Capture2.JPG

I did not modify any part of Hydrodynamics because the modification is about adding the external forces to TMD. The error showed something about Hydrodynamics so I am very confused about this. Does anybody know the reason?

Best

XING WEI

This looks like it is caused by a memory leak or not calling the FAST_End() routine at the end of the S function. The HydroDyn summary file probably gets closed in FAST_End(), so that’s what I would look at first.

How did you stop the simulation? FAST_End should be called with the S-function mdlTerminate() call, which Simulink should call on its own (it also gets called when there is an error in the S-function).

Dear Jonkman

I stopped the simulation by clicking the stop button in the simulation model, which is near the start button.

I double checked the source code and located the error message reported in the first picture. The source code is shown below.

I added “aaa” and ‘‘bbb’’ after the error message so that I can find that it was due to the second statement. I am wondering what does it imply if there is an error for “ALLOCATE (nodeToDistribIndx(numNodes), STAT = ErrStat)”. By the way, I checked the mdlTerminate() call and found it called FAST_End(). I also found that HydroDyn summary file was closed in FAST_End(). I can see the following sentence in Test22.SFunc.HD when the simulation was run successfully for the first time showing that the file has been closed.

For the error occurred in the first picture of my last post, there is no such sentence in Test22.SFunc.HD. The only content in Test22.SFunc.HD is shown below.

Best

XING WEI

Dear Xing,

It appears that for some reason when you stop your Simulink simulation, it is not properly calling the FAST_End() routine to deallocate memory and close files. But I’m not sure why this is the case. Does the model run fine a second time when the Simulink simulation ends properly i.e. when simulation time TMax is reached?

An error generated by the ALLOCATE() function implies that your computer does not have enough memory to allocate the array e.g. because the memory was not deallocated properly in a prior simulation. Closing and restarting MATLAB should fix the problem in this case.

Best regards,

Dear Jason

Thank you very much for your reply! I have figured out this issue. It was because I changed the name of S-function. I recompiled the S-function using FAST_SFun.c and change its name to “FAST_SFun_c.c”. Then I got an S-function with the same name. I called this S-function in Simulink and the previous problem occurred. If I change the name back, it worked.

I am running the simulation now and examining the result of modification of source code. I would like to add two inputs from Simulink as the external forces and apply it on the tower TMD. I want this force only to influence the velocity and acceleration of TMD but with no influence on tower movement. Unlike the spring and damper will generate force on both TMD and tower base. The forces I imported from Simulink are different as it will only influence the movement TMD. This is the function I want to achieve.

Here is what I did in the source code. I added the force to “B_X” and “B_Y” which are described as the inputs in Subroutine “TMD_CalcContStateDeriv”. The “B_X” and “B_Y” are shown below. I think adding forces to these two variables will influence the dynamics of TMD.

As I do not want these force influence the tower. I did no modification in Subroutine “TMD_CalcOutput” because I think the following variables describe the force exerted on tower base. The variables include “F_x_tmdY_P_N”, “F_z_tmdY_P_N”, “F_y_tmdX_P_N”, “F_z_tmdX_P_N”, “F_P_N(1)”, “F_P_N(2)”, “F_P_N(3)”, “M_P_N(1)”, “M_P_N(2)”, “M_P_N(3)”. I am wondering if my understanding is right and if my modification is right? These variables are shown below.

Best

XING WEI

Dear Xing Wei,

You understanding is correct in that the external forces in routine TMD_CalcContStateDeriv() will be applied to the TMD and the external forces in TMD_CalcOutput are the reactions to be applied to the tower. But I’m not sure I understand why you want to apply a force only to the TMD and not equally and oppositely to the tower. How would this force be created physically?

Best regards,

Dear Jason

Thank you very much for your kind reply. Sorry for the late response as I was on the holiday for the last month. Like you said, I would like to apply the force only on TMD and not equally and oppositely to the tower. The reason is that I would like to place some water on top of the TTMD mass and I think the motion of water will exert the force on TTMD mass only and not equally and oppositely to the tower. Am I right?

Besides, I have a question about the TTMD. I am wondering if the TTMD mass has direct interaction on the wind turbine platform (supposing it is floating wind turbine). The “direct interaction” I mentioned above means the friction force between the mass and the platform when the mass is moving relative to the platform. The reason why I want to know this is that I want to calculate the force applied on the wind turbine by the motion of water. If the friction force exists between the TTMD mass and the platform, it means that I need to consider the force exerted on the platform due to the motion of the water. I do not know if my understanding is right.

Best

XING WEI

Dear Xing,

So, the TMD system you are considering consists of a water tank that allows for sloshing of water installed on top of an oscillating mass? And you are trying to model the water sloshing as load applied to the TMD? In that case I agree that the applied load would not have an equal and opposite reaction on the tower; however, the force in the TMD module was originally meant to reflect the reaction force between the TMD and tower.

I’m not really sure I understand your second question. When you say “motion of water”, are you referring to the sloshing water in the tank or the wave-loads applied to the floating platform?

Best regards,

Dear Jason

Yes, you are right. What I want to describe is that we place a water tank on top of the oscillating mass. The sloshing water will apply loads on the TMD mass. According to what you said, I can just add the force on TMD mass only but not oppositely and equally on the tower. Am I right?

The second question is about the sloshing water in the tank. “Motion of water” means the sloshing water. I am wondering if my statement in the previous post is correct?

Best

XING WEI

Dear Xing Wei,

Yes.

I’m still not really sure I understand your second question. The TMD is impacted by the combination of the platform and tower motion if that is what you are asking.

Best regards,

Dear Jason

For the second question, like you said that TMD is impacted by the combination of the platform and tower motion. My question is about the impact from the platform. From my understanding, the pitch, roll, yaw and heave motions of the platform will influence the TMD mass directly as the TMD mass is placed on top of the platform and its displacements along xt, yt, zt axes are caused by the pitch, roll, yaw and heave motions of the platform. Am I right?

As for the surge and sway motions of the platform, I am wondering if the TMD mass is influenced by the friction caused by the relative displacements between the platform and the TMD mass. Because I think that if the contact surface between the TMD mass and platform is frictionless, there will be no direct influence from surge and sway motions of the platform but the direct influence from heave, pitch, roll, and yaw motions of the platform still exist.

However, I think that the surge and sway motions of the platform can still influence the motion of TMD by influencing the tower and through the spring and damper connected between the tower and TMD mass. So the core question is that if the surge and sway motions of the platform will influence the TMD mass directly through friction or just through the tower and spring and damper?

Please correct me if any of my statements are wrong! Thank you!

Best

XING WEI

Dear Xing,

Correct.

I’m still not sure what you mean by “friction caused by the relative displacements between the platform and the TMD mass”. Regardless, the forces transmitted to the TMD from the tower and platform are the result of (1) the spring and damper connecting the tower and TMD in the direction of the TMD DOF and (2) direct motion-induced loads (from platform and tower motion) in the direction(s) normal to the direction of the TMD DOF(s).

I hope that helps.

Best regards,

Dear Jason

Thank you for your reply. The statement “friction caused by the relative displacements between the platform and the TMD mass” means the following:

According to my knowledge, I thought the TTMD mass is oscillating on top of the platform if there are external loads like wind and wave. While the TTMD mass is oscillating on top of the platform, I am wondering if there exists friction between the TTMD mass and platform. The reason why I ask this is that I think the surge and sway motions of the platform will drag the TTMD mass to oscillate through friction between them. What I am curious is that I do not know if this friction exist? If the friction does not exist, I think the surge and sway motions of the platform do not cause direct motion-induced loads and it can only influence the TTMD mass through the spring and damper. Am I right?

Pitch, roll, yaw and heave motions of the platform will cause direct motion-induced loads like you said but I think these loads may not only in the direction normal to the direction of the TMD DOF(s), but partially in the direction of TMD DOF(s). The simple assumption is that if we only enable the pitch motion of the platform, the TTMD mass will oscillate as the platform pitching because the platform underneath the TTMD mass is not horizontal all the time and the gravity of the TTMD mass will cause it to move on the platform in the direction of TMD DOF(s).

So I am wondering if you mean that the “direct motion-induced loads from the platform” will only in the direction normal to the direction of TMD DOF(s)? Thank you for your patience.

Best

XING WEI

Dear Xing,

The TTMD is connected to the tower, not the platform. But because the tower is cantilevered to the platform, both the platform and tower motions will impact the TTMD motion.

As I said, the forces transmitted to the TMD from the tower and platform are the result of (1) the spring and damper connecting the tower and TMD in the direction of the TMD DOF and (2) direct motion-induced loads (from platform and tower motion) in the direction(s) normal to the direction of the TMD DOF(s). The direction(s) of the TTMD DOF(s) continuously changes with the rotation of the platform and deflection of the tower. That is, if e.g. the platform is pitched 10 degrees and the tower deflection results in an additional 1 degree of inclination, then the TTMD will be tilted by 11 degrees and the spring force and damper will act in this direction as well. There is no “friction” applied between the tower and TTMD beyond what is applied by the damper.

I hope that clarifies things.

Best regards,

Dear Jason

Thank you very much! Basically, your statement means that the motions of platform and tower will only influence the position of TTMD mass in space. The force that actually applied on TTMD mass is only through the spring and damper. Am I right?

By the way, I am considering the output “TTMD_XQD”. Is this the variable that means the velocity of the TTMD mass in relative to the tower. If so, if I need the velocity of TTMD mass relative to the inertial frame (the coordinate system xi,yi,zi). Is it correct to add “TTMD_XQD” with the “QD_Sg” (platform horizontal surge translation velocity) to obtain the velocity of TTMD relative to the inertial frame?

Best

XING WEI

Dear Xing,

Yes, except for the direct motion-induced loads (from platform and tower motion) in the direction(s) normal to the direction of the TMD DOF(s), discussed above.

Correct.

This would work only if you there is no rotation of the platform or deflection of the tower; otherwise, the surge motion and TTMD motion do not have the same vector direction. See the TMD Module Theory Manual for more information: nwtc.nrel.gov/system/files/TMD_ … manual.pdf.

Best regards,

Dear Jason

Thank you for your kind reply! I have studied the TMD Module Theory Manual. I found that it was based on the TMD in the nacelle. Studying the source code gives me the same information. I believe that for the TTMD in tower base, the platform acts the same as the nacelle for NTMD. Am I right?

By the way, According to your statement

The deflection of tower will also influence the direction(s) of the TTMD DOF(s). Does the TMD Module Theory manual give any clue about how to find the influence of tower deflection on TTMD DOF directions? I did not find anything in theory manual so I am wondering where can I find it because it is important to transform the coordinates of TTMD DOF(s) to inertial reference frame correctly.

I know that the transforming matrix describing the influence of platform can be obtained from “Dynamics modeling and loads analysis of an offshore floating wind turbine”.

Best

XING WEI

Dear Xing,

Correct.

As you said, the TMD manual discusses the NTMD. The TTMD is identical, except that it uses the displacement and orientation at the local height along the tower where the TTMD is placed rather than the displacement and orientation of the nacelle.

In the ElastoDyn source code, the local tower displacement and orientation for nodes along the tower are stored on the mesh. E.g. the orientation is stored as y_ED%TowerLn2Mesh%Orientation. This is a 3x3 direction-cosine matrix defined such that premultiplication of a vector in global coordinates will rotate the vector to local coordinates i.e.

v_local = Orientation*v_global

or to transform a local vector to global coordinates would be:

v_global = TRANSPOSE(Orientation)*v_local.

I hope that helps.

Best regards,

Dear Jason

Thank you for your quick reply! I have studied the source code and found the following:
In TMD module, the following picture showed the orientation matrix used to obtain the local coordinates for TTMD.

The second picture showed the way to get u%Mesh%Orientation(:,:,1) for TTMD:

The third picture showed how to get y%TowerLn2Mesh%Orientation(:,:,1):

It looks like the orientation used in TTMD in the first picture is obtained directly from the orientation at the tower node 1. I think the orientation used in TTMD module should include the orientation caused by platform motions. Am I right? If so, where can I find the inclusion of the orientation caused by platform motions?

Best

XING WEI

Dear Xing,

Correct.

The local tower coordinate system (t1/t2/t3) includes the orientations of both the platform and local tower deflection. You can see how these are set in SUBROUTINE ElastoDyn.f90/SetCoordSy().

Best regards,