# Differencing / differentiating discrete values to assess changes in averaged values over different batch runs.

## Recommended Posts

I am investigating a fouling case study for a batch process. During a batch run the heat exchangers fouls, which can be seen in a decreasing heat transfer coefficient. At the end of the batch the heat exchanger is cleaned without taking it out of service. As result the heat transfer coefficient is again higher. However, with every batch a little bit of extra fouling remains. This can be seen by calculating the average heat transfer coefficient over 1 batch and comparing these for a number of consecutive batches. Finally, the heat exchanger has to be taken out of service and thoroughly cleaned to remove all fouling.

What I did so far was using the signal from condition tool to compute the average heat transfer coefficient for one 1 batch and
put this value each time as a discrete value in the middle of the batch.

Now I want the compare the average value for multiple batches and compute for instance the delta between to adjecent batches, differencing/differentiating the signal to get the slope of the decrease, ... .

How can this be done with discrete samples / values?

##### Share on other sites

To get the difference between adjacent discrete values, I would use the following formula...

`\$signal.toStep(2d).runningDelta()`

the runningDelta() function requires a continuous signal, so the signal must first be converted to a continuous signal using to toStep() with the included maxInterpolation parameter. The maxInterpolation must be large enough to span the time between to adjacent batches. You could then convert the delta signal back to discrete if you'd like with toDiscrete().

If you want to calculate slope, you'll also need to the time between each value. There are probably many ways to do this, but I converted the discrete value to a condition using the following formula...

`\$signal.toStep(2d).toCondition()`

I then used Signal From Condition tool to output the duration of each capsule as a signal name 'Condition Duration'.

I now have two signals at the same time, Delta and Condition Duration. I used the formula tool again to calculate slope as rise/run or Delta/Condition Duration.

Hope this helps,

Andrew ##### Share on other sites

Thanks, it is good to know that this can be done by converting it to a continuous signal!

Alternatively, I found out that when you have equally spaced (discrete) values (e,g, daily averages coming from using signal from condition using a periodic condition) that you can easily code the finite difference scheme yourself allowing to go broader than only the adject points or to use scheme of higher accuaracy order, e.g.,

(\$signal - \$signal.move(+7d))/(7d)

This may be a little bit less noisy although differentiation inherently amplifies the noise 🙂. So removing outliers and filtering the original signal is surely advisable.