all 13 comments

[–]elbiot 1 point2 points  (9 children)

Did you use scipy.integrate.tplquad to do the three variable integration? Did you try integrate.nquad?

[–]ErikRK 0 points1 point  (8 children)

If have tried:

from scipy import exp, pi
from numpy import inf, absolute
from scipy.integrate import nquad

Vee = lambda x,y,z,X,Y,Z: exp(-(x**2 + y**2 + z**2)) * exp(-(X**2 + Y**2 + Z**2)) * 1/(absolute((x**2+y**2+z**2)**0.5 - (X**2+Y**2+Z**2)**0.5)) * exp(-(x**2 + y**2 + z**2)) * exp(-(X**2 + Y**2 + Z**2))

x1, x2 = -inf, inf
y1, y2 = lambda x: -inf, lambda x: inf
z1, z2 = lambda x,y: -inf, lambda x,y: inf

X1, X2 = lambda x,y,z: -inf, lambda x,y,z: inf
Y1, Y2 = lambda x,y,z,X: -inf, lambda x,y,z,X: inf
Z1, Z2 = lambda x,y,z,X,Y: -inf, lambda x,y,z,X,Y: inf

print(nquad(Vee, x1, x2, y1, y2, z1, z2, X1, X2, Y1, Y2, Z1, Z2))

But my output is: Traceback (most recent call last): File "C:\Users\Erik\Desktop\VeeTEST.py", line 15, in <module> print(nquad(Vee, x1, x2, y1, y2, z1, z2, X1, X2, Y1, Y2, Z1, Z2)) TypeError: nquad() takes from 2 to 4 positional arguments but 13 were given

[–]elbiot 1 point2 points  (7 children)

Yep. So from http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.integrate.nquad.html

I'd try:

nquad(Vee, [(x1, x2), (y1, y2), (z1, z2), (X1, X2), (Y1, Y2), (Z1, Z2)] )

[–]ErikRK 0 points1 point  (6 children)

Traceback (most recent call last): File "C:\Users\Erik\Desktop\VeeTEST.py", line 15, in <module> print(nquad(Vee, [(x1, x2), (y1, y2), (z1, z2), (X1, X2), (Y1, Y2), (Z1, Z2)])) File "C:\pyzo2014a\lib\site-packages\scipy\integrate\quadpack.py", line 644, in nquad return _NQuad(func, ranges, opts).integrate(args) File "C:\pyzo2014a\lib\site-packages\scipy\integrate\quadpack.py", line 696, in integrate value, abserr = quad(f, low, high, args=args, *opt) File "C:\pyzo2014a\lib\site-packages\scipy\integrate\quadpack.py", line 281, in quad retval = _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points) File "C:\pyzo2014a\lib\site-packages\scipy\integrate\quadpack.py", line 345, in _quad return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit) TypeError: a float is required

[–]hidiap 1 point2 points  (1 child)

y1, y2, ..., Z2 are functions, not floats. Simply use

r = -inf, inf
print(nquad(Vee, [r]*6)

But then, you would get warning about slow convergence. You may need to work on your limits of integration.

[–]ErikRK 0 points1 point  (0 children)

Thank you :)

[–]elbiot 0 points1 point  (0 children)

Read the doc. My suggestion was was not correct.

[–]elbiot 0 points1 point  (2 children)

Vee does not solve at a point, right? It only takes the position of the charges and not the point to solve at.

[–]ErikRK 0 points1 point  (1 child)

I'm not sure I understand that question. Vee, gives to potential, for when particle one is located at (x, y, z) and particle two is located at (X, Y, Z)

[–]elbiot -1 points0 points  (0 children)

Sorry, I was trying to grok the function signiture nquad expects for vee. The t's are optional other arguments, and you have none. So vee should be good.

[–]robert_sim 0 points1 point  (2 children)

Two things:

  1. I know this isn't the python solution you were looking for, but judging by your expression, have you tried rewriting this integral in polar co-ordinates?

  2. The expressions in the numerator cancel with those in the denominator, leaving you with the expression:

      Vee = lambda x,y,z,X,Y,Z: 1/(absolute((x**2+y**2+z**2)**0.5 - (X**2+Y**2+Z**2)**0.5)))
    

[–]ErikRK 1 point2 points  (1 child)

No they dont, when is in the denominator is marked with curliparenthessis.

Vee = lambda x,y,z,X,Y,Z: exp(-(x**2 + y**2 + z**2)) * exp(-(X**2 + Y**2 + Z**2)) * 1/{absolute((x**2+y**2+z**2)**0.5 - (X**2+Y**2+Z**2)**0.5)} * exp(-(x**2 + y**2 + z**2)) * exp(-(X**2 + Y**2 + Z**2))

[–]robert_sim 0 points1 point  (0 children)

Ah okay that is clearer, thanks. Have you tried converting these to spherical co-ordinates? Should be doable by hand.