@simplepuddin/openenviro-core 0.0.0-stage → 0.1.0-alpha.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/API.json +254 -0
- package/LICENSE +21 -0
- package/README.md +40 -2
- package/dist/buswell.d.ts +74 -0
- package/dist/buswell.js +123 -0
- package/dist/cityScenario.d.ts +148 -0
- package/dist/cityScenario.js +125 -0
- package/dist/climateImpact.d.ts +209 -0
- package/dist/climateImpact.js +124 -0
- package/dist/compostAeration.d.ts +53 -0
- package/dist/compostAeration.js +108 -0
- package/dist/compostConditioning.d.ts +33 -0
- package/dist/compostConditioning.js +152 -0
- package/dist/compostFacility.d.ts +119 -0
- package/dist/compostFacility.js +107 -0
- package/dist/compostMix.d.ts +46 -0
- package/dist/compostMix.js +88 -0
- package/dist/energyRecovery.d.ts +240 -0
- package/dist/energyRecovery.js +135 -0
- package/dist/fleetComparison.d.ts +122 -0
- package/dist/fleetComparison.js +129 -0
- package/dist/fleetEconomics.d.ts +101 -0
- package/dist/fleetEconomics.js +99 -0
- package/dist/gasScenario.d.ts +445 -0
- package/dist/gasScenario.js +69 -0
- package/dist/hcs.d.ts +43 -0
- package/dist/hcs.js +94 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/landfillCapacity.d.ts +62 -0
- package/dist/landfillCapacity.js +96 -0
- package/dist/landfillGas.d.ts +71 -0
- package/dist/landfillGas.js +85 -0
- package/dist/landfillGeometry.d.ts +63 -0
- package/dist/landfillGeometry.js +126 -0
- package/dist/landfillPhases.d.ts +105 -0
- package/dist/landfillPhases.js +237 -0
- package/dist/landfillScenario.d.ts +544 -0
- package/dist/landfillScenario.js +62 -0
- package/dist/landfillSizing.d.ts +268 -0
- package/dist/landfillSizing.js +141 -0
- package/dist/landfillWaste.d.ts +151 -0
- package/dist/landfillWaste.js +124 -0
- package/dist/localizedNumber.d.ts +7 -0
- package/dist/localizedNumber.js +43 -0
- package/dist/methaneManagement.d.ts +126 -0
- package/dist/methaneManagement.js +150 -0
- package/dist/population.d.ts +13 -0
- package/dist/population.js +43 -0
- package/dist/populationCsv.d.ts +28 -0
- package/dist/populationCsv.js +167 -0
- package/dist/populationCsvDraft.d.ts +12 -0
- package/dist/populationCsvDraft.js +18 -0
- package/dist/populationTemplates.d.ts +13 -0
- package/dist/populationTemplates.js +26 -0
- package/dist/scenarioComparison.d.ts +1824 -0
- package/dist/scenarioComparison.js +106 -0
- package/dist/scs.d.ts +49 -0
- package/dist/scs.js +144 -0
- package/dist/transfer.d.ts +58 -0
- package/dist/transfer.js +60 -0
- package/dist/waste.d.ts +8 -0
- package/dist/waste.js +16 -0
- package/dist/wasteAllocation.d.ts +18 -0
- package/dist/wasteAllocation.js +38 -0
- package/dist/wasteCharacterization.d.ts +30 -0
- package/dist/wasteCharacterization.js +69 -0
- package/dist/windrowGeometry.d.ts +57 -0
- package/dist/windrowGeometry.js +71 -0
- package/package.json +158 -4
package/API.json
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"module": "buswell",
|
|
4
|
+
"exports": [
|
|
5
|
+
"calculateBuswell",
|
|
6
|
+
"normalMolarVolume",
|
|
7
|
+
"sakaryaLandfillMaterials"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"module": "cityScenario",
|
|
12
|
+
"exports": [
|
|
13
|
+
"CITY_SCENARIO_SCHEMA_VERSION",
|
|
14
|
+
"MAX_CITY_OPERATING_YEARS",
|
|
15
|
+
"calculateCityScenario",
|
|
16
|
+
"parseCityScenario",
|
|
17
|
+
"sakaryaCityScenario"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"module": "climateImpact",
|
|
22
|
+
"exports": [
|
|
23
|
+
"BIOGENIC_METHANE_GWP",
|
|
24
|
+
"EXAMPLE_CLIMATE_ASSUMPTIONS",
|
|
25
|
+
"calculateClimateImpact",
|
|
26
|
+
"compareClimateScenarios",
|
|
27
|
+
"projectClimateImpact"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"module": "compostAeration",
|
|
32
|
+
"exports": [
|
|
33
|
+
"calculateCompostAeration",
|
|
34
|
+
"defaultAerationSettings",
|
|
35
|
+
"sakaryaAerobicMaterials"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"module": "compostConditioning",
|
|
40
|
+
"exports": [
|
|
41
|
+
"solveCNTarget",
|
|
42
|
+
"solveJointTargets",
|
|
43
|
+
"solveMoistureTarget",
|
|
44
|
+
"solveWaterTarget"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"module": "compostFacility",
|
|
49
|
+
"exports": [
|
|
50
|
+
"calculateCompostFacility",
|
|
51
|
+
"calculateCompostYield",
|
|
52
|
+
"sakaryaFacilityDefaults"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"module": "compostMix",
|
|
57
|
+
"exports": [
|
|
58
|
+
"calculateCompostMix",
|
|
59
|
+
"sakaryaCompostFeed",
|
|
60
|
+
"sakaryaWoodChips"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"module": "energyRecovery",
|
|
65
|
+
"exports": [
|
|
66
|
+
"EXAMPLE_ENERGY_ASSUMPTIONS",
|
|
67
|
+
"calculateEnergyRecovery",
|
|
68
|
+
"calculateIntegratedEnergyRecovery",
|
|
69
|
+
"projectEnergyRecovery"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"module": "fleetComparison",
|
|
74
|
+
"exports": [
|
|
75
|
+
"SAKARYA_FLEET_ASSUMPTIONS",
|
|
76
|
+
"SAKARYA_FLEET_ZONES",
|
|
77
|
+
"SAKARYA_SERVICE_LOAD",
|
|
78
|
+
"compareFleetNetwork"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"module": "fleetEconomics",
|
|
83
|
+
"exports": [
|
|
84
|
+
"DIESEL_CO2_KG_PER_LITRE",
|
|
85
|
+
"EXAMPLE_FLEET_ECONOMICS",
|
|
86
|
+
"compareFleetEconomics"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"module": "gasScenario",
|
|
91
|
+
"exports": [
|
|
92
|
+
"calculateGasScenario",
|
|
93
|
+
"sakaryaGasDefaults"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"module": "hcs",
|
|
98
|
+
"exports": [
|
|
99
|
+
"calculateHCS"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"module": "landfillCapacity",
|
|
104
|
+
"exports": [
|
|
105
|
+
"calculateLandfillCapacity",
|
|
106
|
+
"calculateLandfillCapacitySchedule"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"module": "landfillGas",
|
|
111
|
+
"exports": [
|
|
112
|
+
"landgemFirstYearFactor",
|
|
113
|
+
"projectLandfillGas"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"module": "landfillGeometry",
|
|
118
|
+
"exports": [
|
|
119
|
+
"calculateLandfillGeometry",
|
|
120
|
+
"calculateLandfillLifts",
|
|
121
|
+
"landfillSectionAtHeight",
|
|
122
|
+
"landfillVolumeBelowHeight",
|
|
123
|
+
"landfillVolumeBetweenHeights"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"module": "landfillPhases",
|
|
128
|
+
"exports": [
|
|
129
|
+
"calculateLandfillPhases",
|
|
130
|
+
"evaluateLandfillPhaseScenario",
|
|
131
|
+
"landfillLongitudinalVolume",
|
|
132
|
+
"landfillPhaseEndYears",
|
|
133
|
+
"landfillPositionAtVolume"
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"module": "landfillScenario",
|
|
138
|
+
"exports": [
|
|
139
|
+
"calculateLandfillScenario",
|
|
140
|
+
"landfillFillHeight",
|
|
141
|
+
"sakaryaLandfillScenario"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"module": "landfillSizing",
|
|
146
|
+
"exports": [
|
|
147
|
+
"calculateLandfillSizing",
|
|
148
|
+
"compareLandfillSizingHeights"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"module": "landfillWaste",
|
|
153
|
+
"exports": [
|
|
154
|
+
"calculateLandfillSchedule",
|
|
155
|
+
"calculateLandfillYear",
|
|
156
|
+
"projectLandfillSchedule"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"module": "localizedNumber",
|
|
161
|
+
"exports": [
|
|
162
|
+
"canonicalDecimalDraft",
|
|
163
|
+
"decimalInputHint",
|
|
164
|
+
"displayDecimalDraft",
|
|
165
|
+
"parseCanonicalEngineeringNumber"
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"module": "methaneManagement",
|
|
170
|
+
"exports": [
|
|
171
|
+
"calculateMethaneManagement",
|
|
172
|
+
"projectMethaneManagement"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"module": "population",
|
|
177
|
+
"exports": [
|
|
178
|
+
"projectPopulation"
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"module": "populationCsv",
|
|
183
|
+
"exports": [
|
|
184
|
+
"POPULATION_CSV_MAX_BYTES",
|
|
185
|
+
"POPULATION_CSV_MAX_ROWS",
|
|
186
|
+
"PopulationCsvError",
|
|
187
|
+
"parsePopulationCsv"
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"module": "populationCsvDraft",
|
|
192
|
+
"exports": [
|
|
193
|
+
"decodePopulationCsv",
|
|
194
|
+
"populationCsvDraft"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"module": "populationTemplates",
|
|
199
|
+
"exports": [
|
|
200
|
+
"POPULATION_EXAMPLE_IDS",
|
|
201
|
+
"POPULATION_TEMPLATE_FORMATS",
|
|
202
|
+
"createPopulationTemplate"
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"module": "scenarioComparison",
|
|
207
|
+
"exports": [
|
|
208
|
+
"COMPARISON_METRICS",
|
|
209
|
+
"compareCityScenarios",
|
|
210
|
+
"comparisonBasis",
|
|
211
|
+
"comparisonDelta",
|
|
212
|
+
"evaluateComparisonScenario"
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"module": "scs",
|
|
217
|
+
"exports": [
|
|
218
|
+
"calculateSCS"
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"module": "transfer",
|
|
223
|
+
"exports": [
|
|
224
|
+
"calculateTransfer",
|
|
225
|
+
"calculateTransferNetwork"
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"module": "waste",
|
|
230
|
+
"exports": [
|
|
231
|
+
"dailyWaste"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"module": "wasteAllocation",
|
|
236
|
+
"exports": [
|
|
237
|
+
"allocateWaste"
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"module": "wasteCharacterization",
|
|
242
|
+
"exports": [
|
|
243
|
+
"characterizeWaste"
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"module": "windrowGeometry",
|
|
248
|
+
"exports": [
|
|
249
|
+
"calculateWindrowCapacity",
|
|
250
|
+
"calculateWindrowGeometry",
|
|
251
|
+
"sakaryaWindrowGeometry"
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hikmet Emre Kurtbay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenEnviro Core (Alpha)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A dependency-free ESM engineering SDK. This is a local distribution candidate, not a claim of registry publication. Node 24+.
|
|
4
|
+
|
|
5
|
+
`import { dailyWaste, projectPopulation } from '@simplepuddin/openenviro-core';`
|
|
6
|
+
|
|
7
|
+
Additional engineering model entry points:
|
|
8
|
+
- `./buswell`
|
|
9
|
+
- `./cityScenario`
|
|
10
|
+
- `./climateImpact`
|
|
11
|
+
- `./compostAeration`
|
|
12
|
+
- `./compostConditioning`
|
|
13
|
+
- `./compostFacility`
|
|
14
|
+
- `./compostMix`
|
|
15
|
+
- `./energyRecovery`
|
|
16
|
+
- `./fleetComparison`
|
|
17
|
+
- `./fleetEconomics`
|
|
18
|
+
- `./gasScenario`
|
|
19
|
+
- `./hcs`
|
|
20
|
+
- `./landfillCapacity`
|
|
21
|
+
- `./landfillGas`
|
|
22
|
+
- `./landfillGeometry`
|
|
23
|
+
- `./landfillPhases`
|
|
24
|
+
- `./landfillScenario`
|
|
25
|
+
- `./landfillSizing`
|
|
26
|
+
- `./landfillWaste`
|
|
27
|
+
- `./localizedNumber`
|
|
28
|
+
- `./methaneManagement`
|
|
29
|
+
- `./population`
|
|
30
|
+
- `./populationCsv`
|
|
31
|
+
- `./populationCsvDraft`
|
|
32
|
+
- `./populationTemplates`
|
|
33
|
+
- `./scenarioComparison`
|
|
34
|
+
- `./scs`
|
|
35
|
+
- `./transfer`
|
|
36
|
+
- `./waste`
|
|
37
|
+
- `./wasteAllocation`
|
|
38
|
+
- `./wasteCharacterization`
|
|
39
|
+
- `./windrowGeometry`
|
|
40
|
+
|
|
41
|
+
See API.json for runtime exports and dist/*.d.ts for signatures. Scientific screening only; no field validation or regulatory approval. MIT.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CompostMaterial } from "./compostMix.js";
|
|
2
|
+
export type BuswellMaterial = CompostMaterial & {
|
|
3
|
+
hydrogenFraction: number;
|
|
4
|
+
oxygenFraction: number;
|
|
5
|
+
biodegradationFraction: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const normalMolarVolume = 22.414;
|
|
8
|
+
/**
|
|
9
|
+
* Computes per-material and total potential. The biodegradable fraction is
|
|
10
|
+
* a uniform dry-element conversion proxy, not a kinetic rate or VS measurement.
|
|
11
|
+
* The reported gas fraction includes CH4 and CO2 only; NH3 is a stoichiometric
|
|
12
|
+
* product, not a prediction of gas-phase ammonia. Net reaction water is signed:
|
|
13
|
+
* positive = required by reaction; negative = produced. No moisture feasibility
|
|
14
|
+
* or dissolved gas correction is imposed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateBuswell(materials: BuswellMaterial[]): {
|
|
17
|
+
components: {
|
|
18
|
+
name: string;
|
|
19
|
+
wetMass: number;
|
|
20
|
+
dryMass: number;
|
|
21
|
+
biodegradationFraction: number;
|
|
22
|
+
biodegradableDryMassProxy: number;
|
|
23
|
+
biodegradableCHONMass: number;
|
|
24
|
+
carbonMass: number;
|
|
25
|
+
hydrogenMass: number;
|
|
26
|
+
oxygenMass: number;
|
|
27
|
+
nitrogenMass: number;
|
|
28
|
+
carbonKmol: number;
|
|
29
|
+
hydrogenKmol: number;
|
|
30
|
+
oxygenKmol: number;
|
|
31
|
+
nitrogenKmol: number;
|
|
32
|
+
methaneKmol: number;
|
|
33
|
+
carbonDioxideKmol: number;
|
|
34
|
+
ammoniaKmol: number;
|
|
35
|
+
waterKmol: number;
|
|
36
|
+
methaneVolume: number;
|
|
37
|
+
carbonDioxideVolume: number;
|
|
38
|
+
totalGasVolume: number;
|
|
39
|
+
methaneMass: number;
|
|
40
|
+
carbonDioxideMass: number;
|
|
41
|
+
ammoniaMass: number;
|
|
42
|
+
netWaterDemand: number;
|
|
43
|
+
reactionMassBalanceError: number;
|
|
44
|
+
}[];
|
|
45
|
+
totalWetMass: number;
|
|
46
|
+
totalDryMass: number;
|
|
47
|
+
biodegradableDryMassProxy: number;
|
|
48
|
+
biodegradableCHONMass: number;
|
|
49
|
+
carbonKmol: number;
|
|
50
|
+
hydrogenKmol: number;
|
|
51
|
+
oxygenKmol: number;
|
|
52
|
+
nitrogenKmol: number;
|
|
53
|
+
methaneKmol: number;
|
|
54
|
+
carbonDioxideKmol: number;
|
|
55
|
+
ammoniaKmol: number;
|
|
56
|
+
methaneVolume: number;
|
|
57
|
+
carbonDioxideVolume: number;
|
|
58
|
+
totalGasVolume: number;
|
|
59
|
+
methaneMass: number;
|
|
60
|
+
carbonDioxideMass: number;
|
|
61
|
+
ammoniaMass: number;
|
|
62
|
+
netWaterDemand: number;
|
|
63
|
+
reactionMassBalanceError: number;
|
|
64
|
+
methanePotential: number | null;
|
|
65
|
+
carbonDioxidePotential: number | null;
|
|
66
|
+
totalGasPotential: number | null;
|
|
67
|
+
methaneFraction: number | null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* ENVE307 residual waste preset, no wood chips or compost product.
|
|
71
|
+
* Food and paper factors are screening assumptions (wet-basis indicators
|
|
72
|
+
* applied to dry CHON); ash/others 0..0.5 is the report's uncertainty range.
|
|
73
|
+
*/
|
|
74
|
+
export declare function sakaryaLandfillMaterials(wetMass: number, ashBiodegradability?: number): BuswellMaterial[];
|
package/dist/buswell.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screening-level ultimate CH4/CO2 potential from biodegradable CHON.
|
|
3
|
+
* Based on the nitrogen-inclusive Buswell balance, excluding sulfur.
|
|
4
|
+
* Wet and dry masses are metric tonnes (any common batch or time basis).
|
|
5
|
+
* Elemental fractions are dry-basis; moisture is wet-basis; all fractions 0..1.
|
|
6
|
+
* Gas volumes use ideal dry gas at 0 C and 1 atm (22.414 m3/kmol by default).
|
|
7
|
+
* This is NOT a generation rate, measured methane yield, or collected gas.
|
|
8
|
+
* See ENVE307 Sakarya Sections 5.2-5.4 and 6.4.1 (Tables 5.2, 5.3, 6.5).
|
|
9
|
+
*/
|
|
10
|
+
import { calculateCompostMix, sakaryaCompostFeed } from "./compostMix.js";
|
|
11
|
+
export const normalMolarVolume = 22.414; // Nm3/kmol, 0 C, 1 atm
|
|
12
|
+
const atomic = { C: 12.01, H: 1.008, O: 16, N: 14.01 };
|
|
13
|
+
const fraction = (v) => Number.isFinite(v) && v >= 0 && v <= 1;
|
|
14
|
+
function finite(values) {
|
|
15
|
+
if (!values.every(Number.isFinite))
|
|
16
|
+
throw new RangeError('Result exceeds model limits');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Computes per-material and total potential. The biodegradable fraction is
|
|
20
|
+
* a uniform dry-element conversion proxy, not a kinetic rate or VS measurement.
|
|
21
|
+
* The reported gas fraction includes CH4 and CO2 only; NH3 is a stoichiometric
|
|
22
|
+
* product, not a prediction of gas-phase ammonia. Net reaction water is signed:
|
|
23
|
+
* positive = required by reaction; negative = produced. No moisture feasibility
|
|
24
|
+
* or dissolved gas correction is imposed.
|
|
25
|
+
*/
|
|
26
|
+
export function calculateBuswell(materials) {
|
|
27
|
+
const mix = calculateCompostMix(materials);
|
|
28
|
+
const components = materials.map((m, i) => {
|
|
29
|
+
if (![m.hydrogenFraction, m.oxygenFraction, m.biodegradationFraction].every(fraction)) {
|
|
30
|
+
throw new RangeError('Elemental and biodegradation fractions must be between 0 and 1');
|
|
31
|
+
}
|
|
32
|
+
if (m.carbonFraction + m.hydrogenFraction + m.oxygenFraction + m.nitrogenFraction > 1 + 1e-12) {
|
|
33
|
+
throw new RangeError('CHON fractions cannot exceed dry mass');
|
|
34
|
+
}
|
|
35
|
+
const dryMass = mix.components[i].dryMass;
|
|
36
|
+
const biodegradableDryMassProxy = dryMass * m.biodegradationFraction;
|
|
37
|
+
const carbonMass = biodegradableDryMassProxy * m.carbonFraction;
|
|
38
|
+
const hydrogenMass = biodegradableDryMassProxy * m.hydrogenFraction;
|
|
39
|
+
const oxygenMass = biodegradableDryMassProxy * m.oxygenFraction;
|
|
40
|
+
const nitrogenMass = biodegradableDryMassProxy * m.nitrogenFraction;
|
|
41
|
+
const a = carbonMass / atomic.C * 1000;
|
|
42
|
+
const b = hydrogenMass / atomic.H * 1000;
|
|
43
|
+
const c = oxygenMass / atomic.O * 1000;
|
|
44
|
+
const d = nitrogenMass / atomic.N * 1000;
|
|
45
|
+
const rawMethane = a / 2 + b / 8 - c / 4 - 3 * d / 8;
|
|
46
|
+
const rawCarbonDioxide = a / 2 - b / 8 + c / 4 + 3 * d / 8;
|
|
47
|
+
const waterKmol = a - b / 4 - c / 2 + 3 * d / 4;
|
|
48
|
+
finite([a, b, c, d, rawMethane, rawCarbonDioxide, waterKmol]);
|
|
49
|
+
const tolerance = 1e-12 * Math.max(a, b, c, d);
|
|
50
|
+
if (rawMethane < -tolerance || rawCarbonDioxide < -tolerance) {
|
|
51
|
+
throw new RangeError(`Negative gas yield for ${m.name}: outside the CHON Buswell model`);
|
|
52
|
+
}
|
|
53
|
+
const methaneKmol = Math.max(0, rawMethane);
|
|
54
|
+
const carbonDioxideKmol = Math.max(0, rawCarbonDioxide);
|
|
55
|
+
const ammoniaKmol = d;
|
|
56
|
+
const methaneVolume = methaneKmol * normalMolarVolume;
|
|
57
|
+
const carbonDioxideVolume = carbonDioxideKmol * normalMolarVolume;
|
|
58
|
+
const methaneMass = methaneKmol * (atomic.C + 4 * atomic.H) / 1000;
|
|
59
|
+
const carbonDioxideMass = carbonDioxideKmol * (atomic.C + 2 * atomic.O) / 1000;
|
|
60
|
+
const ammoniaMass = ammoniaKmol * (atomic.N + 3 * atomic.H) / 1000;
|
|
61
|
+
const netWaterDemand = waterKmol * (2 * atomic.H + atomic.O) / 1000;
|
|
62
|
+
const biodegradableCHONMass = carbonMass + hydrogenMass + oxygenMass + nitrogenMass;
|
|
63
|
+
const reactionMassBalanceError = biodegradableCHONMass + netWaterDemand - methaneMass - carbonDioxideMass - ammoniaMass;
|
|
64
|
+
const totalGasVolume = methaneVolume + carbonDioxideVolume;
|
|
65
|
+
finite([methaneVolume, carbonDioxideVolume, methaneMass, carbonDioxideMass, ammoniaMass,
|
|
66
|
+
netWaterDemand, biodegradableCHONMass, reactionMassBalanceError, totalGasVolume]);
|
|
67
|
+
return { name: mix.components[i].name, wetMass: m.wetMass, dryMass,
|
|
68
|
+
biodegradationFraction: m.biodegradationFraction, biodegradableDryMassProxy,
|
|
69
|
+
biodegradableCHONMass, carbonMass, hydrogenMass, oxygenMass, nitrogenMass,
|
|
70
|
+
carbonKmol: a, hydrogenKmol: b, oxygenKmol: c, nitrogenKmol: d,
|
|
71
|
+
methaneKmol, carbonDioxideKmol, ammoniaKmol, waterKmol,
|
|
72
|
+
methaneVolume, carbonDioxideVolume, totalGasVolume,
|
|
73
|
+
methaneMass, carbonDioxideMass, ammoniaMass, netWaterDemand, reactionMassBalanceError };
|
|
74
|
+
});
|
|
75
|
+
const sum = (key) => components.reduce((total, row) => total + row[key], 0);
|
|
76
|
+
const totalWetMass = mix.totalWetMass;
|
|
77
|
+
const totalDryMass = mix.totalDryMass;
|
|
78
|
+
const biodegradableDryMassProxy = sum('biodegradableDryMassProxy');
|
|
79
|
+
const biodegradableCHONMass = sum('biodegradableCHONMass');
|
|
80
|
+
const carbonKmol = sum('carbonKmol');
|
|
81
|
+
const hydrogenKmol = sum('hydrogenKmol');
|
|
82
|
+
const oxygenKmol = sum('oxygenKmol');
|
|
83
|
+
const nitrogenKmol = sum('nitrogenKmol');
|
|
84
|
+
const methaneKmol = sum('methaneKmol');
|
|
85
|
+
const carbonDioxideKmol = sum('carbonDioxideKmol');
|
|
86
|
+
const ammoniaKmol = sum('ammoniaKmol');
|
|
87
|
+
const methaneVolume = sum('methaneVolume');
|
|
88
|
+
const carbonDioxideVolume = sum('carbonDioxideVolume');
|
|
89
|
+
const totalGasVolume = methaneVolume + carbonDioxideVolume;
|
|
90
|
+
const methaneMass = sum('methaneMass');
|
|
91
|
+
const carbonDioxideMass = sum('carbonDioxideMass');
|
|
92
|
+
const ammoniaMass = sum('ammoniaMass');
|
|
93
|
+
const netWaterDemand = sum('netWaterDemand');
|
|
94
|
+
const reactionMassBalanceError = biodegradableCHONMass + netWaterDemand - methaneMass - carbonDioxideMass - ammoniaMass;
|
|
95
|
+
finite([biodegradableDryMassProxy, biodegradableCHONMass, carbonKmol, hydrogenKmol, oxygenKmol, nitrogenKmol,
|
|
96
|
+
methaneKmol, carbonDioxideKmol, ammoniaKmol, methaneVolume, carbonDioxideVolume, totalGasVolume,
|
|
97
|
+
methaneMass, carbonDioxideMass, ammoniaMass, netWaterDemand, reactionMassBalanceError]);
|
|
98
|
+
const methanePotential = totalWetMass > 0 ? methaneVolume / totalWetMass : null;
|
|
99
|
+
const carbonDioxidePotential = totalWetMass > 0 ? carbonDioxideVolume / totalWetMass : null;
|
|
100
|
+
const totalGasPotential = totalWetMass > 0 ? totalGasVolume / totalWetMass : null;
|
|
101
|
+
const methaneFraction = totalGasVolume > 0 ? methaneVolume / totalGasVolume : null;
|
|
102
|
+
finite([methanePotential ?? 0, carbonDioxidePotential ?? 0, totalGasPotential ?? 0, methaneFraction ?? 0]);
|
|
103
|
+
return { components, totalWetMass, totalDryMass, biodegradableDryMassProxy, biodegradableCHONMass,
|
|
104
|
+
carbonKmol, hydrogenKmol, oxygenKmol, nitrogenKmol, methaneKmol, carbonDioxideKmol, ammoniaKmol,
|
|
105
|
+
methaneVolume, carbonDioxideVolume, totalGasVolume, methaneMass, carbonDioxideMass, ammoniaMass,
|
|
106
|
+
netWaterDemand, reactionMassBalanceError, methanePotential, carbonDioxidePotential, totalGasPotential,
|
|
107
|
+
methaneFraction };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ENVE307 residual waste preset, no wood chips or compost product.
|
|
111
|
+
* Food and paper factors are screening assumptions (wet-basis indicators
|
|
112
|
+
* applied to dry CHON); ash/others 0..0.5 is the report's uncertainty range.
|
|
113
|
+
*/
|
|
114
|
+
export function sakaryaLandfillMaterials(wetMass, ashBiodegradability = 0.5) {
|
|
115
|
+
if (!fraction(ashBiodegradability))
|
|
116
|
+
throw new RangeError('Ash biodegradation fraction must be between 0 and 1');
|
|
117
|
+
const [food, paper, ash] = sakaryaCompostFeed(wetMass);
|
|
118
|
+
return [
|
|
119
|
+
{ ...food, hydrogenFraction: 0.064, oxygenFraction: 0.376, biodegradationFraction: 0.82 },
|
|
120
|
+
{ ...paper, hydrogenFraction: 0.06, oxygenFraction: 0.44, biodegradationFraction: 0.5 },
|
|
121
|
+
{ ...ash, hydrogenFraction: 0.06, oxygenFraction: 0.35, biodegradationFraction: ashBiodegradability }
|
|
122
|
+
];
|
|
123
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/** M12.01: canonical, versioned shared city inputs.
|
|
2
|
+
* Units: people, kg/person/day, wet metric tonnes, fractions (not percentages).
|
|
3
|
+
* Module-specific engineering settings remain in their respective labs.
|
|
4
|
+
* The existing landfill waste engine owns the annual material flow equations.
|
|
5
|
+
*/
|
|
6
|
+
import { type LandfillProjectionInput } from "./landfillWaste.js";
|
|
7
|
+
export declare const CITY_SCENARIO_SCHEMA_VERSION: 1;
|
|
8
|
+
export declare const MAX_CITY_OPERATING_YEARS = 200;
|
|
9
|
+
export type CityScenario = {
|
|
10
|
+
schemaVersion: typeof CITY_SCENARIO_SCHEMA_VERSION;
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
city: {
|
|
14
|
+
name: string;
|
|
15
|
+
country: string;
|
|
16
|
+
};
|
|
17
|
+
designYear: number;
|
|
18
|
+
projection: Required<LandfillProjectionInput>;
|
|
19
|
+
provenance: {
|
|
20
|
+
origin: 'reference' | 'user-defined';
|
|
21
|
+
note: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** Safe boundary for decoded JSON. Rejects unsupported versions and invalid projections. */
|
|
25
|
+
export declare function parseCityScenario(value: unknown): CityScenario;
|
|
26
|
+
/** Reuse the same reference basis as Landfill Builder; do not mix rounded population presets. */
|
|
27
|
+
export declare function sakaryaCityScenario(): CityScenario;
|
|
28
|
+
/** One source of truth for shared lab input snapshots. No module UI is changed. */
|
|
29
|
+
export declare function calculateCityScenario(value: CityScenario): {
|
|
30
|
+
scenario: CityScenario;
|
|
31
|
+
schedule: {
|
|
32
|
+
startYear: number;
|
|
33
|
+
endYear: number;
|
|
34
|
+
designYears: number;
|
|
35
|
+
totalDays: number;
|
|
36
|
+
rows: {
|
|
37
|
+
cumulativeLandfill: number;
|
|
38
|
+
year: number;
|
|
39
|
+
population: number;
|
|
40
|
+
wasteRate: number;
|
|
41
|
+
recyclingFraction: number;
|
|
42
|
+
compostFractionOfResidual: number;
|
|
43
|
+
compostRejectFraction: number;
|
|
44
|
+
daysInYear: number;
|
|
45
|
+
dailyGenerated: number;
|
|
46
|
+
dailyRecycled: number;
|
|
47
|
+
dailyResidual: number;
|
|
48
|
+
dailyCompostFeed: number;
|
|
49
|
+
dailyDirectLandfill: number;
|
|
50
|
+
dailyCompostReject: number;
|
|
51
|
+
dailyCompostRetained: number;
|
|
52
|
+
dailyLandfill: number;
|
|
53
|
+
annualGenerated: number;
|
|
54
|
+
annualRecycled: number;
|
|
55
|
+
annualCompostFeed: number;
|
|
56
|
+
annualDirectLandfill: number;
|
|
57
|
+
annualCompostReject: number;
|
|
58
|
+
annualCompostRetained: number;
|
|
59
|
+
annualLandfill: number;
|
|
60
|
+
effectiveLandfillFraction: number | null;
|
|
61
|
+
annualMassBalanceError: number;
|
|
62
|
+
}[];
|
|
63
|
+
totals: {
|
|
64
|
+
generated: number;
|
|
65
|
+
recycled: number;
|
|
66
|
+
compostFeed: number;
|
|
67
|
+
directLandfill: number;
|
|
68
|
+
compostReject: number;
|
|
69
|
+
compostRetained: number;
|
|
70
|
+
landfill: number;
|
|
71
|
+
};
|
|
72
|
+
totalLandfillMass: number;
|
|
73
|
+
averageDailyLandfill: number;
|
|
74
|
+
peakDailyLandfill: number;
|
|
75
|
+
massBalanceError: number;
|
|
76
|
+
};
|
|
77
|
+
design: {
|
|
78
|
+
cumulativeLandfill: number;
|
|
79
|
+
year: number;
|
|
80
|
+
population: number;
|
|
81
|
+
wasteRate: number;
|
|
82
|
+
recyclingFraction: number;
|
|
83
|
+
compostFractionOfResidual: number;
|
|
84
|
+
compostRejectFraction: number;
|
|
85
|
+
daysInYear: number;
|
|
86
|
+
dailyGenerated: number;
|
|
87
|
+
dailyRecycled: number;
|
|
88
|
+
dailyResidual: number;
|
|
89
|
+
dailyCompostFeed: number;
|
|
90
|
+
dailyDirectLandfill: number;
|
|
91
|
+
dailyCompostReject: number;
|
|
92
|
+
dailyCompostRetained: number;
|
|
93
|
+
dailyLandfill: number;
|
|
94
|
+
annualGenerated: number;
|
|
95
|
+
annualRecycled: number;
|
|
96
|
+
annualCompostFeed: number;
|
|
97
|
+
annualDirectLandfill: number;
|
|
98
|
+
annualCompostReject: number;
|
|
99
|
+
annualCompostRetained: number;
|
|
100
|
+
annualLandfill: number;
|
|
101
|
+
effectiveLandfillFraction: number | null;
|
|
102
|
+
annualMassBalanceError: number;
|
|
103
|
+
};
|
|
104
|
+
warnings: string[];
|
|
105
|
+
labInputs: {
|
|
106
|
+
population: {
|
|
107
|
+
referenceYear: number;
|
|
108
|
+
referencePopulation: number;
|
|
109
|
+
annualGrowthFraction: number;
|
|
110
|
+
designYear: number;
|
|
111
|
+
projectedPopulation: number;
|
|
112
|
+
};
|
|
113
|
+
waste: {
|
|
114
|
+
population: number;
|
|
115
|
+
wasteRate: number;
|
|
116
|
+
recyclingFraction: number;
|
|
117
|
+
compostFractionOfResidual: number;
|
|
118
|
+
referenceYear: number;
|
|
119
|
+
};
|
|
120
|
+
fleet: {
|
|
121
|
+
generatedWetTonnesPerDay: number;
|
|
122
|
+
referenceYear: number;
|
|
123
|
+
};
|
|
124
|
+
compost: {
|
|
125
|
+
incomingWetTonnesPerDay: number;
|
|
126
|
+
referenceYear: number;
|
|
127
|
+
};
|
|
128
|
+
landfill: {
|
|
129
|
+
baseYear: number;
|
|
130
|
+
basePopulation: number;
|
|
131
|
+
annualPopulationGrowth: number;
|
|
132
|
+
startYear: number;
|
|
133
|
+
endYear: number;
|
|
134
|
+
baseWasteRate: number;
|
|
135
|
+
annualWasteRateGrowth: number;
|
|
136
|
+
recyclingFraction: number;
|
|
137
|
+
compostFractionOfResidual: number;
|
|
138
|
+
compostRejectFraction: number;
|
|
139
|
+
daysInYear: number;
|
|
140
|
+
};
|
|
141
|
+
gas: {
|
|
142
|
+
waste: {
|
|
143
|
+
year: number;
|
|
144
|
+
annualLandfill: number;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|