30 lines
780 B
TypeScript
30 lines
780 B
TypeScript
export interface PowerInput {
|
|
quantity: number;
|
|
installedPowerPerUnitKw: number;
|
|
demandFactor: number;
|
|
}
|
|
|
|
export interface CurrentInput {
|
|
demandPowerKw: number;
|
|
voltageV: number;
|
|
phaseCount: 1 | 3;
|
|
powerFactor: number;
|
|
}
|
|
|
|
export function calculateInstalledPowerKw(input: PowerInput): number {
|
|
return input.quantity * input.installedPowerPerUnitKw;
|
|
}
|
|
|
|
export function calculateDemandPowerKw(input: PowerInput): number {
|
|
return calculateInstalledPowerKw(input) * input.demandFactor;
|
|
}
|
|
|
|
export function calculateCurrentA(input: CurrentInput): number {
|
|
const powerW = input.demandPowerKw * 1000;
|
|
if (input.phaseCount === 1) {
|
|
return powerW / (input.voltageV * input.powerFactor);
|
|
}
|
|
return powerW / (Math.sqrt(3) * input.voltageV * input.powerFactor);
|
|
}
|
|
|