Пример #1
0
    def comp_init(self, nw):

        if not self.P.is_set:
            self.set_attr(P='var')
            msg = ('The power input of a water electrolyzer must be set! '
                   'We are adding the power input of component ' + self.label +
                   ' as custom variable of the system.')
            logging.info(msg)

        for fluid in ['o2', 'h2o', 'h2']:
            try:
                setattr(self, fluid, [
                    x for x in nw.fluids if x in [
                        a.replace(' ', '')
                        for a in CP.get_aliases(fluid.upper())
                    ]
                ][0])
            except IndexError:
                msg = ('The component ' + self.label + ' (class ' +
                       self.__class__.__name__ + ') requires that the fluid '
                       '[fluid] is in the network\'s list of fluids.')
                aliases = ', '.join(CP.get_aliases(fluid.upper()))
                msg = msg.replace(
                    '[fluid]',
                    fluid.upper() + ' (aliases: ' + aliases + ')')
                logging.error(msg)
                raise TESPyComponentError(msg)

        self.e0 = self.calc_e0()

        Component.comp_init(self, nw)
Пример #2
0
    def comp_init(self, nw):
        Component.comp_init(self, nw, num_eq=len(nw.fluids) + 1)

        self.Tamb.val_SI = convert_to_SI('T', self.Tamb.val, nw.T_unit)
Пример #3
0
 def comp_init(self, nw):
     Component.comp_init(self, nw)
     self.setup_reaction_parameters()
Пример #4
0
    def comp_init(self, nw):

        self.overheating.is_set = not self.overheating.val
        self.subcooling.is_set = not self.subcooling.val
        Component.comp_init(self, nw)
Пример #5
0
    def comp_init(self, nw):

        # if subcooling is True, outlet state method must not be calculated
        self.subcooling.is_set = not self.subcooling.val
        Component.comp_init(self, nw)
    def comp_init(self, nw):
        if not self.fuel.is_set or not isinstance(self.fuel.val, dict):
            msg = ('You must specify the fuel composition for stoichimetric '
                   'combustion chamber ' + self.label + '.')
            logging.error(msg)
            raise TESPyComponentError(msg)

        if not self.fuel_alias.is_set:
            msg = ('You must specify a fuel alias for stoichimetric '
                   'combustion chamber ' + self.label + '.')
            logging.error(msg)
            raise TESPyComponentError(msg)

        if not self.air.is_set or not isinstance(self.air.val, dict):
            msg = ('You must specify the air composition for stoichimetric '
                   'combustion chamber ' + self.label + '.')
            logging.error(msg)
            raise TESPyComponentError(msg)

        if not self.air_alias.is_set:
            msg = ('You must specify an air alias for stoichimetric '
                   'combustion chamber ' + self.label + '.')
            logging.error(msg)
            raise TESPyComponentError(msg)

        Component.comp_init(self, nw)

        # adjust the names for required fluids according to naming in the
        # network air
        for f in list(self.air.val.keys()):
            alias = [x for x in self.nw_fluids if x in [
                a.replace(' ', '') for a in CP.get_aliases(f)]]
            if len(alias) > 0:
                self.air.val[alias[0]] = self.air.val.pop(f)

        # fuel
        for f in list(self.fuel.val.keys()):
            alias = [x for x in self.air.val.keys() if x in [
                a.replace(' ', '') for a in CP.get_aliases(f)]]
            if len(alias) > 0:
                self.fuel.val[alias[0]] = self.fuel.val.pop(f)

        # list of all fluids of air and fuel
        fluids = list(self.air.val.keys()) + list(self.fuel.val.keys())

        # oxygen
        alias = [x for x in fluids if x in [
            a.replace(' ', '') for a in CP.get_aliases('O2')]]
        if len(alias) == 0:
            msg = 'Oxygen missing in input fluids.'
            logging.error(msg)
            raise TESPyComponentError(msg)
        else:
            self.o2 = alias[0]

        # carbondioxide
        self.co2 = [x for x in self.nw_fluids if x in [
            a.replace(' ', '') for a in CP.get_aliases('CO2')]]
        if len(self.co2) == 0:
            self.co2 = 'CO2'
        else:
            self.co2 = self.co2[0]

        # water
        self.h2o = [x for x in self.nw_fluids if x in [
            a.replace(' ', '') for a in CP.get_aliases('H2O')]]
        if len(self.h2o) == 0:
            self.h2o = 'H2O'
        else:
            self.h2o = self.h2o[0]

        # calculate lower heating value of specified fuel
        self.lhv = self.calc_lhv()
        msg = ('Combustion chamber fuel (' + self.fuel_alias.val +
               ') LHV is ' + str(self.lhv) + ' for component ' +
               self.label + '.')
        logging.debug(msg)
        # generate fluid properties for stoichiometric flue gas
        self.stoich_flue_gas(nw)