Update the energy flow calculation and add the ascii topology as a comment
This commit is contained in:
parent
9edd875066
commit
9e31046f43
|
@ -18,6 +18,7 @@ using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc.Control;
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
||||||
using InnovEnergy.Lib.Time.Unix;
|
using InnovEnergy.Lib.Time.Unix;
|
||||||
using InnovEnergy.Lib.Units;
|
using InnovEnergy.Lib.Units;
|
||||||
|
using InnovEnergy.Lib.Units.Power;
|
||||||
using InnovEnergy.Lib.Utils;
|
using InnovEnergy.Lib.Utils;
|
||||||
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig;
|
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig;
|
||||||
using AcPower = InnovEnergy.Lib.Units.Composite.AcPower;
|
using AcPower = InnovEnergy.Lib.Units.Composite.AcPower;
|
||||||
|
@ -96,37 +97,77 @@ internal static class Program
|
||||||
|
|
||||||
StatusRecord ReadStatus()
|
StatusRecord ReadStatus()
|
||||||
{
|
{
|
||||||
var battery = batteryDevices.Read();
|
|
||||||
|
// ┌────┐ ┌────┐
|
||||||
|
// │ Pv │ │ Pv │ ┌────┐
|
||||||
|
// └────┘ └────┘ │ Pv │
|
||||||
|
// V V └────┘
|
||||||
|
// V V V
|
||||||
|
// (b) 0 W (e) 0 W V
|
||||||
|
// V V (i) 13.2 kW ┌────────────┐
|
||||||
|
// V V V │ Battery │
|
||||||
|
// ┌─────────┐ ┌──────────┐ ┌────────────┐ ┌─────────┐ V ├────────────┤
|
||||||
|
// │ Grid │ │ Grid Bus │ │ Island Bus │ │ AC/DC │ ┌────────┐ ┌───────┐ │ 52.3 V │
|
||||||
|
// ├─────────┤ -10.3 kW ├──────────┤ -11.7 kW ├────────────┤ -11.7 kW ├─────────┤ -11.7 kW │ Dc Bus │ 1008 W │ DC/DC │ 1008 W │ 99.1 % │
|
||||||
|
// │ -3205 W │<<<<<<<<<<│ 244 V │<<<<<<<<<<│ 244 V │<<<<<<<<<<│ -6646 W │<<<<<<<<<<├────────┤>>>>>>>>>>├───────┤>>>>>>>>>>│ 490 mA │
|
||||||
|
// │ -3507 W │ (a) │ 244 V │ (d) │ 244 V │ (g) │ -5071 W │ (h) │ 776 V │ (k) │ 56 V │ (l) │ 250 °C │
|
||||||
|
// │ -3605 W │ K1 │ 246 V │ K2 │ 246 V │ K3 └─────────┘ └────────┘ └───────┘ │ 445 A │
|
||||||
|
// └─────────┘ └──────────┘ └────────────┘ V │ 0 Warnings │
|
||||||
|
// V V V │ 0 Alarms │
|
||||||
|
// V V (j) 0 W └────────────┘
|
||||||
|
// (c) 1400 W (f) 0 W V
|
||||||
|
// V V V
|
||||||
|
// V V ┌──────┐
|
||||||
|
// ┌──────┐ ┌──────┐ │ Load │
|
||||||
|
// │ Load │ │ Load │ └──────┘
|
||||||
|
// └──────┘ └──────┘
|
||||||
|
|
||||||
|
|
||||||
|
// AC side
|
||||||
|
// a + b - c - d = 0 [eq1]
|
||||||
|
// d + e - f - g = 0 [eq2]
|
||||||
|
//
|
||||||
|
// c & d are not measured!
|
||||||
|
//
|
||||||
|
// d = f + g - e [eq2]
|
||||||
|
// c = a + b - d [eq1]
|
||||||
|
//
|
||||||
|
// DC side
|
||||||
|
// h + i - j - k = 0 [eq3]
|
||||||
|
//
|
||||||
|
// g = h assuming no losses in ACDC
|
||||||
|
// k = l assuming no losses in DCDC
|
||||||
|
// j = h + i - k [eq3]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var acDc = acDcDevices.Read();
|
var acDc = acDcDevices.Read();
|
||||||
var dcDc = dcDcDevices.Read();
|
var dcDc = dcDcDevices.Read();
|
||||||
var relays = saliMaxRelaysDevice.Read();
|
var relays = saliMaxRelaysDevice.Read();
|
||||||
var loadOnAcIsland = acIslandLoadMeter.Read();
|
var loadOnAcIsland = acIslandLoadMeter.Read();
|
||||||
var gridMeter = gridMeterDevice.Read();
|
var gridMeter = gridMeterDevice.Read();
|
||||||
var pvOnDc = amptDevice.Read();
|
var pvOnDc = amptDevice.Read();
|
||||||
|
var battery = batteryDevices.Read();
|
||||||
|
|
||||||
var pvOnAcGrid = AcPowerDevice.Null;
|
var pvOnAcGrid = AcPowerDevice.Null;
|
||||||
var pvOnAcIsland = AcPowerDevice.Null;
|
var pvOnAcIsland = AcPowerDevice.Null;
|
||||||
var gridPower = gridMeter is null ? AcPower.Null : gridMeter.Ac.Power;
|
var gridPower = gridMeter is null ? AcPower.Null : gridMeter.Ac.Power;
|
||||||
var islandLoadPower = loadOnAcIsland is null ? AcPower.Null : loadOnAcIsland.Ac.Power;
|
var islandLoadPower = loadOnAcIsland is null ? AcPower.Null : loadOnAcIsland.Ac.Power;
|
||||||
var inverterAcPower = acDc.Ac.Power;
|
var inverterAcPower = acDc.Ac.Power;
|
||||||
|
var inverterDcPower = acDc.Dc.Power;
|
||||||
|
|
||||||
var loadOnAcGrid = gridPower
|
var a = gridPower;
|
||||||
+ pvOnAcGrid.Power
|
var b = pvOnAcGrid.Power;
|
||||||
+ pvOnAcIsland.Power
|
var e = pvOnAcIsland.Power;
|
||||||
- islandLoadPower
|
var f = islandLoadPower;
|
||||||
- inverterAcPower;
|
var g = inverterAcPower;
|
||||||
|
var h = inverterDcPower;
|
||||||
var gridBusToIslandBusPower = gridPower
|
var i = pvOnDc?.Dc.Power;
|
||||||
+ pvOnAcGrid.Power
|
var k = dcDc.Dc.Link.Power;
|
||||||
- loadOnAcGrid;
|
var l = k;
|
||||||
|
var j = Sum(h, i, -k);
|
||||||
// var dcPower = acDc.Dc.Power.Value
|
var d = Sum(f, g, -e);
|
||||||
// + pvOnDc.Dc?.Power.Value ?? 0
|
var c = Sum(a, b, -d);
|
||||||
// - dcDc.Dc.Link.Power.Value;
|
|
||||||
|
|
||||||
var dcPower = 0;
|
|
||||||
|
|
||||||
var loadOnDc = new DcPowerDevice { Power = dcPower} ;
|
|
||||||
|
|
||||||
return new StatusRecord
|
return new StatusRecord
|
||||||
{
|
{
|
||||||
|
@ -140,10 +181,10 @@ internal static class Program
|
||||||
PvOnAcIsland = pvOnAcIsland,
|
PvOnAcIsland = pvOnAcIsland,
|
||||||
PvOnDc = pvOnDc,
|
PvOnDc = pvOnDc,
|
||||||
|
|
||||||
AcGridToAcIsland = new AcPowerDevice { Power = gridBusToIslandBusPower },
|
AcGridToAcIsland = new AcPowerDevice { Power = d },
|
||||||
LoadOnAcGrid = new AcPowerDevice { Power = loadOnAcGrid },
|
LoadOnAcGrid = new AcPowerDevice { Power = c },
|
||||||
LoadOnAcIsland = loadOnAcIsland,
|
LoadOnAcIsland = loadOnAcIsland,
|
||||||
LoadOnDc = loadOnDc,
|
LoadOnDc = new DcPowerDevice { Power = j.Value},
|
||||||
|
|
||||||
StateMachine = StateMachine.Default,
|
StateMachine = StateMachine.Default,
|
||||||
EssControl = EssControl.Default,
|
EssControl = EssControl.Default,
|
||||||
|
@ -236,10 +277,10 @@ internal static class Program
|
||||||
var inverters = r.AcDc.Devices;
|
var inverters = r.AcDc.Devices;
|
||||||
var dcDevices = r.DcDc.Devices;
|
var dcDevices = r.DcDc.Devices;
|
||||||
|
|
||||||
inverters.ForEach(d => d.Control.Dc.MaxVoltage = r.Config.MaxDcLinkVoltageFromAcDc);
|
inverters.ForEach(d => d.Control.Dc.MaxVoltage = r.Config.MaxDcLinkVoltageFromAcDc);
|
||||||
inverters.ForEach(d => d.Control.Dc.MinVoltage = r.Config.MinDcLinkVoltageFromAcDc);
|
inverters.ForEach(d => d.Control.Dc.MinVoltage = r.Config.MinDcLinkVoltageFromAcDc);
|
||||||
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = r.Config.ReferenceDcLinkVoltageFromAcDc);
|
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = r.Config.ReferenceDcLinkVoltageFromAcDc);
|
||||||
inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
|
inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
|
||||||
|
|
||||||
dcDevices.ForEach(d => d.Control.DroopControl.UpperVoltage = r.Config.UpperDcLinkVoltageFromDc);
|
dcDevices.ForEach(d => d.Control.DroopControl.UpperVoltage = r.Config.UpperDcLinkVoltageFromDc);
|
||||||
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = r.Config.LowerDcLinkVoltageFromDc);
|
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = r.Config.LowerDcLinkVoltageFromDc);
|
||||||
|
@ -332,10 +373,26 @@ internal static class Program
|
||||||
if (response.StatusCode != 200)
|
if (response.StatusCode != 200)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ERROR: PUT");
|
Console.WriteLine("ERROR: PUT");
|
||||||
var error = response.GetStringAsync();
|
var error = await response.GetStringAsync();
|
||||||
Console.WriteLine(error);
|
Console.WriteLine(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ActivePower? Sum(ActivePower? e, ActivePower? f, ActivePower? g)
|
||||||
|
{
|
||||||
|
if (e is null || f is null || g is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return f + g + e;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AcPower? Sum(AcPower? e, AcPower? f, AcPower? g)
|
||||||
|
{
|
||||||
|
if (e is null || f is null || g is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return f + g + e;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue