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.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://forum.dynamobim.com/t/conical-tank-geometry-with-python/86346", "fetch_time": 1709494686000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-10/segments/1707947476397.24/warc/CC-MAIN-20240303174631-20240303204631-00553.warc.gz", "warc_record_offset": 258096884, "warc_record_length": 7170, "token_count": 519, "char_count": 1864, "score": 3.59375, "int_score": 4, "crawl": "CC-MAIN-2024-10", "snapshot_type": "latest", "language": "en", "language_score": 0.7399934530258179, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00050-of-00064.parquet"}