Calculadora per fer rases (swales)

In this updated version, we calculate the spacing between swales using the formula distance / (log(num_swales + 2) / log(2)). This formula uses the base-2 logarithm to calculate the number of intervals between the swales, which ensures that the spacing increases exponentially as the number of swales increases. This spacing formula is commonly used in permaculture design for swale placement.

With this updated code, the program will output the volume of water held in each swale, the minimum cross-sectional area of each swale, and the placement of each swale from the bottom of the hill with the spacing determined by the logarithmic formula.


We calculate the slope ratio using the formula tan(slope_deg * PI / 180). We then use this slope ratio to calculate the depth and width of each swale.

The depth of each swale can be calculated using the formula height * slope_ratio, where height is half the distance between the bottom and top of the hill.

The width of each swale can be calculated using the formula depth / slope_ratio.

We then include the swale dimensions in the output along with the swale placement and other previously calculated values.