Functional Weave
Code in Rust

energy.solar-generation@1.0.0

vectors.json

2,464 bytes · view raw

[
  {"name": "a 4 kWp south-facing array, no shading, Kk 950", "args": [[{"wattsPeak": 4000, "kk": 950, "shadeFactor": 100}]], "expect": {"arrays": [3800], "total": 3800}},
  {"name": "4.32 kWp with 11% shading loss: 3368.04 kWh rounds to 3368", "args": [[{"wattsPeak": 4320, "kk": 876, "shadeFactor": 89}]], "expect": {"arrays": [3368], "total": 3368}},
  {"name": "an exact half kWh rounds up: 3.25 kWp x 1000 x 0.45 is 1462.5", "args": [[{"wattsPeak": 3250, "kk": 1000, "shadeFactor": 45}]], "expect": {"arrays": [1463], "total": 1463}},
  {"name": "east/west arrays are estimated separately and summed", "args": [[{"wattsPeak": 3000, "kk": 700, "shadeFactor": 100}, {"wattsPeak": 3000, "kk": 720, "shadeFactor": 95}]], "expect": {"arrays": [2100, 2052], "total": 4152}},
  {"name": "two half-kWh arrays total 2926, not the 2925 rounding the sum would give", "args": [[{"wattsPeak": 3250, "kk": 1000, "shadeFactor": 45}, {"wattsPeak": 3250, "kk": 1000, "shadeFactor": 45}]], "expect": {"arrays": [1463, 1463], "total": 2926}},
  {"name": "a fully shaded array generates nothing", "args": [[{"wattsPeak": 4000, "kk": 950, "shadeFactor": 0}]], "expect": {"arrays": [0], "total": 0}},
  {"name": "a single 400 W panel", "args": [[{"wattsPeak": 400, "kk": 1011, "shadeFactor": 100}]], "expect": {"arrays": [404], "total": 404}},
  {"name": "a 100 kWp commercial roof", "args": [[{"wattsPeak": 100000, "kk": 890, "shadeFactor": 97}]], "expect": {"arrays": [86330], "total": 86330}},
  {"name": "a vertical north-facing array with a tiny Kk", "args": [[{"wattsPeak": 2000, "kk": 215, "shadeFactor": 100}]], "expect": {"arrays": [430], "total": 430}},
  {"name": "no arrays is an error", "args": [[]], "expectError": "a solar estimate needs at least one array"},
  {"name": "a shade factor above 1.00 is refused", "args": [[{"wattsPeak": 4000, "kk": 950, "shadeFactor": 101}]], "expectError": "shadeFactor must be a whole number from 0 to 100"},
  {"name": "a shade factor given as a fraction is refused", "args": [[{"wattsPeak": 4000, "kk": 950, "shadeFactor": 0.89}]], "expectError": "shadeFactor must be a whole number from 0 to 100"},
  {"name": "a negative rating is refused", "args": [[{"wattsPeak": -4000, "kk": 950, "shadeFactor": 100}]], "expectError": "wattsPeak must be a whole number"},
  {"name": "an implausible Kk is refused", "args": [[{"wattsPeak": 4000, "kk": 9500, "shadeFactor": 100}]], "expectError": "kk must be a whole number from 0 to 5000"}
]