How to use the tespy.tools.fluid_properties.h_mix_pT 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 / tespy / components / reactors.py View on Github external
def derivatives(self, increment_filter):
        r"""Calculate partial derivatives for given equations."""
        ######################################################################
        # derivatives fluid, mass flow and reactor pressure are static
        k = self.num_nw_fluids * 4 + 5
        ######################################################################
        # derivatives for energy balance equations
        T_ref = 293.15
        p_ref = 1e5
        h_refh2o = h_mix_pT([1, p_ref, 0, self.inl[1].fluid.val], T_ref)
        h_refh2 = h_mix_pT([1, p_ref, 0, self.outl[2].fluid.val], T_ref)
        h_refo2 = h_mix_pT([1, p_ref, 0, self.outl[1].fluid.val], T_ref)

        # derivatives cooling water inlet
        self.jacobian[k, 0, 0] = -(
            self.outl[0].h.val_SI - self.inl[0].h.val_SI)
        self.jacobian[k, 0, 2] = self.inl[0].m.val_SI

        # derivatives feed water inlet
        self.jacobian[k, 1, 0] = (self.inl[1].h.val_SI - h_refh2o)
        self.jacobian[k, 1, 2] = self.inl[1].m.val_SI

        # derivative cooling water outlet
        self.jacobian[k, 2, 2] = - self.inl[0].m.val_SI

        # derivatives oxygen outlet
github oemof / tespy / tespy / components / reactors.py View on Github external
def derivatives(self, increment_filter):
        r"""Calculate partial derivatives for given equations."""
        ######################################################################
        # derivatives fluid, mass flow and reactor pressure are static
        k = self.num_nw_fluids * 4 + 5
        ######################################################################
        # derivatives for energy balance equations
        T_ref = 293.15
        p_ref = 1e5
        h_refh2o = h_mix_pT([1, p_ref, 0, self.inl[1].fluid.val], T_ref)
        h_refh2 = h_mix_pT([1, p_ref, 0, self.outl[2].fluid.val], T_ref)
        h_refo2 = h_mix_pT([1, p_ref, 0, self.outl[1].fluid.val], T_ref)

        # derivatives cooling water inlet
        self.jacobian[k, 0, 0] = -(
            self.outl[0].h.val_SI - self.inl[0].h.val_SI)
        self.jacobian[k, 0, 2] = self.inl[0].m.val_SI

        # derivatives feed water inlet
        self.jacobian[k, 1, 0] = (self.inl[1].h.val_SI - h_refh2o)
        self.jacobian[k, 1, 2] = self.inl[1].m.val_SI

        # derivative cooling water outlet
        self.jacobian[k, 2, 2] = - self.inl[0].m.val_SI

        # derivatives oxygen outlet
        self.jacobian[k, 3, 0] = - (self.outl[1].h.val_SI - h_refo2)
github oemof / tespy / tespy / networks / networks.py View on Github external
def solve_check_temperature(self, c):
        r"""
        Check if temperature is within user specified limits.

        Parameters
        ----------
        c : tespy.connections.connection
            Connection to check fluid properties.
        """
        hmin = fp.h_mix_pT(c.to_flow(), self.T_range_SI[0])
        hmax = fp.h_mix_pT(c.to_flow(), self.T_range_SI[1])

        if c.h.val_SI < hmin:
            if c.h.val_SI < 0:
                c.h.val_SI = hmin * 0.9
            else:
                c.h.val_SI = hmin * 1.1
            logging.debug(self.property_range_message(c, 'h'))

        if c.h.val_SI > hmax:
            c.h.val_SI = hmax * 0.95
            logging.debug(self.property_range_message(c, 'h'))
github oemof / tespy / tespy / networks / networks.py View on Github external
def solve_check_temperature(self, c):
        r"""
        Check if temperature is within user specified limits.

        Parameters
        ----------
        c : tespy.connections.connection
            Connection to check fluid properties.
        """
        hmin = fp.h_mix_pT(c.to_flow(), self.T_range_SI[0])
        hmax = fp.h_mix_pT(c.to_flow(), self.T_range_SI[1])

        if c.h.val_SI < hmin:
            if c.h.val_SI < 0:
                c.h.val_SI = hmin * 0.9
            else:
                c.h.val_SI = hmin * 1.1
            logging.debug(self.property_range_message(c, 'h'))

        if c.h.val_SI > hmax:
            c.h.val_SI = hmax * 0.95
            logging.debug(self.property_range_message(c, 'h'))
github oemof / tespy / tespy / components / reactors.py View on Github external
the feed water must be liquid as proposed in the calculation of
        the minimum specific energy consumption for electrolysis:
        :func:`tespy.components.reactors.water_electrolyzer.calc_e0`.
        The part of the equation regarding the cooling water is implemented
        with negative sign as the energy for cooling is extracted from the
        reactor.

        - Reference temperature: 293.15 K.
        - Reference pressure: 1 bar.
        """
        T_ref = 293.15
        p_ref = 1e5

        # equations to set a reference point for each h2o, h2 and o2
        h_refh2o = h_mix_pT([1, p_ref, 0, self.inl[1].fluid.val], T_ref)
        h_refh2 = h_mix_pT([1, p_ref, 0, self.outl[2].fluid.val], T_ref)
        h_refo2 = h_mix_pT([1, p_ref, 0, self.outl[1].fluid.val], T_ref)

        val = (self.inl[1].m.val_SI * (self.inl[1].h.val_SI - h_refh2o) -
               self.outl[2].m.val_SI * self.e0 -
               self.inl[0].m.val_SI * (self.outl[0].h.val_SI -
                                       self.inl[0].h.val_SI) -
               self.outl[1].m.val_SI * (self.outl[1].h.val_SI - h_refo2) -
               self.outl[2].m.val_SI * (self.outl[2].h.val_SI - h_refh2))
        return val
github oemof / tespy / src / tespy / networks / networks.py View on Github external
if self.mode == 'design':
                    if b.comps.loc[cp, 'base'] == 'component':
                        b.comps.loc[cp, 'P_ref'] = (
                            val / abs(b.comps.loc[cp, 'char'].evaluate(1)))
                    else:
                        b.comps.loc[cp, 'P_ref'] = val

        # connections
        for c in self.conns.index:
            flow = c.to_flow()
            c.good_starting_values = True
            c.T.val_SI = fp.T_mix_ph(flow, T0=c.T.val_SI)
            fluid = hlp.single_fluid(c.fluid.val)
            if (fluid is None and
                    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)
github oemof / tespy / tespy / components / reactors.py View on Github external
the minimum specific energy consumption for electrolysis:
        :func:`tespy.components.reactors.water_electrolyzer.calc_e0`.
        The part of the equation regarding the cooling water is implemented
        with negative sign as the energy for cooling is extracted from the
        reactor.

        - Reference temperature: 293.15 K.
        - Reference pressure: 1 bar.
        """
        T_ref = 293.15
        p_ref = 1e5

        # equations to set a reference point for each h2o, h2 and o2
        h_refh2o = h_mix_pT([1, p_ref, 0, self.inl[1].fluid.val], T_ref)
        h_refh2 = h_mix_pT([1, p_ref, 0, self.outl[2].fluid.val], T_ref)
        h_refo2 = h_mix_pT([1, p_ref, 0, self.outl[1].fluid.val], T_ref)

        val = (self.inl[1].m.val_SI * (self.inl[1].h.val_SI - h_refh2o) -
               self.outl[2].m.val_SI * self.e0 -
               self.inl[0].m.val_SI * (self.outl[0].h.val_SI -
                                       self.inl[0].h.val_SI) -
               self.outl[1].m.val_SI * (self.outl[1].h.val_SI - h_refo2) -
               self.outl[2].m.val_SI * (self.outl[2].h.val_SI - h_refh2))
        return val
github oemof / tespy / src / tespy / networks / networks.py View on Github external
Parameters
        ----------
        c : tespy.connections.connection
            Connection to check fluid properties.
        """
        flow = c.to_flow()
        Tmin = max(
            [fp.memorise.value_range[f][2] for
             f in flow[3].keys() if flow[3][f] > err]
        ) + 100
        Tmax = min(
            [fp.memorise.value_range[f][3] for
             f in flow[3].keys() if flow[3][f] > err]
        ) - 100
        hmin = fp.h_mix_pT(flow, Tmin)
        hmax = fp.h_mix_pT(flow, Tmax)

        if c.h.val_SI < hmin:
            c.h.val_SI = hmin
            logging.debug(self.property_range_message(c, 'h'))

        if c.h.val_SI > hmax:
            c.h.val_SI = hmax
            logging.debug(self.property_range_message(c, 'h'))