summaryrefslogtreecommitdiff
path: root/precharge.cpp
diff options
context:
space:
mode:
authorJoshua Drake <joshua.drake@ditchwitch.com>2022-11-21 16:34:17 -0600
committerJoshua Drake <joshua.drake@ditchwitch.com>2022-11-21 16:34:17 -0600
commit179ed918aed1c9f190ae6846ea4bcccccbeab18f (patch)
tree1fabd0bbc20e102097eeecf18e2238f121629d0f /precharge.cpp
parent341e61f7a6f9deebf086a2b8147e252be6d45f33 (diff)
Added Pre-Charge functionality and made thing prettier.
Diffstat (limited to 'precharge.cpp')
-rw-r--r--precharge.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/precharge.cpp b/precharge.cpp
new file mode 100644
index 0000000..e19820b
--- /dev/null
+++ b/precharge.cpp
@@ -0,0 +1,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();
+}
+
+