2023-06-13 11:03:49 +00:00
|
|
|
using InnovEnergy.Lib.Units.Power;
|
2023-04-25 09:27:57 +00:00
|
|
|
using static System.Math;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Units.Composite;
|
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public record AcPower
|
2023-04-25 09:27:57 +00:00
|
|
|
{
|
2023-06-27 11:14:17 +00:00
|
|
|
public required ActivePower Active { get; init; }
|
2023-09-01 06:54:46 +00:00
|
|
|
public required ReactivePower Reactive { get; init; }
|
2023-05-04 07:36:30 +00:00
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public ApparentPower Apparent => Sqrt(Active * Active + Reactive * Reactive);
|
2023-05-04 07:36:30 +00:00
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public static AcPower operator +(AcPower left, AcPower right) => new AcPower
|
2023-04-25 09:27:57 +00:00
|
|
|
{
|
2023-09-01 06:54:46 +00:00
|
|
|
Active = left.Active + right.Active,
|
|
|
|
Reactive = left.Reactive + right.Reactive
|
|
|
|
};
|
2023-04-25 09:27:57 +00:00
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public static AcPower operator -(AcPower left, AcPower right) => new AcPower
|
2023-05-04 07:36:30 +00:00
|
|
|
{
|
2023-09-01 06:54:46 +00:00
|
|
|
Active = left.Active - right.Active,
|
|
|
|
Reactive = left.Reactive - right.Reactive
|
|
|
|
};
|
2023-08-30 14:50:38 +00:00
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public static AcPower operator -(AcPower p) => new AcPower
|
|
|
|
{
|
|
|
|
Active = -p.Active,
|
|
|
|
Reactive = -p.Reactive
|
|
|
|
};
|
2023-08-30 14:50:38 +00:00
|
|
|
|
2023-09-01 06:54:46 +00:00
|
|
|
public static implicit operator AcPower(Double p) => new AcPower { Active = p, Reactive = 0 };
|
|
|
|
public static implicit operator AcPower(Int32 p) => new AcPower { Active = p, Reactive = 0 };
|
2023-09-11 09:31:41 +00:00
|
|
|
|
|
|
|
public static AcPower Zero => new AcPower { Active = 0, Reactive = 0, };
|
2023-04-25 09:27:57 +00:00
|
|
|
}
|