Commit | Line | Data |
---|---|---|
3f40bc9c JB |
1 | |
2 | export default class ElectricUtils { | |
3 | static ampTotal(nbOfPhases, Iph) { | |
4 | return nbOfPhases * Iph; | |
5 | } | |
6 | ||
7 | static powerPerPhase(V, Iph, cosPhi = 1) { | |
8 | const powerPerPhase = V * Iph * cosPhi; | |
9 | if (cosPhi === 1) { | |
10 | return powerPerPhase; | |
11 | } | |
12 | return Math.round(powerPerPhase); | |
13 | } | |
14 | ||
15 | static powerTotal(nbOfPhases, V, Iph, cosPhi = 1) { | |
16 | return nbOfPhases * ElectricUtils.powerPerPhase(V, Iph, cosPhi); | |
17 | } | |
18 | ||
19 | static ampTotalFromPower(P, V, cosPhi = 1) { | |
20 | const power = P / (V * cosPhi); | |
21 | if (cosPhi === 1 && P % V === 0) { | |
22 | return power; | |
23 | } | |
24 | return Math.round(power); | |
25 | } | |
26 | ||
27 | static ampPerPhaseFromPower(nbOfPhases, P, V, cosPhi = 1) { | |
28 | const power = ElectricUtils.ampTotalFromPower(P, V, cosPhi); | |
29 | const powerPerPhase = power / nbOfPhases; | |
30 | if (power % nbOfPhases === 0) { | |
31 | return powerPerPhase; | |
32 | } | |
33 | return Math.round(powerPerPhase); | |
34 | } | |
35 | } |