Works out how many modules go in a string and how many strings on an inverter from the module and inverter ratings and the temperatures given.
How the precision is kept
Cold and hot voltages are linear in temperature and computed in 64-bit. The longest and shortest string come from the unrounded voltages, with a 1e-9 guard before floor and ceil. The string voltages that are checked against the limits, however, are built from per-module voltages already rounded to 0.01 V and are rounded again, so a check can disagree with the string length just computed.
Open item. Compute the string voltages and their checks from the unrounded cold and hot voltages, and round only what is shown.
Calculations under this policy
6 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
The counts use the unrounded voltages. The voltages returned in the result (vocCold, vmpCold, vmpHot) are rounded to two decimals, and designStrings reads those rounded values.
The string length inside the window that leaves the fewest modules over.
count = ⌊modules ÷ n⌋; left = modules − count × n
Integer arithmetic, from the longest string down; the search stops at the first length that divides the modules evenly.
pv-string.js
lines 36 to 41
BimCraft 0.8.1
for (let n = Math.min(W.nMax, modules); n >= Math.max(1, W.nMin); n--) {
const count = Math.floor(modules / n), left = modules - count * n;
if (count < 1) continue;
if (!best || left < best.left) best = { n, count, left };
if (left === 0) break;
}
String voltage checks
64-bit
The string's cold and hot voltages against the inverter's and the system's limits.
W.vocCold, W.vmpHot and W.vmpCold are already rounded to 0.01 V; the product is rounded again and that value is compared with the limit. The rounding of the module voltage, up to 0.005 V, is multiplied by n.
V(T) = V × (1 + β × (T − 25)); nMax = ⌊min(V_dc max, system limit) ÷ (Voc,cold × factor)⌋ and ⌊MPPT max ÷ Vmp,cold⌋; nMin = ⌈MPPT min ÷ Vmp,hot⌉; strings per input = ⌊I max ÷ I module⌋.
Number types
64-bit numbers; counts are integers.
Tolerances
1e-9 added before Math.floor and subtracted before Math.ceil (absolute, on a ratio).
Limits
Example: a cold Voc of 47.617 V and a 1000 V limit allow 21 modules (999.957 V), but for a string of 21 the check uses 21 × 47.62 = 1000.02 V and reports the limit as exceeded. The starter temperatures and factors are labelled as placeholders in the file.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.