How to use finite difference method for non-uniform grid in python?

358 views Asked by At

I have a function f = dp/de (variation in pressure as a function of variation in energy) and I would like to calculate this derivative with finite differences. I have a list for the p values ​​and a list for the e values. However, the grid formed by interpolating p with e is not uniform.

I tried, earlier, to calculate f as follows:

f.append((p[i+1] - p[i])/(e[i+1]- e[i]))

However, I need a better refinement at least in the first points.

How can I use finite difference method for non-uniform grids in python? Basically the grid has this format below (photo)

grid

1

There are 1 answers

0
mariolpantunes On

I have a python library named uts (uneven time series) that allows one to compute the central differences for the first and second order. The code that matters is here.