একটি খসড়া ডেমো

ছাদের এক বৃষ্টিমাপকের হিসাব

মেনু

The Roof Notebook · উপকরণ

The Roof Notebook

২০টি ফাইল

frustum.py১ KBডাউনলোড

"""How much a tapering biscuit tin overstates the rain.

Worked on the back of the 24 July page, then typed up. The tin is a frustum: 110 mm radius at the mouth, 98 mm at
the base, 95 mm deep. Rain is measured over the mouth; the ruler reads depth in a vessel that narrows below it.
"""

from math import pi

MOUTH_R = 110.0  # mm
BASE_R = 98.0    # mm
DEPTH = 95.0     # mm


def radius_at(h: float) -> float:
    """Radius of the water's surface h millimetres above the base."""
    return BASE_R + (MOUTH_R - BASE_R) * h / DEPTH


def volume_to(h: float) -> float:
    """Volume of water standing h millimetres deep, in cubic millimetres."""
    r0, r1 = BASE_R, radius_at(h)
    return pi * h * (r0 * r0 + r0 * r1 + r1 * r1) / 3


def rain_for(reading: float) -> float:
    """Millimetres of rain over the mouth that leave `reading` millimetres standing in the tin."""
    return volume_to(reading) / (pi * MOUTH_R * MOUTH_R)


if __name__ == "__main__":
    for reading in (1, 5, 12, 41, 80, 95):
        rain = rain_for(reading)
        print(f"{reading:>3} mm in the tin  =  {rain:5.1f} mm of rain  (overstated x{reading / rain:.2f})")

khosra · khata 30723e3a · content bbf50b9e · 228 publications, 4256671 bytes · built in 1.41295s