formulab 0.32.0 → 0.32.1

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
@@ -5,6 +5,25 @@ 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.32.1] - 2026-09-02
9
+
10
+ ### Fixed
11
+
12
+ - **`environmental/scope2Emissions()` grid emission factors were stale and unreproducible.**
13
+ `GRID_EMISSION_FACTORS` carried an "IEA 2023 Emission Factors" citation whose values could not
14
+ be reproduced against any accessible source — IEA's own Emissions Factors data product requires
15
+ a paid license, and the specific figures previously cited (attempted in docket `#173`) did not
16
+ match any independently verifiable dataset. Replaced with Our World in Data's "Carbon intensity
17
+ of electricity generation" series (sourced from Ember's Yearly Electricity Data, 2025 figures —
18
+ a freely reproducible, actively maintained global dataset), cross-checked against Umweltbundesamt
19
+ (German Federal Environment Agency) national statistics for Germany (within 1%). All 12 region
20
+ factors changed, in both directions — the largest swings are Canada (110 → 191 gCO2/kWh, +74%,
21
+ a 3-year rising trend in the source data toward more gas generation) and Brazil (75 → 110, +47%,
22
+ reduced hydro output), against France (56 → 41, -27%, continued nuclear-heavy low-carbon
23
+ generation) and Australia (656 → 525, -20%, continued coal-to-renewables buildout).
24
+ `scope2Emissions()` callers using the default region factors will see different
25
+ `co2Kg`/`co2Tonnes` output for the same input — this is a data correction, not an API change.
26
+
8
27
  ## [0.32.0] - 2026-08-31
9
28
 
10
29
  ### Added
@@ -5,7 +5,7 @@ import type { Scope2EmissionsInput, Scope2EmissionsResult } from './types.js';
5
5
  *
6
6
  * @formula location-based: CO2(kg) = kWh × gridFactor / 1000
7
7
  * @formula market-based: CO2(kg) = (contractedKwh × supplierFactor + (kWh − contractedKwh) × residualMixFactor) / 1000
8
- * @reference GHG Protocol Scope 2, IEA Emission Factors 2023 (location-based grid factors);
8
+ * @reference GHG Protocol Scope 2, Our World in Data / Ember Yearly Electricity Data 2025 (location-based grid factors, see `GRID_EMISSION_FACTORS` above);
9
9
  * GHG Protocol Scope 2 Guidance (2015) Ch.4-6 (market-based dual reporting — this library does
10
10
  * not embed residual-mix emission factors, since they are jurisdiction- and year-specific
11
11
  * published figures; callers supply `residualMixFactor` from their own residual-mix disclosure
@@ -1 +1 @@
1
- {"version":3,"file":"scope2Emissions.d.ts","sourceRoot":"","sources":["../../src/environmental/scope2Emissions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAqB1F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAmDlF"}
1
+ {"version":3,"file":"scope2Emissions.d.ts","sourceRoot":"","sources":["../../src/environmental/scope2Emissions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA8B1F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAmDlF"}
@@ -1,21 +1,30 @@
1
1
  import { roundTo } from '../utils.js';
2
2
  /**
3
- * Grid emission factors (gCO2/kWh)
4
- * @reference IEA 2023 Emission Factors
3
+ * Grid emission factors (gCO2/kWh), most recent full calendar year.
4
+ * @reference Our World in Data — "Carbon intensity of electricity generation"
5
+ * (ourworldindata.org/grapher/carbon-intensity-electricity), sourced from Ember's Yearly
6
+ * Electricity Data; 2025 figures, accessed 2026-09-02. Cross-checked against Umweltbundesamt
7
+ * (German Federal Environment Agency) national statistics for Germany (2025: ~328 gCO2/kWh,
8
+ * within 1% of the Ember-sourced 330 used here).
9
+ * @remarks Replaces the previous "IEA 2023 Emission Factors" table (docket
10
+ * `iyulab/formulab` #173 / `iyulab/online-tools` ISSUE-formulab-20260902 — the prior figures
11
+ * could not be reproduced against any accessible source, IEA's own Emissions Factors data
12
+ * product requires a paid license). Update annually against the same Our World in Data series
13
+ * when a new calendar year of data lands (structural drift, not a one-off fix).
5
14
  */
6
15
  const GRID_EMISSION_FACTORS = {
7
- US_average: 386,
8
- EU_average: 230,
9
- China: 555,
10
- India: 708,
11
- Japan: 457,
12
- Korea: 415,
13
- UK: 207,
14
- Germany: 350,
15
- France: 56,
16
- Brazil: 75,
17
- Australia: 656,
18
- Canada: 110,
16
+ US_average: 384,
17
+ EU_average: 210,
18
+ China: 525,
19
+ India: 670,
20
+ Japan: 477,
21
+ Korea: 417,
22
+ UK: 217,
23
+ Germany: 330,
24
+ France: 41,
25
+ Brazil: 110,
26
+ Australia: 525,
27
+ Canada: 191,
19
28
  };
20
29
  /**
21
30
  * Calculate Scope 2 (indirect) CO2 emissions from purchased electricity — location-based always,
@@ -23,7 +32,7 @@ const GRID_EMISSION_FACTORS = {
23
32
  *
24
33
  * @formula location-based: CO2(kg) = kWh × gridFactor / 1000
25
34
  * @formula market-based: CO2(kg) = (contractedKwh × supplierFactor + (kWh − contractedKwh) × residualMixFactor) / 1000
26
- * @reference GHG Protocol Scope 2, IEA Emission Factors 2023 (location-based grid factors);
35
+ * @reference GHG Protocol Scope 2, Our World in Data / Ember Yearly Electricity Data 2025 (location-based grid factors, see `GRID_EMISSION_FACTORS` above);
27
36
  * GHG Protocol Scope 2 Guidance (2015) Ch.4-6 (market-based dual reporting — this library does
28
37
  * not embed residual-mix emission factors, since they are jurisdiction- and year-specific
29
38
  * published figures; callers supply `residualMixFactor` from their own residual-mix disclosure
@@ -1 +1 @@
1
- {"version":3,"file":"scope2Emissions.js","sourceRoot":"","sources":["../../src/environmental/scope2Emissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;GAGG;AACH,MAAM,qBAAqB,GAAkD;IAC3E,UAAU,E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U,CAAC,kCAAkC,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,sBAAsB,GAAG,CAAC,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YACzD,MAAM,IAAI,UAAU,CAAC,mDAAmD,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,sBAAsB,GAAG,cAAc,EAAE,CAAC;YAC5C,MAAM,IAAI,UAAU,CAAC,4CAA4C,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,YAAY,GAAG,cAAc,GAAG,sBAAsB,CAAC;QAC7D,IAAI,YAAY,GAAG,CAAC,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;YAClD,MAAM,IAAI,UAAU,CAAC,mEAAmE,CAAC,CAAC;QAC5F,CAAC;QAED,MAAM,cAAc,GAAG,sBAAsB,GAAG,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,YAAY,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC,CAAC;QAC7D,gBAAgB,GAAG,OAAO,CAAC,CAAC,cAAc,GAAG,YAAY,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;QACtE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS;QACT,UAAU;QACV,MAAM;QACN,kBAAkB,EAAE,KAAK;QACzB,sBAAsB,EAAE,SAAS;QACjC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formulab",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
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",