Commit | Line | Data |
---|---|---|
b2acff85 | 1 | /** |
6bf6769e | 2 | * Rationale: https://wiki.piment-noir.org/doku.php/en:cs:modelling_multi-phased_electrical_system_interconnexion |
cb31c873 JB |
3 | */ |
4 | ||
5 | /** | |
b2acff85 | 6 | * Targeted to AC related values calculation. |
b2acff85 | 7 | */ |
cb31c873 JB |
8 | export class ACElectricUtils { |
9 | static amperageTotal(nbOfPhases: number, Iph: number): number { | |
3f40bc9c JB |
10 | return nbOfPhases * Iph; |
11 | } | |
12 | ||
6af9012e | 13 | static powerPerPhase(V: number, Iph: number, cosPhi = 1): number { |
3f40bc9c JB |
14 | const powerPerPhase = V * Iph * cosPhi; |
15 | if (cosPhi === 1) { | |
16 | return powerPerPhase; | |
17 | } | |
18 | return Math.round(powerPerPhase); | |
19 | } | |
20 | ||
6af9012e | 21 | static powerTotal(nbOfPhases: number, V: number, Iph: number, cosPhi = 1): number { |
cb31c873 | 22 | return nbOfPhases * ACElectricUtils.powerPerPhase(V, Iph, cosPhi); |
3f40bc9c JB |
23 | } |
24 | ||
cb31c873 JB |
25 | static amperageTotalFromPower(P: number, V: number, cosPhi = 1): number { |
26 | const amperage = P / (V * cosPhi); | |
3f40bc9c | 27 | if (cosPhi === 1 && P % V === 0) { |
cb31c873 | 28 | return amperage; |
3f40bc9c | 29 | } |
cb31c873 | 30 | return Math.round(amperage); |
3f40bc9c JB |
31 | } |
32 | ||
cb31c873 JB |
33 | static amperagePerPhaseFromPower(nbOfPhases: number, P: number, V: number, cosPhi = 1): number { |
34 | const amperage = ACElectricUtils.amperageTotalFromPower(P, V, cosPhi); | |
35 | const amperagePerPhase = amperage / nbOfPhases; | |
36 | if (amperage % nbOfPhases === 0) { | |
37 | return amperagePerPhase; | |
3f40bc9c | 38 | } |
cb31c873 JB |
39 | return Math.round(amperagePerPhase); |
40 | } | |
41 | } | |
42 | ||
43 | /** | |
44 | * Targeted to DC related values calculation. | |
45 | */ | |
46 | export class DCElectricUtils { | |
47 | static power(V: number, I: number): number { | |
48 | return V * I; | |
49 | } | |
50 | ||
51 | static amperage(P: number, V: number): number { | |
52 | const amperage = P / V; | |
53 | if (P % V === 0) { | |
54 | return amperage; | |
55 | } | |
56 | return Math.round(amperage); | |
3f40bc9c JB |
57 | } |
58 | } |