@open3cl/engine 1.8.30 → 1.8.31

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/9_conso_ch.js CHANGED
@@ -59,6 +59,11 @@ function coef_ch(Fch) {
59
59
  };
60
60
  }
61
61
 
62
+ /**
63
+ * Calcule la consommation de chauffage du générateur (di.conso_ch, di.conso_ch_depensier).
64
+ * @return {number} besoin de chauffage effectivement couvert par le générateur (kWh), utilisé
65
+ * pour ses auxiliaires de génération (§15.1 : Caux_g = Paux_g × Bch_générateur / Pn)
66
+ */
62
67
  export function conso_ch(
63
68
  di,
64
69
  de,
@@ -94,7 +99,7 @@ export function conso_ch(
94
99
 
95
100
  switch (cfg_ch) {
96
101
  case 'installation de chauffage collectif avec base + appoint': {
97
- calc_ch_base_appoint(
102
+ return calc_ch_base_appoint(
98
103
  di,
99
104
  de,
100
105
  bch,
@@ -111,7 +116,6 @@ export function conso_ch(
111
116
  ilpa,
112
117
  tbase
113
118
  );
114
- break;
115
119
  }
116
120
  case 'convecteurs bi-jonction': {
117
121
  // Installation individuelle
@@ -136,7 +140,7 @@ export function conso_ch(
136
140
  di.conso_ch = consoInd.conso_ch + consoColl.conso_ch;
137
141
  di.conso_ch_depensier = consoInd.conso_ch_dep + consoColl.conso_ch_dep;
138
142
 
139
- break;
143
+ return bch;
140
144
  }
141
145
  default: {
142
146
  const { conso_ch, conso_ch_dep } = calc_conso_ch_default(
@@ -155,7 +159,12 @@ export function conso_ch(
155
159
  );
156
160
  di.conso_ch = conso_ch;
157
161
  di.conso_ch_depensier = conso_ch_dep;
158
- break;
162
+ /**
163
+ * Part du besoin couverte par le générateur selon la configuration (ex. 0,75 / 0,25 pour une
164
+ * chaudière en relève d'une chaudière bois, 0,8 / 0,2 pour une chaudière en relève de PAC).
165
+ * Les PAC hybrides ont déjà leur part (prorata de zone) dans bch.
166
+ */
167
+ return isPacHybride(de.enum_type_generateur_ch_id) ? bch : coef * bch;
159
168
  }
160
169
  }
161
170
  }
@@ -224,6 +233,12 @@ function calc_ch_base_appoint(
224
233
  ilpa,
225
234
  tbase
226
235
  ) {
236
+ /**
237
+ * Besoin couvert par le générateur : part de base (pos 0) ou d'appoint (bch - base), au prorata
238
+ * de la surface de ses émetteurs. Autotest CSTB APP3-0-3 : chaudière bois en base (Tribu
239
+ * Bgen = 3108,34 kWh, Qaux_ch = 13,27 kWh), générateur d'air chaud en appoint (Qaux_ch = 0).
240
+ */
241
+ let besoinCouvert = 0;
227
242
  if (bch > 0) {
228
243
  let bch_base = 0;
229
244
 
@@ -296,15 +311,28 @@ function calc_ch_base_appoint(
296
311
  }
297
312
  if (!isAppoint) {
298
313
  const ratio_s_em = em.donnee_entree.surface_chauffee / de.surface_chauffee;
314
+ besoinCouvert = ratio_s_em * (bch_base / 1000);
299
315
  di.conso_ch = (ratio_s_em * (bch_base / 1000) * Ich * Int) / Rend;
300
316
  } else {
301
317
  const ratio_s_em =
302
318
  em.donnee_entree.surface_chauffee / emAppoint.donnee_entree.surface_chauffee;
319
+ besoinCouvert = ratio_s_em * (bch - bch_base / 1000);
303
320
  di.conso_ch = (ratio_s_em * (bch - bch_base / 1000) * Int * Ich) / Rend;
304
321
  }
305
322
 
306
323
  di.conso_ch = Math.max(di.conso_ch, 0);
307
324
  }
325
+ return Math.max(besoinCouvert, 0);
326
+ }
327
+
328
+ /**
329
+ * PAC hybride (partie PAC ou partie chaudière) : enum_type_generateur_ch_id 145 à 170.
330
+ * @param typeGenerateurId {string|number}
331
+ * @return {boolean}
332
+ */
333
+ export function isPacHybride(typeGenerateurId) {
334
+ const id = Number.parseInt(typeGenerateurId);
335
+ return id >= 145 && id <= 170;
308
336
  }
309
337
 
310
338
  function getEmetteursFromGenerateur(de, em_filt, pos, cfg_ch) {
@@ -50,7 +50,7 @@ vi.mock('./enums.js', () => ({
50
50
  }
51
51
  }));
52
52
 
53
- const { conso_ch } = await import('./9_conso_ch.js');
53
+ const { conso_ch, isPacHybride } = await import('./9_conso_ch.js');
54
54
  const { default: tvs } = await import('./tv.js');
55
55
  const { requestInputID } = await import('./utils.js');
56
56
  const { rendement_emission } = await import('./9_emetteur_ch.js');
@@ -366,7 +366,7 @@ describe('conso_ch - installation collective base + appoint', () => {
366
366
  s_chauffee_inst,
367
367
  gen_ch_list
368
368
  ] = baseAppointArgs(pos, opts);
369
- conso_ch(
369
+ di.besoinCouvert = conso_ch(
370
370
  di,
371
371
  de,
372
372
  {},
@@ -401,6 +401,23 @@ describe('conso_ch - installation collective base + appoint', () => {
401
401
  expect(di.conso_ch).toBeCloseTo(55.55555555555556, 9);
402
402
  });
403
403
 
404
+ /**
405
+ * Besoin couvert retourné (auxiliaires de génération, §15.1) : base = Σ besoin de base (kWh),
406
+ * appoint = bch - base ; la somme vaut le besoin de l'installation (50 kWh).
407
+ */
408
+ test('besoin couvert : part de base (pos 0) et part d’appoint (pos 1) = besoin total', () => {
409
+ const base = callBaseAppoint(0).besoinCouvert;
410
+ const appoint = callBaseAppoint(1).besoinCouvert;
411
+ // référence de régression
412
+ expect(base).toBeCloseTo(5, 9);
413
+ expect(appoint).toBeCloseTo(45, 9);
414
+ expect(base + appoint).toBeCloseTo(50, 9);
415
+ });
416
+
417
+ test('besoin couvert nul quand la part de base calculée est nulle', () => {
418
+ expect(callBaseAppoint(0, { pn: 100 }).besoinCouvert).toBe(0);
419
+ });
420
+
404
421
  test('puissance nulle (pe = 0) : le besoin de base est forfaitairement la moitié du besoin', () => {
405
422
  const di = callBaseAppoint(0, { pn: 0 });
406
423
  // pe = 0 => bch_base_j = besoin_ch_mois * 0.5 sur chaque mois
@@ -509,3 +526,106 @@ describe('conso_ch - installation collective base + appoint', () => {
509
526
  expect(di.conso_ch).toBeUndefined();
510
527
  });
511
528
  });
529
+
530
+ /**
531
+ * Besoin couvert par le générateur (retour de conso_ch), utilisé pour ses auxiliaires de
532
+ * génération (§15.1 : Caux_g = Paux_g × Bch_générateur / Pn).
533
+ * Autotests CSTB APP5-0-5 (relève de PAC, 0,8 / 0,2) et IC4-0-1 (relève d'une chaudière bois,
534
+ * 0,75 / 0,25).
535
+ * @see : Methode_de_calcul_3CL_DPE_2021-338.pdf - §9 et §15.1
536
+ */
537
+ describe('conso_ch - besoin couvert par le générateur', () => {
538
+ beforeEach(() => {
539
+ vi.mocked(requestInputID).mockReset();
540
+ vi.mocked(rendement_emission).mockReset();
541
+ vi.mocked(calc_intermittence).mockReset();
542
+ vi.mocked(rendement_emission).mockReturnValue(0.8);
543
+ vi.mocked(calc_intermittence).mockImplementation((_gv, _sh, _hsp, i0) => i0);
544
+ });
545
+
546
+ function appel(de, pos, cfg, bch = 1000) {
547
+ const di = { rg: 1, rg_dep: 1 };
548
+ return conso_ch(
549
+ di,
550
+ { surface_chauffee: 100, ...de },
551
+ {},
552
+ pos,
553
+ cfg,
554
+ [emetteur(1)],
555
+ 150,
556
+ 100,
557
+ 2.5,
558
+ bch,
559
+ 2 * bch,
560
+ -9.5,
561
+ 0,
562
+ 1,
563
+ 1
564
+ );
565
+ }
566
+
567
+ test.each([
568
+ ['installation de chauffage avec chaudière en relève de pac', 0, 800],
569
+ ['installation de chauffage avec chaudière en relève de pac', 1, 200],
570
+ [
571
+ 'installation de chauffage avec une chaudière ou une pac en relève d’une chaudière bois',
572
+ 0,
573
+ 750
574
+ ],
575
+ [
576
+ 'installation de chauffage avec une chaudière ou une pac en relève d’une chaudière bois',
577
+ 1,
578
+ 250
579
+ ],
580
+ ['installation de chauffage simple', 0, 1000]
581
+ ])('%s, position %i : besoin couvert = coefficient × besoin (%d)', (cfg, pos, attendu) => {
582
+ expect(appel({ enum_type_generateur_ch_id: '10' }, pos, cfg)).toBeCloseTo(attendu, 9);
583
+ });
584
+
585
+ test('PAC hybride : part déjà appliquée au besoin, pas de second coefficient', () => {
586
+ const cfg = 'installation de chauffage avec chaudière en relève de pac';
587
+ expect(appel({ enum_type_generateur_ch_id: '148' }, 1, cfg)).toBe(1000);
588
+ });
589
+
590
+ test('convecteurs bi-jonction : tout le besoin est couvert', () => {
591
+ expect(appel({ enum_type_generateur_ch_id: '10' }, 0, 'convecteurs bi-jonction')).toBe(1000);
592
+ });
593
+
594
+ test('base + appoint collectif : besoin nul => besoin couvert nul', () => {
595
+ const di = { rg: 1, rg_dep: 1, pn: 0 };
596
+ const couvert = conso_ch(
597
+ di,
598
+ { surface_chauffee: 100, enum_type_generateur_ch_id: '10' },
599
+ {},
600
+ 0,
601
+ 'installation de chauffage collectif avec base + appoint',
602
+ [emetteur(1)],
603
+ 150,
604
+ 100,
605
+ 2.5,
606
+ 0,
607
+ 0,
608
+ -9.5,
609
+ 0,
610
+ 1,
611
+ 1,
612
+ { Janvier: 0, Février: 0 },
613
+ 100,
614
+ []
615
+ );
616
+ expect(couvert).toBe(0);
617
+ });
618
+ });
619
+
620
+ describe('isPacHybride', () => {
621
+ test.each([
622
+ ['145', true],
623
+ [170, true],
624
+ ['148', true],
625
+ ['144', false],
626
+ ['171', false],
627
+ [undefined, false]
628
+ ])('type %s : %s', (id, attendu) => {
629
+ expect(isPacHybride(id)).toBe(attendu);
630
+ });
631
+ });
@@ -249,8 +249,6 @@ export function calc_generateur_ch(
249
249
  tv_rendement_generation(di, de, du);
250
250
  }
251
251
 
252
- conso_aux_gen(di, de, 'ch', bch, bch_dep);
253
-
254
252
  /**
255
253
  * 15 Calcul des consommations d’auxiliaires des installations de chauffage (Caux_ch) et d’ECS (Caux_ecs)
256
254
  */
@@ -258,7 +256,7 @@ export function calc_generateur_ch(
258
256
  conso_aux_distribution_ch(em_ch, de, di, du, Sh, zc_id, ca_id, ilpa, GV);
259
257
  }
260
258
  const paroi_ancienne = isParoisAncienneInertieLourde(dpe);
261
- conso_ch(
259
+ const besoinCouvert = conso_ch(
262
260
  di,
263
261
  de,
264
262
  du,
@@ -279,6 +277,17 @@ export function calc_generateur_ch(
279
277
  gen_ch_list
280
278
  );
281
279
 
280
+ /**
281
+ * 15.1 Auxiliaires de génération : Caux_g = Paux_g × Bch / Pn, avec Bch le besoin couvert par
282
+ * ce générateur (part de base / d'appoint, relève), et non le besoin de toute l'installation.
283
+ * Autotests CSTB APP5-0-5 (chaudière fioul en relève de PAC, Tribu Qaux_ch = 2,13 kWh) et
284
+ * IC4-0-1 (chaudière en relève d'une chaudière bois).
285
+ * @see : Methode_de_calcul_3CL_DPE_2021-338.pdf - §15.1
286
+ */
287
+ const besoinGenerateur = besoinCouvert ?? bch;
288
+ const besoinGenerateurDep = bch > 0 ? (bch_dep * besoinGenerateur) / bch : 0;
289
+ conso_aux_gen(di, de, 'ch', besoinGenerateur, besoinGenerateurDep);
290
+
282
291
  gen_ch.donnee_intermediaire = di;
283
292
  gen_ch.donnee_utilisateur = du;
284
293
  }
@@ -602,3 +602,71 @@ describe('calc_generateur_ch - orchestration du calcul générateur', () => {
602
602
  expect(gen.donnee_utilisateur).toBeDefined();
603
603
  });
604
604
  });
605
+
606
+ /**
607
+ * 15.1 Auxiliaires de génération : Caux_g = Paux_g × Bch_générateur / Pn, avec le besoin
608
+ * effectivement couvert par le générateur (retourné par conso_ch : part de relève, de base ou
609
+ * d'appoint) et non le besoin de toute l'installation.
610
+ * Autotest CSTB APP5-0-5 : chaudière fioul en relève de PAC (part 0,2), Tribu Qaux_ch = 2,13 kWh.
611
+ * @see : Methode_de_calcul_3CL_DPE_2021-338.pdf - §15.1
612
+ */
613
+ describe('calc_generateur_ch - besoin couvert transmis aux auxiliaires de génération', () => {
614
+ const dpe = {
615
+ logement: {
616
+ enveloppe: { inertie: { enum_classe_inertie_id: '3' }, mur_collection: { mur: [] } }
617
+ }
618
+ };
619
+
620
+ function appel(gen, bch, bchDep) {
621
+ calc_generateur_ch(
622
+ dpe,
623
+ gen,
624
+ 1,
625
+ [{ donnee_entree: { enum_lien_generateur_emetteur_id: '1' } }],
626
+ 'installation de chauffage avec chaudière en relève de pac',
627
+ bch,
628
+ bchDep,
629
+ 150,
630
+ 100,
631
+ 2.5,
632
+ 1,
633
+ 1,
634
+ 0,
635
+ -9.5,
636
+ {},
637
+ 100,
638
+ [gen]
639
+ );
640
+ }
641
+
642
+ test('relève : besoin couvert (part 0,2) et dépensier au même prorata', () => {
643
+ vi.mocked(conso_ch).mockReturnValue(200);
644
+ const gen = { donnee_entree: { enum_type_generateur_ch_id: '1' }, donnee_intermediaire: {} };
645
+ appel(gen, 1000, 1500);
646
+ expect(conso_aux_gen).toHaveBeenCalledWith(
647
+ gen.donnee_intermediaire,
648
+ gen.donnee_entree,
649
+ 'ch',
650
+ 200,
651
+ 300
652
+ );
653
+ // les auxiliaires de génération sont calculés après la consommation du générateur
654
+ expect(vi.mocked(conso_ch).mock.invocationCallOrder[0]).toBeLessThan(
655
+ vi.mocked(conso_aux_gen).mock.invocationCallOrder[0]
656
+ );
657
+ });
658
+
659
+ test('conso_ch sans besoin couvert retourné : repli sur le besoin transmis', () => {
660
+ vi.mocked(conso_ch).mockReturnValue(undefined);
661
+ const gen = { donnee_entree: { enum_type_generateur_ch_id: '1' }, donnee_intermediaire: {} };
662
+ appel(gen, 1000, 1500);
663
+ expect(vi.mocked(conso_aux_gen).mock.calls[0].slice(2)).toEqual(['ch', 1000, 1500]);
664
+ });
665
+
666
+ test('besoin nul : besoin dépensier nul (pas de division par zéro)', () => {
667
+ vi.mocked(conso_ch).mockReturnValue(0);
668
+ const gen = { donnee_entree: { enum_type_generateur_ch_id: '1' }, donnee_intermediaire: {} };
669
+ appel(gen, 0, 0);
670
+ expect(vi.mocked(conso_aux_gen).mock.calls[0].slice(2)).toEqual(['ch', 0, 0]);
671
+ });
672
+ });
package/engine.js CHANGED
@@ -33,7 +33,7 @@ import getFicheTechnique from './ficheTechnique.js';
33
33
  import { ProductionENR } from './16.2_production_enr.js';
34
34
  import DpeSanitizerService from './dpe-sanitizer.service.js';
35
35
 
36
- const LIB_VERSION = '1.8.30';
36
+ const LIB_VERSION = '1.8.31';
37
37
 
38
38
  const dpeSanitizerService = new DpeSanitizerService();
39
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open3cl/engine",
3
- "version": "1.8.30",
3
+ "version": "1.8.31",
4
4
  "description": "Open Source 3CL-DPE engine",
5
5
  "main": "index.js",
6
6
  "directories": {