When is the expression of a synthetic variable called?

Hey,

i am currently trying to implement a synthetic variable with calculates the volume measured by a flowmeter. The flowmeter gives me the flowrate, so liters/second. From that i want to calculate the volume. My approach is to discretly integrate the flowrate as follows:

delta_t=flow_rate.timestamp-shift(flow_rate.timestamp,-1)
previous_flow=shift(flow_rate,-1)
volume=volume+previous_flow*delta_t

When is the expression of the synthetic variable call/calculated? Because it would need to be only when there is a new data point coming in. And the variable volume would need to be a variable which is safed overe the iterations.

Any help?

Thanks

Hi @pydro2020,

Thank you for your question and please receive my apologies for this late reply.

Indeed a synthetic variable calculates each time a new dot arrives in any of the variables related to the expression. Now, for this case is necessary to create two synthetic variables, one to calculate the first part of the expression, as follows.

delta_t=flow_rate.timestamp-shift(flow_rate.timestamp,-1)
previous_flow=shift(flow_rate,-1)

and a different synthetic variable that will take that value and calculates the volume, as it is not possible to use the variable to calculate itself in the synthetic variables engine.

volume+previous_flow * delta_t

For more information about synthetic variables, please refer to the article below.

All the best,
-Isabel