From 179ed918aed1c9f190ae6846ea4bcccccbeab18f Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Mon, 21 Nov 2022 16:34:17 -0600 Subject: Added Pre-Charge functionality and made thing prettier. --- precharge.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 precharge.cpp (limited to 'precharge.cpp') 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(); +} + + -- cgit v1.2.3