Exemplo n.º 1
0
    def chooseElements(self):
        oldel = self.mix.g.elementNames()
        newel = getElements(self.mix.g.elementNames())
        removeList = []
        for el in oldel:
            if not el in newel:
                removeList.append(el)
        #self.app.mech.removeElements(removeList)
        addList = []
        for el in newel:
            if not el in oldel:
                addList.append(el)
        #self.app.mech.addElements(addList)
        try:
            self.redraw()
            self.app.makeWindows()
        except:
            handleError('Edit err')

        self.app.mix = IdealGasMixture(self.app.mech)
        self.mix = self.app.mix
        nn = self.mix.speciesList[0].name
        self.mix.set(temperature = 300.0, pressure = 101325.0, moles = {nn:1.0})
        for label in self.element_labels:
            label.destroy()
        self.element_labels = []
        n = 0
        for el in self.mix._mech.elementList():
            x = Label(self.eframe,text=el.symbol(),fg='darkblue')
            x.grid(column = n, row=0)
            self.element_labels.append(x)
            n = n + 1

        self.app.makeWindows()
Exemplo n.º 2
0
def getDrones():
    try:
        drones = copy.deepcopy(drone_awe.drones)
        resp = []
        for drone in drones:
            el = {}
            if 'battery' in drone:
                for prop in drone['battery']:
                    l = list(
                        filter(lambda el: el['param'] == prop,
                               utilities.ParamMap))
                    if len(l) > 0:
                        el[l[0]['display']] = drone['battery'][prop]
                del drone['battery']
            for prop in drone:
                l = list(
                    filter(lambda el: el['param'] == prop, utilities.ParamMap))
                if len(l) > 0:
                    el[l[0]['display']] = drone[prop]
            resp.append(el)

        return Response(json.dumps(resp))
    except Exception as err:
        utilities.handleError(err)
    a.simulate()
Exemplo n.º 3
0
    def chooseElements(self):
        oldel = self.mix.g.elementNames()
        newel = getElements(self.mix.g.elementNames())
        removeList = []
        for el in oldel:
            if not el in newel:
                removeList.append(el)
        #self.app.mech.removeElements(removeList)
        addList = []
        for el in newel:
            if not el in oldel:
                addList.append(el)
        #self.app.mech.addElements(addList)
        try:
            self.redraw()
            self.app.makeWindows()
        except:
            handleError('Edit err')

        self.app.mix = IdealGasMixture(self.app.mech)
        self.mix = self.app.mix
        nn = self.mix.speciesList[0].name
        self.mix.set(temperature=300.0, pressure=101325.0, moles={nn: 1.0})
        for label in self.element_labels:
            label.destroy()
        self.element_labels = []
        n = 0
        for el in self.mix._mech.elementList():
            x = Label(self.eframe, text=el.symbol(), fg='darkblue')
            x.grid(column=n, row=0)
            self.element_labels.append(x)
            n = n + 1

        self.app.makeWindows()
Exemplo n.º 4
0
    def setState(self,event=None):
        if event:
            self.warn = 0
        else:
            self.warn = 1
        self.top.mixfr.update()
        i = self.equil.get()
        optlist = ['frozen','equilibrium']
        opt = [optlist[i]]

        if self.prop[_PRESSURE].isChecked() \
           and self.prop[_TEMPERATURE].isChecked():
            self.mix.set(
                    temperature = self.prop[_TEMPERATURE].get(),
                    pressure = self.prop[_PRESSURE].get(),
                    equil=i)

        elif self.prop[_DENSITY].isChecked() \
             and self.prop[_TEMPERATURE].isChecked():
            self.mix.set(
                    temperature = self.prop[_TEMPERATURE].get(),
                    density = self.prop[_DENSITY].get(),
                    equil=i)

        elif self.prop[_ENTROPY].isChecked() \
             and self.prop[_PRESSURE].isChecked():
            self.mix.set(pressure = self.prop[_PRESSURE].get(),
                         entropy = self.prop[_ENTROPY].get(),
                         equil=i)

        elif self.prop[_ENTHALPY].isChecked() \
             and self.prop[_PRESSURE].isChecked():
            self.mix.set(pressure = self.prop[_PRESSURE].get(),
                         enthalpy = self.prop[_ENTHALPY].get(),
                         equil=i)

        elif self.prop[_INTENERGY].isChecked() \
             and self.prop[_DENSITY].isChecked():
            self.mix.set(density = self.prop[_DENSITY].get(),
                         intEnergy = self.prop[_INTENERGY].get(),
                         equil=i)
        else:
            if self.warn > 0:
                handleError("unsupported property pair")

        self.top.update()
Exemplo n.º 5
0
def getValidationCases():
    try:
        data = drone_awe.validationdatabase
        data = [d for d in data if 'xvalid' in d]
        resp = Response(json.dumps(data))
        return resp
    except Exception as err:
        return utilities.handleError(err)
Exemplo n.º 6
0
	def setState(self,event=None):
		if event:
			self.warn = 0
		else:
			self.warn = 1
		self.top.mixfr.update()
		i = self.equil.get()
		optlist = ['frozen','equilibrium']
		opt = [optlist[i]]
                
		if self.prop[_PRESSURE].isChecked() \
                   and self.prop[_TEMPERATURE].isChecked():
                    self.mix.set(
			    temperature = self.prop[_TEMPERATURE].get(),
                            pressure = self.prop[_PRESSURE].get(),
			    equil=i)

                elif self.prop[_DENSITY].isChecked() \
                     and self.prop[_TEMPERATURE].isChecked():
                    self.mix.set(
			    temperature = self.prop[_TEMPERATURE].get(),
                            density = self.prop[_DENSITY].get(),
			    equil=i)
                    
                elif self.prop[_ENTROPY].isChecked() \
                     and self.prop[_PRESSURE].isChecked():
                    self.mix.set(pressure = self.prop[_PRESSURE].get(),
                                 entropy = self.prop[_ENTROPY].get(),
                                 equil=i)
                    
                elif self.prop[_ENTHALPY].isChecked() \
                     and self.prop[_PRESSURE].isChecked():
                    self.mix.set(pressure = self.prop[_PRESSURE].get(),
                                 enthalpy = self.prop[_ENTHALPY].get(),
                                 equil=i)
                    
		elif self.prop[_INTENERGY].isChecked() \
                     and self.prop[_DENSITY].isChecked():
                    self.mix.set(density = self.prop[_DENSITY].get(),
                                 intEnergy = self.prop[_INTENERGY].get())
		else:
			if self.warn > 0:
				handleError("unsupported property pair")

		self.top.update()
Exemplo n.º 7
0
    def loadmech(self, mechname, pathname, mw=1):

        p = os.path.normpath(os.path.dirname(pathname))
        self.fname = os.path.basename(pathname)
        ff = os.path.splitext(self.fname)

        try:
            self.mech = IdealGasMix(pathname)
            self.mechname = ff[0]

        except:
            utilities.handleError('could not create gas mixture object: '
                                  +ff[0]+'\n')
            self.mechname = 'Error'
            return

        self.makeMix()

        if not mechname:
            mechname = self.mechname

        self.mechframe.addMechanism(mechname, self.mech)
        if mw==1:
            self.makeWindows()
Exemplo n.º 8
0
def simulate():
    try:
        # Track Z-variable
        zParam = None

        params = {}
        if request.data:
            params = json.loads(request.data)
            # zParam = params['zParam']

        for arg in utilities.DefaultArgs:
            if arg['name'] not in params:
                print(f'Missing', {arg['name']}, 'Using default value:',
                      {arg['default']})
                params[arg['name']] = arg['default']

        a = drone_awe.model(params)
        try:
            a.simulate()
            data = a.output

            resp = {
                'error': False,
                'errorType': None,
                'log': 'Successful simulation',
                'plottables': [],
                'zAxis': {
                    'id': zParam,
                    'displayName': '',
                    'values': []
                }
            }

            if zParam:
                resp['zAxis']['displayName'] = data['zvals']

            for key in list(data.keys()):
                if key != 'zvals' and type(data[key][0][0]) != str:
                    l = list(
                        filter(lambda el: el['param'] == key,
                               utilities.ParamMap))

                    if len(l) >= 1:
                        displayName = l[0]['display']
                        plottable = {
                            'id': key,
                            'displayName': displayName,
                            'values': data[key]
                        }
                        if key == 'missionspeed':
                            print(plottable)
                        resp['plottables'].append(plottable)
                    else:
                        print(f'Missing ParamMep entry for {key}')
            resp = Response(json.dumps(resp))
            return resp
        except Exception as err:
            resp = {
                'error': True,
                'errorType': None,
                'log': 'Simulation failed: ' + err.__repr__(),
                'plottables': [],
                'zAxis': {
                    'id': zParam,
                    'displayName': '',
                    'values': []
                }
            }
            resp = Response(json.dumps(resp))
            return resp
    except Exception as err:
        return utilities.handleError(err)