X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FElectricUtils.ts;h=c4fdfa10142c1d7fde8a1fdb685686813f20d91d;hb=452a4864d4a8d0286ddd351958d8cc02574b4ba9;hp=9f0c680ac890ed02e2b277776c63e66c3c7f9ea8;hpb=d5bd1c008c3b2fbe6426ae12e1e12afe97807c57;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/ElectricUtils.ts b/src/utils/ElectricUtils.ts index 9f0c680a..c4fdfa10 100644 --- a/src/utils/ElectricUtils.ts +++ b/src/utils/ElectricUtils.ts @@ -1,4 +1,4 @@ -// Copyright Jerome Benoit. 2021. All Rights Reserved. +// Copyright Jerome Benoit. 2021-2024. All Rights Reserved. /** * Rationale: https://wiki.piment-noir.org/doku.php/en:cs:modelling_multi-phased_electrical_system_interconnexion @@ -7,58 +7,64 @@ /** * Targeted to AC related values calculation. */ +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export class ACElectricUtils { - private constructor() { + private constructor () { // This is intentional } - static amperageTotal(nbOfPhases: number, Iph: number): number { - return nbOfPhases * Iph; + static powerTotal (nbOfPhases: number, V: number, Iph: number, cosPhi = 1): number { + return nbOfPhases * ACElectricUtils.powerPerPhase(V, Iph, cosPhi) } - static powerPerPhase(V: number, Iph: number, cosPhi = 1): number { - const powerPerPhase = V * Iph * cosPhi; + static powerPerPhase (V: number, Iph: number, cosPhi = 1): number { + const powerPerPhase = V * Iph * cosPhi if (cosPhi === 1) { - return powerPerPhase; + return powerPerPhase } - return Math.round(powerPerPhase); + return Math.round(powerPerPhase) } - static powerTotal(nbOfPhases: number, V: number, Iph: number, cosPhi = 1): number { - return nbOfPhases * ACElectricUtils.powerPerPhase(V, Iph, cosPhi); + static amperageTotal (nbOfPhases: number, Iph: number): number { + return nbOfPhases * Iph } - static amperageTotalFromPower(P: number, V: number, cosPhi = 1): number { - const amperage = P / (V * cosPhi); + static amperageTotalFromPower (P: number, V: number, cosPhi = 1): number { + const amperage = P / (V * cosPhi) if (cosPhi === 1 && P % V === 0) { - return amperage; + return amperage } - return Math.round(amperage); + return Math.round(amperage) } - static amperagePerPhaseFromPower(nbOfPhases: number, P: number, V: number, cosPhi = 1): number { - const amperage = ACElectricUtils.amperageTotalFromPower(P, V, cosPhi); - const amperagePerPhase = amperage / nbOfPhases; + static amperagePerPhaseFromPower (nbOfPhases: number, P: number, V: number, cosPhi = 1): number { + const amperage = ACElectricUtils.amperageTotalFromPower(P, V, cosPhi) + const amperagePerPhase = amperage / nbOfPhases if (amperage % nbOfPhases === 0) { - return amperagePerPhase; + return amperagePerPhase } - return Math.round(amperagePerPhase); + return Math.round(amperagePerPhase) } } /** * Targeted to DC related values calculation. */ +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export class DCElectricUtils { - static power(V: number, I: number): number { - return V * I; + private constructor () { + // This is intentional + } + + static power (V: number, I: number): number { + return V * I } - static amperage(P: number, V: number): number { - const amperage = P / V; + static amperage (P: number, V: number): number { + const amperage = P / V if (P % V === 0) { - return amperage; + return amperage } - return Math.round(amperage); + return Math.round(amperage) } }