formulab 0.48.1 → 0.48.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.48.2] - 2026-09-24
11
+
12
+ ### Fixed
13
+
14
+ - **`battery/chargingProfile()` minutes and average C-rate came from the rounded hours.** For example,
15
+ 5 Ah at 2.5 A to a 0.25 A cutoff gave `cvPhaseTimeMin` 43.8 (0.73 h × 60) instead of 43.6 and
16
+ `totalTimeMin` 139.8 instead of 139.6. Every output is now rounded once from the unrounded value.
17
+
10
18
  ## [0.48.1] - 2026-09-24
11
19
 
12
20
  ### Fixed
@@ -1 +1 @@
1
- {"version":3,"file":"chargingProfile.d.ts","sourceRoot":"","sources":["../../src/battery/chargingProfile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAqDlF"}
1
+ {"version":3,"file":"chargingProfile.d.ts","sourceRoot":"","sources":["../../src/battery/chargingProfile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAyDlF"}
@@ -23,20 +23,25 @@ export function chargingProfile(input) {
23
23
  if (!(ccEndSocPercent > 0) || ccEndSocPercent >= 100) {
24
24
  throw new RangeError('ccEndSocPercent must be greater than 0 and less than 100');
25
25
  }
26
- // CC phase delivers ccEndSocPercent of capacity
27
- const ccPhaseAh = roundTo(capacityAh * (ccEndSocPercent / 100), 2);
28
- const cvPhaseAh = roundTo(capacityAh - ccPhaseAh, 2);
26
+ // Every output is rounded once, from the unrounded value. Deriving minutes from the rounded
27
+ // hours (or the C-rate from the rounded total) would carry the hour rounding into them.
28
+ const ccAh = capacityAh * (ccEndSocPercent / 100);
29
+ const cvAh = capacityAh - ccAh;
29
30
  // CC phase time = Ah / current
30
- const ccPhaseTimeH = roundTo(ccPhaseAh / chargingCurrentA, 2);
31
- const ccPhaseTimeMin = roundTo(ccPhaseTimeH * 60, 1);
31
+ const ccH = ccAh / chargingCurrentA;
32
32
  // CV phase time approximation: average current = (Icc + Icut) / 2
33
- const avgCvCurrent = (chargingCurrentA + cutoffCurrentA) / 2;
34
- const cvPhaseTimeH = roundTo(cvPhaseAh / avgCvCurrent, 2);
35
- const cvPhaseTimeMin = roundTo(cvPhaseTimeH * 60, 1);
36
- const totalTimeH = roundTo(ccPhaseTimeH + cvPhaseTimeH, 2);
37
- const totalTimeMin = roundTo(totalTimeH * 60, 1);
38
- // Average C-rate over entire charge
39
- const averageCRate = roundTo(capacityAh / (totalTimeH * capacityAh), 4);
33
+ const cvH = cvAh / ((chargingCurrentA + cutoffCurrentA) / 2);
34
+ const totalH = ccH + cvH;
35
+ const ccPhaseAh = roundTo(ccAh, 2);
36
+ const cvPhaseAh = roundTo(cvAh, 2);
37
+ const ccPhaseTimeH = roundTo(ccH, 2);
38
+ const ccPhaseTimeMin = roundTo(ccH * 60, 1);
39
+ const cvPhaseTimeH = roundTo(cvH, 2);
40
+ const cvPhaseTimeMin = roundTo(cvH * 60, 1);
41
+ const totalTimeH = roundTo(totalH, 2);
42
+ const totalTimeMin = roundTo(totalH * 60, 1);
43
+ // Average C-rate over the entire charge: one capacity delivered over the total time
44
+ const averageCRate = roundTo(1 / totalH, 4);
40
45
  return {
41
46
  ccPhaseTimeH,
42
47
  ccPhaseTimeMin,
@@ -1 +1 @@
1
- {"version":3,"file":"chargingProfile.js","sourceRoot":"","sources":["../../src/battery/chargingProfile.ts"],"names":[],"mappings":"AAAA,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c;QACd,UAAU;QACV,YAAY;QACZ,SAAS;QACT,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formulab",
3
- "version": "0.48.1",
3
+ "version": "0.48.2",
4
4
  "description": "Manufacturing & Engineering calculation formulas library - 203 industrial calculations across 15 domains for OEE, Cpk, SPC, FMEA, Nelson Rules, metal weight, CNC machining, GD&T, battery, environmental, pipe flow, logistics, IE time study, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",