From 545a8e190455cd21f62bae061d79c13a84c68e3a Mon Sep 17 00:00:00 2001 From: Andrew Reilley Date: Sat, 14 Dec 2024 19:58:34 -0500 Subject: [PATCH] Add impulse class percentage display --- motorlib/simResult.py | 11 ++++++++++- uilib/widgets/mainWindow.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/motorlib/simResult.py b/motorlib/simResult.py index 2d7d81c..3a1cc32 100644 --- a/motorlib/simResult.py +++ b/motorlib/simResult.py @@ -184,12 +184,21 @@ def getDesignation(self): imp = self.getImpulse() if imp < 1.25: # This is to avoid a domain error finding log(0) return 'N/A' - return chr(int(math.log(imp/1.25, 2)) + 65) + str(int(self.getAverageForce())) + return chr(int(math.log(imp / 1.25, 2)) + 65) + str(int(self.getAverageForce())) def getFullDesignation(self): """Returns the full motor designation, which also includes the total impulse prepended on""" return '{:.0f}{}'.format(self.getImpulse(), self.getDesignation()) + def getImpulseClassPercentage(self): + """Returns the percentage of the way between the minimum and maximum impulse for the impulse class that the + motor is""" + impulse = self.getImpulse() + if impulse < 1.25: # This is to avoid a domain error finding log(0) + return 0 + minClassImpulse = 1.25 * 2 ** int(math.log(impulse / 1.25, 2)) + return (impulse - minClassImpulse) / minClassImpulse + def getPeakMassFlux(self): """Returns the maximum mass flux observed at any grain end.""" return self.channels['massFlux'].getMax() diff --git a/uilib/widgets/mainWindow.py b/uilib/widgets/mainWindow.py index 0b78237..d1962b3 100644 --- a/uilib/widgets/mainWindow.py +++ b/uilib/widgets/mainWindow.py @@ -291,7 +291,7 @@ def formatMotorStat(self, quantity, inUnit): return '{:.2f} {}'.format(motorlib.units.convert(quantity, inUnit, convUnit), convUnit) def updateMotorStats(self, simResult): - self.ui.labelMotorDesignation.setText(simResult.getDesignation()) + self.ui.labelMotorDesignation.setText('{} ({:.0%})'.format(simResult.getDesignation(), simResult.getImpulseClassPercentage())) self.ui.labelImpulse.setText(self.formatMotorStat(simResult.getImpulse(), 'Ns')) self.ui.labelDeliveredISP.setText(self.formatMotorStat(simResult.getISP(), 's')) self.ui.labelBurnTime.setText(self.formatMotorStat(simResult.getBurnTime(), 's'))