def config(self, config): self.ax.set_autoscale_on(False) chart = config.getboolean("Psychr", "chart") xlabel = "Tdb, " + Temperature.text() ylabel = "%s, %s/%s" % ( QtWidgets.QApplication.translate("pychemqt", "Absolute humidity"), Mass.text(), Mass.text()) tmin = Temperature(config.getfloat("Psychr", "isotdbStart")).config() tmax = Temperature(config.getfloat("Psychr", "isotdbEnd")).config() wmin = config.getfloat("Psychr", "isowStart") wmax = config.getfloat("Psychr", "isowEnd") if chart: self.ax.set_xlabel(xlabel, size="large") self.ax.set_ylabel(ylabel, size="large") self.ax.set_xlim(tmin, tmax) self.ax.set_ylim(wmin, wmax) self.ax.yaxis.set_ticks_position("right") self.ax.yaxis.set_label_position("right") self.ax.figure.subplots_adjust(left=0.05, top=0.95) else: self.ax.set_xlabel(ylabel, size="large") self.ax.set_ylabel(xlabel, size="large") self.ax.set_xlim(wmin, wmax) self.ax.set_ylim(tmin, tmax) self.ax.xaxis.set_ticks_position("top") self.ax.xaxis.set_label_position("top") self.ax.figure.subplots_adjust(right=0.95, bottom=0.05) kw = formatLine(config, "Psychr", "crux") self.lx = self.ax.axhline(**kw) # the horiz line self.ly = self.ax.axvline(**kw) # the vert line
def config(self, config): self.ax.set_autoscale_on(False) chart = config.getboolean("Psychr", "chart") xlabel = "Tdb, " + Temperature.text() ylabel = "%s, %s/%s" % ( QtWidgets.QApplication.translate("pychemqt", "Absolute humidity"), Mass.text(), Mass.text()) tmin = Temperature(config.getfloat("Psychr", "isotdbStart")).config() tmax = Temperature(config.getfloat("Psychr", "isotdbEnd")).config() wmin = Temperature(config.getfloat("Psychr", "isowStart")).config() wmax = Temperature(config.getfloat("Psychr", "isowEnd")).config() if chart: self.ax.set_xlabel(xlabel, size="large") self.ax.set_ylabel(ylabel, size="large") self.ax.set_xlim(tmin, tmax) self.ax.set_ylim(wmin, wmax) self.ax.yaxis.set_ticks_position("right") self.ax.yaxis.set_label_position("right") self.ax.figure.subplots_adjust(left=0.05, top=0.95) else: self.ax.set_xlabel(ylabel, size="large") self.ax.set_ylabel(xlabel, size="large") self.ax.set_xlim(wmin, wmax) self.ax.set_ylim(tmin, tmax) self.ax.xaxis.set_ticks_position("top") self.ax.xaxis.set_label_position("top") self.ax.figure.subplots_adjust(right=0.95, bottom=0.05) kw = formatLine(config, "Psychr", "crux") self.lx = self.ax.axhline(**kw) # the horiz line self.ly = self.ax.axvline(**kw) # the vert line
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 the Standing-Katz chart using the indicate method """ method = self.Preferences.getint("Standing_Katz", "method") Prmin = self.Preferences.getfloat("Standing_Katz", "Prmin") Prmax = self.Preferences.getfloat("Standing_Katz", "Prmax") self.plt.ax.clear() self.plt.ax.set_xlim(Prmin, Prmax) self.plt.ax.set_xlabel(r"$P_r=\frac{P}{P_c}$", ha='center', size='14') self.plt.ax.set_ylabel(r"$Z=\frac{PV}{nRT}$", va="bottom", size='14') self.plt.ax.grid(b=True, which='both', color='0.6', ls=':') if not os.path.isfile(conf_dir + "standing_katz.dat"): calculate(self.Preferences) load = False with open(conf_dir + "standing_katz.dat", "r") as file: try: dat = json.load(file) except ValueError: calculate(self.Preferences) load = True if method not in dat: calculate(self.Preferences, dat) load = True # Reload file if it's created in last with statement if load: with open(conf_dir + "standing_katz.dat", "r") as file: dat = json.load(file) # Define Crux kw = formatLine(self.Preferences, "Standing_Katz", "crux") self.plt.lx = self.plt.ax.axhline(**kw) # the horiz line self.plt.ly = self.plt.ax.axvline(**kw) # the vert line self.plt.lx.set_visible(False) self.plt.ly.set_visible(False) self.note = None # Plot data kw = formatLine(self.Preferences, "Standing_Katz", "line") pzmin = 4 for Tr in sorted(dat[str(method)].keys()): line = dat[str(method)][Tr] self.plt.ax.plot(line["Pr"], line["Z"], **kw) # Add Tr legend # Position as possible at minimum position of line zmin = min(line["Z"]) if zmin < 1: pzmin = line["Pr"][line["Z"].index(zmin)] else: if 4 not in line["Pr"]: line["Pr"].append(pzmin) line["Pr"].sort() zmin = line["Z"][line["Pr"].index(pzmin)] self.plt.ax.text(pzmin, zmin, str(Tr), size="x-small", ha='left', va='bottom') # Add explicative legend of isoline self.plt.ax.text(pzmin, zmin + 0.1, r"$T_r$", size="12", ha='left', va='center') self.plt.draw()
def plot(self): """Plot the Moody chart using the indicate method """ fanning = self.Preferences.getboolean("Moody", "fanning") method = self.Preferences.getint("Moody", "method") if fanning: x = 4 else: x = 1 self.plt.ax.set_autoscale_on(False) self.plt.ax.clear() kw = formatLine(self.Preferences, "Moody", "crux") self.plt.lx = self.plt.ax.axhline(**kw) # the horiz line self.plt.ly = self.plt.ax.axvline(**kw) # the vert line xlabel = QtWidgets.QApplication.translate( "pychemqt", "Reynolds number") + ", " + r"$Re=\frac{V\rho D}{\mu}$" self.plt.ax.set_xlabel(xlabel, ha='center', size='10') if fanning: ylabel = QtWidgets.QApplication.translate( "pychemqt", "Fanning Friction factor") formula = r"$f_f=\frac{2hDg}{LV^2}$" else: ylabel = QtWidgets.QApplication.translate("pychemqt", "Darcy Friction factor") formula = r"$f_d=\frac{2hDg}{LV^2}$" self.plt.ax.set_ylabel(ylabel + ", " + formula, size='10') self.plt.ax.grid(True) self.plt.ax.set_xlim(600, 1e8) self.plt.ax.set_ylim(0.008 / x, 0.11 / x) self.plt.ax.set_xscale("log") self.plt.ax.set_yscale("log") xticks = [ 7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7 ] self.plt.ax.set_xticks(xticks, minor=False) self.plt.ax.set_yticks([], minor=True) if fanning: yticks = [ 2e-3, 2.5e-3, 3e-3, 3.5e-3, 4e-3, 5e-3, 6e-3, 7e-3, 8e-3, 9e-3, 1e-2, 1.1e-2, 1.2e-2, 1.3e-2, 1.4e-2, 1.5e-2, 1.6e-2, 1.7e-2, 1.8e-2, 1.9e-2, 2e-2, 2.1e-2, 2.2e-2, 2.3e-2, 2.4e-2, 2.5e-2 ] ytickslabel = [ 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, r"$10^{-2}$", "", 1.2, "", 1.4, "", 1.6, "", 1.8, "", 2, "", "", "", "", 2.5 ] else: yticks = [ 9e-3, 1e-2, 1.1e-2, 1.2e-2, 1.3e-2, 1.4e-2, 1.5e-2, 1.6e-2, 1.7e-2, 1.8e-2, 1.9e-2, 2e-2, 2.1e-2, 2.2e-2, 2.3e-2, 2.4e-2, 2.5e-2, 2.6e-2, 2.7e-2, 2.8e-2, 2.9e-2, 3e-2, 3.2e-2, 3.4e-2, 3.6e-2, 3.8e-2, 4e-2, 4.2e-2, 4.4e-2, 4.6e-2, 4.8e-2, 5e-2, 5.2e-2, 5.4e-2, 5.6e-2, 5.8e-2, 6e-2, 6.2e-2, 6.4e-2, 6.6e-2, 6.8e-2, 7e-2, 7.5e-2, 8e-2, 8.5e-2, 9e-2, 9.5e-2, 1e-1 ] ytickslabel = [ 9, r"$10^{-2}$", "", 1.2, "", 1.4, "", 1.6, "", 1.8, "", 2, "", "", "", "", 2.5, "", "", "", "", 3, "", "", "", "", 4, "", "", "", "", 5, "", "", "", "", 6, "", "", "", "", 7, "", 8, "", 9, "", r"$10^{-1}$" ] self.plt.ax.set_yticks(yticks) self.plt.ax.set_yticklabels(ytickslabel) if not os.path.isfile(conf_dir + "moody.dat"): calculate(self.Preferences) load = False with open(conf_dir + "moody.dat", "r") as file: try: dat = json.load(file) except ValueError: calculate(self.Preferences) load = True if dat["fanning"] != fanning or dat["method"] != method: calculate(self.Preferences) load = True # Reload file if it's created in last with statement if load: with open(conf_dir + "moody.dat", "r") as file: dat = json.load(file) # Plot data kw = formatLine(self.Preferences, "Moody", "line") self.plt.ax.plot(Re_laminar, dat["laminar"], **kw) for ed, f in dat["turbulent"].items(): self.plt.ax.plot(Re_turbulent, f, **kw) title = " " + representacion(ed, tol=4.5) if f[-1] > 0.008 / x: self.plt.ax.text(1e8, f[-1], title, size="x-small", ha='left', va='center') self.plt.ax.plot(Re_fully, dat["fully"], "k", lw=0.5, ls=":") # Add explicative legend # Laminar zone self.plt.ax.add_artist( ConnectionPatch((600, 0.01 / x), (2400, 0.01 / x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Laminar flux") self.plt.ax.text(1200, 0.0095 / x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Critic zone self.plt.ax.add_artist( ConnectionPatch((2400, 0.01 / x), (4000, 0.01 / x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Critic\nzone") self.plt.ax.text(3200, 0.0095 / x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Transition zone self.plt.ax.add_artist( ConnectionPatch((4000, 0.095 / x), (40000, 0.095 / x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Transition Zone") self.plt.ax.text(11000, 0.098 / x, txt, size="small", va="bottom", ha="center", backgroundcolor="#ffffff") # Turbulent zone self.plt.ax.add_artist( ConnectionPatch((40000, 0.095 / x), (9.9e7, 0.095 / x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate( "pychemqt", "Turbulent flux fully developed") self.plt.ax.text(1e6, 0.098 / x, txt, size="small", va="bottom", ha="center", backgroundcolor="#ffffff") # Smooth tubes self.plt.ax.add_artist( ConnectionPatch((1e6, 0.0095 / x), (1.5e6, 0.011 / x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Smooth tubes") self.plt.ax.text(1e6, 0.009 / x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Laminar equation if fanning: txt = r"$f=\frac{16}{Re}$" else: txt = r"$f=\frac{64}{Re}$" self.plt.ax.text(1.4e3, 0.042 / x, txt, size="12", va="top", ha="center", rotation=-66) # TODO: Calculate the angle dynamically self.plt.draw()
def plot(self): """Plot the Moody chart using the indicate method """ fanning = self.Preferences.getboolean("Moody", "fanning") method = self.Preferences.getint("Moody", "method") if fanning: x = 4 else: x = 1 self.plt.ax.set_autoscale_on(False) self.plt.ax.clear() kw = formatLine(self.Preferences, "Moody", "crux") self.plt.lx = self.plt.ax.axhline(**kw) # the horiz line self.plt.ly = self.plt.ax.axvline(**kw) # the vert line xlabel = QtWidgets.QApplication.translate( "pychemqt", "Reynolds number") + ", " + r"$Re=\frac{V\rho D}{\mu}$" self.plt.ax.set_xlabel(xlabel, ha='center', size='10') if fanning: ylabel = QtWidgets.QApplication.translate( "pychemqt", "Fanning Friction factor") formula = r"$f_f=\frac{2hDg}{LV^2}$" else: ylabel = QtWidgets.QApplication.translate( "pychemqt", "Darcy Friction factor") formula = r"$f_d=\frac{2hDg}{LV^2}$" self.plt.ax.set_ylabel(ylabel+", " + formula, size='10') self.plt.ax.grid(True) self.plt.ax.set_xlim(600, 1e8) self.plt.ax.set_ylim(0.008/x, 0.11/x) self.plt.ax.set_xscale("log") self.plt.ax.set_yscale("log") xticks = [7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7] self.plt.ax.set_xticks(xticks, minor=False) self.plt.ax.set_yticks([], minor=True) if fanning: yticks = [2e-3, 2.5e-3, 3e-3, 3.5e-3, 4e-3, 5e-3, 6e-3, 7e-3, 8e-3, 9e-3, 1e-2, 1.1e-2, 1.2e-2, 1.3e-2, 1.4e-2, 1.5e-2, 1.6e-2, 1.7e-2, 1.8e-2, 1.9e-2, 2e-2, 2.1e-2, 2.2e-2, 2.3e-2, 2.4e-2, 2.5e-2] ytickslabel = [2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, r"$10^{-2}$", "", 1.2, "", 1.4, "", 1.6, "", 1.8, "", 2, "", "", "", "", 2.5] else: yticks = [9e-3, 1e-2, 1.1e-2, 1.2e-2, 1.3e-2, 1.4e-2, 1.5e-2, 1.6e-2, 1.7e-2, 1.8e-2, 1.9e-2, 2e-2, 2.1e-2, 2.2e-2, 2.3e-2, 2.4e-2, 2.5e-2, 2.6e-2, 2.7e-2, 2.8e-2, 2.9e-2, 3e-2, 3.2e-2, 3.4e-2, 3.6e-2, 3.8e-2, 4e-2, 4.2e-2, 4.4e-2, 4.6e-2, 4.8e-2, 5e-2, 5.2e-2, 5.4e-2, 5.6e-2, 5.8e-2, 6e-2, 6.2e-2, 6.4e-2, 6.6e-2, 6.8e-2, 7e-2, 7.5e-2, 8e-2, 8.5e-2, 9e-2, 9.5e-2, 1e-1] ytickslabel = [9, r"$10^{-2}$", "", 1.2, "", 1.4, "", 1.6, "", 1.8, "", 2, "", "", "", "", 2.5, "", "", "", "", 3, "", "", "", "", 4, "", "", "", "", 5, "", "", "", "", 6, "", "", "", "", 7, "", 8, "", 9, "", r"$10^{-1}$"] self.plt.ax.set_yticks(yticks) self.plt.ax.set_yticklabels(ytickslabel) if not os.path.isfile(conf_dir+"moody.dat"): calculate(self.Preferences) load = False with open(conf_dir+"moody.dat", "r") as file: try: dat = json.load(file) except ValueError: calculate(self.Preferences) load = True if dat["fanning"] != fanning or dat["method"] != method: calculate(self.Preferences) load = True # Reload file if it's created in last with statement if load: with open(conf_dir+"moody.dat", "r") as file: dat = json.load(file) # Plot data kw = formatLine(self.Preferences, "Moody", "line") self.plt.ax.plot(Re_laminar, dat["laminar"], **kw) for ed, f in dat["turbulent"].items(): self.plt.ax.plot(Re_turbulent, f, **kw) title = " " + representacion(ed, tol=4.5) if f[-1] > 0.008/x: self.plt.ax.text(1e8, f[-1], title, size="x-small", ha='left', va='center') self.plt.ax.plot(Re_fully, dat["fully"], "k", lw=0.5, ls=":") # Add explicative legend # Laminar zone self.plt.ax.add_artist( ConnectionPatch((600, 0.01/x), (2400, 0.01/x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Laminar flux") self.plt.ax.text(1200, 0.0095/x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Critic zone self.plt.ax.add_artist( ConnectionPatch((2400, 0.01/x), (4000, 0.01/x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Critic\nzone") self.plt.ax.text(3200, 0.0095/x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Transition zone self.plt.ax.add_artist( ConnectionPatch((4000, 0.095/x), (40000, 0.095/x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Transition Zone") self.plt.ax.text(11000, 0.098/x, txt, size="small", va="bottom", ha="center", backgroundcolor="#ffffff") # Turbulent zone self.plt.ax.add_artist( ConnectionPatch((40000, 0.095/x), (9.9e7, 0.095/x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate( "pychemqt", "Turbulent flux fully developed") self.plt.ax.text(1e6, 0.098/x, txt, size="small", va="bottom", ha="center", backgroundcolor="#ffffff") # Smooth tubes self.plt.ax.add_artist( ConnectionPatch((1e6, 0.0095/x), (1.5e6, 0.011/x), "data", "data", arrowstyle="<|-|>", mutation_scale=15, fc="w")) txt = QtWidgets.QApplication.translate("pychemqt", "Smooth tubes") self.plt.ax.text(1e6, 0.009/x, txt, size="small", va="top", ha="center", backgroundcolor="#ffffff") # Laminar equation if fanning: txt = r"$f=\frac{16}{Re}$" else: txt = r"$f=\frac{64}{Re}$" self.plt.ax.text(1.4e3, 0.042/x, txt, size="12", va="top", ha="center", rotation=-66) # TODO: Calculate the angle dynamically self.plt.draw()
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:]))
def plot(self): """Plot the Standing-Katz chart using the indicate method """ method = self.Preferences.getint("Standing_Katz", "method") Prmin = self.Preferences.getfloat("Standing_Katz", "Prmin") Prmax = self.Preferences.getfloat("Standing_Katz", "Prmax") self.plt.ax.clear() self.plt.ax.set_xlim(Prmin, Prmax) self.plt.ax.set_xlabel(r"$P_r=\frac{P}{P_c}$", ha='center', size='14') self.plt.ax.set_ylabel(r"$Z=\frac{PV}{nRT}$", va="bottom", size='14') self.plt.ax.grid(b=True, which='both', color='0.6', ls=':') if not os.path.isfile(conf_dir+"standing_katz.dat"): calculate(self.Preferences) load = False with open(conf_dir+"standing_katz.dat", "r") as file: try: dat = json.load(file) except ValueError: calculate(self.Preferences) load = True if method not in dat: calculate(self.Preferences, dat) load = True # Reload file if it's created in last with statement if load: with open(conf_dir+"standing_katz.dat", "r") as file: dat = json.load(file) # Define Crux kw = formatLine(self.Preferences, "Standing_Katz", "crux") self.plt.lx = self.plt.ax.axhline(**kw) # the horiz line self.plt.ly = self.plt.ax.axvline(**kw) # the vert line self.plt.lx.set_visible(False) self.plt.ly.set_visible(False) self.note = None # Plot data kw = formatLine(self.Preferences, "Standing_Katz", "line") pzmin = 4 for Tr in sorted(dat[str(method)].keys()): line = dat[str(method)][Tr] self.plt.ax.plot(line["Pr"], line["Z"], **kw) # Add Tr legend # Position as possible at minimum position of line zmin = min(line["Z"]) if zmin < 1: pzmin = line["Pr"][line["Z"].index(zmin)] else: if 4 not in line["Pr"]: line["Pr"].append(pzmin) line["Pr"].sort() zmin = line["Z"][line["Pr"].index(pzmin)] self.plt.ax.text(pzmin, zmin, str(Tr), size="x-small", ha='left', va='bottom') # Add explicative legend of isoline self.plt.ax.text(pzmin, zmin+0.1, r"$T_r$", size="12", ha='left', va='center') self.plt.draw()