![](/img/trans.png)
[英]how to use scipy.integrate to get the volume of a truncated sphere?
[英]How to get the correct diameter of a sphere given the volume
一些网站给出了以下等式,用于从球体的体积中获取直径:
直径 = (6(V/pi))^1/3 即 6(V/pi) 的立方根
https://www.sensorsone.com/sphere-volume-to-diameter-calculator/
使用以下代码时,我的答案是十的幂,我不明白为什么
代码
from math import pi
vol = 36.0e-12 #pL
d = (6*(vol/pi))**(1/3)
print("d : ", d)
d_millimetres = d * 1e3
print("d_millimetres : ", d_millimetres)
d_microns = d * 1e6
print("d_microns : ", d_microns)
退货
d : 0.0004096704379531776
d_millimetres : 0.4096704379531776
d_microns : 409.67043795317755
期望的答案
40.9#微米
球体的公式是:
V = (4/3)πr3
求解r
:
r = (3V/4/π)1/3
d = 2r
,所以:
d = 2((3V/4/π)1/3)
2 3 = 8
,所以在立方根内移动 8 得到:
d = ((8*3V/4/π)1/3)
d = (6V/π)1/3
在 Python 中:
import math
def d(V):
return (6*V/math.pi)**(1/3)
# NOTE! make units agree! 36 pL (36e-12 L) == 36e-15 cubic meters
print(d(36e-15))
Output:
4.0967043795317764e-05 # or 40.967 microns
使用r = 2, V = (4/3)π2 3 = 32/3π
进行测试:
print(d(32/3*math.pi))
3.9999999999999996 # 4 expected
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.