Functional Weave
Code in TypeScript

agri.spray-mix@1.0.0

README.md

2,000 bytes · view raw

# agri.spray-mix

**Status: needs review by a qualified agronomist/BASIS adviser before it is
published; always follow the product label.**

How to fill a sprayer for a job: how many tank fills, and how much product
and water go into each full tank and into the last, part-filled one. 24 ha at
a water volume of 200 L/ha with a product at 2.5 L/ha and a 1000 L tank is 5
fills: four full tanks of 12.5 L product and 987.5 L water, each covering
5 ha, and a last tank of 10 L product and 790 L water for the remaining 4 ha.

## Terms

- **Water volume** (the application rate) is the total spray liquid applied
  per hectare, product included, as sprayer calibration sets it.
- **Dose** is the label rate of product per hectare, in litres for a liquid
  or kilograms for a solid (`doseUnit`).
- **Water** in a tank is the spray volume less the product for a liquid,
  since the product takes up room; for a solid it is the whole spray volume
  (the powder or granules dissolve or disperse into it).

## Exactness

Inputs are taken to 0.0001 ha, 0.1 L/ha, 0.001 L or kg per ha and 0.1 L
(`math.round-float`) and held as integers, so the job's total spray volume is
exact and the full-tank count is a whole-number division. In floating point,
129.2 ha x 250 L/ha is 32299.999999999996, which makes 18 full 1700 L tanks
and a sliver; this gives exactly 19.

Each load's area, spray, product and water are worked out from its own spray
volume and rounded half up (area to 0.0001 ha, liquids and product to 0.001).
Water is the rounded spray less the rounded product, so each load adds up.

## What it does not do

It does not check the dose, water volume, number of applications or
buffer zones against the label, account for rinsate, the tank's unusable
residue (give the usable capacity) or a tank-mix order, or convert units.

## Limits

Area more than 0 and at most 100,000 ha; water volume 0.1 to 10,000 L/ha;
dose 0 to 100 per ha, and for a liquid less than the water volume; tank 0.1
to 100,000 L.