Example #1
0
        /**
         * fimeFrom / timeTo - time in day in hours
         */
        private void SimulateTo(int dayInYear, float time)
        {
            //float deltaT =
            var roomState = room_.SetTimeWithWarmUp(dayInYear, time, 7);

            //RoomSimulator.State roomState = room_.Simulate(deltaT);
            fanStatus.Text = room_.FanStatus() ? "On" : "Off";
            TimeSpan ts = TimeSpan.FromHours(time);

            curTime.Text  = ts.ToString(@"hh\:mm");
            curTemp.Text  = roomState.curTemp.ToString("f1");
            minTemp.Text  = roomState.minTemp.ToString("f1");
            maxTemp.Text  = roomState.maxTemp.ToString("f1");
            roomTemp.Text = roomState.roomTemperature_.ToString("f1");
        }
Example #2
0
        private SimulationResults.FanControlResults SimulateDays(FanControl fc, int days)
        {
            float duration = 24.0f * days;

            //DoSimulateDay();

            int dayInYear = DayInYearInput();

            int warmUpDays = 7; // TODO: find shortest warm-up necessary, longer warm-up should make almost no difference

            var room = new RoomSimulator();

            room.SelectFanControl(fc);
            room.SetTimeWithWarmUp(dayInYear, 0, warmUpDays);

            float deltaT = 0.05f;

            int   nSamples   = 0;
            float sumTemp    = 0;
            float sumFanOn   = 0;
            float sumTempOsc = 0;
            float lastTemp   = room.GetRoomTemperature();

            float    lastMin  = lastTemp;
            float    lastMax  = lastTemp;
            OscState oscState = OscState.None;
            float    sumOsc   = 0;
            int      nOsc     = 0;


            for (float t = 0; t < duration; t += deltaT)
            {
                RoomSimulator.State roomState = room.AdvanceTime(deltaT);
                nSamples++;
                float temp = roomState.roomTemperature_;
                sumTemp += temp;

                if (temp > lastTemp)
                {
                    if (oscState == OscState.Down)
                    {
                        lastMin = lastTemp;
                    }
                    oscState = OscState.Up;
                }
                else
                {
                    if (oscState == OscState.Up)
                    {
                        lastMax = lastTemp;
                        sumOsc += lastMax - lastMin;
                        nOsc++;
                    }
                    oscState = OscState.Down;
                }
                sumTempOsc += Math.Abs(temp - lastTemp) / deltaT;
                lastTemp    = temp;
                sumFanOn   += (room.FanStatus() ? 1 : 0) * deltaT;
            }
            return(new SimulationResults.FanControlResults(fc.Name(), sumTemp / nSamples, sumTempOsc / nSamples, sumFanOn * 100 / duration));
            //return new SimulationResults.FanControlResults(fc.Name(), sumTemp / nSamples, sumOsc / nOsc, sumFanOn * 100 / duration);
        }
Example #3
0
        private SimulationResults.FanControlResults SimulateDays(FanControl fc, int days)
        {
            float duration = 24.0f * days;

              //DoSimulateDay();

              int dayInYear = DayInYearInput();

              int warmUpDays = 7; // TODO: find shortest warm-up necessary, longer warm-up should make almost no difference

              var room = new RoomSimulator();

              room.SelectFanControl(fc);
              room.SetTimeWithWarmUp(dayInYear, 0, warmUpDays);

              float deltaT = 0.05f;

              int nSamples = 0;
              float sumTemp = 0;
              float sumFanOn = 0;
              float sumTempOsc = 0;
              float lastTemp = room.GetRoomTemperature();

              float lastMin = lastTemp;
              float lastMax = lastTemp;
              OscState oscState = OscState.None;
              float sumOsc = 0;
              int nOsc = 0;

              for (float t = 0; t < duration; t += deltaT)
              {
            RoomSimulator.State roomState = room.AdvanceTime(deltaT);
            nSamples++;
            float temp = roomState.roomTemperature_;
            sumTemp += temp;

            if (temp > lastTemp)
            {
              if (oscState == OscState.Down)
              {
            lastMin = lastTemp;
              }
              oscState = OscState.Up;
            }
            else
            {
              if (oscState == OscState.Up)
              {
            lastMax = lastTemp;
            sumOsc += lastMax - lastMin;
            nOsc++;
              }
              oscState = OscState.Down;

            }
            sumTempOsc += Math.Abs(temp - lastTemp)/deltaT;
            lastTemp = temp;
            sumFanOn += (room.FanStatus() ? 1 : 0) * deltaT;
              }
              return new SimulationResults.FanControlResults(fc.Name(), sumTemp / nSamples, sumTempOsc / nSamples, sumFanOn * 100 / duration);
              //return new SimulationResults.FanControlResults(fc.Name(), sumTemp / nSamples, sumOsc / nOsc, sumFanOn * 100 / duration);
        }