Example #1
0
def defaultPropellants():

    cl = motorlib.propellant()
    cl.setProperties(clProps)

    ow = motorlib.propellant()
    ow.setProperties({'name': 'Ocean Water', 'density': 1650, 'a': 1.467e-05, 'n': 0.382, 't': 3500, 'm': 23.67, 'k': 1.25})

    return [cl, ow]
Example #2
0
 def loadPropellants(self):
     try:
         propList = loadFile(getConfigPath() + 'propellants.yaml', fileTypes.PROPELLANTS)
         for propDict in propList:
             newProp = propellant()
             newProp.setProperties(propDict)
             self.propellants.append(newProp)
     except FileNotFoundError:
         self.propellants = defaultPropellants()
         self.savePropellants()
Example #3
0
 def loadProperties(self, collection): # Override for ballisitc coefficient units
     props = collection.getProperties()
     # Convert the ballistic coefficient based on the exponent
     ballisticCoeffUnit = self.preferences.getUnit('m/(s*Pa^n)')
     if ballisticCoeffUnit == 'in/(s*psi^n)':
         props['a'] /= 1/(6895**props['n'])
     # Create a new propellant instance using the new A
     newProp = propellant()
     newProp.setProperties(props)
     super().loadProperties(newProp)
     self.labelCStar.show()
Example #4
0
 def newPropellant(self):
     propName = "New Propellant"
     if propName in self.manager.getNames():
         propNumber = 1
         while propName + " " + str(propNumber) in self.manager.getNames():
             propNumber += 1
         propName = propName + " " + str(propNumber)
     np = propellant()
     np.setProperties({'name': propName, 'density': 1680, 'a': 3.517054143255937e-05, 'n': 0.3273, 't': 2800, 'm': 23.67, 'k': 1.21})
     self.manager.propellants.append(np)
     self.setupPropList()
     self.setupButtons()
     self.manager.savePropellants()
Example #5
0
    def importFile(self, path):
        motor = motorlib.motor()
        tree = ET.parse(path)
        root = tree.getroot()
        errors = ''
        propSet = False
        for child in root:
            if child.tag == 'Nozzle':
                motor.nozzle.setProperty('throat',
                                         inToM(child.attrib['ThroatDia']))
                motor.nozzle.setProperty('exit',
                                         inToM(child.attrib['ExitDia']))
                motor.nozzle.setProperty(
                    'efficiency',
                    float(child.attrib['NozzleEfficiency']) / 100)
            if child.tag == 'Grain':
                if child.attrib['Type'] in supportedGrainTable:
                    motor.grains.append(
                        supportedGrainTable[child.attrib['Type']]())
                    motor.grains[-1].setProperty(
                        'diameter', inToM(child.attrib['Diameter']))
                    motor.grains[-1].setProperty('length',
                                                 inToM(child.attrib['Length']))

                    grainType = child.attrib['Type']

                    if child.attrib['EndsInhibited'] == '1':
                        motor.grains[-1].setProperty('inhibitedEnds', 'Top')
                    elif child.attrib['EndsInhibited'] == '2':
                        motor.grains[-1].setProperty('inhibitedEnds', 'Both')

                    if grainType in ('1', '3',
                                     '7'):  # Grains with core diameter
                        motor.grains[-1].setProperty(
                            'coreDiameter',
                            inToM(child.attrib['CoreDiameter']))

                    if grainType == '2':  # D grain specific properties
                        motor.grains[-1].setProperty(
                            'slotOffset', inToM(child.attrib['EdgeOffset']))

                    elif grainType == '3':  # Moonburner specific properties
                        motor.grains[-1].setProperty(
                            'coreOffset', inToM(child.attrib['CoreOffset']))

                    elif grainType == '5':  # C grain specific properties
                        motor.grains[-1].setProperty(
                            'slotWidth', inToM(child.attrib['SlotWidth']))
                        radius = motor.grains[-1].getProperty('diameter') / 2
                        motor.grains[-1].setProperty(
                            'slotOffset',
                            radius - inToM(child.attrib['SlotDepth']))

                    elif grainType == '6':  # X core specific properties
                        motor.grains[-1].setProperty(
                            'slotWidth', inToM(child.attrib['SlotWidth']))
                        motor.grains[-1].setProperty(
                            'slotLength',
                            inToM(child.attrib['CoreDiameter']) / 2)

                    elif grainType == '7':  # Finocyl specific properties
                        motor.grains[-1].setProperty(
                            'finWidth', inToM(child.attrib['FinWidth']))
                        motor.grains[-1].setProperty(
                            'finLength', inToM(child.attrib['FinLength']))
                        motor.grains[-1].setProperty(
                            'numFins', int(child.attrib['FinCount']))

                    if not propSet:  # Use propellant numbers from the forward grain
                        impProp = child.find('Propellant')
                        propellant = motorlib.propellant()
                        propellant.setProperty('name', impProp.attrib['Name'])
                        n = float(impProp.attrib['BallisticN'])
                        a = float(impProp.attrib['BallisticA']) * 1 / (6895**n)
                        propellant.setProperty('n', n)
                        propellant.setProperty(
                            'a',
                            motorlib.convert(a, 'in/(s*psi^n)', 'm/(s*Pa^n)')
                        )  # Conversion only does in/s to m/s, the rest is handled above
                        propellant.setProperty(
                            'density',
                            motorlib.convert(float(impProp.attrib['Density']),
                                             'lb/in^3', 'kg/m^3'))
                        propellant.setProperty(
                            'k', float(impProp.attrib['SpecificHeatRatio']))
                        impMolarMass = impProp.attrib['MolarMass']
                        if impMolarMass == '0':
                            propellant.setProperty(
                                'm', 23.67
                            )  # If the user has entered 0, override it to match the default propellant.
                        else:
                            propellant.setProperty('m', float(impMolarMass))
                        propellant.setProperty(
                            't', 3500
                        )  # Burnsim doesn't provide this property. Set it to match the default propellant.
                        motor.propellant = propellant
                        propSet = True

                else:
                    if child.attrib['Type'] in unsupportedGrainTable:
                        errors += "File contains a " + unsupportedGrainTable[
                            child.attrib[
                                'Type']] + " grain, which can't be imported.\n"
                    else:
                        errors += "File contains an unknown grain of type " + child.attrib[
                            'Type'] + '.\n'

            if child.tag == 'TestData':
                errors += "\nFile contains test data, which is not imported."

        if errors != '':
            self.showWarning(errors +
                             '\nThe rest of the motor will be imported.')

        self.fileManager.startFromMotor(motor)
        return True