コード例 #1
0
        private bool Compare()
        {
            if (!GUIChecks.TryGetValue(OtherSystemPeTextbox, out double otherSysPe) ||
                !GUIChecks.TryGetValue(OtherSystemPheTextbox, out double otherSysPhe))
            {
                return(false);
            }

            double otherSysCOP = Math.Round(otherSysPhe / otherSysPe, 1);

            ResultTextBoxes(otherSysCOP);
            CompareCapacities(otherSysPhe, otherSysPe);
            CompareCOP(otherSysCOP);

            switch (EconomicsTab.SelectedIndex)
            {
            // simple economics
            case 0:
                CompareSimpleEconomics(otherSysPe);
                break;

            // advanced economics
            case 1:
                CompareAdvancedEconomics();
                break;

            default:
                throw new NotImplementedException("Economics option not implemented.");
            }


            return(true);
        }
        private void SetSliderMaximum()
        {
            if (!GUIChecks.TryGetValue(AmbientMaxTEmpTxtBox, out double maxTemp) ||
                !GUIChecks.TryGetValue(AmbientMinTempTxtBox, out double minTemp))
            {
                return;
            }

            CurrentTempSlider.Maximum = maxTemp;
            CurrentTempSlider.Minimum = minTemp;
        }
        private void CalculateUtilization()
        {
            if (isInitializing)
            {
                return;
            }
            if (!GUIChecks.TryGetValue(CurrentHeatLossTextBox, out _bivalentUtilization.CurrentHeatLoss) ||
                !GUIChecks.TryGetValue(HeatPumpMaxCapacityTextBox, out _bivalentUtilization.HeatPumpMaxCapacity) ||
                !GUIChecks.TryGetValue(AdditionalHeatSourceMaxCapacityTextBox,
                                       out _bivalentUtilization.AdditionalSourceMaxCapacity))
            {
                return;
            }

            if (_mode != Mode.Monovalent)
            {
                _bivalentUtilization.CapacityAtBivalentPoint          = _bivalentGraph.CapacityAtBivalentPoint;
                _bivalentUtilization.AdditionalHeatSourceOnlyCapacity = _bivalentGraph.AdditionalHeatSourceOnlyCapacity;
            }
            else
            {
                _bivalentUtilization.CapacityAtBivalentPoint          = 0;
                _bivalentUtilization.AdditionalHeatSourceOnlyCapacity = 0;
            }

            //TODO check if the max capacity is not too low
            var utilization = _bivalentUtilization.Calculate(_mode);

            // if the capacity of heat pump is not enough
            HeatPumpUtilizationTextBox.ToolTip = "Actual utilization is " + utilization.Item1;
            if (utilization.Item1 > 100 && !_bivalentUtilization.HeatPumpOff)
            {
                HeatPumpUtilizationTextBox.Background = Brushes.Red;
                HeatPumpUtilizationTextBox.Text       = "100";
            }
            else if (_bivalentUtilization.HeatPumpOff)
            {
                HeatPumpUtilizationTextBox.Background = Brushes.Gray;
                HeatPumpUtilizationTextBox.ToolTip   += "\n OFF";
                HeatPumpUtilizationTextBox.Text       = "0";
            }
            else
            {
                HeatPumpUtilizationTextBox.Background = Brushes.White;
                HeatPumpUtilizationTextBox.Text       = utilization.Item1.ToString("F1");
                HeatPumpUtilizationTextBox.ToolTip    = null;
            }

            AdditionalHeatSourceUtilizationTextBox.Background = utilization.Item2 > 100 ? Brushes.Red : Brushes.White;

            AdditionalHeatSourceUtilizationTextBox.Text = utilization.Item2.ToString("F1");
        }
コード例 #4
0
        private bool SetEvaporatorData()
        {
            if (!GUIChecks.TryGetValue(EvaporatorTin, out double evaporatorTin) ||
                !GUIChecks.TryGetValue(EvaporatorTout, out double evaporatorTout))
            {
                return(false);
            }


            _systemCalculation.EvaporatorData = new CoilData(null, evaporatorTin - evaporatorTout, evaporatorTin);

            return(true);
        }
        private void TextBoxPopUpSuggestion(object sender, RoutedEventArgs e)
        {
            if (sender is TextBox textBox && textBox.Text == String.Empty)
            {
                textBox.Text = "0";
            }

            RedrawGraph();
            ShowSuggestedHeatPumpCapacity();
            if (!GUIChecks.TryGetValue(CurrentTempTextBox, out double txtBoxValue))
            {
                _bivalentGraph.DrawCurrentHeatLoss(BivalentPointChart, txtBoxValue);
            }

            CalculateUtilization();
        }
コード例 #6
0
        /// <summary>
        /// Set Condenser data into struct
        /// </summary>
        /// <returns><see cref="T:false"/> if encounter problem</returns>
        private bool SetCondenserData()
        {
            // if user knows P of condenser
            if (CondenserPCanvas.Visibility == Visibility.Visible)
            {
                if (!GUIChecks.TryGetValue(CondenserP, out double condenserP))
                {
                    return(false);
                }
                _systemCalculation.CondenserData = new CoilData(condenserP);
                return(true);
            }

            if (!GUIChecks.TryGetValue(CondenserV, out double condenserV))
            {
                return(false);
            }

            // m3/h
            if (CondFlowUnitOptions.SelectedIndex == 0)
            {
                condenserV /= 3600;
            }

            switch (DeltaTCanvas.Visibility)
            {
            case Visibility.Visible:
                if (!GUIChecks.TryGetValue(CondenserDeltaT, out double condenserDeltaT))
                {
                    return(false);
                }
                _systemCalculation.CondenserData = new CoilData(condenserV, condenserDeltaT, null, null);
                break;

            case Visibility.Hidden:
                if (!GUIChecks.TryGetValue(CondenserT1, out double condenserT1) ||
                    !GUIChecks.TryGetValue(CondenserT2, out double condenserT2))
                {
                    return(false);
                }
                _systemCalculation.CondenserData = new CoilData(condenserV, null, condenserT1, condenserT2);
                break;
            }

            return(true);
        }
コード例 #7
0
        private void CompareSimpleEconomics(double otherSysPe)
        {
            if (!GUIChecks.TryGetValue(PriceForkWhTextBox, out double priceForkWh, false))
            {
                PricePercentageLabel.Content = "";
                ThisSystemElectricCostsTextBox.Background = OtherSystemElectricCostsTextBox.Background = Brushes.White;
                return;
            }

            double thisSysPrice  = priceForkWh * (SystemCalculation.GetSysPe / 1000);
            double otherSysPrice = priceForkWh * (otherSysPe / 1000);

            // copy to text boxes
            ThisSystemElectricCostsTextBox.Text  = thisSysPrice.ToString("F1");
            OtherSystemElectricCostsTextBox.Text = otherSysPrice.ToString("F1");

            SetColors(thisSysPrice, otherSysPrice, ThisSystemElectricCostsTextBox, OtherSystemElectricCostsTextBox,
                      PricePercentageLabel, true);
        }
コード例 #8
0
        /// <summary>
        /// Set electrical applianceData
        /// </summary>
        /// <returns><see cref="T:false"/> if encounter problem</returns>
        private bool SetElectricalApplianceData()
        {
            if (CompressorCapacityCanvas.Visibility == Visibility.Visible)
            {
                if (!GUIChecks.TryGetValue(CompressorCapacityTextBox, out double compressorP))
                {
                    return(false);
                }
                _systemCalculation.CompressorData = new ElectricalApplianceData(compressorP);
                return(true);
            }

            if (!GUIChecks.TryGetValue(CompressorUTextBox, out double compressorU) ||
                !GUIChecks.TryGetValue(CompressorITextBox, out double compressorI))
            {
                return(false);
            }
            _systemCalculation.CompressorData = new ElectricalApplianceData(compressorU, compressorI);
            return(true);
        }
コード例 #9
0
        private void SetEvaporator()
        {
            if (!CalculateEvaporatorChkbox.IsChecked.HasValue || !CalculateEvaporatorChkbox.IsChecked.Value)
            {
                return;
            }

            if (SetEvaporatorData() && GUIChecks.TryGetValue(EvaporatorHumidity, out double humidity) &&
                GUIChecks.TryGetValue(HeightOverSea, out double height) &&
                GUIChecks.TryGetValue(EvaporatorV, out double volumeFlow))
            {
                // m3/h
                if (EvapFlowUnitOptions.SelectedIndex == 0)
                {
                    volumeFlow /= 3600;
                }

                EvaporatorResultP.Text =
                    _systemCalculation.CalculateEvaporator(humidity, height, volumeFlow).ToString();
            }
        }
        private void CurrentTempTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //TODO check when the value is below minimal ambient temperature
            if (_isChanging)
            {
                return;
            }
            _isChanging = true;
            GUIChecks.ReplaceDot(sender, e);

            if (!GUIChecks.TryGetValue(CurrentTempTextBox, out double txtBoxValue, false))
            {
                _isChanging = false;
                return;
            }

            CurrentTempSlider.Value = txtBoxValue;
            _bivalentGraph.DrawCurrentHeatLoss(BivalentPointChart, txtBoxValue);
            CalculateUtilization();
            _isChanging = false;
        }
コード例 #11
0
        private void CompareAdvancedEconomics()
        {
            if (!GUIChecks.TryGetValue(CeTextBox, out double Ce, false) ||
                !GUIChecks.TryGetValue(CqTextBox, out double Cq, false) ||
                !GUIChecks.TryGetValue(QrTextBox, out double Qr, false) ||
                !GUIChecks.TryGetValue(EfficiencyTextBox, out double efficiency, false) ||
                !GUIChecks.TryGetValue(ThisSystemNprTextBox, out double thisSysNpr, false) ||
                !GUIChecks.TryGetValue(ThisSystemINTextBox, out double thisSysIN, false) ||
                !GUIChecks.TryGetValue(ThisSystemJINTextBox, out double thisSysJIN, false) ||
                !GUIChecks.TryGetValue(OtherSystemNprTextBox, out double otherSysNpr, false) ||
                !GUIChecks.TryGetValue(OtherSystemINTextBox, out double otherSysIN, false) ||
                !GUIChecks.TryGetValue(OtherSystemJINTextBox, out double otherSysJIN, false))
            {
                NpePercentageLabel.Content             = TotalCostsPercentageLabel.Content = "";
                ThisSystemNpeResultTextBox.Background  = OtherSystemNpeResultTextBox.Background = Brushes.White;
                ThisSystemTotalCostsTextBox.Background = OtherSystemTotalCostsTextBox.Background = Brushes.White;
                return;
            }

            // Npe
            double thisSysNpe  = Ce * Qr * (1 / SystemCalculation.GetSysCOP);
            double otherSysNpe = Cq * Qr * (1 / efficiency);

            SetColors(thisSysNpe, otherSysNpe, ThisSystemNpeResultTextBox, OtherSystemNpeResultTextBox,
                      NpePercentageLabel, true);

            ThisSystemNpeResultTextBox.Text  = thisSysNpe.ToString("F1");
            OtherSystemNpeResultTextBox.Text = otherSysNpe.ToString("F1");

            // total costs
            double thisSysTotalCosts  = thisSysNpe + thisSysIN * thisSysJIN + thisSysNpr;
            double otherSysTotalCosts = otherSysNpe + otherSysIN * otherSysJIN + otherSysNpr;

            SetColors(thisSysTotalCosts, otherSysTotalCosts, ThisSystemTotalCostsTextBox, OtherSystemTotalCostsTextBox,
                      TotalCostsPercentageLabel, true);

            ThisSystemTotalCostsTextBox.Text  = thisSysTotalCosts.ToString("F1");
            OtherSystemTotalCostsTextBox.Text = otherSysTotalCosts.ToString("F1");
        }
        private void RedrawGraph()
        {
            if (!GUIChecks.TryGetValue(AmbientMaxTEmpTxtBox, out _bivalentGraph.AmbientMaxTemp) ||
                !GUIChecks.TryGetValue(AmbientMinTempTxtBox, out _bivalentGraph.AmbientMinTemp) ||
                !GUIChecks.TryGetValue(ObjectHeatLossCoeffTxtBox, out _bivalentGraph.HeatLossCoefficient) ||
                !GUIChecks.TryGetValue(ZeroLoadTempTxtBox, out _bivalentGraph.ZeroLoadTemp))
            {
                return;
            }
            if (_mode != Mode.Monovalent &&
                !GUIChecks.TryGetValue(BivalentTempTxtBox, out _bivalentGraph.BivalentTemp))
            {
                return;
            }
            if (_mode == Mode.PartiallyBivalent &&
                !GUIChecks.TryGetValue(OnlyAdditionalSourceTempTextBox,
                                       out _bivalentGraph.AdditionalSourceOnlyTemp))
            {
                return;
            }

            _bivalentGraph.RedrawGraph(BivalentPointChart, _mode);
            _bivalentGraph.DrawCurrentHeatLoss(BivalentPointChart, CurrentTempSlider.Value);
        }