Курсовая работа: Применение нечёткой логики на примере простой модели зарядного устройства для батарей
}
// Affect the current battery voltage given the load
voltage -= load[curLoad];
// Next, update the battery voltage given input charge
if (ChargeMode == FAST_CHARGE) {
voltage += (charge(t) * (float)Math.Sqrt(timer));
} else {
voltage += ((charge(t) * (float)Math.Sqrt(timer)) / (float)10.0 );
}
if (voltage < 0.0) voltage = (float)0.0;
else if (voltage > 35.0) voltage = (float)35.0;
// Update the temperature
if (ChargeMode == FAST_CHARGE) {
if (voltage > 25) {
temperature += ((load[curLoad] * ((float)Math.Sqrt(timer)/(float)25.0)) * (float)10.0);
} else if (voltage > 15) {
temperature += ((load[curLoad] * ((float)Math.Sqrt(timer) / (float)20.0)) * (float)10.0);
} else {
temperature += ((load[curLoad] * ((float)Math.Sqrt(timer) / (float)15.0)) *(float) 10.0);
}
} else {
if (temperature > 20.0) {
temperature -= ((load[curLoad] * ((float)Math.Sqrt(timer) / (float)20.0)) * (float)10.0);
} else {
temperature -= ((load[curLoad] * ((float)Math.Sqrt(timer) /(float) 100.0)) * (float)10.0);
}
}
if (temperature < 0.0) temperature = (float)0.0;
else if (temperature > 40.0) temperature = (float)40.0;