sandialabs / WecOptTool

WEC Design Optimization Toolbox
https://sandialabs.github.io/WecOptTool/
GNU General Public License v3.0
13 stars 22 forks source link

Simulate WEC without optimization or controller #325

Open brigittedg opened 7 months ago

brigittedg commented 7 months ago

Hi, Before optimizing I want to simulate the dynamics of the WEC with the waves acting on it, without adding PTO force. This, to compare with results I optained using previous software, so no optimization or controller. Is there an easy way to do this?

So far using WecOptTool we have succesfully obtained the mesh, the various types of coefficients and the wave elevation spectrum.

I have tried various things so to simulate without PTO but they did not work, such as:

michaelcdevin commented 7 months ago

Hi @brigittedg,

It sounds like you're already on the right track with your second bullet point. The way we have done this in the past is to provide a dummy x_opt and objective function that solves immediately. x_wec is still forced to satisfy the residual constraint, so WEC.solve() still returns the proper dynamics of the WEC even though nothing is being optimized. Try, for example:

def obj_fun(wec, x_wec, x_opt, waves):
    return np.abs(x_opt)
nstate_opt = 1
x_opt_0 = np.array([0])
results = wec.solve(
            waves,
            obj_fun,
            nstate_opt,
            x_opt_0=x_opt_0)

Setting f_add=None is valid, so it returning an error may indicate another problem with the model.

cmichelenstrofer commented 7 months ago

You can set nstate_opt=0 and then use any objective function that does not depend on x_wec. See #277. Something like this should work:

nstate_opt = 0 
obj_fun = lambda wec, x_wec, x_opt, waves : 0
cmichelenstrofer commented 7 months ago

Action:

brigittedg commented 7 months ago

@michaelcdevin Thank you very much! f_add now also did not have a problem anymore.

rebeccamccabe commented 5 months ago

I read this paper from professor Ringwood about a method called "nonlinear frequency domain method" instead of pseudospectral method, but I think it's the same thing just without optimizing. It seems to imply that when doing simulation without optimization, it is more efficient to solve with a nonlinear equation solver like Newton's method than it is to solve the optimization with a dummy objective. So perhaps there could be a separate simulation mode in WecOptTool that when x_opt is zero length then it uses Newton's method / another solver instead of SQP?