def update_sum(self): """updates the sum of energy and thermo corrections""" self.sum_table.setRowCount(0) if not self.sp_table.rowCount(): return sp_nrg = float(self.sp_table.cellWidget(0, 1).text()) for row in range(0, self.thermo_table.rowCount()): self.sum_table.insertRow(row) label = self.thermo_table.cellWidget(row, 0) tooltip = label.toolTip() text = label.text().replace("𝛿", "") sum_label = QLabel(text) if "href=" in text: sum_label = QLabel() sum_label.setText(text) sum_label.setTextFormat(Qt.RichText) sum_label.setTextInteractionFlags(Qt.TextBrowserInteraction) sum_label.linkActivated.connect(self.open_link) sum_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) sum_label.setToolTip(tooltip) self.sum_table.setCellWidget(row, 0, sum_label) thermo = float(self.thermo_table.cellWidget(row, 1).text()) total = sp_nrg + thermo total_nrg = SmallLineEdit("%.6f" % total) total_nrg.setFrame(False) total_nrg.setReadOnly(True) total_nrg.setToolTip(tooltip) self.sum_table.setCellWidget(row, 1, total_nrg) unit_label = ReadOnlyTableItem() unit_label.setData(Qt.DisplayRole, "E\u2095") unit_label.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) unit_label.setToolTip(tooltip) self.sum_table.setItem(row, 2, unit_label) self.sum_table.resizeRowToContents(row) self.sum_table.resizeColumnToContents(0) self.sum_table.resizeColumnToContents(1) self.sum_table.resizeColumnToContents(2)
def set_thermo(self): """computes thermo corrections and sets thermo entries for when thermo model changes""" #index of combobox is -1 when combobox has no entries self.thermo_table.setRowCount(0) if self.thermo_selector.currentIndex() >= 0: fr = self.thermo_selector.currentData() if fr not in self.thermo_co: self.thermo_co[fr] = CompOutput(fr) co = self.thermo_co[fr] v0 = self.v0_edit.value() if v0 != self.settings.w0: self.settings.w0 = v0 T = self.temperature_line.value() if not T: return dZPE = co.ZPVE #compute enthalpy and entropy at this temperature #AaronTools uses Grimme's Quasi-RRHO, but this is the same as RRHO when w0=0 dE, dH, s = co.therm_corr(temperature=T, v0=0, method="RRHO") rrho_dg = dH - T * s #compute G with quasi entropy treatments qrrho_dg = co.calc_G_corr(v0=v0, temperature=T, method="QRRHO") qharm_dg = co.calc_G_corr(v0=v0, temperature=T, method="QHARM") items = [( "𝛿ZPE =", dZPE, None, "lowest energy the molecule can have\n" "no rotational or vibrational modes populated\n" "equal to enthalpy at 0 K", )] if fr.other["frequency"].anharm_data: dZPE_anh = co.calc_zpe(anharmonic=True) items.append(( "𝛿ZPE<sub>anh</sub> =", dZPE_anh, None, "lowest energy the molecule can have\n" "no rotational or vibrational modes populated\n" "includes corrections for anharmonic vibrations", )) items.extend([ ( "𝛿H<sub>RRHO</sub> =", dH, None, "enthalpy of formation", ), ( "𝛿G<sub>RRHO</sub> =", rrho_dg, None, "energy after taking into account the average\n" "population of vibrational, rotational, and translational\n" "degrees of freedom", ), ( "𝛿G<sub>Quasi-RRHO</sub> =", qrrho_dg, "Grimme's Quasi-RRHO", "vibrational entropy of each real mode is damped and complemented\n" "with rotational entropy, with the damping function being stronger for\n" "frequencies < 𝜔\u2080\n" "can mitigate error from inaccuracies in the harmonic oscillator\n" "approximation for low-frequency vibrations", ), ( "𝛿G<sub>Quasi-Harmonic</sub> =", qharm_dg, "Truhlar's Quasi-Harmonic", "real vibrational frequencies below 𝜔\u2080 are treated as 𝜔\u2080\n" "can mitigate error from inaccuracies in the harmonic oscillator\n" "approximation for low-frequency vibrations", ), ]) for i, (label_text, val, link, tooltip) in enumerate(items): self.thermo_table.insertRow(i) label = QLabel(label_text) if link: label = QLabel() label.setText( "<a href=\"%s\" style=\"text-decoration: none;\">%s</a>" % (link, label_text)) label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.linkActivated.connect(self.open_link) label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) label.setToolTip(tooltip) self.thermo_table.setCellWidget(i, 0, label) unit_label = ReadOnlyTableItem() unit_label.setData(Qt.DisplayRole, "E\u2095") unit_label.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) unit_label.setToolTip(tooltip) self.thermo_table.setItem(i, 2, unit_label) d_nrg = SmallLineEdit("%.6f" % val) d_nrg.setReadOnly(True) d_nrg.setFrame(False) d_nrg.setToolTip(tooltip) self.thermo_table.setCellWidget(i, 1, d_nrg) self.thermo_table.resizeRowToContents(i) self.thermo_table.resizeColumnToContents(0) self.thermo_table.resizeColumnToContents(1) self.thermo_table.resizeColumnToContents(2) self.update_sum()
def _build_ui(self): layout = QGridLayout() library_tabs = QTabWidget() #ligand tab ligand_tab = QWidget() ligand_layout = QFormLayout(ligand_tab) self.ligand_name = QLineEdit() self.ligand_name.setText("") self.ligand_name.setPlaceholderText("leave blank to preview") self.ligand_name.setToolTip( "name of ligand you are adding to your ligand library\nleave blank to open a new model with just the ligand" ) ligand_layout.addRow("ligand name:", self.ligand_name) ligand_key_atoms = QPushButton("set key atoms to current selection") ligand_key_atoms.clicked.connect(self.update_key_atoms) ligand_key_atoms.setToolTip( "the current selection will be the key atoms for the ligand\nleave blank to automatically determine key atoms" ) ligand_layout.addRow(ligand_key_atoms) libadd_ligand = QPushButton("add current selection to library") libadd_ligand.clicked.connect(self.libadd_ligand) ligand_layout.addRow(libadd_ligand) #substituent tab sub_tab = QWidget() sub_layout = QFormLayout(sub_tab) self.sub_name = QLineEdit() self.sub_name.setText("") self.sub_name.setPlaceholderText("leave blank to preview") self.sub_name.setToolTip( "name of substituent you are adding to your substituent library\nleave blank to open a new model with just the substituent" ) sub_layout.addRow("substituent name:", self.sub_name) self.sub_confs = QSpinBox() self.sub_confs.setMinimum(1) sub_layout.addRow("number of conformers:", self.sub_confs) self.sub_angle = QSpinBox() self.sub_angle.setRange(0, 180) self.sub_angle.setSingleStep(30) sub_layout.addRow("angle between conformers:", self.sub_angle) libadd_sub = QPushButton("add current selection to library") libadd_sub.clicked.connect(self.libadd_substituent) sub_layout.addRow(libadd_sub) #ring tab ring_tab = QWidget() ring_layout = QFormLayout(ring_tab) self.ring_name = QLineEdit() self.ring_name.setText("") self.ring_name.setPlaceholderText("leave blank to preview") self.ring_name.setToolTip( "name of ring you are adding to your ring library\nleave blank to open a new model with just the ring" ) ring_layout.addRow("ring name:", self.ring_name) libadd_ring = QPushButton("add ring with selected walk to library") libadd_ring.clicked.connect(self.libadd_ring) ring_layout.addRow(libadd_ring) library_tabs.addTab(sub_tab, "substituent") library_tabs.addTab(ring_tab, "ring") library_tabs.addTab(ligand_tab, "ligand") self.library_tabs = library_tabs layout.addWidget(library_tabs) whats_this = QLabel() whats_this.setText( "<a href=\"req\" style=\"text-decoration: none;\">what's this?</a>" ) whats_this.setTextFormat(Qt.RichText) whats_this.setTextInteractionFlags(Qt.TextBrowserInteraction) whats_this.linkActivated.connect(self.open_link) whats_this.setToolTip( "click for more information about AaronTools libraries") layout.addWidget(whats_this) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)