0

I am looking for å python library that has a function to solve 3D integrals over a tetrahedron. I would like to be able to input four points on the form (x, y, z) and a function f(x, y, z) where f is a polynomial function.

Have only found functions that accepts integration boundaries that go from function to function, but I need an integration tool that accepts points.

gast
  • 11
  • 2
  • I've never used scipy for this but it probably has something useful. What kind of function is this though? Depending on the function, computing the integral might be easy or hard. – Stef Nov 07 '22 at 12:54
  • There is [scipy.integrate.tplquad](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.tplquad.html#scipy.integrate.tplquad). It looks like it will require a (simple?) change of variables to use properly. – Stef Nov 07 '22 at 12:59
  • Gaussian quadrature over a unit tetrahedron is common in finite element analysis. You'd just need a transformation from local to global coordinates. – duffymo Nov 07 '22 at 13:19

1 Answers1

0

You can use the quadpy library to integrate a function over a tetrahedron.

But for a polynomial function f, it is possible to calculate the exact value of the integral of f over a tetrahedron (more generally over a simplex in any dimension). This method is implemented in the R package SimplicialCubature. This paper provides another method; I implemented it in Python: gist.


EDIT

I made a package now.

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225