Coverage for backend/ahuora-builder/src/ahuora_builder/custom/custom_heater.py: 94%
25 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-06-23 21:51 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-06-23 21:51 +0000
1from idaes.core import declare_process_block_class
2from idaes.models.unit_models.heater import HeaterData
3from .add_initial_dynamics import add_initial_dynamics
4from .inverted import add_inverted, initialise_inverted, disable_inverted, enable_inverted
5import pyomo.environ as pyo
7@declare_process_block_class("DynamicHeater")
8class DynamicHeaterData(HeaterData):
9 """
10 Dynamic Heater unit model class.
11 This extends the Heater class to include reference variables for initial holdup and initial accumulation.
12 Which makes it easier for us to set initial conditions in the frontend.
13 """
15 def build(self,*args, **kwargs):
16 """
17 Build method for the DynamicHeaterData class.
18 This method initializes the control volume and sets up the model.
19 """
20 super().build(*args, **kwargs)
22 if hasattr(self,"deltaP"):
23 # else has_pressure_change is false
24 add_inverted(self, "deltaP")
26 add_initial_dynamics(self)
28 def initialize_build(
29 self,*args,**kwargs,
30 ):
31 """
32 Initialize method for the DynamicHeaterData class.
33 This method initializes the control volume and sets up the model.
34 """
35 if hasattr(self,"deltaP"):
36 initialise_inverted(self, "deltaP")
37 disable_inverted(self, "deltaP")
39 super().initialize_build(*args, **kwargs)
41 if hasattr(self,"deltaP"):
42 enable_inverted(self, "deltaP")
44 def diagnose(self):
45 problems = []
46 inlet_flow = pyo.value(self.control_volume.properties_in[0].flow_mol) or 0
48 if inlet_flow <= 0.0001: 48 ↛ 49line 48 didn't jump to line 49 because the condition on line 48 was never true
49 problems.append(
50 (
51 self.control_volume.properties_in[0].flow_mol,
52 f"Inlet flow ({inlet_flow:.2f} mol/s) is very low."
53 )
54 )
55 return problems