Coverage for backend/ahuora-compounds/ahuora_property_packages/combustion/biomass_combustion_rp.py: 44%

37 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-07-22 05:22 +0000

1""" 

2reaction package for the combustion of biomass in air 

3""" 

4from pyomo.environ import Expression 

5 

6# Import Python libraries 

7import logging 

8 

9# Import Pyomo libraries 

10from pyomo.environ import (Set, 

11 Var, 

12 Param, 

13 units as pyunits) 

14 

15# Import IDAES cores 

16from idaes.core import (declare_process_block_class, 

17 MaterialFlowBasis, 

18 ReactionParameterBlock, 

19 ReactionBlockDataBase, 

20 ReactionBlockBase) 

21from idaes.core.util.misc import add_object_reference 

22 

23# Set up logger 

24_log = logging.getLogger(__name__) 

25 

26 

27@declare_process_block_class("BMCombReactionParameterBlock") 

28class BMCombReactionParameterData(ReactionParameterBlock): 

29 """ 

30 Property Parameter Block Class 

31 Contains parameters and indexing sets associated with properties for 

32 superheated steam. 

33 """ 

34 

35 def build(self): 

36 ''' 

37 Callable method for Block construction. 

38 ''' 

39 super(BMCombReactionParameterData, self).build() 

40 

41 self._reaction_block_class = BMReactionBlock # noqa: F821 

42 

43 # List of valid phases in property package 

44 self.phase_list = Set(initialize=['Vap', 'Sol']) 

45 

46 # Component list - a list of component identifiers 

47 self.component_list = Set(initialize=['H2O', 

48 'CO2', 

49 'O2', 

50 'CO', 

51 'N2', 

52 'biomass']) 

53 

54 # Reaction Index 

55 self.rate_reaction_idx = Set(initialize=["R1"]) 

56 

57 # Reaction Stoichiometry 

58 self.rate_reaction_stoichiometry = {("R1", "Vap", "H2O"): 5, 

59 ("R1", "Vap", "CO2"): 6, 

60 ("R1", "Vap", "O2"): -6, 

61 ("R1", "Sol", "biomass"): -1, 

62 ("R1", "Vap", "N2"): 0, 

63 ("R1", "Vap", "CO"): 0, 

64 ("R1", "Sol", "ash"): 0.01#self.ash_content 

65 } 

66 

67 

68 self.reactant_list=Set(initialize=["biomass","O2"]) 

69 

70 self.h=Var(initialize=0.06) #concentration of hydrogen as a percentage of weight, h=6% 

71 self.w=Var(initialize=0.09) #water content of fuel as percentage of weight 

72 self.gcv=Param(initialize=20.2, units=pyunits.MJ/pyunits.kg, doc="gross calorific value") #gross calorific value (dry basis) 

73 self.ncv=(self.gcv*(1-self.w)-2.447*self.w-2.447*self.h*9.01*(1-self.w))*162.1394*1000 #J/mol  

74 #net calorific value (wet basis) (pg. 7) https://www.mbie.govt.nz/dmsdocument/125-industrial-bioenergy- 

75 #ncv multiplied by 162 g/mo (cellulose) to convert from /mass to /mol basis. 

76 

77 

78 def dh_rxn(b,reaction_index): 

79 # only one reaction index, so we are just setting it to the ncv 

80 return -self.ncv 

81 

82 self.dh_rxn = Expression(self.rate_reaction_idx, 

83 rule=dh_rxn, 

84 doc="Heat of reaction") 

85 

86 @classmethod 

87 def define_metadata(cls, obj): 

88 obj.add_default_units({'time': pyunits.s, 

89 'length': pyunits.m, 

90 'mass': pyunits.kg, 

91 'amount': pyunits.mol, 

92 'temperature': pyunits.K}) 

93 

94 

95class ReactionBlock(ReactionBlockBase): 

96 """ 

97 This Class contains methods which should be applied to Reaction Blocks as a 

98 whole, rather than individual elements of indexed Reaction Blocks. 

99 """ 

100 def initialize(blk, outlvl=0, **kwargs): 

101 ''' 

102 Initialization routine for reaction package. 

103 Keyword Arguments: 

104 outlvl : sets output level of initialization routine 

105 * 0 = no output (default) 

106 * 1 = report after each step 

107 Returns: 

108 None 

109 ''' 

110 if outlvl > 0: 

111 _log.info('{} Initialization Complete.'.format(blk.name)) 

112 

113 

114@declare_process_block_class("BMReactionBlock", block_class=ReactionBlock) 

115class BMReactionBlockData(ReactionBlockDataBase): 

116 def build(self): 

117 """ 

118 Callable method for Block construction 

119 """ 

120 super(BMReactionBlockData, self).build() 

121 

122 # Heat of reaction - no _ref as this is the actual property 

123 add_object_reference( 

124 self, 

125 "dh_rxn", 

126 self.config.parameters.dh_rxn) 

127 

128 def get_reaction_rate_basis(b): 

129 return MaterialFlowBasis.molar 

130 

131