923c6849be00268ad41bf1a88480c95ffef69084
1 // Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
4 * Rationale: https://wiki.piment-noir.org/doku.php/en:cs:modelling_multi-phased_electrical_system_interconnexion
8 * Targeted to AC related values calculation.
10 // eslint-disable-next-line @typescript-eslint/no-extraneous-class
11 export class ACElectricUtils
{
12 private constructor () {
13 // This is intentional
16 static amperagePerPhaseFromPower (nbOfPhases
: number, P
: number, V
: number, cosPhi
= 1): number {
17 const amperage
= ACElectricUtils
.amperageTotalFromPower(P
, V
, cosPhi
)
18 const amperagePerPhase
= amperage
/ nbOfPhases
19 if (amperage
% nbOfPhases
=== 0) {
20 return amperagePerPhase
22 return Math.round(amperagePerPhase
)
25 static amperageTotal (nbOfPhases
: number, Iph
: number): number {
26 return nbOfPhases
* Iph
29 static amperageTotalFromPower (P
: number, V
: number, cosPhi
= 1): number {
30 const amperage
= P
/ (V
* cosPhi
)
31 if (cosPhi
=== 1 && P
% V
=== 0) {
34 return Math.round(amperage
)
37 static powerPerPhase (V
: number, Iph
: number, cosPhi
= 1): number {
38 const powerPerPhase
= V
* Iph
* cosPhi
42 return Math.round(powerPerPhase
)
45 static powerTotal (nbOfPhases
: number, V
: number, Iph
: number, cosPhi
= 1): number {
46 return nbOfPhases
* ACElectricUtils
.powerPerPhase(V
, Iph
, cosPhi
)
51 * Targeted to DC related values calculation.
53 // eslint-disable-next-line @typescript-eslint/no-extraneous-class
54 export class DCElectricUtils
{
55 private constructor () {
56 // This is intentional
59 static amperage (P
: number, V
: number): number {
60 const amperage
= P
/ V
64 return Math.round(amperage
)
67 static power (V
: number, I
: number): number {