dba823abc5f16edea664453572920386e3cc5976
2 * Rationale: https://wiki.piment-noir.org/doku.php/en:cs:modelling_multi-phased_electrical_system_interconnexion
3 * Targeted to AC related values calculation.
4 * To use for DC, always consider cosPhi = 1 and do not use per phase helpers
6 export default class ElectricUtils
{
7 static ampTotal(nbOfPhases
: number, Iph
: number): number {
8 return nbOfPhases
* Iph
;
11 static powerPerPhase(V
: number, Iph
: number, cosPhi
= 1): number {
12 const powerPerPhase
= V
* Iph
* cosPhi
;
16 return Math.round(powerPerPhase
);
19 static powerTotal(nbOfPhases
: number, V
: number, Iph
: number, cosPhi
= 1): number {
20 return nbOfPhases
* ElectricUtils
.powerPerPhase(V
, Iph
, cosPhi
);
23 static ampTotalFromPower(P
: number, V
: number, cosPhi
= 1): number {
24 const power
= P
/ (V
* cosPhi
);
25 if (cosPhi
=== 1 && P
% V
=== 0) {
28 return Math.round(power
);
31 static ampPerPhaseFromPower(nbOfPhases
: number, P
: number, V
: number, cosPhi
= 1): number {
32 const power
= ElectricUtils
.ampTotalFromPower(P
, V
, cosPhi
);
33 const powerPerPhase
= power
/ nbOfPhases
;
34 if (power
% nbOfPhases
=== 0) {
37 return Math.round(powerPerPhase
);