summaryrefslogtreecommitdiff
path: root/precharge.cpp
blob: e19820bae2dad4814c1e9a5abb6c1e71f45be20d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "precharge.h"
#include "QDebug"

Precharge::Precharge() :
    maximumVoltage(0),
    preChargeTime(0),
    preChargePercentage(100),
    chosenResistance(0),
    systemCapacitance(0)
{

}

void Precharge::setMaximumVoltage(double voltage)
{
    maximumVoltage = voltage;
}
void Precharge::setPreChargeTime(double time)
{
    preChargeTime = time;
}
void Precharge::setPreChargePercentage(double percentage)
{
    preChargePercentage = percentage;
}
void Precharge::setSystemCapacitance(float capacitance)
{
    systemCapacitance = capacitance*std::pow(10,-6); //uF
    qDebug() << systemCapacitance;
}

void Precharge::setChosenResistance(double resistance)
{
    chosenResistance = resistance;
}

void Precharge::calculate()
{
    emit calculation();
}

double Precharge::maximumResistance(void)
{
    return preChargeTime/(-std::log(1-(preChargePercentage*0.01))*systemCapacitance);
}

double Precharge::actualPreChargeTime(void)
{
    return (-std::log(1-(preChargePercentage*0.01)))*chosenResistance*systemCapacitance;
}

double Precharge::peakInRushCurrent(void)
{
    return maximumVoltage/chosenResistance;
}

double Precharge::averagePower(void)
{
    return (((systemCapacitance*std::pow(maximumVoltage,2))/2)*(1-exp((-2*actualPreChargeTime())/(chosenResistance*systemCapacitance))))/actualPreChargeTime();
}