Skip to content

Commit

Permalink
Add impulse class percentage display
Browse files Browse the repository at this point in the history
  • Loading branch information
reilleya committed Dec 15, 2024
1 parent 40fca7f commit 545a8e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion motorlib/simResult.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion uilib/widgets/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 545a8e1

Please sign in to comment.