Exemple #1
0
        public Tuple <double, double> Calculate(BivalentSimulation.Mode simulationMode)
        {
            double additionalSource    = 0;
            double heatPumpUtilization = (CurrentHeatLoss / HeatPumpMaxCapacity) * 100;

            HeatPumpOff = false;
            switch (simulationMode)
            {
            // calculate additional source only when we cross bivalent point
            case BivalentSimulation.Mode.AlternativeBivalent when CurrentHeatLoss > CapacityAtBivalentPoint:
                additionalSource = (CurrentHeatLoss / AdditionalSourceMaxCapacity) * 100;
                HeatPumpOff      = true;
                break;

            case BivalentSimulation.Mode.AlternativeBivalent:
                additionalSource = 0;
                break;

            // in parallel bivalent mode add additional source only when we cross bivalent point
            case BivalentSimulation.Mode.ParallelBivalent when CurrentHeatLoss > CapacityAtBivalentPoint:
                additionalSource = ((CurrentHeatLoss - HeatPumpMaxCapacity) / AdditionalSourceMaxCapacity) * 100;
                if (additionalSource < 0)
                {
                    additionalSource = 0;
                }
                break;

            case BivalentSimulation.Mode.PartiallyBivalent:

                if (CurrentHeatLoss >= CapacityAtBivalentPoint && CurrentHeatLoss <= AdditionalHeatSourceOnlyCapacity)
                {
                    double capacityDifference = CurrentHeatLoss - CapacityAtBivalentPoint;
                    // not % cause we use it in calculation below
                    heatPumpUtilization = (CurrentHeatLoss - capacityDifference / 2) / HeatPumpMaxCapacity;

                    // heat pump doesn't have spare capacity
                    // so the additional heat source is covering the whole heat loss BUT heat pump is still ON
                    if (heatPumpUtilization > 1)
                    {
                        additionalSource = ((CurrentHeatLoss - HeatPumpMaxCapacity) / AdditionalSourceMaxCapacity) * 100;
                    }
                    else
                    {
                        // heat pump has some spare capacity
                        additionalSource = (((CurrentHeatLoss - heatPumpUtilization * HeatPumpMaxCapacity)) /
                                            AdditionalSourceMaxCapacity) * 100;
                    }

                    // to %
                    heatPumpUtilization *= 100;
                }
                else if (CurrentHeatLoss > AdditionalHeatSourceOnlyCapacity)
                {
                    additionalSource = (CurrentHeatLoss / AdditionalSourceMaxCapacity) * 100;
                    // signalizing that the heat pump is OFF
                    HeatPumpOff = true;
                }
                else
                {
                    additionalSource = 0;
                }

                break;
            }

            heatPumpUtilization = Math.Round(heatPumpUtilization, 3);
            additionalSource    = Math.Round(additionalSource, 3);
            return(new Tuple <double, double>(heatPumpUtilization, additionalSource));
        }
        public void RedrawGraph(CartesianChart graph, BivalentSimulation.Mode simulationMode)
        {
            //TODO check if the input makes sense like MAX > MIN etc...

            // setting minimal values of x Axis
            if (graph.AxisX.Count > 0)
            {
                graph.AxisX[0].MinValue = AmbientMinTemp;
                graph.AxisX[0].MaxValue = AmbientMaxTemp;
            }

            // line of object heat losses
            //TODO check if Min > Zero load temp
            double topPoint = HeatLossCoefficient * (ZeroLoadTemp - AmbientMinTemp);

            CapacityAtBivalentPoint       = HeatLossCoefficient * (ZeroLoadTemp - BivalentTemp);
            _heatLossCollection[0].Values = new ChartValues <ObservablePoint>
            {
                new ObservablePoint(AmbientMinTemp, topPoint),
                new ObservablePoint(ZeroLoadTemp, 0)
            };

            if (simulationMode != BivalentSimulation.Mode.Monovalent)
            {
                _bivalentPointColumnSeries.Values = new ChartValues <ObservablePoint>
                {
                    new ObservablePoint(BivalentTemp, CapacityAtBivalentPoint)
                };
                if (graph.Series != null && graph.Series.Contains(_bivalentPointColumnSeries))
                {
                    _heatLossCollection.Remove(_bivalentPointColumnSeries);
                    _heatLossCollection.Add(_bivalentPointColumnSeries);
                }
                else
                {
                    _heatLossCollection.Add(_bivalentPointColumnSeries);
                }

                if (simulationMode == BivalentSimulation.Mode.PartiallyBivalent)
                {
                    AdditionalHeatSourceOnlyCapacity      = HeatLossCoefficient * (ZeroLoadTemp - AdditionalSourceOnlyTemp);
                    _additionalHeatSourceOnlyPoint.Values = new ChartValues <ObservablePoint>
                    {
                        new ObservablePoint(AdditionalSourceOnlyTemp, AdditionalHeatSourceOnlyCapacity)
                    };
                    if (graph.Series != null && graph.Series.Contains(_additionalHeatSourceOnlyPoint))
                    {
                        _heatLossCollection.Remove(_additionalHeatSourceOnlyPoint);
                        _heatLossCollection.Add(_additionalHeatSourceOnlyPoint);
                    }
                    else
                    {
                        _heatLossCollection.Add(_additionalHeatSourceOnlyPoint);
                    }
                }
                else // if the mode is not partially bivalent delete the line
                {
                    _heatLossCollection.Remove(_additionalHeatSourceOnlyPoint);
                }
            }
            else // if the mode is monovalent
            {
                _heatLossCollection.Remove(_additionalHeatSourceOnlyPoint);
                _heatLossCollection.Remove(_bivalentPointColumnSeries);
            }

            graph.Series = _heatLossCollection;
        }