Пример #1
0
    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            epsilon = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(epsilon)
            L = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(L)
            Q = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(Q)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            u = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(u)

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho

            D = math.sqrt((4.0 * Q) / (math.pi * u))
            Re = rho * u * D / mu
            f_0 = (-1.8 * math.log10((epsilon /
                                      (3.7 * D)**1.11) + 6.9 / Re))**-2.0
            f = (-2.0 * math.log10(epsilon / (3.7 * D) + 2.51 /
                                   (Re * math.sqrt(f_0))))**-2.0
            dP = rho * ((f * L / D + 0.1 * (theta / 90.0))) * ((u**2.0) / 2.0)
            A = (math.pi * D**2) / 4.0

            def arredonda(val):
                return ("%.3f" % val)

            results["Diâmetro"] = arredonda(D) + " m"
            results["Velocidade"] = arredonda(u) + " m/s"
            results["Perda de Carga"] = arredonda(dP) + " Pa"
            results["Área"] = arredonda(A) + " m²"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()
        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #2
0
    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_23 = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(L_23)
            Q_23 = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(Q_23)
            theta = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(theta)
            epsilon = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(epsilon)
            Q_1 = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(Q_1)
            u_1 = float(self.lineEdit_7.text())
            input_v[self.label_7.text()] = str(u_1)
            trecho1 = self.check.isChecked()
            input_v[self.label_8.text()] = "Sim" if trecho1 else "Não"

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho
            if trecho1:
                D_1 = math.sqrt((4.0 * Q_1) / (math.pi * u_1))
                Re_i = rho * u_1 * D_1 / mu
                f_0_i = math.pow(
                    -1.8 * math.log10(
                        math.pow(epsilon / (3.7 * D_1), 1.11) + 6.9 / Re_i),
                    -2.0)
                f_i = math.pow(
                    -2.0 * math.log10(epsilon / (3.7 * D_1) + 2.51 /
                                      (Re_i * math.sqrt(f_0_i))), -2.0)
                dP_m1 = (f_i * L_23 / D_1 +
                         0.1 * theta / 90.0) * u_1**2.0 * rho
                D_23_i = D_1
            else:
                dP_m1 = float(self.lineEdit_9.text())
                input_v[self.label_9.text()] = str(dP_m1)
                D_23_i = float(self.lineEdit_10.text())
                input_v[self.label_10.text()] = str(D_23_i)

            u_23_i = u_1

            def residuals(initial):
                D_23 = initial[0]
                u_23 = initial[1]
                residual = [0.0, 0.0]
                global Re
                global f
                Re = rho * u_23 * D_23 / mu
                f_0 = (-1.8 * math.log10(
                    math.pow(epsilon / (3.7 * D_23), 1.11) + 6.9 / Re))**-2.0
                f = (-2.0 * math.log10(epsilon / (3.7 * D_23) + 2.51 /
                                       (Re * math.sqrt(f_0))))**-2.0
                residual[0] = (f * L_23 / D_23 +
                               0.1 * theta / 90.0) * u_23**2.0 - dP_m1
                residual[1] = D_23 - math.sqrt((4.0 * Q_23) / (math.pi * u_23))
                return residual

            D_23, u_23 = fsolve(residuals, [D_23_i, u_23_i])

            def arredonda(val):
                return ("%.3f" % val)

            results["D2-3"] = arredonda(D_23) + " m"
            results["u2-3"] = arredonda(u_23) + " m/s"
            if trecho1 == 1:
                results["D1"] = arredonda(D_1) + " m"
            results["dP m1"] = arredonda(dP_m1) + " Pa/m"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()

        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #3
0
class Ui_Constante2(object):
    def setupUi(self, Constante2):
        Constante2.setObjectName("Constante2")
        Constante2.resize(800, 600)
        Constante2.setStyleSheet(
            "QWidget { background-color: rgb(11, 173, 224) }\n"
            "QPushButton { border-radius: 5px; background-color: white; border-bottom: 1px solid black }\n"
            "QPushButton:hover { background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(238, 238, 238, 255)) }\n"
            "QLineEdit, QComboBox { background-color: white; color: black }\n"
            "QComboBox { border-radius: 2px; border: 1px solid lightgrey }\n"
            "QComboBox::item { background-color: white }\n"
            "QComboBox::item:selected { background-color: rgb(11, 173, 224) }\n"
            "QLabel { color: white }\n"
            "QCheckBox { height: 25px; margin-left: 83.5% }"
        )  #pq esse número? não sei, parece centralizado assim

        self.titulo = QtWidgets.QLabel(Constante2)
        self.titulo.setGeometry(QtCore.QRect(0, 40, 801, 111))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.titulo.sizePolicy().hasHeightForWidth())
        self.titulo.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(85)
        self.titulo.setFont(font)
        self.titulo.setStyleSheet("color: white")
        self.titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.titulo.setObjectName("titulo")
        self.pushButton = QtWidgets.QPushButton(Constante2)
        self.pushButton.setGeometry(QtCore.QRect(200, 510, 401, 51))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
        self.pushButton.setFlat(True)
        self.pushButton.setObjectName("pushButton")

        self.pushButton.clicked.connect(self.calcula)

        self.formLayoutWidget = QtWidgets.QWidget(Constante2)
        self.formLayoutWidget.setGeometry(QtCore.QRect(0, 160, 801, 326))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setSizeConstraint(
            QtWidgets.QLayout.SetDefaultConstraint)
        self.formLayout.setFieldGrowthPolicy(
            QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout.setLabelAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setFormAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setContentsMargins(200, 0, 200, 0)
        self.formLayout.setObjectName("formLayout")
        self.label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole,
                                  self.label)
        self.lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit.setFont(font)
        self.lineEdit.setStyleSheet("")
        self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit.setClearButtonEnabled(False)
        self.lineEdit.setObjectName("lineEdit")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit)
        self.label_2 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole,
                                  self.label_2)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_2)
        self.label_3 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole,
                                  self.label_3)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_3)
        self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole,
                                  self.label_4)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_4)
        self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole,
                                  self.label_5)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_5.sizePolicy().hasHeightForWidth())
        self.lineEdit_5.setSizePolicy(sizePolicy)
        self.lineEdit_5.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_5)
        self.label_6 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole,
                                  self.label_6)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_6.sizePolicy().hasHeightForWidth())
        self.lineEdit_6.setSizePolicy(sizePolicy)
        self.lineEdit_6.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_6.setFont(font)
        self.lineEdit_6.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_6)
        self.label_7 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole,
                                  self.label_7)
        self.lineEdit_7 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_7.sizePolicy().hasHeightForWidth())
        self.lineEdit_7.setSizePolicy(sizePolicy)
        self.lineEdit_7.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_7.setFont(font)
        self.lineEdit_7.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_7)
        self.label_8 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole,
                                  self.label_8)

        self.check = QtWidgets.QCheckBox(self.formLayoutWidget)
        self.check.setObjectName("check")
        self.check.toggle()
        self.check.toggled.connect(self.change_fields)
        self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole,
                                  self.check)

        #self.lineEdit_8 = QtWidgets.QLineEdit(self.formLayoutWidget)
        #sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        #sizePolicy.setHorizontalStretch(0)
        #sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.lineEdit_8.sizePolicy().hasHeightForWidth())
        #self.lineEdit_8.setSizePolicy(sizePolicy)
        #self.lineEdit_8.setBaseSize(QtCore.QSize(0, 0))
        #font = QtGui.QFont()
        #font.setFamily("Roboto")
        #font.setPointSize(12)
        #self.lineEdit_8.setFont(font)
        #self.lineEdit_8.setAlignment(QtCore.Qt.AlignCenter)
        #self.lineEdit_8.setObjectName("lineEdit_8")
        #self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.lineEdit_8)

        self.label_9 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setUnderline(True)
        self.label_9.setFont(font)
        self.label_9.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
        self.label_9.setStatusTip("")
        self.label_9.setStyleSheet(
            "text-decoration: underline; font-size: 16px")
        self.label_9.setObjectName("label_9")
        self.formLayout.setWidget(8, QtWidgets.QFormLayout.LabelRole,
                                  self.label_9)
        self.lineEdit_9 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_9.sizePolicy().hasHeightForWidth())
        self.lineEdit_9.setSizePolicy(sizePolicy)
        self.lineEdit_9.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_9.setFont(font)
        self.lineEdit_9.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_9.setObjectName("lineEdit_9")

        self.lineEdit_9.setReadOnly(True)
        self.lineEdit_9.setStyleSheet("background-color: lightgray")

        self.formLayout.setWidget(8, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_9)
        self.label_10 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setUnderline(True)
        self.label_10.setFont(font)
        self.label_10.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
        self.label_10.setStatusTip("")
        self.label_10.setStyleSheet(
            "text-decoration: underline; font-size: 16px")
        self.label_10.setObjectName("label_10")
        self.formLayout.setWidget(9, QtWidgets.QFormLayout.LabelRole,
                                  self.label_10)
        self.lineEdit_10 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_10.sizePolicy().hasHeightForWidth())
        self.lineEdit_10.setSizePolicy(sizePolicy)
        self.lineEdit_10.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_10.setFont(font)
        self.lineEdit_10.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_10.setObjectName("lineEdit_10")

        self.lineEdit_10.setReadOnly(True)
        self.lineEdit_10.setStyleSheet("background-color: lightgray")

        self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_10)

        self.retranslateUi(Constante2)
        QtCore.QMetaObject.connectSlotsByName(Constante2)

    def retranslateUi(self, Constante2):
        _translate = QtCore.QCoreApplication.translate
        Constante2.setWindowTitle(
            _translate("Constante2", "DIMduct >> Constante (2)"))
        self.titulo.setText(_translate("Constante2", "DIMduct"))
        self.pushButton.setText(_translate("Constante2", "Calcular"))
        self.label.setText(_translate("Constante2", "Temperatura (°C):"))
        self.label_2.setText(
            _translate("Constante2", "Comprimento do Trecho (m):"))
        self.label_3.setText(
            _translate("Constante2", "Vazão do Trecho (m³/s):"))
        self.label_4.setText(
            _translate("Constante2", "Ângulo Total de Curvas (°):"))
        self.label_5.setText(
            _translate("Constante2", "Rugosidade Absoluta (m):"))
        self.label_6.setText(
            _translate("Constante2", "Vazão do Trecho Ant. (m³/s):"))
        self.label_7.setText(_translate("Constante2",
                                        "Velocidade Ant. (m/s):"))
        self.label_8.setText(_translate("Constante2", "Primeiro trecho?"))
        self.label_9.setToolTip(
            _translate("Constante2", "Será calculado no primeiro trecho."))
        self.label_9.setWhatsThis(
            _translate("Constante2", "Será calculado no primeiro trecho."))
        self.label_9.setText(_translate("Constante2",
                                        "Perda de Carga (Pa/m):"))
        self.label_10.setToolTip(
            _translate("Constante2", "Será calculado no primeiro trecho."))
        self.label_10.setWhatsThis(
            _translate("Constante2", "Será calculado no primeiro trecho."))
        self.label_10.setText(_translate("Constante2", "Diâmetro 2-3 (m):"))

    def change_fields(self):
        if self.check.isChecked():
            style = "background-color: lightgray"
            self.lineEdit_9.setReadOnly(True)
            self.lineEdit_10.setReadOnly(True)
            self.lineEdit_9.setStyleSheet(style)
            self.lineEdit_10.setStyleSheet(style)
        else:
            style = "background-color: white"
            self.lineEdit_9.setReadOnly(False)
            self.lineEdit_10.setReadOnly(False)
            self.lineEdit_9.setStyleSheet(style)
            self.lineEdit_10.setStyleSheet(style)

    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_23 = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(L_23)
            Q_23 = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(Q_23)
            theta = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(theta)
            epsilon = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(epsilon)
            Q_1 = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(Q_1)
            u_1 = float(self.lineEdit_7.text())
            input_v[self.label_7.text()] = str(u_1)
            trecho1 = self.check.isChecked()
            input_v[self.label_8.text()] = "Sim" if trecho1 else "Não"

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho
            if trecho1:
                D_1 = math.sqrt((4.0 * Q_1) / (math.pi * u_1))
                Re_i = rho * u_1 * D_1 / mu
                f_0_i = math.pow(
                    -1.8 * math.log10(
                        math.pow(epsilon / (3.7 * D_1), 1.11) + 6.9 / Re_i),
                    -2.0)
                f_i = math.pow(
                    -2.0 * math.log10(epsilon / (3.7 * D_1) + 2.51 /
                                      (Re_i * math.sqrt(f_0_i))), -2.0)
                dP_m1 = (f_i * L_23 / D_1 +
                         0.1 * theta / 90.0) * u_1**2.0 * rho
                D_23_i = D_1
            else:
                dP_m1 = float(self.lineEdit_9.text())
                input_v[self.label_9.text()] = str(dP_m1)
                D_23_i = float(self.lineEdit_10.text())
                input_v[self.label_10.text()] = str(D_23_i)

            u_23_i = u_1

            def residuals(initial):
                D_23 = initial[0]
                u_23 = initial[1]
                residual = [0.0, 0.0]
                global Re
                global f
                Re = rho * u_23 * D_23 / mu
                f_0 = (-1.8 * math.log10(
                    math.pow(epsilon / (3.7 * D_23), 1.11) + 6.9 / Re))**-2.0
                f = (-2.0 * math.log10(epsilon / (3.7 * D_23) + 2.51 /
                                       (Re * math.sqrt(f_0))))**-2.0
                residual[0] = (f * L_23 / D_23 +
                               0.1 * theta / 90.0) * u_23**2.0 - dP_m1
                residual[1] = D_23 - math.sqrt((4.0 * Q_23) / (math.pi * u_23))
                return residual

            D_23, u_23 = fsolve(residuals, [D_23_i, u_23_i])

            def arredonda(val):
                return ("%.3f" % val)

            results["D2-3"] = arredonda(D_23) + " m"
            results["u2-3"] = arredonda(u_23) + " m/s"
            if trecho1 == 1:
                results["D1"] = arredonda(D_1) + " m"
            results["dP m1"] = arredonda(dP_m1) + " Pa/m"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()

        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #4
0
    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_23 = float(self.lineEdit_2.text())  # Comprimento do Trecho Atual
            input_v[self.label_2.text()] = str(L_23)
            Q_23 = float(self.lineEdit_3.text())  # Vazão do Trecho Atual
            input_v[self.label_3.text()] = str(Q_23)
            u_12 = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(u_12)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            R = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(R)
            epsilon = float(self.lineEdit_7.text())  #Rugosidade
            input_v[self.label_7.text()] = str(epsilon)
            D_23_i = float(self.lineEdit_8.text())
            input_v[self.label_8.text()] = str(D_23_i)
            u_23_i = float(self.lineEdit_9.text())
            input_v[self.label_9.text()] = str(u_23_i)
            trecho1 = float(self.check.isChecked())
            input_v[self.label_10.text()] = "Sim" if trecho1 else "Não"

            # valores fora desses limites (~) não funcionam.
            # desse jeito, não importa o que o usuário colocar, sempre vai dar certo
            if u_23_i < 2.7:
                u_23_i = 2.7
            elif u_23_i > 41:  #41.787441101002
                u_23_i = 41

            if D_23_i <= 0:
                D_23_i = 0.1
            elif D_23_i > 6:
                D_23_i = 6

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho

            def residuals(initial):
                D_23 = initial[0]
                u_23 = initial[1]
                residual = [0.0, 0.0]
                global Re
                global f
                Re = rho * u_23 * D_23 / mu
                f_0 = math.pow(
                    -1.8 * math.log10(
                        math.pow(epsilon / (3.7 * D_23), 1.11) + 6.9 / Re),
                    -2.0)
                f = math.pow(
                    -2.0 * math.log10(epsilon / (3.7 * D_23) + 2.51 /
                                      (Re * math.sqrt(f_0))), -2.0)
                residual[0] = (f * L_23 / D_23 + 0.1 * theta / 90.0 +
                               R) * u_23**2.0 - R * u_12**2.0
                residual[1] = D_23 - math.sqrt((4.0 * Q_23) / (math.pi * u_23))
                return residual

            D_23, u_23 = fsolve(residuals, [D_23_i, u_23_i])
            if trecho1:
                dP = (rho * f * L_23 * u_23**2.0 / (D_23 * 2.0))
            A = (math.pi * D_23**2.0) / 4.0

            def arredonda(val):
                return ("%.3f" % val)

            results["D2-3"] = arredonda(D_23) + " m"  # 3 casas
            results["u2-3"] = arredonda(u_23) + " m/s"  #2 casas
            results["A"] = arredonda(A) + " m²"  # 3 casas
            results["f"] = arredonda(f)  # 4 casas
            if trecho1:
                results["dP"] = arredonda(dP) + " Pa"  # 3 casas

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()

        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n" + str(e))
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #5
0
class Ui_Estatica(object):
    def setupUi(self, Estatica):
        Estatica.setObjectName("Estatica")
        Estatica.resize(800, 600)
        Estatica.setStyleSheet(
            "QWidget { background-color: rgb(11, 173, 224) }\n"
            "QPushButton { border-radius: 5px; background-color: white; border-bottom: 1px solid black }\n"
            "QPushButton:hover { background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(238, 238, 238, 255)) }\n"
            "QLabel{ color: white }\n"
            "QLineEdit{ background-color: white; color: black }\n"
            "QCheckBox { height: 25px; margin-left: 83.5% }")

        self.titulo = QtWidgets.QLabel(Estatica)
        self.titulo.setGeometry(QtCore.QRect(0, 40, 801, 111))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.titulo.sizePolicy().hasHeightForWidth())
        self.titulo.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(85)
        self.titulo.setFont(font)
        self.titulo.setStyleSheet("color: white")
        self.titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.titulo.setObjectName("titulo")
        self.pushButton = QtWidgets.QPushButton(Estatica)
        self.pushButton.setGeometry(QtCore.QRect(200, 520, 401, 51))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
        self.pushButton.setFlat(True)
        self.pushButton.setObjectName("pushButton")

        self.pushButton.clicked.connect(self.calcula)

        self.formLayoutWidget = QtWidgets.QWidget(Estatica)
        self.formLayoutWidget.setGeometry(QtCore.QRect(0, 170, 801, 326))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setSizeConstraint(
            QtWidgets.QLayout.SetDefaultConstraint)
        self.formLayout.setFieldGrowthPolicy(
            QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout.setLabelAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setFormAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setContentsMargins(200, 0, 200, 0)
        self.formLayout.setObjectName("formLayout")
        self.label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole,
                                  self.label)
        self.lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit.setFont(font)
        self.lineEdit.setStyleSheet("")
        self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit.setClearButtonEnabled(False)
        self.lineEdit.setObjectName("lineEdit")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit)
        self.label_2 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole,
                                  self.label_2)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_2)
        self.label_3 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole,
                                  self.label_3)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_3)
        self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole,
                                  self.label_4)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_4)
        self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole,
                                  self.label_5)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_5.sizePolicy().hasHeightForWidth())
        self.lineEdit_5.setSizePolicy(sizePolicy)
        self.lineEdit_5.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_5)
        self.label_6 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole,
                                  self.label_6)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_6.sizePolicy().hasHeightForWidth())
        self.lineEdit_6.setSizePolicy(sizePolicy)
        self.lineEdit_6.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_6.setFont(font)
        self.lineEdit_6.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_6)
        self.label_7 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole,
                                  self.label_7)
        self.lineEdit_7 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_7.sizePolicy().hasHeightForWidth())
        self.lineEdit_7.setSizePolicy(sizePolicy)
        self.lineEdit_7.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_7.setFont(font)
        self.lineEdit_7.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_7)
        self.label_8 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole,
                                  self.label_8)
        self.lineEdit_8 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_8.sizePolicy().hasHeightForWidth())
        self.lineEdit_8.setSizePolicy(sizePolicy)
        self.lineEdit_8.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_8.setFont(font)
        self.lineEdit_8.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_8)
        self.label_9 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.formLayout.setWidget(8, QtWidgets.QFormLayout.LabelRole,
                                  self.label_9)
        self.lineEdit_9 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_9.sizePolicy().hasHeightForWidth())
        self.lineEdit_9.setSizePolicy(sizePolicy)
        self.lineEdit_9.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_9.setFont(font)
        self.lineEdit_9.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_9.setObjectName("lineEdit_9")
        self.formLayout.setWidget(8, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_9)
        self.label_10 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_10.setFont(font)
        self.label_10.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
        self.label_10.setStatusTip("")
        self.label_10.setStyleSheet(
            "text-decoration: underline; font-size: 16px")
        self.label_10.setObjectName("label_10")
        self.formLayout.setWidget(9, QtWidgets.QFormLayout.LabelRole,
                                  self.label_10)

        self.check = QtWidgets.QCheckBox(self.formLayoutWidget)
        self.check.setObjectName("check")
        self.check.toggle()
        self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole,
                                  self.check)

        #self.lineEdit_10 = QtWidgets.QLineEdit(self.formLayoutWidget)
        #sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        #sizePolicy.setHorizontalStretch(0)
        #sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.lineEdit_10.sizePolicy().hasHeightForWidth())
        #self.lineEdit_10.setSizePolicy(sizePolicy)
        #self.lineEdit_10.setBaseSize(QtCore.QSize(0, 0))
        #font = QtGui.QFont()
        #font.setFamily("Roboto")
        #font.setPointSize(12)
        #self.lineEdit_10.setFont(font)
        #self.lineEdit_10.setAlignment(QtCore.Qt.AlignCenter)
        #self.lineEdit_10.setObjectName("lineEdit_10")
        #self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.lineEdit_10)

        self.retranslateUi(Estatica)
        QtCore.QMetaObject.connectSlotsByName(Estatica)

    def retranslateUi(self, Estatica):
        _translate = QtCore.QCoreApplication.translate
        Estatica.setWindowTitle(_translate("Estatica", "DIMduct >> Estática"))
        self.titulo.setText(_translate("Estatica", "DIMduct"))
        self.pushButton.setText(_translate("Estatica", "Calcular"))
        self.label.setText(_translate("Estatica", "Temperatura (°C):"))
        self.label_2.setText(
            _translate("Estatica", "Comprimento do Trecho (m):"))
        self.label_3.setText(_translate("Estatica", "Vazão do Trecho (m³/s):"))
        self.label_4.setText(
            _translate("Estatica", "Velocidade Anterior (m/s):"))
        self.label_5.setText(
            _translate("Estatica", "Ângulo Total de Curvas (°):"))
        self.label_6.setText(_translate("Estatica", "Fator de Recuperação:"))
        self.label_7.setText(_translate("Estatica",
                                        "Rugosidade Absoluta (m):"))
        self.label_8.setText(_translate("Estatica", "Chute Diâmetro (m):"))
        self.label_9.setText(_translate("Estatica", "Chute Velocidade (m/s):"))
        self.label_10.setText(
            _translate("Estatica", "Calcular perda de carga?"))
        self.label_10.setToolTip(
            _translate("Estatica",
                       "Ativar para o primeiro trecho e cálculo de curva."))
        self.label_10.setWhatsThis(
            _translate("Estatica",
                       "Ativar para o primeiro trecho e cálculo de curva."))

    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_23 = float(self.lineEdit_2.text())  # Comprimento do Trecho Atual
            input_v[self.label_2.text()] = str(L_23)
            Q_23 = float(self.lineEdit_3.text())  # Vazão do Trecho Atual
            input_v[self.label_3.text()] = str(Q_23)
            u_12 = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(u_12)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            R = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(R)
            epsilon = float(self.lineEdit_7.text())  #Rugosidade
            input_v[self.label_7.text()] = str(epsilon)
            D_23_i = float(self.lineEdit_8.text())
            input_v[self.label_8.text()] = str(D_23_i)
            u_23_i = float(self.lineEdit_9.text())
            input_v[self.label_9.text()] = str(u_23_i)
            trecho1 = float(self.check.isChecked())
            input_v[self.label_10.text()] = "Sim" if trecho1 else "Não"

            # valores fora desses limites (~) não funcionam.
            # desse jeito, não importa o que o usuário colocar, sempre vai dar certo
            if u_23_i < 2.7:
                u_23_i = 2.7
            elif u_23_i > 41:  #41.787441101002
                u_23_i = 41

            if D_23_i <= 0:
                D_23_i = 0.1
            elif D_23_i > 6:
                D_23_i = 6

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho

            def residuals(initial):
                D_23 = initial[0]
                u_23 = initial[1]
                residual = [0.0, 0.0]
                global Re
                global f
                Re = rho * u_23 * D_23 / mu
                f_0 = math.pow(
                    -1.8 * math.log10(
                        math.pow(epsilon / (3.7 * D_23), 1.11) + 6.9 / Re),
                    -2.0)
                f = math.pow(
                    -2.0 * math.log10(epsilon / (3.7 * D_23) + 2.51 /
                                      (Re * math.sqrt(f_0))), -2.0)
                residual[0] = (f * L_23 / D_23 + 0.1 * theta / 90.0 +
                               R) * u_23**2.0 - R * u_12**2.0
                residual[1] = D_23 - math.sqrt((4.0 * Q_23) / (math.pi * u_23))
                return residual

            D_23, u_23 = fsolve(residuals, [D_23_i, u_23_i])
            if trecho1:
                dP = (rho * f * L_23 * u_23**2.0 / (D_23 * 2.0))
            A = (math.pi * D_23**2.0) / 4.0

            def arredonda(val):
                return ("%.3f" % val)

            results["D2-3"] = arredonda(D_23) + " m"  # 3 casas
            results["u2-3"] = arredonda(u_23) + " m/s"  #2 casas
            results["A"] = arredonda(A) + " m²"  # 3 casas
            results["f"] = arredonda(f)  # 4 casas
            if trecho1:
                results["dP"] = arredonda(dP) + " Pa"  # 3 casas

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()

        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n" + str(e))
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #6
0
    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_1 = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(L_1)
            Q_1 = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(Q_1)
            Q_2 = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(Q_2)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            epsilon = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(epsilon)
            tipo = self.comboBox.currentIndex()
            input_v[self.label_7.text()] = str(self.comboBox.currentText())

            rho = 101303 /(286.9 *(temp + 273.15))
            mu = ((13 + 0.1 * temp)* 0.000001)* rho

            const_tipo = 25 if tipo else 32 #tipo==0 -> 32, tipo==1 -> 25

            Q_1L = Q_1*1000.0 #[l/s]
            D_1 = const_tipo*(math.pow(Q_1L, 0.38))/1000
            A_1 = (math.pi*D_1**2.0)/4.0
            u_1 = Q_1/A_1
            
            Q_2L = Q_2*1000.0 #[l/s]
            D_2 = const_tipo*(math.pow(Q_2L, 0.38))/1000
            A_2 = (math.pi*D_2**2.0)/4.0
            u_2 = Q_2/A_2

               
            Re = rho * u_1 * D_1 / mu
            f_0 = math.pow(-1.8 * math.log10(math.pow(epsilon / (3.7 * D_1), 1.11) + 6.9 / Re), -2.0)
            f = math.pow(-2.0 * math.log10(epsilon / (3.7 * D_1) + 2.51 / (Re * math.sqrt(f_0))), -2.0)
            dP_m = (f * L_1 / D_1 + 0.1 * theta / 90.0) * u_1 ** 2.0 * rho

            def arredonda(val):
                return ("%.3f" % val)
           
            results["D1"] = arredonda(D_1) + " m"
            results["u1"] = arredonda(u_1) + " m/s"
            results["A1"] = arredonda(A_1) + " m²"
            results["D2"] = arredonda(D_2) + " m"
            results["u2"] = arredonda(u_2) + " m/s" 
            results["A2"] = arredonda(A_2) + " m²"
            results["dP m"] = arredonda(dP_m) + " Pa/m"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()
            
        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if(isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n"+str(e))
    
            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #7
0
class Ui_Constante1(object):
    def setupUi(self, Constante1):
        Constante1.setObjectName("Constante1")
        Constante1.resize(800, 600)
        Constante1.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        Constante1.setStyleSheet("QWidget { background-color: rgb(11, 173, 224) }\n"
"QPushButton { border-radius: 5px; background-color: white; border-bottom: 1px solid black }\n"
"QPushButton:hover { background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(238, 238, 238, 255)) }\n"
"QLineEdit, QComboBox { background-color: white; color: black }\n"
"QComboBox { border-radius: 2px; border: 1px solid lightgrey }\n"
"QComboBox QAbstractItemView { background-color: white }\n"
"QComboBox:!editable, QComboBox::drop-down:editable { color: black }\n"
"QLabel { color: white }")

        self.formLayoutWidget = QtWidgets.QWidget(Constante1)
        self.formLayoutWidget.setGeometry(QtCore.QRect(0, 170, 801, 261))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
        self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout.setLabelAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setFormAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setContentsMargins(200, 0, 200, 0)
        self.formLayout.setObjectName("formLayout")
        self.label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
        self.lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit.setFont(font)
        self.lineEdit.setStyleSheet("")
        self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit.setClearButtonEnabled(False)
        self.lineEdit.setObjectName("lineEdit")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.lineEdit)
        self.label_2 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEdit_2)
        self.label_3 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.lineEdit_3)
        self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_4)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.lineEdit_4)
        self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_5)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_5.sizePolicy().hasHeightForWidth())
        self.lineEdit_5.setSizePolicy(sizePolicy)
        self.lineEdit_5.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.lineEdit_5)
        self.label_6 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_6)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_6.sizePolicy().hasHeightForWidth())
        self.lineEdit_6.setSizePolicy(sizePolicy)
        self.lineEdit_6.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_6.setFont(font)
        self.lineEdit_6.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.lineEdit_6)
        self.label_7 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_7.setFont(font)

        self.label_7.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
        self.label_7.setStatusTip("")
        self.label_7.setStyleSheet("text-decoration: underline; font-size: 16px")

        self.label_7.setObjectName("label_7")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.label_7)
        self.comboBox = QtWidgets.QComboBox(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.comboBox.setFont(font)
        self.comboBox.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.comboBox)
        self.titulo = QtWidgets.QLabel(Constante1)
        self.titulo.setGeometry(QtCore.QRect(0, 40, 801, 111))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.titulo.sizePolicy().hasHeightForWidth())
        self.titulo.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(85)
        self.titulo.setFont(font)
        self.titulo.setStyleSheet("color: white")
        self.titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.titulo.setObjectName("titulo")
        self.pushButton = QtWidgets.QPushButton(Constante1)
        self.pushButton.setGeometry(QtCore.QRect(200, 450, 401, 51))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
        self.pushButton.setFlat(True)
        self.pushButton.setObjectName("pushButton")

        self.pushButton.clicked.connect(self.calcula)

        self.retranslateUi(Constante1)
        QtCore.QMetaObject.connectSlotsByName(Constante1)

    def retranslateUi(self, Constante1):
        _translate = QtCore.QCoreApplication.translate
        Constante1.setWindowTitle(_translate("Constante1", "DIMduct >> Constante (1)"))
        self.label.setText(_translate("Constante1", "Temperatura (°C):"))
        self.label_2.setText(_translate("Constante1", "Comprimento do Trecho (m):"))
        self.label_3.setText(_translate("Constante1", "Vazão do Trecho 1 (m³/s):"))
        self.label_4.setText(_translate("Constante1", "Vazão do Trecho 2 (m³/s):"))
        self.label_5.setText(_translate("Constante1", "Ângulo Total de Curvas (°):"))
        self.label_6.setText(_translate("Constante1", "Rugosidade Absoluta (m):"))
        self.label_7.setText(_translate("Constante1", "Tipo:"))
        self.label_7.setToolTip(_translate("Constante1", "Pode ser que a seleção pareça estar em branco.\nPara resolver, clique em algum campo."))
        self.label_7.setWhatsThis(_translate("Constante1", "Pode ser que a seleção pareça estar em branco.\nPara resolver, clique em algum campo."))
        self.comboBox.setItemText(0, _translate("Constante1", "Conforto"))
        self.comboBox.setItemText(1, _translate("Constante1", "Industrial"))
        self.titulo.setText(_translate("Constante1", "DIMduct"))
        self.pushButton.setText(_translate("Constante1", "Calcular"))

    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            L_1 = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(L_1)
            Q_1 = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(Q_1)
            Q_2 = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(Q_2)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            epsilon = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(epsilon)
            tipo = self.comboBox.currentIndex()
            input_v[self.label_7.text()] = str(self.comboBox.currentText())

            rho = 101303 /(286.9 *(temp + 273.15))
            mu = ((13 + 0.1 * temp)* 0.000001)* rho

            const_tipo = 25 if tipo else 32 #tipo==0 -> 32, tipo==1 -> 25

            Q_1L = Q_1*1000.0 #[l/s]
            D_1 = const_tipo*(math.pow(Q_1L, 0.38))/1000
            A_1 = (math.pi*D_1**2.0)/4.0
            u_1 = Q_1/A_1
            
            Q_2L = Q_2*1000.0 #[l/s]
            D_2 = const_tipo*(math.pow(Q_2L, 0.38))/1000
            A_2 = (math.pi*D_2**2.0)/4.0
            u_2 = Q_2/A_2

               
            Re = rho * u_1 * D_1 / mu
            f_0 = math.pow(-1.8 * math.log10(math.pow(epsilon / (3.7 * D_1), 1.11) + 6.9 / Re), -2.0)
            f = math.pow(-2.0 * math.log10(epsilon / (3.7 * D_1) + 2.51 / (Re * math.sqrt(f_0))), -2.0)
            dP_m = (f * L_1 / D_1 + 0.1 * theta / 90.0) * u_1 ** 2.0 * rho

            def arredonda(val):
                return ("%.3f" % val)
           
            results["D1"] = arredonda(D_1) + " m"
            results["u1"] = arredonda(u_1) + " m/s"
            results["A1"] = arredonda(A_1) + " m²"
            results["D2"] = arredonda(D_2) + " m"
            results["u2"] = arredonda(u_2) + " m/s" 
            results["A2"] = arredonda(A_2) + " m²"
            results["dP m"] = arredonda(dP_m) + " Pa/m"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()
            
        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if(isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n"+str(e))
    
            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()
Пример #8
0
class Ui_Arbitraria(object):
    def setupUi(self, arbitraria):
        arbitraria.setObjectName("arbitraria")
        arbitraria.resize(800, 600)
        arbitraria.setStyleSheet(
            "QWidget { background-color: rgb(11, 173, 224) }\n"
            "QPushButton { border-radius: 5px; background-color: white; border-bottom: 1px solid black }\n"
            "QPushButton:hover { background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(238, 238, 238, 255)) }\n"
            "QLabel{ color: white }\n"
            "QLineEdit{ background-color: white; color: black }")

        self.titulo = QtWidgets.QLabel(arbitraria)
        self.titulo.setGeometry(QtCore.QRect(0, 40, 801, 111))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.titulo.sizePolicy().hasHeightForWidth())
        self.titulo.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(85)
        self.titulo.setFont(font)
        self.titulo.setStyleSheet("color: white")
        self.titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.titulo.setObjectName("titulo")
        self.formLayoutWidget = QtWidgets.QWidget(arbitraria)
        self.formLayoutWidget.setGeometry(QtCore.QRect(0, 170, 801, 206))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setSizeConstraint(
            QtWidgets.QLayout.SetDefaultConstraint)
        self.formLayout.setFieldGrowthPolicy(
            QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout.setLabelAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setFormAlignment(QtCore.Qt.AlignCenter)
        self.formLayout.setContentsMargins(200, 0, 200, 0)
        self.formLayout.setObjectName("formLayout")
        self.label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole,
                                  self.label)
        self.lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit.setFont(font)
        self.lineEdit.setStyleSheet("")
        self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit.setClearButtonEnabled(False)
        self.lineEdit.setObjectName("lineEdit")  # temperatura
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit)
        self.label_2 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole,
                                  self.label_2)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_2)
        self.label_3 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole,
                                  self.label_3)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_3)
        self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole,
                                  self.label_4)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_4)
        self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole,
                                  self.label_5)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_5.sizePolicy().hasHeightForWidth())
        self.lineEdit_5.setSizePolicy(sizePolicy)
        self.lineEdit_5.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_5)
        self.label_6 = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole,
                                  self.label_6)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.formLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.lineEdit_6.sizePolicy().hasHeightForWidth())
        self.lineEdit_6.setSizePolicy(sizePolicy)
        self.lineEdit_6.setBaseSize(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Roboto")
        font.setPointSize(12)
        self.lineEdit_6.setFont(font)
        self.lineEdit_6.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole,
                                  self.lineEdit_6)
        self.pushButton = QtWidgets.QPushButton(arbitraria)
        self.pushButton.setGeometry(QtCore.QRect(200, 420, 401, 51))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
        self.pushButton.setFlat(True)
        self.pushButton.setObjectName("pushButton")

        self.pushButton.clicked.connect(self.calcula)

        self.retranslateUi(arbitraria)
        QtCore.QMetaObject.connectSlotsByName(arbitraria)

    def retranslateUi(self, arbitraria):
        _translate = QtCore.QCoreApplication.translate
        arbitraria.setWindowTitle(
            _translate("arbitraria", "DIMduct >> Arbitrária"))
        self.titulo.setText(_translate("arbitraria", "DIMduct"))
        self.label.setText(_translate("arbitraria", "Temperatura (°C):"))
        self.label_2.setText(
            _translate("arbitraria", "Rugosidade Absoluta (m):"))
        self.label_3.setText(
            _translate("arbitraria", "Comprimento do Trecho (m):"))
        self.label_4.setText(
            _translate("arbitraria", "Vazão do Trecho (m³/s):"))
        self.label_5.setText(
            _translate("arbitraria", "Ângulo Total de Curvas (°):"))
        self.label_6.setText(_translate("arbitraria", "Velocidade (m/s):"))
        self.pushButton.setText(_translate("arbitraria", "Calcular"))

    def calcula(self):
        # calculos
        results = {}
        input_v = {}

        try:
            temp = float(self.lineEdit.text())
            input_v[self.label.text()] = str(temp)
            epsilon = float(self.lineEdit_2.text())
            input_v[self.label_2.text()] = str(epsilon)
            L = float(self.lineEdit_3.text())
            input_v[self.label_3.text()] = str(L)
            Q = float(self.lineEdit_4.text())
            input_v[self.label_4.text()] = str(Q)
            theta = float(self.lineEdit_5.text())
            input_v[self.label_5.text()] = str(theta)
            u = float(self.lineEdit_6.text())
            input_v[self.label_6.text()] = str(u)

            rho = 101303 / (286.9 * (temp + 273.15))
            mu = ((13 + 0.1 * temp) * 0.000001) * rho

            D = math.sqrt((4.0 * Q) / (math.pi * u))
            Re = rho * u * D / mu
            f_0 = (-1.8 * math.log10((epsilon /
                                      (3.7 * D)**1.11) + 6.9 / Re))**-2.0
            f = (-2.0 * math.log10(epsilon / (3.7 * D) + 2.51 /
                                   (Re * math.sqrt(f_0))))**-2.0
            dP = rho * ((f * L / D + 0.1 * (theta / 90.0))) * ((u**2.0) / 2.0)
            A = (math.pi * D**2) / 4.0

            def arredonda(val):
                return ("%.3f" % val)

            results["Diâmetro"] = arredonda(D) + " m"
            results["Velocidade"] = arredonda(u) + " m/s"
            results["Perda de Carga"] = arredonda(dP) + " Pa"
            results["Área"] = arredonda(A) + " m²"

            # janela
            self.window = QtWidgets.QDialog()
            self.ui = Ui_Resultados()
            self.ui.setupUi(self.window, results, input_v)

            self.window.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.window.show()
        except Exception as e:
            self.erro = QtWidgets.QDialog()
            self.ui = Ui_Erro()

            if (isinstance(e, ValueError)):
                self.ui.setupUi(self.erro, "Algum campo inválido.\n")
            else:
                self.ui.setupUi(self.erro, "Algo deu errado:\n" + str(e))

            self.erro.setWindowIcon(QtGui.QIcon('./imgs/icon.ico'))

            self.erro.show()