@open3cl/engine 1.0.13 → 1.0.15

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.
Files changed (30) hide show
  1. package/13.2_generateur_combustion_ch.js +1 -1
  2. package/features/dpe/domain/models/climatisation.model.ts +1 -0
  3. package/features/dpe/domain/models/installation-chauffage.model.ts +24 -0
  4. package/features/dpe/domain/models/type-generateur.model.js +8 -0
  5. package/features/dpe/infrastructure/ch/chTv.store.js +94 -0
  6. package/features/dpe/infrastructure/ch/chTv.store.spec.js +99 -0
  7. package/features/dpe/infrastructure/ecs/ecsTv.store.js +5 -3
  8. package/features/dpe/infrastructure/ecs/ecsTv.store.spec.js +4 -0
  9. package/features/dpe/infrastructure/froid/frTv.store.js +27 -0
  10. package/features/dpe/infrastructure/froid/frTv.store.spec.js +22 -0
  11. package/features/dpe/infrastructure/tv.store.js +28 -0
  12. package/features/dpe/infrastructure/tv.store.spec.js +12 -0
  13. package/features/engine/domain/apport_et_besoin/apport-et-besoin.service.js +14 -0
  14. package/features/engine/domain/apport_et_besoin/apport-et-besoin.service.spec.js +14 -0
  15. package/features/engine/domain/ch/emetteur-ch.service.js +100 -0
  16. package/features/engine/domain/ch/emetteur-ch.service.spec.js +78 -0
  17. package/features/engine/domain/ch/generateur-ch.service.js +365 -0
  18. package/features/engine/domain/ch/generateur-ch.service.spec.js +734 -0
  19. package/features/engine/domain/ch/installation-ch.service.js +39 -0
  20. package/features/engine/domain/ch/installation-ch.service.spec.js +41 -0
  21. package/features/engine/domain/conso/conso.service.js +26 -0
  22. package/features/engine/domain/conso/conso.service.spec.js +29 -0
  23. package/features/engine/domain/conso/froid/conso-froid.service.js +94 -0
  24. package/features/engine/domain/conso/froid/conso-froid.service.spec.js +152 -0
  25. package/features/engine/domain/contexte.builder.js +1 -0
  26. package/features/engine/domain/contexte.builder.spec.js +2 -0
  27. package/features/engine/domain/ecs/generateur-ecs.service.js +2 -2
  28. package/features/engine/domain/engine.service.js +10 -0
  29. package/features/engine/domain/models/contexte.model.ts +1 -0
  30. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ import { inject } from 'dioma';
2
+ import { GenerateurChService } from './generateur-ch.service.js';
3
+
4
+ /**
5
+ * Calcul des installations de chauffage
6
+ *
7
+ * @see Méthode de calcul 3CL-DPE 2021 (cotobre 2021) chapitre 3
8
+ */
9
+ export class InstallationChService {
10
+ /**
11
+ * @type {GenerateurChService}
12
+ */
13
+ #generateurChService;
14
+
15
+ /**
16
+ * @param generateurChService {GenerateurChService}
17
+ */
18
+ constructor(generateurChService = inject(GenerateurChService)) {
19
+ this.#generateurChService = generateurChService;
20
+ }
21
+
22
+ /**
23
+ * Détermination des données des installations de chauffage
24
+ *
25
+ * @param ctx {Contexte}
26
+ * @param logement {Logement}
27
+ */
28
+ execute(ctx, logement) {
29
+ const installationsChauffage =
30
+ logement.installation_chauffage_collection?.installation_chauffage || [];
31
+
32
+ installationsChauffage.forEach((installationChauffage) => {
33
+ /**
34
+ * Calcul des données nécessaires au calcul pour chaque générateur (qp0)
35
+ */
36
+ this.#generateurChService.execute(ctx, logement, installationChauffage);
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,41 @@
1
+ import { beforeEach, describe, expect, test, vi } from 'vitest';
2
+ import { InstallationChService } from './installation-ch.service.js';
3
+ import { GenerateurChService } from './generateur-ch.service.js';
4
+
5
+ /** @type {InstallationChService} **/
6
+ let service;
7
+
8
+ /** @type {GenerateurChService} **/
9
+ let generateurChService;
10
+
11
+ describe('Calcul des installations de chauffage', () => {
12
+ beforeEach(() => {
13
+ generateurChService = new GenerateurChService();
14
+ service = new InstallationChService(generateurChService);
15
+ });
16
+
17
+ test('Calcul des données des générateurs de chaque installation de chauffage', () => {
18
+ vi.spyOn(generateurChService, 'execute').mockReturnThis();
19
+
20
+ /** @type {InstallationChauffage} */
21
+ const installationCh = {
22
+ donnee_entree: { enum_type_installation_id: 1 },
23
+ generateur_chauffage_collection: {
24
+ generateur_chauffage: [{ donnee_entree: { position_volume_chauffe_stockage: 1 } }]
25
+ }
26
+ };
27
+
28
+ /** @type {Logement} */
29
+ const logement = {
30
+ installation_chauffage_collection: { installation_chauffage: [installationCh] }
31
+ };
32
+
33
+ /** @type {Contexte} */
34
+ const ctx = {
35
+ zoneClimatique: { id: 1 }
36
+ };
37
+
38
+ service.execute(ctx, logement);
39
+ expect(generateurChService.execute).toHaveBeenCalledWith(ctx, logement, installationCh);
40
+ });
41
+ });
@@ -0,0 +1,26 @@
1
+ import { inject } from 'dioma';
2
+ import { ConsoFroidService } from './froid/conso-froid.service.js';
3
+
4
+ export class ConsoService {
5
+ /**
6
+ * @type {ConsoFroidService}
7
+ */
8
+ #consoFroidService;
9
+
10
+ /**
11
+ * @param consoFroidService {ConsoFroidService}
12
+ */
13
+ constructor(consoFroidService = inject(ConsoFroidService)) {
14
+ this.#consoFroidService = consoFroidService;
15
+ }
16
+
17
+ /**
18
+ * Calcul des consommations
19
+ *
20
+ * @param ctx {Contexte}
21
+ * @param logement {Logement}
22
+ */
23
+ execute(ctx, logement) {
24
+ this.#consoFroidService.execute(ctx, logement);
25
+ }
26
+ }
@@ -0,0 +1,29 @@
1
+ import { beforeEach, describe, expect, test, vi } from 'vitest';
2
+ import { ConsoFroidService } from './froid/conso-froid.service.js';
3
+ import { ConsoService } from './conso.service.js';
4
+
5
+ /** @type {ConsoService} **/
6
+ let service;
7
+
8
+ /** @type {ConsoFroidService} **/
9
+ let consoFroidService;
10
+
11
+ describe('Calcul des consos du logement', () => {
12
+ beforeEach(() => {
13
+ consoFroidService = new ConsoFroidService();
14
+ service = new ConsoService(consoFroidService);
15
+ });
16
+
17
+ test('Determination des consommmations du logement', () => {
18
+ vi.spyOn(consoFroidService, 'execute').mockReturnThis();
19
+
20
+ /** @type {Contexte} */
21
+ const ctx = { zoneClimatique: { id: 1 }, nadeq: 2.5 };
22
+ /** @type { Logement } **/
23
+ const logement = { enveloppe: {} };
24
+
25
+ service.execute(ctx, logement);
26
+
27
+ expect(consoFroidService.execute).toHaveBeenCalledWith(ctx, logement);
28
+ });
29
+ });
@@ -0,0 +1,94 @@
1
+ import { inject } from 'dioma';
2
+ import { FrTvStore } from '../../../../dpe/infrastructure/froid/frTv.store.js';
3
+
4
+ /**
5
+ * Calcul de la consommation en froid
6
+ * Chapitre 10.3 - Les consommations de refroidissement
7
+ *
8
+ * Methode_de_calcul_3CL_DPE_2021 - Page 69
9
+ * Octobre 2021
10
+ * @see consolide_anne…arrete_du_31_03_2021_relatif_aux_methodes_et_procedures_applicables.pdf
11
+ */
12
+ export class ConsoFroidService {
13
+ /**
14
+ * @type {FrTvStore}
15
+ */
16
+ #frStore;
17
+
18
+ /**
19
+ * @param frStore {FrTvStore}
20
+ */
21
+ constructor(frStore = inject(FrTvStore)) {
22
+ this.#frStore = frStore;
23
+ }
24
+
25
+ /**
26
+ * @param ctx {Contexte}
27
+ * @param logement {Logement}
28
+ * @return {{besoin_fr: number, besoin_fr_depensier: number}}
29
+ */
30
+ execute(ctx, logement) {
31
+ const climatisations = logement.climatisation_collection?.climatisation || [];
32
+
33
+ climatisations.forEach((climatisation) => {
34
+ const consos = this.consoFroid(ctx, logement.sortie.apport_et_besoin, climatisation);
35
+
36
+ climatisation.donnee_intermediaire ??= {};
37
+ climatisation.donnee_intermediaire.besoin_fr = consos.besoin_fr;
38
+ climatisation.donnee_intermediaire.besoin_fr_depensier = consos.besoin_fr_depensier;
39
+ climatisation.donnee_intermediaire.conso_fr = consos.conso_fr;
40
+ climatisation.donnee_intermediaire.conso_fr_depensier = consos.conso_fr_depensier;
41
+ });
42
+ }
43
+
44
+ /**
45
+ * Calcul de la consommation en froid d'un système de refroidissement
46
+ *
47
+ * @param ctx {Contexte}
48
+ * @param apportEtBesoin {ApportEtBesoin}
49
+ * @param climatisation {Climatisation}
50
+ * @returns {{besoin_fr: number, besoin_fr_depensier: number, conso_fr: number, conso_fr_depensier: number}}
51
+ */
52
+ consoFroid(ctx, apportEtBesoin, climatisation) {
53
+ let eer;
54
+
55
+ /** @type {ClimatisationDE} **/
56
+ const climatisationDE = climatisation.donnee_entree;
57
+
58
+ /** @type {ClimatisationDI} **/
59
+ const climatisationDI = climatisation.donnee_intermediaire || {};
60
+
61
+ const ratioSurfaceClimatisation =
62
+ (climatisationDE.surface_clim || ctx.surfaceHabitable) / ctx.surfaceHabitable;
63
+ const besoin_fr = apportEtBesoin.besoin_fr * ratioSurfaceClimatisation;
64
+ const besoin_fr_depensier = apportEtBesoin.besoin_fr_depensier * ratioSurfaceClimatisation;
65
+
66
+ /**
67
+ * Si la méthode de saisie n'est pas "Valeur forfaitaire" mais "caractéristiques saisies"
68
+ * Documentation 3CL : "Pour les installations récentes ou recommandées, les caractéristiques réelles des chaudières présentées sur les bases
69
+ * de données professionnelles peuvent être utilisées."
70
+ *
71
+ * 6 - caractéristiques saisies à partir de la plaque signalétique ou d'une documentation technique du système thermodynamique : scop/cop/eer
72
+ * 7 - déterminé à partir du rset/rsee( etude rt2012/re2020)
73
+ * 8 - seer saisi pour permettre la saisie de réseau de froid ou de système de climatisations qui ne sont pas éléctriques
74
+ */
75
+ if (
76
+ ![6, 7, 8].includes(parseInt(climatisationDE.enum_methode_saisie_carac_sys_id)) ||
77
+ !climatisationDI.eer
78
+ ) {
79
+ eer = this.#frStore.getEer(
80
+ ctx.zoneClimatique.id,
81
+ parseInt(climatisationDE.enum_periode_installation_fr_id)
82
+ );
83
+ } else {
84
+ eer = climatisationDI.eer;
85
+ }
86
+
87
+ return {
88
+ besoin_fr,
89
+ besoin_fr_depensier,
90
+ conso_fr: (0.9 * besoin_fr) / eer,
91
+ conso_fr_depensier: (0.9 * besoin_fr_depensier) / eer
92
+ };
93
+ }
94
+ }
@@ -0,0 +1,152 @@
1
+ import { beforeEach, describe, expect, test, vi } from 'vitest';
2
+ import { DpeNormalizerService } from '../../../../normalizer/domain/dpe-normalizer.service.js';
3
+ import { ContexteBuilder } from '../../contexte.builder.js';
4
+ import corpus from '../../../../../../test/corpus-sano.json';
5
+ import { getAdemeFileJson } from '../../../../../../test/test-helpers.js';
6
+ import { FrTvStore } from '../../../../dpe/infrastructure/froid/frTv.store.js';
7
+ import { ConsoFroidService } from './conso-froid.service.js';
8
+
9
+ /** @type {ConsoFroidService} **/
10
+ let service;
11
+
12
+ /** @type {DpeNormalizerService} **/
13
+ let normalizerService;
14
+
15
+ /** @type {ContexteBuilder} **/
16
+ let contexteBuilder;
17
+
18
+ /** @type {FrTvStore} **/
19
+ let tvStore;
20
+
21
+ describe('Calcul des consos en froid du logement', () => {
22
+ beforeEach(() => {
23
+ tvStore = new FrTvStore();
24
+ service = new ConsoFroidService(tvStore);
25
+ normalizerService = new DpeNormalizerService();
26
+ contexteBuilder = new ContexteBuilder();
27
+ });
28
+
29
+ test.each([
30
+ {
31
+ label: 'Climatisation avec méthode de saisie 6, sans surface clim',
32
+ enumMethodeSaisieCaracSysId: 6,
33
+ eerInitial: 125,
34
+ expected: { conso_fr: 7.2, conso_fr_depensier: 10.8 }
35
+ },
36
+ {
37
+ label: 'Climatisation avec méthode de saisie 7, sans surface clim',
38
+ enumMethodeSaisieCaracSysId: 7,
39
+ eerInitial: 125,
40
+ expected: { conso_fr: 7.2, conso_fr_depensier: 10.8 }
41
+ },
42
+ {
43
+ label: 'Climatisation avec méthode de saisie 8, sans surface clim',
44
+ enumMethodeSaisieCaracSysId: 8,
45
+ eerInitial: 125,
46
+ expected: { conso_fr: 7.2, conso_fr_depensier: 10.8 }
47
+ },
48
+ {
49
+ label: 'Climatisation avec méthode de saisie 6, avec surface clim',
50
+ enumMethodeSaisieCaracSysId: 6,
51
+ eerInitial: 125,
52
+ surfaceClim: 80,
53
+ expected: { conso_fr: 5.76, conso_fr_depensier: 8.64 }
54
+ },
55
+ {
56
+ label: 'Climatisation avec méthode de saisie 7, avec surface clim',
57
+ enumMethodeSaisieCaracSysId: 7,
58
+ eerInitial: 125,
59
+ surfaceClim: 80,
60
+ expected: { conso_fr: 5.76, conso_fr_depensier: 8.64 }
61
+ },
62
+ {
63
+ label: 'Climatisation avec méthode de saisie 8, avec surface clim',
64
+ enumMethodeSaisieCaracSysId: 8,
65
+ eerInitial: 125,
66
+ surfaceClim: 80,
67
+ expected: { conso_fr: 5.76, conso_fr_depensier: 8.64 }
68
+ },
69
+ {
70
+ label: 'Climatisation avec méthode de saisie 5, sans surface clim',
71
+ enumMethodeSaisieCaracSysId: 5,
72
+ eer: 90,
73
+ expected: { conso_fr: 10, conso_fr_depensier: 15 }
74
+ },
75
+ {
76
+ label: 'Climatisation avec méthode de saisie 5, avec surface clim',
77
+ enumMethodeSaisieCaracSysId: 5,
78
+ eer: 90,
79
+ surfaceClim: 80,
80
+ expected: { conso_fr: 8, conso_fr_depensier: 12 }
81
+ }
82
+ ])(
83
+ 'Détermination des consommations des systèmes de refroidissement pour $label',
84
+ ({
85
+ enumMethodeSaisieCaracSysId,
86
+ surfaceClim = undefined,
87
+ eer = undefined,
88
+ eerInitial,
89
+ expected
90
+ }) => {
91
+ vi.spyOn(tvStore, 'getEer').mockReturnValue(eer);
92
+
93
+ /** @type {Contexte} */
94
+ const contexte = {
95
+ zoneClimatique: { id: 1 },
96
+ surfaceHabitable: 100
97
+ };
98
+
99
+ /** @type {Climatisation} */
100
+ const climatisation = {
101
+ donnee_entree: {
102
+ enum_methode_saisie_carac_sys_id: enumMethodeSaisieCaracSysId,
103
+ surface_clim: surfaceClim
104
+ },
105
+ donnee_intermediaire: { eer: eerInitial }
106
+ };
107
+
108
+ /** @type {ApportEtBesoin} */
109
+ const apportEtBesoin = {
110
+ besoin_fr: 1000,
111
+ besoin_fr_depensier: 1500
112
+ };
113
+
114
+ const consoFroid = service.consoFroid(contexte, apportEtBesoin, climatisation);
115
+ expect(consoFroid.conso_fr).toBeCloseTo(expected.conso_fr, 2);
116
+ expect(consoFroid.conso_fr_depensier).toBeCloseTo(expected.conso_fr_depensier, 2);
117
+ }
118
+ );
119
+
120
+ describe("Test d'intégration pour le besoin en froid", () => {
121
+ test.each(corpus)('vérification des sorties besoin_fr et conso_fr pour dpe %s', (ademeId) => {
122
+ /**
123
+ * @type {Dpe}
124
+ */
125
+ let dpeRequest = getAdemeFileJson(ademeId);
126
+ dpeRequest = normalizerService.normalize(dpeRequest);
127
+
128
+ /** @type {Contexte} */
129
+ const ctx = contexteBuilder.fromDpe(dpeRequest);
130
+
131
+ const climatisations = structuredClone(
132
+ dpeRequest.logement.climatisation_collection?.climatisation || []
133
+ );
134
+ service.execute(ctx, dpeRequest.logement);
135
+
136
+ climatisations.forEach((climatisation, i) => {
137
+ console.log('climatisation.donnee_intermediaire.besoin_fr');
138
+ expect(climatisation.donnee_intermediaire.besoin_fr).toBeCloseTo(
139
+ dpeRequest.logement.climatisation_collection.climatisation[i].donnee_intermediaire
140
+ .besoin_fr,
141
+ 2
142
+ );
143
+ console.log(climatisation.donnee_intermediaire.conso_fr);
144
+ expect(climatisation.donnee_intermediaire.conso_fr).toBeCloseTo(
145
+ dpeRequest.logement.climatisation_collection.climatisation[i].donnee_intermediaire
146
+ .conso_fr,
147
+ 2
148
+ );
149
+ });
150
+ });
151
+ });
152
+ });
@@ -36,6 +36,7 @@ export class ContexteBuilder {
36
36
  typeHabitation: this.#getTypeHabitation(caracteristiqueGenerale),
37
37
  typeDpe: typeDpe,
38
38
  enumPeriodeConstructionId: caracteristiqueGenerale.enum_periode_construction_id?.toString(),
39
+ anneeConstruction: parseInt(caracteristiqueGenerale.annee_construction),
39
40
  effetJoule: this.#hasEffetJoule(dpe),
40
41
  surfaceHabitable: surfaceHabitable,
41
42
  hauteurSousPlafond: caracteristiqueGenerale.hsp,
@@ -106,6 +106,7 @@ describe('Generateur du contexte du calcul', () => {
106
106
  enum_classe_altitude_id: 2
107
107
  },
108
108
  caracteristique_generale: {
109
+ annee_construction: 2005,
109
110
  enum_periode_construction_id: 4,
110
111
  surface_habitable_logement: 48.9,
111
112
  surface_habitable_immeuble: 105,
@@ -120,6 +121,7 @@ describe('Generateur du contexte du calcul', () => {
120
121
  surfaceHabitable: dpe.logement.caracteristique_generale.surface_habitable_logement,
121
122
  typeHabitation: TypeHabitation.MAISON,
122
123
  typeDpe: TypeDpe.MAISON,
124
+ anneeConstruction: 2005,
123
125
  enumPeriodeConstructionId: '4',
124
126
  hauteurSousPlafond: 2.8,
125
127
  nombreAppartement: 18,
@@ -21,12 +21,12 @@ export class GenerateurEcsService {
21
21
  }
22
22
 
23
23
  /**
24
- * Détermination des apports et besoins pour le bien concerné
24
+ * Détermination des données de calcul pour une installation ECS
25
25
  *
26
26
  * @param installationEcs {InstallationEcs}
27
27
  */
28
28
  execute(installationEcs) {
29
- const generateursEcs = installationEcs.generateur_ecs_collection.generateur_ecs || [];
29
+ const generateursEcs = installationEcs.generateur_ecs_collection?.generateur_ecs || [];
30
30
 
31
31
  generateursEcs.forEach((generateurEcs) => {
32
32
  /** @type {GenerateurEcsDE}*/
@@ -3,6 +3,7 @@ import { ContexteBuilder } from './contexte.builder.js';
3
3
  import { DeperditionEnveloppeService } from './enveloppe/deperdition-enveloppe.service.js';
4
4
  import { logger } from '../../../core/util/logger/log-service.js';
5
5
  import { ApportEtBesoinService } from './apport_et_besoin/apport-et-besoin.service.js';
6
+ import { ConsoService } from './conso/conso.service.js';
6
7
 
7
8
  export class EngineService {
8
9
  /**
@@ -15,6 +16,11 @@ export class EngineService {
15
16
  */
16
17
  #apportEtBesoinService;
17
18
 
19
+ /**
20
+ * @type {ConsoService}
21
+ */
22
+ #consoService;
23
+
18
24
  /**
19
25
  * @type {ContexteBuilder}
20
26
  */
@@ -23,15 +29,18 @@ export class EngineService {
23
29
  /**
24
30
  * @param deperditionService {DeperditionEnveloppeService}
25
31
  * @param apportEtBesoinService {ApportEtBesoinService}
32
+ * @param consoService {ConsoService}
26
33
  * @param contextBuilder {ContexteBuilder}
27
34
  */
28
35
  constructor(
29
36
  deperditionService = inject(DeperditionEnveloppeService),
30
37
  apportEtBesoinService = inject(ApportEtBesoinService),
38
+ consoService = inject(ConsoService),
31
39
  contextBuilder = inject(ContexteBuilder)
32
40
  ) {
33
41
  this.#deperditionService = deperditionService;
34
42
  this.#apportEtBesoinService = apportEtBesoinService;
43
+ this.#consoService = consoService;
35
44
  this.#contextBuilder = contextBuilder;
36
45
  }
37
46
 
@@ -98,6 +107,7 @@ export class EngineService {
98
107
  // Calcul des consommations chauffage
99
108
 
100
109
  // Calcul des consommations de froid
110
+ this.#consoService.execute(ctx, proceededDpe.logement);
101
111
 
102
112
  // Calcul des consommations ECS
103
113
 
@@ -4,6 +4,7 @@ export interface Contexte {
4
4
  typeHabitation: TypeHabitation;
5
5
  typeDpe: TypeDpe;
6
6
  enumPeriodeConstructionId: number;
7
+ anneeConstruction: number;
7
8
  surfaceHabitable: number;
8
9
  hauteurSousPlafond: number;
9
10
  nombreAppartement: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open3cl/engine",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Open Source 3CL-DPE engine",
5
5
  "main": "index.js",
6
6
  "directories": {