Posted Mon, 03 Jul 2017 19:48:56 GMT by Youri Amerlinck
Hi,

Is it possible to calculate an integral in the calculator variables?

Thanks

Youri
Posted Tue, 04 Jul 2017 07:59:46 GMT by Enrico Remigi WEST Product Owner
Yes of course but it requires some coding: there's no out-of-the-box model in the current library.
I have recently written one: I will send it to you via email. If it should not be exactly what you need, you could at least use it as a base for your own development.
It would be great, if we could eventually come to a sufficiently generic version that can then be incorporated in the standard library.
Posted Tue, 04 Jul 2017 08:39:10 GMT by Youri Amerlinck
Hi Enrico,

I'm not sure if you understood my question correctly.

In MSL you can indeed calculate an integral. You can do it either by using the buffer functions and calculate the integral from it or you can use differential equations to calculate it (the latter is done in the PI controller).

[code]DERIV(state.Integ_e, [independent.t]) = state.e ;[/code]

But what I wanted to know if you can do this in the calculator variables.

Thanks,

Youri

Posted Tue, 04 Jul 2017 09:13:04 GMT by Enrico Remigi WEST Product Owner
Hi Youri,
yes, I immediately thought of calculator block, sorry.

No, I don't think it's possible through a [b]calculator variable[/b].
It is certainly possible though using the new (in 2017) [b]Top-level Quantities[/b] where you can write the usual MSL code - including what you have just suggested.
Posted Tue, 04 Jul 2017 12:22:14 GMT by Filip Claeys
If you just want the "final" integral (i.e. at the end of the simulation, over the entire horizon) of a calculator variable, you can add that calculator variable as a variable to the objective evaluation and tick the integral time series criterion. If you don't want this integral to be taken into account for the overall objective value computation, you can set the weight of the integral criterion to 0 (or set the weight of the variable to 0 if the integral is the only criterion that is active).

If you want the integral to be computed at every time point, you cannot do with calculator variables. Calculator variables are in fact the old (pre-2017), limited approach to defining additional top-level computations. The new top-level items window (that Enrico is referring to) supersedes the old calculator variables and also adds extra possibilities such as aggregation (e.g. integral computation) and much more. Actually, the top-level items approach even allows for computing the integral in 2 ways: through a differential equation and through the MSLUBuffer functionality. The first is the simplest, but the latter is more versatile since it allows for using a moving window for the integral computation (should this be necessary).

See the attached screenshot.
Posted Mon, 07 Aug 2017 14:03:59 GMT by Youri Amerlinck
Cool, thanks for the answer!

By the way, how smoothly is it to move from WEST2016 to WEST2017?

You must be signed in to post in this forum.