-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Max Pressure" tool, Kn->pressure graph
This commit moves the function for going from kn to pressure from the motor class to the propellant class and uses it for a new graph in the propellant editor. It also adds a new tool that takes in a desired max pressure and changes the nozzle throat so the motor won't exceed it.
- Loading branch information
Showing
10 changed files
with
132 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .changeDiameter import * | ||
from .initialKN import * | ||
from .maxKN import * | ||
from .maxPressure import * | ||
from .expansion import * | ||
from .neutralBates import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import motorlib | ||
|
||
from ..tool import Tool | ||
|
||
|
||
class MaxPressureTool(Tool): | ||
def __init__(self, manager): | ||
props = {'pressure': motorlib.properties.FloatProperty('Pressure', 'Pa', 0, 7e7)} | ||
super().__init__(manager, | ||
'Max Pressure', | ||
'Use this tool to set the nozzle throat to keep the chamber pressure below a certain value during the burn.', | ||
props, | ||
True) | ||
|
||
def applyChanges(self, inp, motor, simulation): | ||
kn = motor.propellant.getKnFromPressure(inp['pressure']) | ||
surfArea = simulation.getPeakKN() * motorlib.geometry.circleArea(motor.nozzle.props['throat'].getValue()) | ||
throatArea = surfArea / kn | ||
motor.nozzle.props['throat'].setValue(motorlib.geometry.circleDiameterFromArea(throatArea)) | ||
self.manager.updateMotor(motor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas | ||
from matplotlib.figure import Figure | ||
|
||
from motorlib.units import convertAll | ||
|
||
class PropellantPressureGraph(FigureCanvas): | ||
def __init__(self): | ||
super(PropellantPressureGraph, self).__init__(Figure()) | ||
self.setParent(None) | ||
self.preferences = None | ||
|
||
self.figure = Figure() | ||
self.canvas = FigureCanvas(self.figure) | ||
self.figure.tight_layout() | ||
|
||
self.plot = self.figure.add_subplot(111) | ||
|
||
def setPreferences(self, pref): | ||
self.preferences = pref | ||
|
||
def cleanup(self): | ||
self.plot.clear() | ||
self.draw() | ||
|
||
def showGraph(self, points): | ||
presUnit = self.preferences.getUnit('Pa') | ||
|
||
self.plot.plot(points[0], convertAll(points[1], 'Pa', presUnit)) | ||
self.plot.set_xlabel('Kn') | ||
self.plot.set_ylabel('Pressure - {}'.format(presUnit)) | ||
self.plot.grid(True) | ||
self.figure.subplots_adjust(top=0.95, bottom=0.25) | ||
self.draw() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters