def __add__(self, other):
        """
        Addition operator (+).

        Add this stream (self) and 'other' together, return the result as a
        new stream, and leave self unchanged.

        :param other: Can can be one of the following:
                 1. MaterialStream
                    'other' is added to self to create a new stream.
                 2. tuple: (compound, mass flow rate)
                    The specified mass flow rate of the specified compound is added to \
                    self, assuming the added material has the same \
                    temperature as self.
                 3. tuple: (compound, mass flow rate, temperature)
                    The specified mass flow rate of the specified compound at the \
                    specified temperature is added to self.

        :returns: A new MaterialStream that is the sum of self and 'other'.
        """

        # Add another stream.
        if type(other) is MaterialStream:
            if self.material == other.material:  # Streams of same material.
                if self.isCoal or other.isCoal:
                    HHV = 0
                    if self.HHV:
                        HHV += self.HHV * self.mfr
                    if other.HHV:
                        HHV += other.HHV * other.mfr
                    HHV /= self.mfr + other.mfr
                    isCoal = True
                else:
                    isCoal = False
                    HHV = None

                result = MaterialStream(self.material,
                                         self._compound_mfrs +
                                         other._compound_mfrs, isCoal=isCoal, HHV=HHV)
                result.Hfr = self._Hfr + other._Hfr
                result.P = self.P
                return result
            else:  # Streams of different materials.
                Hfr = self.Hfr + other.Hfr
                result = self.clone()
                for compound in other.material.compounds:
                    if compound not in self.material.compounds:
                        raise Exception("Streams of '" + other.material.name +
                                        "' cannot be added to streams of '" +
                                        self.material.name +
                                        "'. The compound '" + compound +
                                        "' was not found in '" +
                                        self.material.name + "'.")
                    result = result + (compound,
                                       other.get_compound_mfr(compound))
                result.Hfr = Hfr
                return result

        # Add the specified mass flow rate of the specified compound.
        elif self._is_compound_mfr_tuple(other):
            # Added material variables.
            compound = other[0]
            index = self.material.get_compound_index(compound)
            mfr = other[1]
            enthalpy = thermo.H(compound, self._T, mfr)

            # Create the result stream.
            result = self.clone()
            result._compound_mfrs[index] += mfr
            result._update_HHV(compound, mfr)
            result._Hfr += enthalpy
            result._P = self._P
            return result

        # Add the specified mass flow rate of 'compound' at the specified temperature.
        elif self._is_compound_mfr_temperature_tuple(other):
            # Added material varialbes.
            compound = other[0]
            index = self.material.get_compound_index(compound)
            mfr = other[1]
            temperature = other[2]
            enthalpy = thermo.H(compound, temperature, mfr)

            # Create the result stream.
            result = self * 1.0
            result._compound_mfrs[index] += mfr
            result.Hfr = self._Hfr + enthalpy
            result._P = self._P
            return result

        # If not one of the above, it must be an invalid argument.
        else:
            raise TypeError("Invalid addition argument.")
def __add__ ( self , other ) : if type ( other ) is MaterialStream : if self . material == other . material : if self . isCoal or other . isCoal : HHV = 0 if self . HHV : HHV += self . HHV * self . mfr if other . HHV : HHV += other . HHV * other . mfr HHV /= self . mfr + other . mfr isCoal = True else : isCoal = False HHV = None result = MaterialStream ( self . material , self . _compound_mfrs + other . _compound_mfrs , isCoal = isCoal , HHV = HHV ) result . Hfr = self . _Hfr + other . _Hfr result . P = self . P return result else : Hfr = self . Hfr + other . Hfr result = self . clone ( ) for compound in other . material . compounds : if compound not in self . material . compounds : raise Exception ( "Streams of '" + other . material . name + "' cannot be added to streams of '" + self . material . name + "'. The compound '" + compound + "' was not found in '" + self . material . name + "'." ) result = result + ( compound , other . get_compound_mfr ( compound ) ) result . Hfr = Hfr return result elif self . _is_compound_mfr_tuple ( other ) : compound = other [ 0 ] index = self . material . get_compound_index ( compound ) mfr = other [ 1 ] enthalpy = thermo . H ( compound , self . _T , mfr ) result = self . clone ( ) result . _compound_mfrs [ index ] += mfr result . _update_HHV ( compound , mfr ) result . _Hfr += enthalpy result . _P = self . _P return result elif self . _is_compound_mfr_temperature_tuple ( other ) : compound = other [ 0 ] index = self . material . get_compound_index ( compound ) mfr = other [ 1 ] temperature = other [ 2 ] enthalpy = thermo . H ( compound , temperature , mfr ) result = self * 1.0 result . _compound_mfrs [ index ] += mfr result . Hfr = self . _Hfr + enthalpy result . _P = self . _P return result else : raise TypeError ( "Invalid addition argument." )
Addition operator (+).

        Add this stream (self) and 'other' together, return the result as a
        new stream, and leave self unchanged.

        :param other: Can can be one of the following:
                 1. MaterialStream
                    'other' is added to self to create a new stream.
                 2. tuple: (compound, mass flow rate)
                    The specified mass flow rate of the specified compound is added to \
                    self, assuming the added material has the same \
                    temperature as self.
                 3. tuple: (compound, mass flow rate, temperature)
                    The specified mass flow rate of the specified compound at the \
                    specified temperature is added to self.

        :returns: A new MaterialStream that is the sum of self and 'other'.