Skip to content

Conversation

@jtgrasb
Copy link
Contributor

@jtgrasb jtgrasb commented Mar 14, 2022

This is an updated version of PR #820 to be compatible with the new updates to dev.

In this PR, I’ve implemented warning and error flags that seek to provide more feedback to the user regarding common errors and issues. The following flags/messages have been implemented into wecSim as part of this PR:

  • Argument checks were placed in some functions (such as plotResponse, plotForces, etc) of the response and wave classes to provide context on the expected function inputs.
  • Properties within the simulation and wave class were given more specific requirements (such as requiring a positive timestep value).
  • Error message when non-hydro bodies are specified before hydro in the wecSimInputFile
  • Warning message when waves.waterDepth is defined and there is an .h5 file present
  • Error message when waveSpread does not sum to 1
  • Error when the name or filename is not specified in the body, constraint, pto, cable, mooring, and ptoSim classes, which indicates to the user that the objects have likely been defined in the wrong order.
  • Error messages when necessary parameters (such as cg and cb) are not defined for bodies based on type (hydro, non-hydro, etc)
  • Warning messages when extra parameters specified that don’t affect result (such as cg and cb for hydro body)
  • Warning message for STL greater than half the size of the domain and error message for when it is greater than the domain size
  • Warning for noWaveCIC case that waves.T is not used
  • Errors and warning messages for parameters needed for each wave type
  • Warning message when simu.dtOut < simu.dt
  • Moves check for geometry file to only when explorer is on because the geometry file is not necessary when simulation explorer is off

I am working on more warning and error flags, but wanted to get a PR started here so that it can start to be reviewed.

Copy link
Collaborator

@kmruehl kmruehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtgrasb this looks great so far. I've made several comments in line. Also, the tests are failing, any idea why?

solver = 'ode4' % (`string`) PDE solver used by the Simulink/SimMechanics simulation. Any continuous solver in Simulink possible. Recommended to use 'ode4, 'ode45' for WEC-Sim. Default = ``'ode4'``
stateSpace {mustBeMember(stateSpace,0:1)} = 0 % (`integer`) Flag for convolution integral or state-space calculation, Options: 0 (convolution integral), 1 (state-space). Default = ``0``
startTime {mustBeNonnegative} = 0 % (`float`) Simulation start time. Default = ``0`` s
zeroCross = 'DisableAll' % (`string`) Disable zero cross control. Default = ``'DisableAll'``
Copy link
Collaborator

@kmruehl kmruehl Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do this property validation work? Can you share a MATLAB link? How does it affect our documentation, etc? Are you planning to add this to the other classes too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.mathworks.com/help/matlab/matlab_oop/validate-property-values.html
Here's the documentation for this MATLAB feature. I used it for the simulation class because there are a lot of simple checks on properties that I felt would be helpful (such as limiting the different timesteps to positive values), so I thought would be an easy way to check these.
Not sure how it affects the documentation yet, but I will check.
I think it would be helpful to add to more of the properties/classes, but I felt most of the other classes were easier to check using checkInputs methods.
Lastly, it is possible to add checks for the variable type (double, string, etc.) and size, but I ran into some issues with these when the variable is optional and can remain undefined.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtgrasb I like this feature a lot, and think we should implement it, but I'm wondering whether it's something we should push to after v5.0 and implement across all the classes, or whether we should work to include it in v5.0, LMK what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kmruehl I agree, it is a very useful feature. I think it may be best to wait until after v5.0 because although helpful, I don't think it affects WEC-Sim significantly with most use cases. It would also give me more time to work out the kinks and implement it for the other classes. If you think it should be part of v5.0 though, I can try to get the rest of the classes implemented.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, let's hold off of this on v5.0, but please add it to the project board for future development.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you revert the simulationClass property validation, and then I'll merge this.

@kmruehl kmruehl added the SCM source code mangagement and warnings label Mar 15, 2022
@kmruehl
Copy link
Collaborator

kmruehl commented Mar 15, 2022

@jtgrasb can you resolve the merge conflicts?

@kmruehl
Copy link
Collaborator

kmruehl commented Mar 16, 2022

@jtgrasb sorry that dev is a moving target due to the other PRs. This should be the last major change to dev to resolve conflicts with and then we can merge this PR too.

@kmruehl
Copy link
Collaborator

kmruehl commented Mar 23, 2022

@jtgrasb thanks for resolving merge conflicts! I'll merge this once the property validation has been removed.

solver = 'ode4' % (`string`) PDE solver used by the Simulink/SimMechanics simulation. Any continuous solver in Simulink possible. Recommended to use 'ode4, 'ode45' for WEC-Sim. Default = ``'ode4'``
stateSpace {mustBeMember(stateSpace,0:1)} = 0 % (`integer`) Flag for convolution integral or state-space calculation, Options: 0 (convolution integral), 1 (state-space). Default = ``0``
startTime {mustBeNonnegative} = 0 % (`float`) Simulation start time. Default = ``0`` s
zeroCross = 'DisableAll' % (`string`) Disable zero cross control. Default = ``'DisableAll'``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you revert the simulationClass property validation, and then I'll merge this.

@kmruehl kmruehl merged commit 30963ad into WEC-Sim:dev Mar 23, 2022
@kmruehl
Copy link
Collaborator

kmruehl commented Mar 23, 2022

Thanks @jtgrasb

@jtgrasb jtgrasb deleted the warningFlags-updated branch July 5, 2022 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SCM source code mangagement and warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants