Пример #1
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);
        }
Пример #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);
        }