-
Notifications
You must be signed in to change notification settings - Fork 184
Fix wave elevation import with rampTime = 0 #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jtgrasb Thank you for making this change to the userDefinedWaveElevation function and this will resolve the calculation so as not to try and convolute with a NaN. I have no issue with the few lines of code you have changed. However, prior to approval I can across the similar situation within the ramp function in the Therefore, my comment here is more general as the current implementation does not seem to be impacted and we can merge and move forward. I am wondering if we should also try to implement another switch or if statement within Ramp function to output a different value than I am happy to approve and merge as you have, but this additional note may be helpful for documentation. |
|
@nathanmtom Thanks for pointing this out -- I hadn't thought to look into how the rampTime is used in Simulink. I just looked at the implementation, and like you said, R is a vector of all NaN's. The switching statement is actually always true though (rampTime<current time), which means that R is passed through the switch, but interestingly the output is all zeros. I wasn't able to find much on why this is, but it seems that some Simulink blocks map NaN to zero for some reason. Anyway, it seems to me that the switch block fixes the issue of NaN's within Simulink. |
|
@jtgrasb In reviewing Issue #926 I've realized that the |
|
@nathanmtom After exploring the issue further, I realized I went about the problem in the wrong way. In the waveClass where the rampFunction is calculated, it is replaced with a 1 for any time greater than the specified rampTime. By changing this to greater than or equal to, it will then replace the rampFunction with a 1 for all times when rampTime is equal to zero. I have changed this for the reg, irreg, and user wave elevation calculation. To summarize the process (when rampTime=0), the rampFunction is calculated as Nan's due to dividing by zero, but then immediately replaced by all ones. Similarly, for the Morison Element calculation, I updated the 3 Morison functions so that the ramp and curramp variables are only calculated when Time<rampTime. Since the current time is never less than zero, this calculation never occurs and there is no issue with Nan's. Lastly, in the Excitation Force calculation, it doesn't make sense to me to put an extra switching block. The current switching block already avoids the issue, and I feel like adding another switch adds unnecessary complication. Let me know if you have any thoughts/concerns on this. --Jeff |
|
Thanks @jtgrasb I agree that your latest changes are the simplest implementation. I am also fine with not updating the working blocks within the body block for the wave excitation force ramp implementation. We are already implementing the 'less than' logic statement which is the same as the implementation that you have used to update the I have no other requests and barring no further comments or requests from the larger WEC-Sim team will plan to merge at the next group meeting. |
|
Thanks @jtgrasb for your help in solving this issue. Per the discussion this morning during the development meeting I am going to go ahead and merge this PR to fix the identified bug. If you can follow-up by putting on the project board a note to investigate how the ramp function can be converted to a function rather than Simulink blocks that would be great. |



This PR is a fix for issue #916. Because the equation for the rampFunction divides by the rampTime, it leads to an Nan value, which is not replaced by the interpolated elevation as it should be. The solution provided here checks if the rampTime is greater than 0 and applies a vector of 1s for the rampFunction if not.