Exemple #1
0
        public void Discharge(BatteryPack battery, float current, TimeSpan time)
        {
            if (!Check(battery))
            {
                return;
            }

            // Vorbereitungen...
            var seconds = (float)time.TotalSeconds;
            var initial = battery.State.Initial;
            var now     = battery.State.Now;

            // Berechnungen...
            now.TemperaturFactor = 1;
            now.CurrentFactor    = 1;
            SetSelfDischarge(initial, now, seconds);
            float qt = GetChargeConsumption(now, seconds, current);

            SetStateOfDischarge(initial, now, qt);

            now.Voltage = GetDischargeVoltage(battery, now);
            now.Charge += qt;
            now.AddTime(time);

            // finish & check again
            Check(battery);
        }
Exemple #2
0
 /// <summary>
 /// Check if the battery is out of energy or not
 /// </summary>
 /// <param name="battery"></param>
 /// <returns></returns>
 private bool Check(BatteryPack battery)
 {
     if (battery.IsUnlimited)
     {
         return(true);
     }
     else
     {
         return(!battery.State.IsDepleted);
     }
 }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>the resulting voltage </returns>
        private float GetDischargeVoltage(BatteryPack battery, BatteryFields now)
        {
            /*
             * Berechnung des Entladeverhaltens:
             * ---------------------------------
             * Polynom-Funktion des n ten-Grades, bestimmt durch die Länge des Arrays "polynomials"
             * die Laufvariable i entspricht der Potenz:
             * [0] -> x^0 | [1] -> x^1 | [2] -> x^2 ...
             *
             * resultierende Formel:
             * --------------------
             * v = poly.[0] + poly.[1] * sod ^ 1 + poly.[2] * sod ^ [2] ...
             * v *= Temperaturkorrektur
             */
            float v = 0;

            for (int i = 0; i < battery.Polynom.Length; i++)
            {
                v += (float)(battery.Polynom[i] * Math.Pow(now.SoD, i));
            }
            v *= now.TemperaturFactor;

            return(v);
        }