@idm-plugin/ghg
Version:
idm plugin for greenhouse gas
1,281 lines (1,280 loc) • 41.9 kB
JavaScript
var j = Object.defineProperty;
var y = (s, e, t) => e in s ? j(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var H = (s, e, t) => (y(s, typeof e != "symbol" ? e + "" : e, t), t);
import B from "@log4js-node/log4js-api";
import * as g from "@turf/turf";
const q = {};
let N;
try {
N = B.getLogger("eu-ets");
} catch {
} finally {
}
const L = class L {
static async readBoundaries(e) {
const t = q.readFileSync(e, "utf-8");
return JSON.parse(t);
}
static async convert2Geojson(e) {
const t = [];
for (const l of e) {
const c = l.bound;
let n = c.at(-1);
const R = c.at(-2);
R[0] === n[0] && R[1] === n[1] && c.pop();
const i = c.at(0);
n = c.at(-1), (i[0] !== n[0] || i[1] !== n[1]) && c.push(i);
const E = c.map((r) => [r[1], r[0]]);
t.push([E]);
}
return g.multiPolygon(t);
}
static async isInEU(e, t = {}) {
const a = g.point([e.lng, e.lat]), l = g.booleanPointInPolygon(a, L.euMrvBoundaries, { ignoreBoundary: !1 });
return N == null || N.info("[%s] port(%j) in-eu: %s", t.requireId, e, l), l;
}
static async isFuelEUExclude(e, t = {}) {
const a = g.point([e.lng, e.lat]), l = g.booleanPointInPolygon(a, L.fuelEuExclude, { ignoreBoundary: !1 });
return N == null || N.info("[%s] port(%j) in-eu: %s", t.requireId, e, l), l;
}
};
H(L, "boundaries", {
type: "Feature",
properties: {},
geometry: {
type: "MultiPolygon",
coordinates: [
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[-0.13184, 49.86632],
[-3.2959, 49.83798],
[-5.75684, 48.40003],
[-11.7334, 41.54148],
[-9.66797, 35.88905],
[-6.89941, 35.81781],
[-5.81726, 35.9113],
[-4.3396, 36.16449],
[-0.41748, 36.75649],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-24.16992, 67.27204],
[-26.80664, 64.77413],
[-18.54492, 62.14498],
[-9.31641, 63.62674],
[-8.4375, 67.33986],
[-18.28125, 68.39918],
[-24.16992, 67.27204]
]
],
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-7.20154, 55.06893],
[-6.99829, 55.17887],
[-6.86646, 55.23529],
[-7.11914, 55.44771],
[-8.08594, 55.5193],
[-9.25049, 54.99337],
[-10.85449, 53.96901],
[-10.85449, 52.38901],
[-10.21729, 50.99993],
[-7.40479, 51.60437],
[-6.24023, 52.01194],
[-5.66895, 52.65639],
[-5.76782, 53.7617],
[-6.05896, 53.9884],
[-6.25671, 54.1045],
[-6.95984, 54.23634],
[-7.43225, 54.12704],
[-7.94312, 54.29409],
[-8.15186, 54.45407],
[-8.02551, 54.54021],
[-7.68494, 54.62934],
[-7.85522, 54.74048],
[-7.58606, 54.73731],
[-7.4762, 54.86712],
[-7.39929, 54.99022],
[-7.20154, 55.06893]
]
],
[
[
[-15.16113, 29.36303],
[-18.21533, 29.31514],
[-18.28125, 27.23509],
[-15.35889, 27.17647],
[-13.93066, 27.73216],
[-13.12866, 29.02735],
[-12.84302, 29.77391],
[-15.16113, 29.36303]
]
],
[
[
[-61.59485, 16.57829],
[-62.00684, 16.35177],
[-61.96289, 15.85567],
[-61.61682, 15.71295],
[-61.0675, 15.7764],
[-60.82031, 16.13554],
[-60.88623, 16.46769],
[-61.40259, 16.62567],
[-61.59485, 16.57829]
]
],
[
[
[-53.83301, 6.06409],
[-54.14063, 5.58318],
[-54.54712, 4.97056],
[-54.32739, 3.28311],
[-54.56909, 2.30651],
[-53.80005, 1.90029],
[-52.59155, 2.06498],
[-51.87744, 3.72175],
[-51.61377, 4.10537],
[-51.60278, 4.23686],
[-51.5918, 4.91583],
[-53.00903, 5.9439],
[-53.83301, 6.06409]
]
],
[
[
[-61.16089, 14.95009],
[-61.41907, 14.80675],
[-61.17737, 14.36551],
[-60.69397, 14.35487],
[-60.5896, 14.58358],
[-60.83679, 14.85985],
[-61.16089, 14.95009]
]
],
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-63.13705, 18.0943],
[-63.16383, 18.09071],
[-63.17276, 18.06101],
[-63.15491, 18.04403],
[-63.13362, 18.05317],
[-63.1089, 18.05317],
[-63.09311, 18.04403],
[-63.08006, 18.0486],
[-63.06702, 18.0584],
[-63.05122, 18.06297],
[-63.02856, 18.05383],
[-63.01071, 18.05252],
[-62.98187, 18.0486],
[-62.94617, 18.10539],
[-62.95715, 18.14585],
[-63.06358, 18.14259],
[-63.1192, 18.12171],
[-63.13705, 18.0943]
]
],
[
[
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-16.83655, 33.19733],
[-17.44629, 33.00866],
[-17.65503, 32.5607],
[-16.75415, 32.30571],
[-15.75989, 32.28249],
[-16.00159, 33.16974],
[-16.3092, 33.42686],
[-16.83655, 33.19733]
]
],
[
[
[-26.72974, 39.3343],
[-31.15723, 40.00237],
[-31.76147, 39.45316],
[-30.53101, 38.03079],
[-26.15845, 36.85325],
[-23.68652, 36.46547],
[-23.48877, 38.39334],
[-26.16943, 39.15562],
[-26.72974, 39.3343]
]
]
]
}
}), H(L, "euMrvBoundaries", {
type: "Feature",
properties: {},
geometry: {
type: "MultiPolygon",
coordinates: [
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[-0.13183, 49.86632],
[-2.06818, 49.8433],
[-2.0462, 49.68007],
[-2.14233, 49.54125],
[-1.81823, 49.21042],
[-1.91987, 48.86472],
[-2.406, 48.81228],
[-3.52662, 48.96398],
[-5.75683, 48.40003],
[-11.7334, 41.54148],
[-9.66797, 35.88905],
[-6.89942, 35.81782],
[-6.37618, 35.92687],
[-6.08643, 35.97023],
[-5.85708, 35.9491],
[-5.56183, 35.95745],
[-5.49042, 35.98023],
[-5.4578, 36.00607],
[-5.35308, 36.04217],
[-5.33763, 36.05493],
[-5.35068, 36.06187],
[-5.36305, 36.07657],
[-5.3754, 36.09627],
[-5.39668, 36.13095],
[-5.38708, 36.14702],
[-5.3627, 36.16005],
[-5.35085, 36.15632],
[-5.33248, 36.1595],
[-5.23293, 36.14342],
[-5.22675, 36.1057],
[-5.25627, 36.05908],
[-5.29198, 35.98245],
[-5.38673, 35.95855],
[-5.39017, 35.92353],
[-5.37935, 35.91185],
[-5.37643, 35.8935],
[-5.373, 35.88182],
[-5.35308, 35.87292],
[-5.34278, 35.87403],
[-5.32493, 35.85622],
[-5.23842, 35.87903],
[-5.14228, 35.96578],
[-5.10933, 36.05465],
[-5.0283, 36.08352],
[-4.8539, 36.08458],
[-4.3396, 36.16448],
[-0.41748, 36.75648],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-24.16992, 67.27203],
[-26.80663, 64.77413],
[-18.54492, 62.14498],
[-9.31642, 63.62673],
[-8.4375, 67.33987],
[-18.28125, 68.39918],
[-24.16992, 67.27203]
]
],
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-7.20154, 55.06893],
[-6.99829, 55.17887],
[-6.86646, 55.23529],
[-7.11914, 55.44771],
[-8.08594, 55.5193],
[-9.25049, 54.99337],
[-10.85449, 53.96901],
[-10.85449, 52.38901],
[-10.21729, 50.99993],
[-7.40479, 51.60437],
[-6.24023, 52.01194],
[-5.66895, 52.65639],
[-5.76782, 53.7617],
[-6.05896, 53.9884],
[-6.25671, 54.1045],
[-6.95984, 54.23634],
[-7.43225, 54.12704],
[-7.94312, 54.29409],
[-8.15186, 54.45407],
[-8.02551, 54.54021],
[-7.68494, 54.62934],
[-7.85522, 54.74048],
[-7.58606, 54.73731],
[-7.4762, 54.86712],
[-7.39929, 54.99022],
[-7.20154, 55.06893]
]
],
[
[
[-15.16113, 29.36303],
[-18.21533, 29.31514],
[-18.28125, 27.23509],
[-15.35889, 27.17647],
[-13.93066, 27.73216],
[-13.12866, 29.02735],
[-12.84302, 29.77391],
[-15.16113, 29.36303]
]
],
[
[
[-61.59485, 16.57829],
[-62.00684, 16.35177],
[-61.96289, 15.85567],
[-61.61682, 15.71295],
[-61.0675, 15.7764],
[-60.82031, 16.13554],
[-60.88623, 16.46769],
[-61.40259, 16.62567],
[-61.59485, 16.57829]
]
],
[
[
[-53.83301, 6.06409],
[-54.14063, 5.58318],
[-54.54712, 4.97056],
[-54.32739, 3.28311],
[-54.56909, 2.30651],
[-53.80005, 1.90029],
[-52.59155, 2.06498],
[-51.87744, 3.72175],
[-51.61377, 4.10537],
[-51.60278, 4.23686],
[-51.5918, 4.91583],
[-53.00903, 5.9439],
[-53.83301, 6.06409]
]
],
[
[
[-61.16089, 14.95009],
[-61.41907, 14.80675],
[-61.17737, 14.36551],
[-60.69397, 14.35487],
[-60.5896, 14.58358],
[-60.83679, 14.85985],
[-61.16089, 14.95009]
]
],
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-63.13705, 18.0943],
[-63.16383, 18.09071],
[-63.17276, 18.06101],
[-63.15491, 18.04403],
[-63.13362, 18.05317],
[-63.1089, 18.05317],
[-63.09311, 18.04403],
[-63.08006, 18.0486],
[-63.06702, 18.0584],
[-63.05122, 18.06297],
[-63.02856, 18.05383],
[-63.01071, 18.05252],
[-62.98187, 18.0486],
[-62.94617, 18.10539],
[-62.95715, 18.14585],
[-63.06358, 18.14259],
[-63.1192, 18.12171],
[-63.13705, 18.0943]
]
],
[
[
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-16.83655, 33.19733],
[-17.44629, 33.00866],
[-17.65503, 32.5607],
[-16.75415, 32.30571],
[-15.75989, 32.28249],
[-16.00159, 33.16974],
[-16.3092, 33.42686],
[-16.83655, 33.19733]
]
],
[
[
[-26.72974, 39.3343],
[-31.15723, 40.00237],
[-31.76147, 39.45316],
[-30.53101, 38.03079],
[-26.15845, 36.85325],
[-23.68652, 36.46547],
[-23.48877, 38.39334],
[-26.16943, 39.15562],
[-26.72974, 39.3343]
]
]
]
}
}), H(L, "fuelEuExclude", {
type: "Feature",
properties: {},
geometry: {
type: "MultiPolygon",
coordinates: [
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
],
[
[
[-24.16992, 67.27203],
[-26.80663, 64.77413],
[-18.54492, 62.14498],
[-9.31642, 63.62673],
[-8.4375, 67.33987],
[-18.28125, 68.39918],
[-24.16992, 67.27203]
]
]
]
}
});
let v = L, A;
try {
A = B.getLogger("eu-ets");
} catch {
} finally {
}
const K = {
2024: 0.4,
2025: 0.7,
2026: 1
};
var V = /* @__PURE__ */ ((s) => (s[s.PROP5 = 0.99] = "PROP5", s[s.PROP10 = 0.97] = "PROP10", s[s.PROP15 = 0.95] = "PROP15", s))(V || {});
const M = {
DGO_Factor: {
co2: 3.206,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0427,
//MJ/g
wtt: 14.4
//gCO2eq/MJ
},
MDO_Factor: {
co2: 3.206,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0427,
//MJ/g
wtt: 14.4
//gCO2eq/MJ
},
MGO_Factor: {
co2: 3.206,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0427,
//MJ/g
wtt: 14.4
//gCO2eq/MJ
},
HFO_Factor: {
co2: 3.114,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0405,
//MJ/g
wtt: 13.5
//gCO2eq/MJ
},
LFO_Factor: {
co2: 3.151,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.041,
//MJ/g
wtt: 13.2
//gCO2eq/MJ
},
LNG_OTTO_MEDIUM_SPD_Factor: {
co2: 2.75,
// gCO2/gFuel
ch4: 0,
n2o: 11e-5,
cj: 3.1,
// 燃料泄漏排放因子
lcv: 0.0491,
//MJ/g
wtt: 18.5
//gCO2eq/MJ
},
LNG_OTTO_SLOW_SPD_Factor: {
co2: 2.75,
// gCO2/gFuel
ch4: 0,
n2o: 11e-5,
cj: 1.7,
// 燃料泄漏排放因子
lcv: 0.0491,
//MJ/g
wtt: 18.5
//gCO2eq/MJ
},
LNG_DIESEL_SLOW_SPD_Factor: {
co2: 2.75,
// gCO2/gFuel
ch4: 0,
n2o: 11e-5,
cj: 0.2,
// 燃料泄漏排放因子
lcv: 0.0491,
//MJ/g
wtt: 18.5
//gCO2eq/MJ
},
LNG_LBSI_Factor: {
co2: 2.75,
// gCO2/gFuel
ch4: 0,
n2o: 11e-5,
cj: 2.6,
// 燃料泄漏排放因子
lcv: 0.0491,
//MJ/g
wtt: 18.5
//gCO2eq/MJ
},
ETHANE_Factor: {
co2: 2.927,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0464,
//MJ/g
wtt: 18.5
//gCO2eq/MJ
},
// LNG_Factor: {
// co2: 2.75, // gCO2/gFuel
// },
LPG_PROPANE_Factor: {
co2: 3,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.046,
//MJ/g
wtt: 7.8
//gCO2eq/MJ
},
LPG_BUTANE_Factor: {
co2: 3.03,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.046,
//MJ/g
wtt: 7.8
//gCO2eq/MJ
},
// LPG_Factor: {
// co2: 3.03, // gCO2/gFuel
// },
METHANOL_Factor: {
co2: 1.375,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0199,
//MJ/g
wtt: 31.3
//gCO2eq/MJ
},
CUSTOM_Factor: {
co2: 3.114,
// gCO2/gFuel
ch4: 5e-5,
n2o: 18e-5,
lcv: 0.0405,
//MJ/g
wtt: 13.5,
//gCO2eq/MJ
E: 90.389
}
}, D = {
CO2: 1,
CH4: 28,
N2O: 265
}, T = {
CO2: 1,
CH4: 25,
N2O: 298
};
var x = /* @__PURE__ */ ((s) => (s.HFO = "HFO", s.LFO = "LFO", s.LSFO = "LSFO", s.DGO = "DGO", s.MGO = "MGO", s.MDO = "MDO", s.LNG_OTTO_MEDIUM_SPD = "LNG_OTTO_MEDIUM_SPD", s.LNG_OTTO_SLOW_SPD = "LNG_OTTO_SLOW_SPD", s.LNG_DIESEL_SLOW_SPD = "LNG_DIESEL_SLOW_SPD", s.LNG_LBSI = "LNG_LBSI", s.LPG = "LPG", s.LNG = "LNG", s.METHANOL = "METHANOL", s.BIODIESEL = "BIODIESEL", s))(x || {}), b = /* @__PURE__ */ ((s) => (s.EU_MRV_Non_EU = "Non EU", s.EU_MRV_Arrived_EU = "Arrived EU", s.EU_MRV_Departed_EU = "Departed EU", s.EU_MRV_Between_EU = "Between EU", s))(b || {});
class W {
/**
* 计算MRV
* @param cons 油耗, 单位 mt
* @param fc 排放因子
* @param cj 燃料泄漏系数
* @param lcv
* @param ch4 是否是 CH4
*/
static calculateMRV(e, t, a, l, c) {
let n = 0, R = 0;
return a ? c ? (n = e * (1 - a / 100) * t + e * (a / 100), R = ((1 - a / 100) * t + a / 100) / l) : (n = e * (1 - a / 100) * t, R = (1 - a / 100) * t / l) : (n = e * t, R = t / l), { mrv: n, ttw: R };
}
/**
*计算WtT GHG Intensity
* @param factor
*/
static calculateWtT(e) {
let t = 0;
return e.wtt ? t = e.wtt : e.E && e.lcv && (t = e.E - e.co2 / e.lcv), t;
}
static calculateCO2MRV(e, t, a, l = {}) {
const c = M[`${t}_Factor`] || M.CUSTOM_Factor, n = (a == null ? void 0 : a.co2) || c.co2, R = (a == null ? void 0 : a.cj) || c.cj, i = (a == null ? void 0 : a.lcv) || c.lcv, { mrv: E, ttw: r } = this.calculateMRV(e, n, R, i || 0);
return A == null || A.info("[%s] co2 emission: %j", l.requireId, { cons: e, type: t, factor: c, customFactor: a, mrv: E, ttw: r }), { mrv: Math.round(E * D.CO2 * 1e3) / 1e3, ttw: Math.round(r * T.CO2 * 1e3) / 1e3 };
}
static calculateCH4MRV(e, t, a, l = {}) {
const c = M[`${t}_Factor`] || M.CUSTOM_Factor, n = (a == null ? void 0 : a.ch4) || c.ch4, R = (a == null ? void 0 : a.cj) || c.cj, i = (a == null ? void 0 : a.lcv) || c.lcv, { mrv: E, ttw: r } = this.calculateMRV(e, n || 0, R, i || 0, !0);
return A == null || A.info("[%s] ch4 emission: %j", l.requireId, { cons: e, type: t, factor: c, customFactor: a, mrv: E, ttw: r }), { mrv: Math.round(E * D.CH4 * 1e3) / 1e3, ttw: Math.round(r * T.CH4 * 1e3) / 1e3 };
}
static calculateN2OMRV(e, t, a, l = {}) {
const c = M[`${t}_Factor`] || M.CUSTOM_Factor, n = (a == null ? void 0 : a.n2o) || c.n2o, R = (a == null ? void 0 : a.cj) || c.cj, i = (a == null ? void 0 : a.lcv) || c.lcv, { mrv: E, ttw: r } = this.calculateMRV(e, n || 0, R, i || 0);
return A == null || A.info("[%s] n2o emission: %j", l.requireId, { cons: e, type: t, factor: c, customFactor: a, mrv: E, ttw: r }), { mrv: Math.round(E * D.N2O * 1e3) / 1e3, ttw: Math.round(r * T.N2O * 1e3) / 1e3 };
}
/**
* @param cons 油耗, 单位 mt
* @param type 油耗类型
* @param year 年份
* @param price 碳税价格
* @param areaRate 区域税率
* @param options
*/
static calculateGHGMRV(e, t, a = 64.56, l = 2025, c = 1, n = {}) {
const R = this.calculateCO2MRV(e, t, n.factor), i = this.calculateCH4MRV(e, t, n.factor), E = this.calculateN2OMRV(e, t, n.factor), r = n.factor || M[`${t}_Factor`] || M.CUSTOM_Factor;
let I = 0, u = 0, f = 0;
l >= 2026 ? (u = R.mrv + i.mrv + E.mrv, f = 1) : (u = R.mrv, f = K[l] || 0), l >= 2024 ? I = R.mrv + i.mrv + E.mrv : I = R.mrv, I = Math.round(I * 1e3) / 1e3, u = Math.round(u * c * 1e3) / 1e3;
const h = Math.round(u * f * 1e3) / 1e3, G = Math.round(a * h * 100) / 100, S = Math.round(this.calculateWtT(r) * 1e3) / 1e3, d = Math.round((R.ttw + i.ttw + E.ttw) * 1e3) / 1e3, _ = r.lcv || 0, U = Math.round(e * _ * c * 1e3) / 1e3;
return { ghg: I, ghg2: u, euas: h, price: a, year: l, radio: f, cost: G, energy: U, lcv: _, wtt: S, ttw: d, co2: R, ch4: i, n2o: E };
}
/**
* 计算MRV及FuelEU
* @param fuels 按类型分组油耗类型及消耗
* @param year 年份
* @param price 碳税价格
* @param options
*/
static calculateGHGMRV2(e, t = 2025, a = 64.56, l = {}) {
let c = 0, n = 0, R = 0, i = 0, E = 0, r = 0;
const I = /* @__PURE__ */ new Map();
for (const C of e) {
const o = this.calculateGHGMRV(C.cons, C.type, a, t, C.areaRate, { requireId: l.requireId, factor: C.customFactor });
c = Math.round((c + o.ghg2) * 1e3) / 1e3, n = Math.round((n + o.euas) * 1e3) / 1e3, R = Math.round((R + o.cost) * 1e3) / 1e3, i = Math.round((i + o.energy) * 1e3) / 1e3, E = Math.round((E + o.wtt * o.energy) * 1e3) / 1e3, r = Math.round((r + o.ttw * o.energy) * 1e3) / 1e3;
const O = I.get(C.type) || {
cons: 0,
ghg2: 0,
euas: 0,
cost: 0,
energy: 0,
wtt: 0,
ttw: { total: 0, co2: 0, ch4: 0, n2o: 0 },
lcv: 0,
wtw: 0,
type: C.type,
wttEmission: 0,
ttwEmission: 0
};
O.cons = Math.round((O.cons + C.cons) * 1e3) / 1e3, O.ghg2 = Math.round((O.ghg2 + o.ghg2) * 1e3) / 1e3, O.euas = Math.round((O.euas + o.euas) * 1e3) / 1e3, O.cost = Math.round((O.cost + o.cost) * 1e3) / 1e3, O.energy = Math.round((O.energy + o.energy) * 1e3) / 1e3, O.lcv = o.lcv, O.wtt = o.wtt, O.ttw.total = o.ttw, O.ttw.co2 = o.co2.ttw, O.ttw.ch4 = o.ch4.ttw, O.ttw.n2o = o.n2o.ttw, O.wtw = Math.round((o.wtt + o.ttw) * 1e3) / 1e3, O.wttEmission = Math.round((O.wttEmission + o.wtt * o.energy) * 1e3) / 1e3, O.ttwEmission = Math.round((O.ttwEmission + o.ttw * o.energy) * 1e3) / 1e3, I.set(C.type, O);
}
const u = Array.from(I.values()), f = l.fwind || 1;
let h = 0, G = 0, S = 0, d = 0, _ = 0, U = 0;
return t >= 2025 && (h = Math.round(E / i * 1e3) / 1e3, G = Math.round(r / i * 1e3) / 1e3, S = Math.round(f * (h + G) * 1e3) / 1e3, d = this.calculateGHGITarget(t), _ = Math.round((d - S) * i * 1e3) / 1e3, U = _ < 0 ? Math.round(Math.abs(_ * 1e6) / (S * 41e3) * 2400 * 1e3) / 1e3 : 0), {
ghg2: c,
euas: n,
cost: R,
energy: i,
wtwEmission: Math.round((E + r) * 1e3) / 1e3,
wttGhgi: h,
ttwGhgi: G,
actualGhgi: S,
targetGhgi: d,
balance: _,
penalty: U,
fwind: f,
fuels: u
};
}
static calculateGHGITarget(e) {
let t = 91.16;
return e >= 2025 && (e >= 2050 ? t = t * (1 - 0.8) : e >= 2045 ? t = t * (1 - 0.62) : e >= 2040 ? t = t * (1 - 0.31) : e >= 2035 ? t = t * (1 - 0.145) : e >= 2030 ? t = t * (1 - 0.06) : t = t * (1 - 0.02)), Math.round(t * 1e3) / 1e3;
}
static async calculateEUMRVLegCategory(e, t, a = !1, l = {}) {
let c = "Non EU";
const n = {
departure: 0,
destination: 0,
atSea: 0
};
if (e && t) {
let R = await v.isInEU(e, l), i = await v.isInEU(t, l);
a && (R = R && !await v.isFuelEUExclude(e, l), i = i && !await v.isFuelEUExclude(t, l)), R && i ? (c = "Between EU", n.departure = 1, n.destination = 1, n.atSea = 1) : R ? (c = "Departed EU", n.departure = 1, n.destination = 0, n.atSea = 0.5) : i && (c = "Arrived EU", n.departure = 0, n.destination = 1, n.atSea = 0.5);
}
return { category: c, areaRate: n };
}
}
let w;
try {
w = B.getLogger("cii");
} catch {
} finally {
}
var Y = /* @__PURE__ */ ((s) => (s.BULK_CARRIER = "BULK CARRIER", s.GAS_CARRIER = "GAS CARRIER", s.TANKER = "TANKER", s.CONTAINER_SHIP = "CONTAINER SHIP", s.GENERAL_CARGO_SHIP = "GENERAL CARGO SHIP", s.REFRIGERATED_CARGO_CARRIER = "REFRIGERATED CARGO CARRIER", s.COMBINATION_CARRIER = "COMBINATION CARRIER", s.LNG_CARRIER = "LNG CARRIER", s.RO_RO_CARGO_SHIP = "RO-RO CARGO SHIP", s.RO_RO_CARGO_VEHICLE_SHIP = "RO-RO CARGO VEHICLE SHIP", s.RO_RO_PASSENGER_SHIP = "RO-RO PASSENGER SHIP", s.CRUISE_PASSENGER_SHIP = "CRUISE PASSENGER SHIP", s))(Y || {});
class P {
/**
* 船舶载运能力:dwt or gt
* @see https://docs.qq.com/pdf/DYWl3T1NuemNIZ0JJ?
* -对于散货船、液货船、集装箱船、气体运输船、LNG船、杂货船、冷藏货船和兼用船,
* 应使用载重吨(DWT)作为载运能力;
* -对于豪华邮轮、滚装货船(车辆运输船)、滚装货船及滚装客船,应使用总吨(GT)作
* 为载运能力;
* @param props
* @param options
*/
static calculateCapacity(e, t = {}) {
var n;
const a = ((n = e.type) == null ? void 0 : n.toUpperCase()) || "BULK CARRIER", l = [
"BULK CARRIER",
"GAS CARRIER",
"TANKER",
"CONTAINER SHIP",
"GENERAL CARGO SHIP",
"REFRIGERATED CARGO CARRIER",
"LNG CARRIER",
"COMBINATION CARRIER"
/* COMBINATION_CARRIER */
], c = [
"RO-RO CARGO SHIP",
"RO-RO CARGO VEHICLE SHIP",
"RO-RO PASSENGER SHIP",
"CRUISE PASSENGER SHIP"
/* CRUISE_PASSENGER_SHIP */
];
return l.includes(a) ? (w.info("[%s] use dwt as the vessel capacity: %s", t.requestId, e), e.dwt) : c.includes(a) ? (w.info("[%s] use gt as the vessel capacity: %s", t.requestId, e), e.gt) : (w.info("[%s] use max(gt,dwt) as the vessel capacity: %s", t.requestId, e), e.dwt > e.gt ? e.dwt : e.gt);
}
/**
* CII基准(2019)
* @see https://docs.qq.com/pdf/DYXRJSkNJbmJQZFJu?
* 3.1 考虑到2008年的数据有限,以2019年船型营运碳强度性能为基准。
* 3.2 对于规定的一组船舶,基线的公式如下:
* CIIref =aCapacity-c
* 单位是 g/(dwt⋅nmile) 或 g/(gt⋅nmile)
*
* 式中CIIref系指2019年的基准值,Capacity与某一船型特定碳强度指标(CII)规定的值相
* 同,见表1;a和c系指通过中值回归拟合所估算的参数,以2019年通过IMODCS收集的
* attainedCII和单个船舶的Capacity为样本。
*
* @param props
* @param options
*/
static calculateReferCII(e, t = {}) {
var i, E;
const a = P.calculateCapacity(e, t), l = ((E = (i = e.type) == null ? void 0 : i.trim()) == null ? void 0 : E.toUpperCase()) || "BULK CARRIER";
let c = 0, n = 0;
l === "BULK CARRIER" ? (c = 4745, n = 0.622) : l === "GAS CARRIER" ? a >= 65e3 ? (c = Math.pow(14405, 7), n = 2.071) : (c = 8104, n = 0.639) : l === "TANKER" ? (c = 5247, n = 0.61) : l === "CONTAINER SHIP" ? (c = 1984, n = 0.489) : l === "GENERAL CARGO SHIP" ? a >= 2e4 ? (c = 31948, n = 0.792) : (c = 588, n = 0.3885) : l === "REFRIGERATED CARGO CARRIER" ? (c = 4600, n = 0.557) : l === "COMBINATION CARRIER" ? (c = 5119, n = 0.622) : l === "LNG CARRIER" ? a >= 1e5 ? (c = 9.827, n = 0) : (c = Math.pow(14479, 10), n = 2.673) : l === "RO-RO CARGO VEHICLE SHIP" ? a < 3e4 ? (c = 330, n = 0.329) : (c = 3627, n = 0.59) : l === "RO-RO CARGO SHIP" ? (c = 1967, n = 0.485) : l === "RO-RO PASSENGER SHIP" ? (c = 2023, n = 0.46) : l === "CRUISE PASSENGER SHIP" && (c = 930, n = 0.383);
const R = Math.round(c * Math.pow(a, -n) * 1e3) / 1e3;
return w.info("[%s] calculate refer cii (%d) with props: %j ", t.requestId, R, e), { referCii: R, referYear: 2019 };
}
/**
* 年度达标需求的cii, 已经按年份折减
* @see https://docs.qq.com/pdf/DYVRtWGlsUVdNcGlu?
* 按照MARPOL附则VI第28条,对船舶要求的年度营运CII折减因素计算如下:
* 要求的年度营运CII=(1–Z/100)×CIIR
* 式中CIIR是2019年的基准值,定义见《2021年营运碳强度指标基线指南(G2)》,Z
* 是2023年至2030年对船型要求的年度营运CII折减因素的一般参考,
*
* @param ref
* @param year
* @param options
*/
static calculateRequiredCII(e, t, a = {}) {
let l = 0;
t === 2020 ? l = 1 : t === 2021 ? l = 2 : t === 2022 ? l = 3 : t === 2023 ? l = 5 : t === 2024 ? l = 7 : t === 2025 ? l = 9 : t === 2026 && (l = 11);
const c = Math.round((1 - l / 100) * e * 1e3) / 1e3;
return w.info("[%s] calculate required cii (%d) with: %j", a.requestId, c, { year: t, ref: e }), { requiredCii: c, z: l, year: t, ref: e };
}
/**
* 计算CO2, 注意需要换算为: g
* @param cons 油耗, 单位: mt
* @param type
* @param options
*/
static calculateCO2(e, t, a = {}) {
const { mrv: l } = W.calculateCO2MRV(e, t, a.customFactor, a);
return l * Math.pow(10, 6);
}
/**
* 计算当前实际CII
* @see https://docs.qq.com/pdf/DYWl3T1NuemNIZ0JJ?
* ,单个船舶每年可达到的营运CII是按某一给定日历年内所排放的CO2总质量
* (M)与所承担的总运输功(W)之比计算的
* @param props
* @param co2 co2总质量(g)
* @param distance 航行距离(nm)
* @param options
*/
static calculateAttainedCII(e, t, a, l = {}) {
const c = P.calculateCapacity(e, l), n = c * a, R = n ? Math.round(t / n * 1e3) / 1e3 : 0;
return w.info("[%s] calculate attained cii (%d) with: %j", l.requestId, R, { co2: t, distance: a, capacity: c }), { attainedCii: R, w: n, c: t };
}
/**
* 计算营运碳强度等级
* @see https://docs.qq.com/pdf/DYWhnWUJIeGZBRUhw?
*
* @param props
* @param requiredCii
* @param attainedCii
* @param options
*/
static calculateGrade(e, t, a, l = {}) {
var S, d;
const c = P.calculateCapacity(e, l);
let n = 0, R = 0, i = 0, E = 0;
const r = ((d = (S = e.type) == null ? void 0 : S.trim()) == null ? void 0 : d.toUpperCase()) || "BULK CARRIER";
r === "BULK CARRIER" ? (n = 0.86, R = 0.94, i = 1.06, E = 1.18) : r === "GAS CARRIER" ? c >= 65e3 ? (n = 0.81, R = 0.91, i = 1.12, E = 1.44) : (n = 0.85, R = 0.95, i = 1.06, E = 1.25) : r === "TANKER" ? (n = 0.82, R = 0.93, i = 1.08, E = 1.28) : r === "CONTAINER SHIP" ? (n = 0.83, R = 0.94, i = 1.07, E = 1.19) : r === "GENERAL CARGO SHIP" ? (n = 0.83, R = 0.94, i = 1.06, E = 1.19) : r === "REFRIGERATED CARGO CARRIER" ? (n = 0.78, R = 0.91, i = 1.07, E = 1.2) : r === "COMBINATION CARRIER" ? (n = 0.87, R = 0.96, i = 1.06, E = 1.14) : r === "LNG CARRIER" ? c >= 1e5 ? (n = 0.89, R = 0.98, i = 1.06, E = 1.13) : (n = 0.78, R = 0.92, i = 1.1, E = 1.37) : r === "RO-RO CARGO VEHICLE SHIP" ? (n = 0.86, R = 0.94, i = 1.06, E = 1.16) : r === "RO-RO CARGO SHIP" ? (n = 0.76, R = 0.89, i = 1.08, E = 1.27) : r === "RO-RO PASSENGER SHIP" ? (n = 0.76, R = 0.92, i = 1.14, E = 1.3) : r === "CRUISE PASSENGER SHIP" ? (n = 0.87, R = 0.95, i = 1.06, E = 1.16) : (n = 0.86, R = 0.94, i = 1.06, E = 1.18);
let I;
const u = t * n, f = t * R, h = t * i, G = t * E;
return a <= u ? I = "A" : a <= f ? I = "B" : a <= h ? I = "C" : a <= G ? I = "D" : I = n ? "E" : "-", w.info("[%s] calculate level (%s) with: %j", l.requestId, I, { ...e, requiredCii: t, attainedCii: a, capacity: c, p1: u, p2: f, p3: h, p4: G }), { grade: I, attainedCii: a, requiredCii: t, capacity: c };
}
/**
* 计算CII
* @param props
* @param year
* @param co2 co2总质量(g)
* @param distance
* @param options
*/
static calculateCII(e, t, a, l, c = {}) {
const { attainedCii: n } = P.calculateAttainedCII(e, a, l, c), { referCii: R, referYear: i } = P.calculateReferCII(e, c), { requiredCii: E, z: r } = P.calculateRequiredCII(R, t, c), { grade: I, capacity: u } = P.calculateGrade(e, E, n, c);
return { grade: I, attainedCii: n, requiredCii: E, referYear: i, year: t, z: r, capacity: u };
}
}
export {
P as CIIHelper,
b as EUMRVLegCategory,
W as EUTESHelper,
v as EuBoundHelper,
x as FuelType,
M as GHGEmissionFactor,
T as GWP_AR4,
D as GWP_AR5,
Y as VesselType,
V as WindRewardFactor,
K as YearRadio
};