How to use the tespy.tools.fluid_properties.v_mix_ph function in tespy

To help you get started, we’ve selected a few tespy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oemof / tespy / src / tespy / components / heat_exchangers.py View on Github external
def calc_parameters(self):
        r"""Postprocessing parameter calculation."""
        i = self.inl[0].to_flow()
        o = self.outl[0].to_flow()
        v_i = v_mix_ph(i, T0=self.inl[0].T.val_SI)
        v_o = v_mix_ph(o, T0=self.outl[0].T.val_SI)

        self.SQ1.val = i[0] * (s_mix_ph(o) - s_mix_ph(i))
        self.Q.val = i[0] * (o[2] - i[2])
        self.pr.val = o[1] / i[1]
        self.zeta.val = ((i[1] - o[1]) * np.pi ** 2 /
                         (8 * i[0] ** 2 * (v_i + v_o) / 2))

        if self.Tamb.is_set:
            self.SQ2.val = -i[0] * (o[2] - i[2]) / self.Tamb.val_SI
            self.Sirr.val = self.SQ1.val + self.SQ2.val

            ttd_1 = T_mix_ph(i, T0=self.inl[0].T.val_SI) - self.Tamb.val_SI
            ttd_2 = T_mix_ph(o, T0=self.outl[0].T.val_SI) - self.Tamb.val_SI

            if ttd_1 > ttd_2:
github oemof / tespy / src / tespy / components / heat_exchangers.py View on Github external
def calc_parameters(self):
        r"""Postprocessing parameter calculation."""
        i = self.inl[0].to_flow()
        o = self.outl[0].to_flow()

        self.SQ.val = i[0] * (s_mix_ph(o) - s_mix_ph(i))
        self.Q.val = i[0] * (o[2] - i[2])
        self.pr.val = o[1] / i[1]
        self.zeta.val = ((i[1] - o[1]) * np.pi ** 2 /
                         (8 * i[0] ** 2 * (v_mix_ph(i) + v_mix_ph(o)) / 2))
        if self.energy_group.is_set is True:
            self.Q_loss.val = self.E.val * self.A.val - self.Q.val

        self.check_parameter_bounds()
github oemof / tespy / tespy / components / customs.py View on Github external
def calc_parameters(self):
        r"""Postprocessing parameter calculation."""
        # connection information
        i1 = self.inl[0].to_flow()
        i2 = self.inl[1].to_flow()
        i3 = self.inl[2].to_flow()
        o1 = self.outl[0].to_flow()
        o2 = self.outl[1].to_flow()
        o3 = self.outl[2].to_flow()

        # specific volume
        v_i1 = v_mix_ph(i1, T0=self.inl[0].T.val_SI)
        v_i2 = v_mix_ph(i2, T0=self.inl[1].T.val_SI)
        v_i3 = v_mix_ph(i3, T0=self.inl[2].T.val_SI)
        v_o1 = v_mix_ph(o1, T0=self.outl[0].T.val_SI)
        v_o2 = v_mix_ph(o2, T0=self.outl[1].T.val_SI)
        v_o3 = v_mix_ph(o3, T0=self.outl[2].T.val_SI)

        # specific entropy
        s_i1 = s_mix_ph(i1, T0=self.inl[0].T.val_SI)
        s_i2 = s_mix_ph(i2, T0=self.inl[1].T.val_SI)
        s_i3 = s_mix_ph(i3, T0=self.inl[2].T.val_SI)
        s_o1 = s_mix_ph(o1, T0=self.outl[0].T.val_SI)
        s_o2 = s_mix_ph(o2, T0=self.outl[1].T.val_SI)
        s_o3 = s_mix_ph(o3, T0=self.outl[2].T.val_SI)

        # component parameters
        self.Q.val = -i3[0] * (o3[2] - i3[2])
github oemof / tespy / tespy / components / reactors.py View on Github external
def calc_parameters(self):
        r"""Postprocessing parameter calculation."""
        self.Q.val = - self.inl[0].m.val_SI * (self.outl[0].h.val_SI -
                                               self.inl[0].h.val_SI)
        self.pr_c.val = self.outl[0].p.val_SI / self.inl[0].p.val_SI
        self.e.val = self.P.val / self.outl[2].m.val_SI
        self.eta.val = self.e0 / self.e.val

        i = self.inl[0].to_flow()
        o = self.outl[0].to_flow()
        self.zeta.val = ((i[1] - o[1]) * np.pi ** 2 /
                         (8 * i[0] ** 2 * (v_mix_ph(i) + v_mix_ph(o)) / 2))

        if self.eta_char.is_set:
            # get bound errors for efficiency characteristics
            expr = self.outl[2].m.val_SI / self.outl[2].m.design
            self.eta_char.func.get_bound_errors(expr, self.label)

        self.check_parameter_bounds()
github oemof / tespy / src / tespy / networks / networks.py View on Github external
self.residual[k] = c.h.val_SI - (
                        fp.h_mix_pQ(flow, c.x.val_SI))
                if not self.increment_filter[col + 1]:
                    self.jacobian[k, col + 1] = -(
                        fp.dh_mix_dpQ(flow, c.x.val_SI))
                self.jacobian[k, col + 2] = 1
                k += 1

            # volumetric flow
            if c.v.val_set is True:
                if (np.absolute(self.residual[k]) > err ** 2 or
                        self.iter % 2 == 0):
                    self.residual[k] = (
                        c.v.val_SI - fp.v_mix_ph(flow, T0=c.T.val_SI) *
                        c.m.val_SI)
                self.jacobian[k, col] = -fp.v_mix_ph(flow, T0=c.T.val_SI)
                self.jacobian[k, col + 1] = -(
                    fp.dv_mix_dph(flow, T0=c.T.val_SI) * c.m.val_SI)
                self.jacobian[k, col + 2] = -(
                    fp.dv_mix_pdh(flow, T0=c.T.val_SI) * c.m.val_SI)
                k += 1

            # temperature difference to boiling point
            if c.Td_bp.val_set is True:
                if (np.absolute(self.residual[k]) > err ** 2 or
                        self.iter % 2 == 0):
                    self.residual[k] = (
                        fp.T_mix_ph(flow, T0=c.T.val_SI) - c.Td_bp.val_SI -
                        fp.T_bp_p(flow))
                if not self.increment_filter[col + 1]:
                    self.jacobian[k, col + 1] = (
                        fp.dT_mix_dph(flow, T0=c.T.val_SI) - fp.dT_bp_dp(flow))
github oemof / tespy / src / tespy / networks / networks.py View on Github external
abs(
                        fp.h_mix_pT(flow, c.T.val_SI) - c.h.val_SI
                    ) > err ** .5):
                c.T.val_SI = np.nan
                c.vol.val_SI = np.nan
                c.v.val_SI = np.nan
                c.s.val_SI = np.nan
                msg = (
                    'Could not find a feasible value for mixture temperature '
                    'at connection ' + c.label + '. The values for '
                    'temperature, specific volume, volumetric flow and '
                    'entropy are set to nan.')
                logging.warning(msg)

            else:
                c.vol.val_SI = fp.v_mix_ph(flow, T0=c.T.val_SI)
                c.v.val_SI = c.vol.val_SI * c.m.val_SI
                c.s.val_SI = fp.s_mix_ph(flow, T0=c.T.val_SI)

            c.T.val = (c.T.val_SI / self.T[c.T.unit][1] - self.T[c.T.unit][0])
            c.m.val = c.m.val_SI / self.m[c.m.unit]
            c.p.val = c.p.val_SI / self.p[c.p.unit]
            c.h.val = c.h.val_SI / self.h[c.h.unit]
            c.v.val = c.v.val_SI / self.v[c.v.unit]
            c.vol.val = c.vol.val_SI / self.vol[c.vol.unit]
            c.s.val = c.s.val_SI / self.s[c.s.unit]
            if fluid is not None and not c.x.val_set:
                c.x.val_SI = fp.Q_ph(c.p.val_SI, c.h.val_SI, fluid)
                c.x.val = c.x.val_SI / self.x[c.x.unit]
            c.T.val0 = c.T.val
            c.m.val0 = c.m.val
            c.p.val0 = c.p.val
github oemof / tespy / src / tespy / components / turbomachinery.py View on Github external
Equation for given flow characteristic of a pump.

        Returns
        -------
        res : ndarray
            Residual value of equation.

            .. math::

                0 = p_{out} - p_{in} - char\left( \dot{m}_{in}
                \cdot v_{in} \right)
        """
        i = self.inl[0].to_flow()
        o = self.outl[0].to_flow()

        expr = i[0] * v_mix_ph(i, T0=self.inl[0].T.val_SI)

        return o[1] - i[1] - self.flow_char.func.evaluate(expr)