Beispiel #1
0
 def setMassFractions(self, x, norm = 1):
     """Set the mass fractions.
     See: setMoleFractions
     """
     if type(x) == types.StringType:
         _cantera.phase_setstring(self._phase_id,2,x)
     elif _isseq(self.nSpecies(), x):
         _cantera.phase_setarray(self._phase_id,2,norm,asarray(x))
     else:
         raise CanteraError('mass fractions must be a string or array')
Beispiel #2
0
    def setMoleFractions(self, x, norm = 1):
        """Set the mole fractions.

        :param x:
            string or array of mole fraction values
        :param norm:
            If non-zero (default), array values will be scaled to sum to 1.0.

        >>> ph.setMoleFractions('CO:1, H2:7, H2O:7.8')
        >>> x = [1.0]*ph.nSpecies()
        >>> ph.setMoleFractions(x)
        >>> ph.setMoleFractions(x, norm = 0)  # don't normalize values
        """
        if type(x) == types.StringType:
            _cantera.phase_setstring(self._phase_id,1,x)
        elif _isseq(self.nSpecies(), x):
            _cantera.phase_setarray(self._phase_id,1,norm,asarray(x))
        else:
            raise CanteraError('mole fractions must be a string or array')
Beispiel #3
0
    def setMoleFractions(self, x, norm = 1):
        """Set the mole fractions.

        x - string or array of mole fraction values

        norm - If non-zero (default), array values will be
        scaled to sum to 1.0.

        >>> ph.setMoleFractions('CO:1, H2:7, H2O:7.8')
        >>> x = [1.0]*ph.nSpecies()
        >>> ph.setMoleFractions(x)
        >>> ph.setMoleFractions(x, norm = 0)  # don't normalize values

        """
        if type(x) == types.StringType:
            _cantera.phase_setstring(self._phase_id,1,x)
        elif _isseq(self.nSpecies(), x): 
            _cantera.phase_setarray(self._phase_id,1,norm,asarray(x))
        else:
            raise CanteraError('mole fractions must be a string or array')