Conical Tank geometry with Python

Hi All,
@c.poupin

In order to find the top radius R2 of my Tank according to its total volume VT and the choosen angle theta, I should iterate the value of bottom radius R1 which start from 3.40m (see the image bellow)

To find a solution to R2 (Top radius) I used the volume formula of conical geometry which give me two solutions after computing the discriminant and I should choose the positive one

according to my calculations in Excel If I fixe choosen angle = 45 degrees the approximate solution which I can take is:
angle = 45.056

But python give me this:

So, what is missing in my script bellow, and can I find the exact value for the angle 45 degrees?

``````import sys
import clr
import math
from Autodesk.DesignScript.Geometry import *
#Total volume (volume water + volume chimeny)
VT = 1023.7797
#
H_water = 6
# desired angle
angle_Tank = 45

Axis = Vector.ByCoordinates(0, 0, 1)
Center = Point.ByCoordinates(0, 0, 0)
#initial bottom radius value in iteration

#compute the discriminant of 2nd degree equation
delta = length_radius**2 + 4 * (3 * VT/ (math.pi * H_water) -(length_radius**2))
OUT = delta
# choosing the positive solution for Top radius
if R1 > 0:
else:
out = []
k = 0
while k < 100:
k +=1
delta = length_radius**2 + 4 * (3 * VT/ (math.pi * H_water) -(length_radius**2))
if R1 > 0:
if math.ceil(temp_angle) == angle_Tank:
out.append(temp_angle)
break
else:
if math.ceil(temp_angle) == angle_Tank:
out.append(temp_angle)
break
OUT = out

``````

Thanks.

Hi All,
I’ve solve my issue by increasing rounding of offset_radius to 0.001 and in the same time increasing k to 764.
Also, I’ve correct the error I made for the condition which give the angle

``````if math.ceil(temp_angle) == angle_Tank:
``````

replaced by :

``````if math.ceil(temp_angle) > angle_Tank:
``````

which give me this:

Thanks.