formulab 0.5.0 → 0.9.0
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 +84 -0
- package/README.md +162 -31
- package/dist/automotive/chargingLoss.d.ts +15 -0
- package/dist/automotive/chargingLoss.d.ts.map +1 -0
- package/dist/automotive/chargingLoss.js +62 -0
- package/dist/automotive/chargingLoss.js.map +1 -0
- package/dist/automotive/index.d.ts +2 -1
- package/dist/automotive/index.d.ts.map +1 -1
- package/dist/automotive/index.js +1 -0
- package/dist/automotive/index.js.map +1 -1
- package/dist/automotive/types.d.ts +23 -0
- package/dist/automotive/types.d.ts.map +1 -1
- package/dist/battery/guards.d.ts +7 -0
- package/dist/battery/guards.d.ts.map +1 -0
- package/dist/battery/guards.js +17 -0
- package/dist/battery/guards.js.map +1 -0
- package/dist/battery/index.d.ts +1 -0
- package/dist/battery/index.d.ts.map +1 -1
- package/dist/battery/index.js +2 -0
- package/dist/battery/index.js.map +1 -1
- package/dist/chemical/flowControl.d.ts +14 -0
- package/dist/chemical/flowControl.d.ts.map +1 -0
- package/dist/chemical/flowControl.js +69 -0
- package/dist/chemical/flowControl.js.map +1 -0
- package/dist/chemical/guards.d.ts +17 -0
- package/dist/chemical/guards.d.ts.map +1 -0
- package/dist/chemical/guards.js +54 -0
- package/dist/chemical/guards.js.map +1 -0
- package/dist/chemical/index.d.ts +5 -1
- package/dist/chemical/index.d.ts.map +1 -1
- package/dist/chemical/index.js +5 -0
- package/dist/chemical/index.js.map +1 -1
- package/dist/chemical/pid.d.ts +14 -0
- package/dist/chemical/pid.d.ts.map +1 -0
- package/dist/chemical/pid.js +103 -0
- package/dist/chemical/pid.js.map +1 -0
- package/dist/chemical/reliefValve.d.ts +14 -0
- package/dist/chemical/reliefValve.d.ts.map +1 -0
- package/dist/chemical/reliefValve.js +98 -0
- package/dist/chemical/reliefValve.js.map +1 -0
- package/dist/chemical/types.d.ts +63 -0
- package/dist/chemical/types.d.ts.map +1 -1
- package/dist/construction/guards.d.ts +7 -0
- package/dist/construction/guards.d.ts.map +1 -0
- package/dist/construction/guards.js +31 -0
- package/dist/construction/guards.js.map +1 -0
- package/dist/construction/index.d.ts +1 -0
- package/dist/construction/index.d.ts.map +1 -1
- package/dist/construction/index.js +2 -0
- package/dist/construction/index.js.map +1 -1
- package/dist/electronics/guards.d.ts +7 -0
- package/dist/electronics/guards.d.ts.map +1 -0
- package/dist/electronics/guards.js +17 -0
- package/dist/electronics/guards.js.map +1 -0
- package/dist/electronics/index.d.ts +1 -0
- package/dist/electronics/index.d.ts.map +1 -1
- package/dist/electronics/index.js +2 -0
- package/dist/electronics/index.js.map +1 -1
- package/dist/energy/boilerEfficiency.d.ts +13 -0
- package/dist/energy/boilerEfficiency.d.ts.map +1 -0
- package/dist/energy/boilerEfficiency.js +46 -0
- package/dist/energy/boilerEfficiency.js.map +1 -0
- package/dist/energy/cusum.d.ts +15 -0
- package/dist/energy/cusum.d.ts.map +1 -0
- package/dist/energy/cusum.js +71 -0
- package/dist/energy/cusum.js.map +1 -0
- package/dist/energy/degreeDay.d.ts +13 -0
- package/dist/energy/degreeDay.d.ts.map +1 -0
- package/dist/energy/degreeDay.js +46 -0
- package/dist/energy/degreeDay.js.map +1 -0
- package/dist/energy/heatPump.d.ts +13 -0
- package/dist/energy/heatPump.d.ts.map +1 -0
- package/dist/energy/heatPump.js +48 -0
- package/dist/energy/heatPump.js.map +1 -0
- package/dist/energy/index.d.ts +9 -1
- package/dist/energy/index.d.ts.map +1 -1
- package/dist/energy/index.js +8 -0
- package/dist/energy/index.js.map +1 -1
- package/dist/energy/insulationRoi.d.ts +14 -0
- package/dist/energy/insulationRoi.d.ts.map +1 -0
- package/dist/energy/insulationRoi.js +52 -0
- package/dist/energy/insulationRoi.js.map +1 -0
- package/dist/energy/ledRoi.d.ts +14 -0
- package/dist/energy/ledRoi.d.ts.map +1 -0
- package/dist/energy/ledRoi.js +49 -0
- package/dist/energy/ledRoi.js.map +1 -0
- package/dist/energy/transformerLoss.d.ts +13 -0
- package/dist/energy/transformerLoss.d.ts.map +1 -0
- package/dist/energy/transformerLoss.js +63 -0
- package/dist/energy/transformerLoss.js.map +1 -0
- package/dist/energy/types.d.ts +168 -0
- package/dist/energy/types.d.ts.map +1 -1
- package/dist/energy/windOutput.d.ts +14 -0
- package/dist/energy/windOutput.d.ts.map +1 -0
- package/dist/energy/windOutput.js +77 -0
- package/dist/energy/windOutput.js.map +1 -0
- package/dist/food/index.d.ts +3 -1
- package/dist/food/index.d.ts.map +1 -1
- package/dist/food/index.js +2 -0
- package/dist/food/index.js.map +1 -1
- package/dist/food/stabilityStudy.d.ts +15 -0
- package/dist/food/stabilityStudy.d.ts.map +1 -0
- package/dist/food/stabilityStudy.js +92 -0
- package/dist/food/stabilityStudy.js.map +1 -0
- package/dist/food/types.d.ts +43 -0
- package/dist/food/types.d.ts.map +1 -1
- package/dist/food/waterActivity.d.ts +17 -0
- package/dist/food/waterActivity.d.ts.map +1 -0
- package/dist/food/waterActivity.js +63 -0
- package/dist/food/waterActivity.js.map +1 -0
- package/dist/logistics/abcAnalysis.d.ts +15 -0
- package/dist/logistics/abcAnalysis.d.ts.map +1 -0
- package/dist/logistics/abcAnalysis.js +101 -0
- package/dist/logistics/abcAnalysis.js.map +1 -0
- package/dist/logistics/index.d.ts +4 -1
- package/dist/logistics/index.d.ts.map +1 -1
- package/dist/logistics/index.js +3 -0
- package/dist/logistics/index.js.map +1 -1
- package/dist/logistics/inventoryTurnover.d.ts +13 -0
- package/dist/logistics/inventoryTurnover.d.ts.map +1 -0
- package/dist/logistics/inventoryTurnover.js +36 -0
- package/dist/logistics/inventoryTurnover.js.map +1 -0
- package/dist/logistics/loadCapacity.d.ts +13 -0
- package/dist/logistics/loadCapacity.d.ts.map +1 -0
- package/dist/logistics/loadCapacity.js +46 -0
- package/dist/logistics/loadCapacity.js.map +1 -0
- package/dist/logistics/types.d.ts +78 -0
- package/dist/logistics/types.d.ts.map +1 -1
- package/dist/metal/guards.d.ts +12 -0
- package/dist/metal/guards.d.ts.map +1 -0
- package/dist/metal/guards.js +36 -0
- package/dist/metal/guards.js.map +1 -0
- package/dist/metal/index.d.ts +1 -0
- package/dist/metal/index.d.ts.map +1 -1
- package/dist/metal/index.js +2 -0
- package/dist/metal/index.js.map +1 -1
- package/dist/quality/cmk.d.ts +17 -0
- package/dist/quality/cmk.d.ts.map +1 -0
- package/dist/quality/cmk.js +43 -0
- package/dist/quality/cmk.js.map +1 -0
- package/dist/quality/gageRR.d.ts +18 -0
- package/dist/quality/gageRR.d.ts.map +1 -0
- package/dist/quality/gageRR.js +110 -0
- package/dist/quality/gageRR.js.map +1 -0
- package/dist/quality/index.d.ts +5 -1
- package/dist/quality/index.d.ts.map +1 -1
- package/dist/quality/index.js +4 -0
- package/dist/quality/index.js.map +1 -1
- package/dist/quality/paretoAnalysis.d.ts +15 -0
- package/dist/quality/paretoAnalysis.d.ts.map +1 -0
- package/dist/quality/paretoAnalysis.js +92 -0
- package/dist/quality/paretoAnalysis.js.map +1 -0
- package/dist/quality/types.d.ts +91 -0
- package/dist/quality/types.d.ts.map +1 -1
- package/dist/quality/weibull.d.ts +17 -0
- package/dist/quality/weibull.d.ts.map +1 -0
- package/dist/quality/weibull.js +106 -0
- package/dist/quality/weibull.js.map +1 -0
- package/dist/safety/arcFlash.d.ts +14 -0
- package/dist/safety/arcFlash.d.ts.map +1 -0
- package/dist/safety/arcFlash.js +90 -0
- package/dist/safety/arcFlash.js.map +1 -0
- package/dist/safety/confinedSpace.d.ts +15 -0
- package/dist/safety/confinedSpace.d.ts.map +1 -0
- package/dist/safety/confinedSpace.js +116 -0
- package/dist/safety/confinedSpace.js.map +1 -0
- package/dist/safety/ergonomicRisk.d.ts +9 -0
- package/dist/safety/ergonomicRisk.d.ts.map +1 -0
- package/dist/safety/ergonomicRisk.js +208 -0
- package/dist/safety/ergonomicRisk.js.map +1 -0
- package/dist/safety/illuminance.d.ts +13 -0
- package/dist/safety/illuminance.d.ts.map +1 -0
- package/dist/safety/illuminance.js +91 -0
- package/dist/safety/illuminance.js.map +1 -0
- package/dist/safety/index.d.ts +8 -1
- package/dist/safety/index.d.ts.map +1 -1
- package/dist/safety/index.js +7 -0
- package/dist/safety/index.js.map +1 -1
- package/dist/safety/ladderAngle.d.ts +16 -0
- package/dist/safety/ladderAngle.d.ts.map +1 -0
- package/dist/safety/ladderAngle.js +87 -0
- package/dist/safety/ladderAngle.js.map +1 -0
- package/dist/safety/lel.d.ts +14 -0
- package/dist/safety/lel.d.ts.map +1 -0
- package/dist/safety/lel.js +66 -0
- package/dist/safety/lel.js.map +1 -0
- package/dist/safety/thermalComfort.d.ts +14 -0
- package/dist/safety/thermalComfort.d.ts.map +1 -0
- package/dist/safety/thermalComfort.js +96 -0
- package/dist/safety/thermalComfort.js.map +1 -0
- package/dist/safety/types.d.ts +164 -0
- package/dist/safety/types.d.ts.map +1 -1
- package/dist/utility/bilinearInterpolation.d.ts +3 -0
- package/dist/utility/bilinearInterpolation.d.ts.map +1 -0
- package/dist/utility/bilinearInterpolation.js +47 -0
- package/dist/utility/bilinearInterpolation.js.map +1 -0
- package/dist/utility/correlation.d.ts +3 -0
- package/dist/utility/correlation.d.ts.map +1 -0
- package/dist/utility/correlation.js +29 -0
- package/dist/utility/correlation.js.map +1 -0
- package/dist/utility/depreciation.d.ts +3 -0
- package/dist/utility/depreciation.d.ts.map +1 -0
- package/dist/utility/depreciation.js +57 -0
- package/dist/utility/depreciation.js.map +1 -0
- package/dist/utility/histogram.d.ts +3 -0
- package/dist/utility/histogram.d.ts.map +1 -0
- package/dist/utility/histogram.js +42 -0
- package/dist/utility/histogram.js.map +1 -0
- package/dist/utility/index.d.ts +15 -1
- package/dist/utility/index.d.ts.map +1 -1
- package/dist/utility/index.js +14 -0
- package/dist/utility/index.js.map +1 -1
- package/dist/utility/lcc.d.ts +3 -0
- package/dist/utility/lcc.d.ts.map +1 -0
- package/dist/utility/lcc.js +26 -0
- package/dist/utility/lcc.js.map +1 -0
- package/dist/utility/linearInterpolation.d.ts +3 -0
- package/dist/utility/linearInterpolation.d.ts.map +1 -0
- package/dist/utility/linearInterpolation.js +42 -0
- package/dist/utility/linearInterpolation.js.map +1 -0
- package/dist/utility/movingAverage.d.ts +3 -0
- package/dist/utility/movingAverage.d.ts.map +1 -0
- package/dist/utility/movingAverage.js +41 -0
- package/dist/utility/movingAverage.js.map +1 -0
- package/dist/utility/normalize.d.ts +3 -0
- package/dist/utility/normalize.d.ts.map +1 -0
- package/dist/utility/normalize.js +35 -0
- package/dist/utility/normalize.js.map +1 -0
- package/dist/utility/npv.d.ts +3 -0
- package/dist/utility/npv.d.ts.map +1 -0
- package/dist/utility/npv.js +45 -0
- package/dist/utility/npv.js.map +1 -0
- package/dist/utility/percentile.d.ts +3 -0
- package/dist/utility/percentile.d.ts.map +1 -0
- package/dist/utility/percentile.js +24 -0
- package/dist/utility/percentile.js.map +1 -0
- package/dist/utility/regression.d.ts +3 -0
- package/dist/utility/regression.d.ts.map +1 -0
- package/dist/utility/regression.js +40 -0
- package/dist/utility/regression.js.map +1 -0
- package/dist/utility/roi.d.ts +3 -0
- package/dist/utility/roi.d.ts.map +1 -0
- package/dist/utility/roi.js +19 -0
- package/dist/utility/roi.js.map +1 -0
- package/dist/utility/statistics.d.ts +3 -0
- package/dist/utility/statistics.d.ts.map +1 -0
- package/dist/utility/statistics.js +34 -0
- package/dist/utility/statistics.js.map +1 -0
- package/dist/utility/types.d.ts +213 -1
- package/dist/utility/types.d.ts.map +1 -1
- package/dist/utility/unit.d.ts.map +1 -1
- package/dist/utility/unit.js +51 -0
- package/dist/utility/unit.js.map +1 -1
- package/dist/utility/weightedScore.d.ts +3 -0
- package/dist/utility/weightedScore.d.ts.map +1 -0
- package/dist/utility/weightedScore.js +35 -0
- package/dist/utility/weightedScore.js.map +1 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,90 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.9.0] - 2026-02-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Type Guards** — 8 runtime type guard functions for discriminated union inputs ([#2](https://github.com/iyulab/formulab/issues/2)):
|
|
13
|
+
- `isCRateInput()` — battery domain (mode: currentToRate | rateToCurrent)
|
|
14
|
+
- `isDilutionInput()` — chemical domain (solveFor: c1 | v1 | c2 | v2)
|
|
15
|
+
- `isReactorInput()` — chemical domain (shape: cylindrical | spherical)
|
|
16
|
+
- `isHeatTransferInput()` — chemical domain (mode: conduction | convection | radiation)
|
|
17
|
+
- `isMomentOfInertiaInput()` — construction domain (shape: 7 variants)
|
|
18
|
+
- `isOhmsLawInput()` — electronics domain (solveFor: voltage | current | resistance | power)
|
|
19
|
+
- `isMetalWeightInput()` — metal domain (shape: plate | round | pipe | angle)
|
|
20
|
+
- `isBoltInput()` — metal domain (mode: torqueToPreload | preloadToTorque)
|
|
21
|
+
|
|
22
|
+
- **Error Behavior Specification** — `ERRORS.md` documenting error policy and per-function error behavior ([#1](https://github.com/iyulab/formulab/issues/1)):
|
|
23
|
+
- Defined error policy: validation failures → throw RangeError
|
|
24
|
+
- Documented all 174 functions' error behavior (throw / NaN / Infinity / null / safe)
|
|
25
|
+
- Identified 6 legacy NaN/Infinity patterns with migration roadmap to v0.10.0
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Total function count: 174 → 182 (+8 type guards)
|
|
30
|
+
|
|
31
|
+
## [0.7.0] - 2026-02-07
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **Quality** (+4 functions, 14 → 18):
|
|
36
|
+
- `gageRR()` — Gage R&R repeatability/reproducibility analysis (AIAG MSA 4th Edition)
|
|
37
|
+
- `cmk()` — Machine capability index Cm/Cmk (threshold ≥ 1.67)
|
|
38
|
+
- `weibull()` — Weibull reliability analysis with median rank regression
|
|
39
|
+
- `paretoAnalysis()` — Pareto 80/20 ABC classification
|
|
40
|
+
|
|
41
|
+
- **Safety** (+5 functions, 9 → 14):
|
|
42
|
+
- `thermalComfort()` — PMV/PPD thermal comfort (ISO 7730 Fanger model)
|
|
43
|
+
- `ergonomicRisk()` — REBA ergonomic risk assessment scoring
|
|
44
|
+
- `arcFlash()` — Arc flash incident energy & PPE category (IEEE 1584/NFPA 70E)
|
|
45
|
+
- `confinedSpace()` — Confined space atmospheric assessment (OSHA 29 CFR 1910.146)
|
|
46
|
+
- `lel()` — Lower explosive limit for mixed gases (Le Chatelier's rule)
|
|
47
|
+
|
|
48
|
+
- **Energy** (+4 functions, 11 → 15):
|
|
49
|
+
- `heatPump()` — Heat pump COP & Carnot efficiency with annual savings
|
|
50
|
+
- `degreeDay()` — Heating/Cooling degree day calculation (HDD/CDD)
|
|
51
|
+
- `windOutput()` — Wind turbine output with Rayleigh capacity factor
|
|
52
|
+
- `cusum()` — CUSUM energy anomaly detection (Page's algorithm)
|
|
53
|
+
|
|
54
|
+
- **Chemical** (+3 functions, 9 → 12):
|
|
55
|
+
- `flowControl()` — Control valve Cv/Kv sizing (ISA/IEC 60534)
|
|
56
|
+
- `reliefValve()` — Safety relief valve sizing (API 520/526)
|
|
57
|
+
- `pid()` — PID controller tuning (Ziegler-Nichols / Cohen-Coon)
|
|
58
|
+
|
|
59
|
+
- **Logistics** (+1 function, 16 → 17):
|
|
60
|
+
- `abcAnalysis()` — ABC inventory classification by annual value
|
|
61
|
+
|
|
62
|
+
- **Food** (+2 functions, 4 → 6):
|
|
63
|
+
- `waterActivity()` — Water activity microbial growth risk (HACCP)
|
|
64
|
+
- `stabilityStudy()` — Accelerated stability study with Arrhenius regression (ICH Q1A)
|
|
65
|
+
|
|
66
|
+
- **Automotive** (+1 function, 8 → 9):
|
|
67
|
+
- `chargingLoss()` — EV charging loss/efficiency with temperature derating
|
|
68
|
+
|
|
69
|
+
### Changed
|
|
70
|
+
|
|
71
|
+
- Total function count: 154 → 174 (+20)
|
|
72
|
+
- Total domains: 14 (unchanged)
|
|
73
|
+
|
|
74
|
+
## [0.6.0] - 2026-02-07
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
|
|
78
|
+
- **Energy** (+4 functions, 7 → 11):
|
|
79
|
+
- `boilerEfficiency()` — Boiler thermal efficiency (direct input-output method)
|
|
80
|
+
- `transformerLoss()` — Transformer loss calculation with optimal load point
|
|
81
|
+
- `insulationRoi()` — Insulation ROI with payback period
|
|
82
|
+
- `ledRoi()` — LED lighting retrofit ROI with CO2 savings
|
|
83
|
+
|
|
84
|
+
- **Safety** (+2 functions, 7 → 9):
|
|
85
|
+
- `ladderAngle()` — Ladder safety angle calculation (OSHA 4:1 rule, 70°–80° compliance)
|
|
86
|
+
- `illuminance()` — Workplace illuminance calculation (Lumen Method with CU lookup)
|
|
87
|
+
|
|
88
|
+
- **Logistics** (+2 functions, 14 → 16):
|
|
89
|
+
- `inventoryTurnover()` — Inventory turnover ratio, days/weeks of supply, GMROII
|
|
90
|
+
- `loadCapacity()` — Forklift load capacity derating with attachment loss
|
|
91
|
+
|
|
8
92
|
## [0.5.0] - 2026-02-07
|
|
9
93
|
|
|
10
94
|
### Added
|
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
> Industrial & manufacturing calculation library for engineers
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/formulab)
|
|
6
|
+
[](https://github.com/iyulab/formulab/actions/workflows/ci.yml)
|
|
6
7
|
[](https://opensource.org/licenses/MIT)
|
|
7
8
|
[](https://www.typescriptlang.org/)
|
|
8
9
|
|
|
@@ -10,28 +11,28 @@ A comprehensive collection of engineering formulas and calculations for manufact
|
|
|
10
11
|
|
|
11
12
|
## Features
|
|
12
13
|
|
|
13
|
-
- **
|
|
14
|
+
- **174 industrial calculations** — OEE, Cpk, SPC control charts, Gage R&R, Weibull, metal weight, CNC machining, GD&T, pipe flow, CBM, NIOSH lifting, PMV/PPD, arc flash, battery SOH, GHG emissions, PID tuning, and more
|
|
14
15
|
- **14 specialized domains** — Quality, Metal, Chemical, Electronics, Construction, Automotive, Logistics, Energy, Safety, Food, Utility, Battery, Environmental, Machining
|
|
15
16
|
- **Zero dependencies** — Lightweight and fast
|
|
16
17
|
- **TypeScript first** — Full type definitions included
|
|
17
18
|
- **Tree-shakeable** — Import only what you need
|
|
18
|
-
- **
|
|
19
|
-
- **Research-based** —
|
|
19
|
+
- **1,956 tests** — Coverage thresholds: 90% lines, 95% functions, 85% branches ([CI pipeline](https://github.com/iyulab/formulab/actions/workflows/ci.yml))
|
|
20
|
+
- **Research-based** — Golden reference tests verified against NIOSH 94-110, AIAG/ASTM E2587, JIPM, ASME B16.5, ISO 22514-2, and more
|
|
20
21
|
|
|
21
22
|
## Verification Status
|
|
22
23
|
|
|
23
24
|
| Domain | Functions | Golden Tests | Key References |
|
|
24
25
|
|--------|-----------|-------------|----------------|
|
|
25
|
-
| Quality |
|
|
26
|
+
| Quality | 18 | oee, cpk, controlChart, gageRR | ISO 22400-2, AIAG/ASTM E2587, JIPM, AIAG MSA |
|
|
26
27
|
| Metal | 25 | metalWeight | Machinery's Handbook, ASME B36.10/B16.5 |
|
|
27
|
-
| Logistics |
|
|
28
|
-
| Safety |
|
|
29
|
-
| Chemical |
|
|
28
|
+
| Logistics | 17 | cbm | Physical formula |
|
|
29
|
+
| Safety | 14 | nioshLifting | NIOSH 94-110, ISO 7730, IEEE 1584, OSHA |
|
|
30
|
+
| Chemical | 12 | — | Darcy-Weisbach, Fourier, API 520, ISA |
|
|
30
31
|
| Electronics | 11 | — | IPC-2221 |
|
|
31
32
|
| Construction | 12 | — | AISC, Timoshenko |
|
|
32
|
-
| Automotive |
|
|
33
|
-
| Energy |
|
|
34
|
-
| Food |
|
|
33
|
+
| Automotive | 9 | — | AASHTO, SAE J1772 |
|
|
34
|
+
| Energy | 15 | — | NREL PVWatts, ISO 50001 |
|
|
35
|
+
| Food | 6 | — | HACCP, ICH Q1A |
|
|
35
36
|
| Utility | 3 | — | — |
|
|
36
37
|
| Battery | 10 | — | IEEE 1188, IEC 62620, Battery University |
|
|
37
38
|
| Environmental | 10 | — | GHG Protocol, IPCC AR6, IEA 2023 |
|
|
@@ -40,6 +41,72 @@ A comprehensive collection of engineering formulas and calculations for manufact
|
|
|
40
41
|
> Functions with golden reference tests have been verified against authoritative engineering sources.
|
|
41
42
|
> See each function's JSDoc for specific references.
|
|
42
43
|
|
|
44
|
+
## Numerical Accuracy & Testing
|
|
45
|
+
|
|
46
|
+
### Floating-Point Handling
|
|
47
|
+
|
|
48
|
+
All calculations use a sign-aware `roundTo()` utility with epsilon correction to avoid IEEE 754 rounding artifacts:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
roundTo(0.615, 2) // → 0.62 (not 0.61)
|
|
52
|
+
roundTo(-2.555, 2) // → -2.56 (sign-aware)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Non-finite values (`NaN`, `Infinity`) pass through unchanged. Each function's JSDoc specifies output precision (typically 2-4 decimal places).
|
|
56
|
+
|
|
57
|
+
### Golden Reference Tests
|
|
58
|
+
|
|
59
|
+
The following functions include tests verified against published reference values:
|
|
60
|
+
|
|
61
|
+
| Function | Standard / Source | What is verified |
|
|
62
|
+
|----------|-------------------|------------------|
|
|
63
|
+
| `nioshLifting()` | NIOSH Publication 94-110 | LC=23kg ideal, FM/CM table values, RWL calculation |
|
|
64
|
+
| `oee()` | JIPM TPM Handbook | World-class OEE (A≥90%, P≥95%, Q≥99.9%), perfect 100% |
|
|
65
|
+
| `cpk()` | ISO 22514-2 | Six Sigma Cpk=2.0, minimum capable Cpk≈1.33, off-center penalty |
|
|
66
|
+
| `controlChart()` | AIAG/ASTM E2587-16 | A2, D3, D4, d2 constants for n=2, 3, 5 |
|
|
67
|
+
| `cbm()` | Physical formula | 20ft container 33.2m³, 1m³ cube reference |
|
|
68
|
+
| `metalWeight()` | Machinery's Handbook | Steel plate density 7.85 g/cm³ |
|
|
69
|
+
| `flangeSpec()` | ASME B16.5 | Class 150/300/600 flange dimensions |
|
|
70
|
+
| `pipeSpec()` | ASME B36.10 | SCH40/80/160 wall thickness |
|
|
71
|
+
| `awgProperties()` | ANSI/AWG | AWG 0-40 diameter, resistance |
|
|
72
|
+
|
|
73
|
+
### Edge Case Handling
|
|
74
|
+
|
|
75
|
+
Functions validate or handle these boundary conditions:
|
|
76
|
+
|
|
77
|
+
- **Division by zero**: `cpk()` with zero standard deviation, `oee()` with zero planned time
|
|
78
|
+
- **Out-of-range inputs**: `tolerance()` rejects invalid IT grades, `aql()` validates lot sizes
|
|
79
|
+
- **Physical impossibility**: `pressFit()` rejects negative interference, `nioshLifting()` clamps multipliers to [0, 1]
|
|
80
|
+
- **Extreme values**: `aql()` handles 1M-unit lots, `awgProperties()` covers AWG 0-40
|
|
81
|
+
|
|
82
|
+
### Optimization Functions — Algorithms & Limitations
|
|
83
|
+
|
|
84
|
+
Three functions solve NP-hard combinatorial problems using **heuristic** algorithms. They provide good practical results but **do not guarantee optimal solutions**:
|
|
85
|
+
|
|
86
|
+
| Function | Algorithm | Complexity | Optimality |
|
|
87
|
+
|----------|-----------|-----------|-----------|
|
|
88
|
+
| `tsp()` | Nearest Neighbor + 2-Opt local search; brute force for n ≤ 10 | O(n²) per NN start, O(n!) exact for n ≤ 10 | **Heuristic** — no approximation ratio guarantee; exact only for n ≤ 10 |
|
|
89
|
+
| `pallet3d()` | Bottom-Left-Fill + First Fit Decreasing with AABB collision & stability checks | O(m² × n) where m = placed boxes | **Heuristic** — greedy placement; enforces physical constraints (80% support, weight limit) |
|
|
90
|
+
| `cuttingStock()` | First Fit Decreasing (FFD) or Best Fit Decreasing (BFD), user-selectable | O(q²) worst case | **FFD: ≤ 11/9 × OPT + 1** (proven bound); not optimal |
|
|
91
|
+
|
|
92
|
+
> For mission-critical optimization requiring proven-optimal solutions, use dedicated solvers (e.g., OR-Tools, Gurobi). These functions are designed for quick shop-floor estimates.
|
|
93
|
+
|
|
94
|
+
### CI Pipeline
|
|
95
|
+
|
|
96
|
+
GitHub Actions runs on every push to `main` and every pull request:
|
|
97
|
+
|
|
98
|
+
- **Matrix**: Node.js 18, 20
|
|
99
|
+
- **Steps**: `pnpm install` → `tsc` (type check) → `vitest run --coverage`
|
|
100
|
+
- **Coverage enforcement**: Fails if below thresholds (lines 90%, functions 95%, branches 85%, statements 90%)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Run tests locally
|
|
104
|
+
pnpm test
|
|
105
|
+
|
|
106
|
+
# Run with coverage report
|
|
107
|
+
pnpm test:coverage
|
|
108
|
+
```
|
|
109
|
+
|
|
43
110
|
## Installation
|
|
44
111
|
|
|
45
112
|
```bash
|
|
@@ -90,10 +157,10 @@ console.log(volume.totalCbm); // 0.96 m³
|
|
|
90
157
|
|
|
91
158
|
## Domains
|
|
92
159
|
|
|
93
|
-
### Quality & Production (
|
|
160
|
+
### Quality & Production (18 functions)
|
|
94
161
|
|
|
95
162
|
```typescript
|
|
96
|
-
import { oee, cpk, taktTime, dpmo, controlChart } from 'formulab/quality';
|
|
163
|
+
import { oee, cpk, taktTime, dpmo, controlChart, gageRR, weibull } from 'formulab/quality';
|
|
97
164
|
```
|
|
98
165
|
|
|
99
166
|
| Function | Description |
|
|
@@ -112,6 +179,10 @@ import { oee, cpk, taktTime, dpmo, controlChart } from 'formulab/quality';
|
|
|
112
179
|
| `ppm()` | Parts Per Million conversion |
|
|
113
180
|
| `rpn()` | Risk Priority Number (FMEA) |
|
|
114
181
|
| `yieldCalc()` | First Pass Yield / RTY |
|
|
182
|
+
| `gageRR()` | Gage R&R (AIAG MSA Average & Range) |
|
|
183
|
+
| `cmk()` | Machine capability index Cm/Cmk |
|
|
184
|
+
| `weibull()` | Weibull reliability analysis |
|
|
185
|
+
| `paretoAnalysis()` | Pareto 80/20 ABC classification |
|
|
115
186
|
|
|
116
187
|
### Metal & Machining (25 functions)
|
|
117
188
|
|
|
@@ -129,7 +200,7 @@ import { metalWeight, bendAllowance, cutting, bearing } from 'formulab/metal';
|
|
|
129
200
|
| `bearing()` | L10 bearing life calculation |
|
|
130
201
|
| `bolt()` | Bolt torque and preload |
|
|
131
202
|
| `cutting()` | Cutting speed, feed rate, RPM |
|
|
132
|
-
| `cuttingStock()` | 1D cutting
|
|
203
|
+
| `cuttingStock()` | 1D cutting stock heuristic (FFD/BFD) |
|
|
133
204
|
| `gear()` | Gear module calculation |
|
|
134
205
|
| `hardness()` | Hardness conversion (HRC, HB, HV) |
|
|
135
206
|
| `material()` | Material properties lookup |
|
|
@@ -147,10 +218,10 @@ import { metalWeight, bendAllowance, cutting, bearing } from 'formulab/metal';
|
|
|
147
218
|
| `pipeSpec()` | ANSI/ASME pipe dimensions lookup |
|
|
148
219
|
| `flangeSpec()` | ASME B16.5 flange dimensions lookup |
|
|
149
220
|
|
|
150
|
-
### Chemical & Process (
|
|
221
|
+
### Chemical & Process (12 functions)
|
|
151
222
|
|
|
152
223
|
```typescript
|
|
153
|
-
import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer } from 'formulab/chemical';
|
|
224
|
+
import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer, flowControl, pid } from 'formulab/chemical';
|
|
154
225
|
```
|
|
155
226
|
|
|
156
227
|
| Function | Description |
|
|
@@ -164,6 +235,9 @@ import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer } from 'fo
|
|
|
164
235
|
| `reactor()` | Reactor sizing |
|
|
165
236
|
| `shelfLife()` | Shelf life prediction (Arrhenius) |
|
|
166
237
|
| `injectionCycle()` | Injection molding cycle time |
|
|
238
|
+
| `flowControl()` | Control valve Cv/Kv sizing (ISA/IEC 60534) |
|
|
239
|
+
| `reliefValve()` | Safety relief valve sizing (API 520/526) |
|
|
240
|
+
| `pid()` | PID controller tuning (Z-N / Cohen-Coon) |
|
|
167
241
|
|
|
168
242
|
### Electronics & SMT (11 functions)
|
|
169
243
|
|
|
@@ -206,10 +280,10 @@ import { concreteMix, rebarWeight, slope, stair, momentOfInertia } from 'formula
|
|
|
206
280
|
| `roof()` | Roof calculation |
|
|
207
281
|
| `stair()` | Stair dimension calculation |
|
|
208
282
|
|
|
209
|
-
### Automotive (
|
|
283
|
+
### Automotive (9 functions)
|
|
210
284
|
|
|
211
285
|
```typescript
|
|
212
|
-
import { batteryRuntime, evCharging, torque, brakingDistance } from 'formulab/automotive';
|
|
286
|
+
import { batteryRuntime, evCharging, torque, brakingDistance, chargingLoss } from 'formulab/automotive';
|
|
213
287
|
```
|
|
214
288
|
|
|
215
289
|
| Function | Description |
|
|
@@ -222,66 +296,85 @@ import { batteryRuntime, evCharging, torque, brakingDistance } from 'formulab/au
|
|
|
222
296
|
| `tireCompare()` | Tire size comparison |
|
|
223
297
|
| `torque()` | Torque conversion |
|
|
224
298
|
| `power()` | Power conversion (HP, kW) |
|
|
299
|
+
| `chargingLoss()` | EV charging loss/efficiency |
|
|
225
300
|
|
|
226
|
-
### Logistics & Inventory (
|
|
301
|
+
### Logistics & Inventory (17 functions)
|
|
227
302
|
|
|
228
303
|
```typescript
|
|
229
|
-
import { cbm, eoq, safetyStock, kanban } from 'formulab/logistics';
|
|
304
|
+
import { cbm, eoq, safetyStock, kanban, inventoryTurnover, abcAnalysis } from 'formulab/logistics';
|
|
230
305
|
```
|
|
231
306
|
|
|
232
307
|
| Function | Description |
|
|
233
308
|
|----------|-------------|
|
|
309
|
+
| `abcAnalysis()` | ABC inventory classification by annual value |
|
|
234
310
|
| `cbm()` | Cubic meter calculation |
|
|
235
311
|
| `containerFit()` | Container capacity estimation |
|
|
236
312
|
| `dimWeight()` | Dimensional weight |
|
|
237
313
|
| `eoq()` | Economic Order Quantity |
|
|
238
314
|
| `fillRate()` | Fill rate calculation |
|
|
239
315
|
| `freightClass()` | NMFC freight class |
|
|
316
|
+
| `inventoryTurnover()` | Inventory turnover ratio & days of supply |
|
|
240
317
|
| `kanban()` | Kanban quantity |
|
|
241
|
-
| `
|
|
318
|
+
| `loadCapacity()` | Forklift load capacity derating |
|
|
319
|
+
| `pallet3d()` | 3D pallet loading heuristic (BLF + FFD) |
|
|
242
320
|
| `palletStack()` | Pallet stacking calculation |
|
|
243
321
|
| `pickTime()` | Picking time estimation |
|
|
244
322
|
| `safetyStock()` | Safety stock calculation |
|
|
245
323
|
| `serviceLevel()` | Service level calculation |
|
|
246
324
|
| `shipping()` | Shipping cost estimation |
|
|
247
|
-
| `tsp()` |
|
|
325
|
+
| `tsp()` | TSP heuristic (NN + 2-Opt; exact for n ≤ 10) |
|
|
248
326
|
|
|
249
|
-
### Energy & Utilities (
|
|
327
|
+
### Energy & Utilities (15 functions)
|
|
250
328
|
|
|
251
329
|
```typescript
|
|
252
|
-
import { powerCost, motorEfficiency, carbonFootprint, solarOutput } from 'formulab/energy';
|
|
330
|
+
import { powerCost, motorEfficiency, carbonFootprint, solarOutput, boilerEfficiency, heatPump, cusum } from 'formulab/energy';
|
|
253
331
|
```
|
|
254
332
|
|
|
255
333
|
| Function | Description |
|
|
256
334
|
|----------|-------------|
|
|
257
|
-
| `
|
|
335
|
+
| `boilerEfficiency()` | Boiler thermal efficiency (direct method) |
|
|
258
336
|
| `carbonFootprint()` | Scope 2 emissions |
|
|
259
337
|
| `compressedAirCost()` | Compressed air cost |
|
|
338
|
+
| `cusum()` | CUSUM energy anomaly detection |
|
|
339
|
+
| `degreeDay()` | Heating/Cooling degree days (HDD/CDD) |
|
|
340
|
+
| `heatPump()` | Heat pump COP & Carnot efficiency |
|
|
341
|
+
| `insulationRoi()` | Insulation ROI & payback |
|
|
342
|
+
| `ledRoi()` | LED lighting retrofit ROI |
|
|
260
343
|
| `motorEfficiency()` | Motor upgrade ROI |
|
|
261
344
|
| `pfCorrection()` | Power factor correction |
|
|
262
345
|
| `powerCost()` | Electricity cost with demand |
|
|
346
|
+
| `solarOutput()` | Solar panel output estimation (PVWatts-based) |
|
|
347
|
+
| `transformerLoss()` | Transformer loss & efficiency |
|
|
263
348
|
| `vfdSavings()` | VFD energy savings |
|
|
349
|
+
| `windOutput()` | Wind turbine output with Rayleigh CF |
|
|
264
350
|
|
|
265
|
-
### Safety & Ergonomics (
|
|
351
|
+
### Safety & Ergonomics (14 functions)
|
|
266
352
|
|
|
267
353
|
```typescript
|
|
268
|
-
import { nioshLifting, noiseExposure, wbgtCalculate, ventilationRate } from 'formulab/safety';
|
|
354
|
+
import { nioshLifting, noiseExposure, wbgtCalculate, ventilationRate, thermalComfort, arcFlash, lel } from 'formulab/safety';
|
|
269
355
|
```
|
|
270
356
|
|
|
271
357
|
| Function | Description |
|
|
272
358
|
|----------|-------------|
|
|
273
|
-
| `
|
|
359
|
+
| `arcFlash()` | Arc flash incident energy & PPE (IEEE 1584) |
|
|
360
|
+
| `confinedSpace()` | Confined space atmospheric assessment (OSHA) |
|
|
361
|
+
| `ergonomicRisk()` | REBA ergonomic risk scoring |
|
|
274
362
|
| `fallClearance()` | Fall protection clearance |
|
|
363
|
+
| `havsCalculate()` | Hand-arm vibration exposure |
|
|
364
|
+
| `illuminance()` | Workplace illuminance (Lumen Method) |
|
|
365
|
+
| `ladderAngle()` | Ladder safety angle (OSHA 4:1) |
|
|
366
|
+
| `lel()` | Mixed gas LEL (Le Chatelier's rule) |
|
|
275
367
|
| `nioshLifting()` | NIOSH lifting equation |
|
|
276
368
|
| `noiseExposure()` | TWA/Dose calculation |
|
|
277
|
-
| `wbgtCalculate()` | WBGT heat stress index |
|
|
278
|
-
| `havsCalculate()` | Hand-arm vibration exposure |
|
|
279
369
|
| `respiratorCalculate()` | Respirator MUC calculation |
|
|
370
|
+
| `thermalComfort()` | PMV/PPD thermal comfort (ISO 7730) |
|
|
371
|
+
| `ventilationRate()` | Required ventilation ACH/CFM (ASHRAE/OSHA) |
|
|
372
|
+
| `wbgtCalculate()` | WBGT heat stress index |
|
|
280
373
|
|
|
281
|
-
### Food & HACCP (
|
|
374
|
+
### Food & HACCP (6 functions)
|
|
282
375
|
|
|
283
376
|
```typescript
|
|
284
|
-
import { calorie, nutrition, haccp } from 'formulab/food';
|
|
377
|
+
import { calorie, nutrition, haccp, waterActivity, stabilityStudy } from 'formulab/food';
|
|
285
378
|
```
|
|
286
379
|
|
|
287
380
|
| Function | Description |
|
|
@@ -290,6 +383,8 @@ import { calorie, nutrition, haccp } from 'formulab/food';
|
|
|
290
383
|
| `expiry()` | Expiry date calculation |
|
|
291
384
|
| `nutrition()` | Nutrition facts calculation |
|
|
292
385
|
| `haccp()` | HACCP checklist generation |
|
|
386
|
+
| `waterActivity()` | Water activity microbial risk (HACCP) |
|
|
387
|
+
| `stabilityStudy()` | Accelerated stability (Arrhenius, ICH Q1A) |
|
|
293
388
|
|
|
294
389
|
### Utility (3 functions)
|
|
295
390
|
|
|
@@ -432,6 +527,42 @@ console.log(result);
|
|
|
432
527
|
// }
|
|
433
528
|
```
|
|
434
529
|
|
|
530
|
+
## Type Guards for Discriminated Unions
|
|
531
|
+
|
|
532
|
+
formulab provides runtime type guard functions for all [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions) input types. These enable type-safe integration when working with dynamic data (e.g., form inputs, API responses):
|
|
533
|
+
|
|
534
|
+
```typescript
|
|
535
|
+
import { isCRateInput, cRate } from 'formulab/battery';
|
|
536
|
+
|
|
537
|
+
// Form data from user input (Record<string, unknown>)
|
|
538
|
+
const formData: unknown = { mode: 'currentToRate', capacityAh: 100, currentA: 50 };
|
|
539
|
+
|
|
540
|
+
if (isCRateInput(formData)) {
|
|
541
|
+
const result = cRate(formData); // Type-safe, no 'as any' needed
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Available Type Guards
|
|
546
|
+
|
|
547
|
+
| Guard | Domain | Discriminant | Variants |
|
|
548
|
+
|-------|--------|-------------|----------|
|
|
549
|
+
| `isCRateInput()` | battery | `mode` | currentToRate, rateToCurrent |
|
|
550
|
+
| `isDilutionInput()` | chemical | `solveFor` | c1, v1, c2, v2 |
|
|
551
|
+
| `isReactorInput()` | chemical | `shape` | cylindrical, spherical |
|
|
552
|
+
| `isHeatTransferInput()` | chemical | `mode` | conduction, convection, radiation |
|
|
553
|
+
| `isMomentOfInertiaInput()` | construction | `shape` | rectangle, circle, hollowRectangle, hollowCircle, iBeam, tSection, cChannel |
|
|
554
|
+
| `isOhmsLawInput()` | electronics | `solveFor` | voltage, current, resistance, power |
|
|
555
|
+
| `isMetalWeightInput()` | metal | `shape` | plate, round, pipe, angle |
|
|
556
|
+
| `isBoltInput()` | metal | `mode` | torqueToPreload, preloadToTorque |
|
|
557
|
+
|
|
558
|
+
## Error Handling
|
|
559
|
+
|
|
560
|
+
See [ERRORS.md](./ERRORS.md) for the complete error behavior specification. Key points:
|
|
561
|
+
|
|
562
|
+
- **Validation failures** throw `RangeError` with descriptive messages
|
|
563
|
+
- **Legacy NaN/Infinity patterns** are documented and scheduled for migration
|
|
564
|
+
- Each function's error behavior is documented in the specification
|
|
565
|
+
|
|
435
566
|
## Tree Shaking
|
|
436
567
|
|
|
437
568
|
Import only what you need to minimize bundle size:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChargingLossInput, ChargingLossResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* EV Charging Loss Calculator
|
|
4
|
+
*
|
|
5
|
+
* @formula
|
|
6
|
+
* - energyDelivered = batteryCapacity × (targetSoc − soc) / 100
|
|
7
|
+
* - energyConsumed = energyDelivered / (chargerEff × batteryEff)
|
|
8
|
+
* - totalLoss = energyConsumed − energyDelivered
|
|
9
|
+
* - chargingTime = energyConsumed / effectivePower
|
|
10
|
+
*
|
|
11
|
+
* @reference SAE J1772 — Electric Vehicle Charging
|
|
12
|
+
* @reference IEC 61851 — Electric vehicle conductive charging system
|
|
13
|
+
*/
|
|
14
|
+
export declare function chargingLoss(input: ChargingLossInput): ChargingLossResult;
|
|
15
|
+
//# sourceMappingURL=chargingLoss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargingLoss.d.ts","sourceRoot":"","sources":["../../src/automotive/chargingLoss.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AASxE;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,CAiDzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { roundTo } from '../utils.js';
|
|
2
|
+
// Default charger efficiencies by type
|
|
3
|
+
const DEFAULT_CHARGER_EFFICIENCY = {
|
|
4
|
+
ac_l1: 0.85,
|
|
5
|
+
ac_l2: 0.90,
|
|
6
|
+
dc_fast: 0.93,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* EV Charging Loss Calculator
|
|
10
|
+
*
|
|
11
|
+
* @formula
|
|
12
|
+
* - energyDelivered = batteryCapacity × (targetSoc − soc) / 100
|
|
13
|
+
* - energyConsumed = energyDelivered / (chargerEff × batteryEff)
|
|
14
|
+
* - totalLoss = energyConsumed − energyDelivered
|
|
15
|
+
* - chargingTime = energyConsumed / effectivePower
|
|
16
|
+
*
|
|
17
|
+
* @reference SAE J1772 — Electric Vehicle Charging
|
|
18
|
+
* @reference IEC 61851 — Electric vehicle conductive charging system
|
|
19
|
+
*/
|
|
20
|
+
export function chargingLoss(input) {
|
|
21
|
+
const { batteryCapacity, chargerPower, chargerType, batteryEfficiency = 0.95, soc, ambientTemp, } = input;
|
|
22
|
+
const chargerEfficiency = input.chargerEfficiency ?? DEFAULT_CHARGER_EFFICIENCY[chargerType] ?? 0.90;
|
|
23
|
+
const targetSoc = input.targetSoc ?? (chargerType === 'dc_fast' ? 80 : 100);
|
|
24
|
+
// Temperature derating
|
|
25
|
+
let derating = 1.0;
|
|
26
|
+
if (ambientTemp != null) {
|
|
27
|
+
if (ambientTemp < 0) {
|
|
28
|
+
derating = 0.70; // Cold weather significant derating
|
|
29
|
+
}
|
|
30
|
+
else if (ambientTemp < 10) {
|
|
31
|
+
derating = 0.85;
|
|
32
|
+
}
|
|
33
|
+
else if (ambientTemp > 40) {
|
|
34
|
+
derating = 0.90;
|
|
35
|
+
}
|
|
36
|
+
else if (ambientTemp > 35) {
|
|
37
|
+
derating = 0.95;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const effectivePower = chargerPower * derating;
|
|
41
|
+
// Energy calculations
|
|
42
|
+
const energyDelivered = batteryCapacity * (targetSoc - soc) / 100;
|
|
43
|
+
const overallEff = chargerEfficiency * batteryEfficiency;
|
|
44
|
+
const energyConsumed = overallEff > 0 ? energyDelivered / overallEff : 0;
|
|
45
|
+
const totalLoss = energyConsumed - energyDelivered;
|
|
46
|
+
// Loss breakdown
|
|
47
|
+
const chargerLoss = energyConsumed * (1 - chargerEfficiency);
|
|
48
|
+
const batteryLoss = (energyConsumed - chargerLoss) * (1 - batteryEfficiency);
|
|
49
|
+
// Charging time
|
|
50
|
+
const chargingTime = effectivePower > 0 ? energyConsumed / effectivePower : 0;
|
|
51
|
+
return {
|
|
52
|
+
energyDelivered: roundTo(energyDelivered, 2),
|
|
53
|
+
energyConsumed: roundTo(energyConsumed, 2),
|
|
54
|
+
totalLoss: roundTo(totalLoss, 2),
|
|
55
|
+
overallEfficiency: roundTo(overallEff * 100, 2),
|
|
56
|
+
chargerLoss: roundTo(chargerLoss, 2),
|
|
57
|
+
batteryLoss: roundTo(batteryLoss, 2),
|
|
58
|
+
chargingTime: roundTo(chargingTime, 2),
|
|
59
|
+
effectivePower: roundTo(effectivePower, 2),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=chargingLoss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargingLoss.js","sourceRoot":"","sources":["../../src/automotive/chargingLoss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA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GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,cAAc,GAAG,eAAe,CAAC;IAEnD,iBAAiB;IACjB,MAAM,WAAW,GAAG,cAAc,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAE7E,gBAAgB;IAChB,MAAM,YAAY,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QAC5C,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1C,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAChC,iBAAiB,EAAE,OAAO,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC;QAC/C,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QACtC,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -6,5 +6,6 @@ export { gearRatio } from './gearRatio.js';
|
|
|
6
6
|
export { tireCompare } from './tireCompare.js';
|
|
7
7
|
export { torque } from './torque.js';
|
|
8
8
|
export { power } from './power.js';
|
|
9
|
-
export
|
|
9
|
+
export { chargingLoss } from './chargingLoss.js';
|
|
10
|
+
export type { BrakingDistanceInput, BrakingDistanceResult, BatteryInput, BatteryResult, ChargingInput, ChargingResult, FuelUnit, FuelInput, FuelResult, GearRatioInput, GearRatioResult, TireSpec, TireInput, TireData, TireResult, TorqueUnit, TorqueInput, TorqueResult, PowerUnit, PowerInput, PowerResult, ChargingLossInput, ChargingLossResult, } from './types.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,YAAY,EAEV,oBAAoB,EACpB,qBAAqB,EAErB,YAAY,EACZ,aAAa,EAEb,aAAa,EACb,cAAc,EAEd,QAAQ,EACR,SAAS,EACT,UAAU,EAEV,cAAc,EACd,eAAe,EAEf,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EAEV,UAAU,EACV,WAAW,EACX,YAAY,EAEZ,SAAS,EACT,UAAU,EACV,WAAW,EAEX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/automotive/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -127,4 +127,27 @@ export interface PowerResult {
|
|
|
127
127
|
HP: number;
|
|
128
128
|
PS: number;
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* EV Charging Loss Calculator Types
|
|
132
|
+
*/
|
|
133
|
+
export interface ChargingLossInput {
|
|
134
|
+
batteryCapacity: number;
|
|
135
|
+
chargerPower: number;
|
|
136
|
+
chargerType: 'ac_l1' | 'ac_l2' | 'dc_fast';
|
|
137
|
+
chargerEfficiency?: number;
|
|
138
|
+
batteryEfficiency?: number;
|
|
139
|
+
soc: number;
|
|
140
|
+
targetSoc?: number;
|
|
141
|
+
ambientTemp?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface ChargingLossResult {
|
|
144
|
+
energyDelivered: number;
|
|
145
|
+
energyConsumed: number;
|
|
146
|
+
totalLoss: number;
|
|
147
|
+
overallEfficiency: number;
|
|
148
|
+
chargerLoss: number;
|
|
149
|
+
batteryLoss: number;
|
|
150
|
+
chargingTime: number;
|
|
151
|
+
effectivePower: number;
|
|
152
|
+
}
|
|
130
153
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/automotive/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW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
|
+
/**
|
|
3
|
+
* Runtime type guard for {@link CRateInput} discriminated union.
|
|
4
|
+
* Validates the `mode` discriminant and required fields for each variant.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isCRateInput(input: unknown): input is CRateInput;
|
|
7
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/battery/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAShE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime type guard for {@link CRateInput} discriminated union.
|
|
3
|
+
* Validates the `mode` discriminant and required fields for each variant.
|
|
4
|
+
*/
|
|
5
|
+
export function isCRateInput(input) {
|
|
6
|
+
if (typeof input !== 'object' || input === null)
|
|
7
|
+
return false;
|
|
8
|
+
const o = input;
|
|
9
|
+
if (typeof o.capacityAh !== 'number')
|
|
10
|
+
return false;
|
|
11
|
+
switch (o.mode) {
|
|
12
|
+
case 'currentToRate': return typeof o.currentA === 'number';
|
|
13
|
+
case 'rateToCurrent': return typeof o.cRate === 'number';
|
|
14
|
+
default: return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/battery/guards.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACnD,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,eAAe,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAC5D,KAAK,eAAe,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;QACzD,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC;IACxB,CAAC;AACH,CAAC"}
|
package/dist/battery/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { BatteryChemistry, EnergyDensityInput, EnergyDensityResult, CRateMode, CRateInput, CRateResult, StateOfHealthInput, SohStatus, StateOfHealthResult, BatteryPackConfigInput, BatteryPackConfigResult, CycleLifeInput, CycleLifeResult, InternalResistanceInput, InternalResistanceResult, SelfDischargeInput, SelfDischargeResult, ThermalRunawayInput, ThermalRunawayResult, BmsBalancingInput, BmsBalancingResult, ChargingProfileInput, ChargingProfileResult, } from './types.js';
|
|
2
|
+
export { isCRateInput } from './guards.js';
|
|
2
3
|
export { energyDensity } from './energyDensity.js';
|
|
3
4
|
export { cRate } from './cRate.js';
|
|
4
5
|
export { stateOfHealth } from './stateOfHealth.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/battery/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO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