def calculo(self): tdp, tdb, twb, P, Pvs, Pv, ws, w, HR, v, h = self._lib() self.tdp = Temperature(tdp) self.tdb = Temperature(tdb) self.twb = Temperature(twb) self.P = Pressure(P) self.Pvs = Pressure(Pvs) self.Pv = Pressure(Pv) self.ws = Dimensionless(ws, txt="kgw/kgda") self.w = Dimensionless(w, txt="kgw/kgda") self.HR = Dimensionless(HR, txt="%") self.mu = Dimensionless(w/ws*100) self.v = SpecificVolume(v) self.rho = Density(1/v) self.h = Enthalpy(h, "kJkg") self.Xa = 1/(1+self.w/0.62198) self.Xw = 1-self.Xa
def plot(self): """Plot chart""" self.plt.clearPointData() self.plt.ax.clear() chart = self.Preferences.getboolean("Psychr", "chart") self.plt.config(self.Preferences) filename = conf_dir+"%s_%i.json" % ( PsychroState().__class__.__name__, self.inputs.P.value) if os.path.isfile(filename): with open(filename, "r") as archivo: data = json.load(archivo) self.status.setText(QtWidgets.QApplication.translate( "pychemqt", "Loading cached data...")) QtWidgets.QApplication.processEvents() else: self.progressBar.setVisible(True) self.status.setText(QtWidgets.QApplication.translate( "pychemqt", "Calculating data...")) QtWidgets.QApplication.processEvents() data = PsychroState.calculatePlot(self) with open(filename, "w") as file: json.dump(data, file, indent=4) self.progressBar.setVisible(False) self.status.setText( QtWidgets.QApplication.translate("pychemqt", "Plotting...")) QtWidgets.QApplication.processEvents() # Saturation line t = [Temperature(ti).config() for ti in data["t"]] Hs = data["Hs"] format = formatLine(self.Preferences, "Psychr", "saturation") if chart: self.plt.plot(t, Hs, **format) else: self.plt.plot(Hs, t, **format) # Iso dew bulb temperaure lines, vertial lines in normal h-Tdb plot, # vertical in mollier diagram format = formatLine(self.Preferences, "Psychr", "isotdb") for i, T in enumerate(t): if chart: self.plt.plot([T, T], [0, Hs[i]], **format) else: self.plt.plot([0, Hs[i]], [T, T], **format) # Iso humidity lines, horizontal lines in normal h-Tdb plot, vertical # in mollier diagram H = data["H"] th = data["th"] tm = Temperature(self.Preferences.getfloat("Psychr", "isotdbEnd")) format = formatLine(self.Preferences, "Psychr", "isow") for i, H in enumerate(H): ts = Temperature(th[i]).config() if chart: self.plt.plot([ts, tm.config()], [H, H], **format) else: self.plt.plot([H, H], [ts, tm.config()], **format) # Iso relative humidity lines format = formatLine(self.Preferences, "Psychr", "isohr") for Hr, H0 in list(data["Hr"].items()): if chart: self.plt.plot(t, H0, **format) self.drawlabel("isohr", t, H0, Hr, "%") else: self.plt.plot(H0, t, **format) self.drawlabel("isohr", H0, t, Hr, "%") # Iso wet bulb temperature lines format = formatLine(self.Preferences, "Psychr", "isotwb") for T, (H, Tw) in list(data["Twb"].items()): value = Temperature(T).config() Tw_conf = [Temperature(Twi).config() for Twi in Tw] txt = Temperature.text() if chart: self.plt.plot(Tw_conf, H, **format) self.drawlabel("isotwb", Tw_conf, H, value, txt) else: self.plt.plot(H, Tw_conf, **format) self.drawlabel("isotwb", H, Tw_conf, value, txt) # Isochor lines format = formatLine(self.Preferences, "Psychr", "isochor") for v, (Td, H) in list(data["v"].items()): value = SpecificVolume(v).config() Td_conf = [Temperature(Tdi).config() for Tdi in Td] txt = SpecificVolume.text() if chart: self.plt.plot(Td_conf, H, **format) self.drawlabel("isochor", Td_conf, H, value, txt) else: self.plt.plot(H, Td_conf, **format) self.drawlabel("isochor", H, Td_conf, value, txt) if self.plt.state: self.plt.createCrux(self.plt.state, chart) self.plt.draw() self.status.setText("%s %s" % ( QtWidgets.QApplication.translate("pychemqt", "Using"), PsychroState().__class__.__name__[3:]))
def plot(self): """Plot chart""" self.plt.clearPointData() self.plt.ax.clear() chart = self.Preferences.getboolean("Psychr", "chart") self.plt.config(self.Preferences) filename = conf_dir+"%s_%i.pkl" % ( PsychroState().__class__.__name__, self.inputs.P.value) if os.path.isfile(filename): with open(filename, "rb") as archivo: data = pickle.load(archivo) self.status.setText(QtWidgets.QApplication.translate( "pychemqt", "Loading cached data...")) QtWidgets.QApplication.processEvents() else: self.progressBar.setVisible(True) self.status.setText(QtWidgets.QApplication.translate( "pychemqt", "Calculating data...")) QtWidgets.QApplication.processEvents() data = PsychroState.calculatePlot(self) pickle.dump(data, open(filename, "wb")) self.progressBar.setVisible(False) self.status.setText( QtWidgets.QApplication.translate("pychemqt", "Plotting...")) QtWidgets.QApplication.processEvents() # Saturation line t = [Temperature(ti).config() for ti in data["t"]] Hs = data["Hs"] format = formatLine(self.Preferences, "Psychr", "saturation") if chart: self.plt.plot(t, Hs, **format) else: self.plt.plot(Hs, t, **format) # Iso dew bulb temperaure lines, vertial lines in normal h-Tdb plot, # vertical in mollier diagram format = formatLine(self.Preferences, "Psychr", "isotdb") for i, T in enumerate(t): if chart: self.plt.plot([T, T], [0, Hs[i]], **format) else: self.plt.plot([0, Hs[i]], [T, T], **format) # Iso humidity lines, horizontal lines in normal h-Tdb plot, vertical # in mollier diagram H = data["H"] th = data["th"] tm = Temperature(self.Preferences.getfloat("Psychr", "isotdbEnd")) format = formatLine(self.Preferences, "Psychr", "isow") for i, H in enumerate(H): if chart: self.plt.plot([th[i], tm.config()], [H, H], **format) else: self.plt.plot([H, H], [th[i], tm.config()], **format) # Iso relative humidity lines format = formatLine(self.Preferences, "Psychr", "isohr") for Hr, H0 in list(data["Hr"].items()): if chart: self.plt.plot(t, H0, **format) self.drawlabel("isohr", t, H0, Hr, "%") else: self.plt.plot(H0, t, **format) self.drawlabel("isohr", H0, t, Hr, "%") # Iso wet bulb temperature lines format = formatLine(self.Preferences, "Psychr", "isotwb") for T, (H, Tw) in list(data["Twb"].items()): value = Temperature(T).config() txt = Temperature.text() if chart: self.plt.plot(Tw, H, **format) self.drawlabel("isotwb", Tw, H, value, txt) else: self.plt.plot(H, Tw, **format) self.drawlabel("isotwb", H, Tw, value, txt) # Isochor lines format = formatLine(self.Preferences, "Psychr", "isochor") for v, (Td, H) in list(data["v"].items()): value = SpecificVolume(v).config() txt = SpecificVolume.text() if chart: self.plt.plot(Td, H, **format) self.drawlabel("isochor", Td, H, value, txt) else: self.plt.plot(H, Td, **format) self.drawlabel("isochor", H, Td, value, txt) if self.plt.state: self.plt.createCrux(self.plt.state, chart) self.plt.draw() self.status.setText("%s %s" % ( QtWidgets.QApplication.translate("pychemqt", "Using"), PsychroState().__class__.__name__[3:]))