Python Forum
Integrating for the volume of a torus in SciPy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Integrating for the volume of a torus in SciPy
#3
(Jan-07-2020, 03:43 PM)Gribouillis Wrote: My guess is that for z_low and z_high it should be lambda theta, rho:... because the documentation says qfun(x, y) and rfun(x, y)

It turns out you are correct! Thanks!
I ran the code
import numpy as np
from scipy.integrate import tplquad

R = 4
r = 1

# Volume integral
# Order of integration is z, rho, theta
f1 = lambda z, rho, theta: 2 * rho
# set theta limits
a, b = 0, 2 * np.pi
# set rho limits
rho_low = lambda rho: R - r
rho_high = lambda rho: R + r
# set z limits
z_low = lambda theta, rho: 0
z_high = lambda theta, rho: np.sqrt(r**2 - (rho - R)**2)
# calculate integral
V, _ = tplquad(f1, a, b, rho_low, rho_high, z_low, z_high)
print(V)
which gives the correct result. I did not have to integrate in the first octant only and then multiply by 8 after all Think. How come the order 'lambda rho, theta' did not work and 'lambda theta, rho' does?
Reply


Messages In This Thread
RE: Integrating for the volume of a torus in SciPy - by Nitram - Jan-08-2020, 04:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting up and integrating Jupyter Notebook development environment with VSC Drone4four 3 1,912 Sep-12-2022, 09:18 AM
Last Post: Drone4four
  How to accumulate volume of time series amdi40 3 2,330 Feb-15-2022, 02:23 PM
Last Post: amdi40
  error on stock indicator code on balance volume yatish 19 9,617 Dec-14-2018, 05:40 PM
Last Post: yatish

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020