Home

Awesome

Building Energy Model (MATLAB)

It is a small software which is developed by MATLAB for modeling the energy system of a building or a HVAC system.

Method of Solution

In this code, the temperatures are considered variables of the problem, which are solved implicitly by solving a system of linear equations based on energy equations of each element.

Elements Classes

Boiler

The boiler contains an inlet fluid pipe, an outlet fluid pipe, a fluid tank which is heated up, and the rest. The class of boiler receives input values including the id of the inlet, the id of outlet, the solver, the specific heat capacity of the rest, the mass of the rest, specific heat capacity of the fluid, mass of the fluid, the boiler power, the mass flow rate, and the status. The inlet and outlet should be outlet and inlet of pipes which are connected to the boiler respectively. The solver is the class of the solver that is used. Next, there are specific heat capacity and mass of the boiler except containing fluid. Then, there are those of the fluid. The next argument is the power of the boiler. The mass flow rate also should be given as an input value. The status works as a switch in the boiler which can be controlled by the smart controller in the next stages of the project.

Equations

Schematic Equations

Variables

SymbolDescriptionUnit
mMasskg
CSpecific Heat CapacityJ/(K.kg)
TTemperatureK
E.Energy RateW
SubscriptDescription
bBoiler
ffluid
b,fFluid inside Boiler
b,iBoiler Inlet
b,oBoiler Outlet

Code

Construction
boiler = Boiler(id_inlet, id_outlet, solver, specific_heat_capacity, mass, specific_heat_capacity_fluid, mass_fluid, power, mass_flow_rate, status);
InputDescriptionTypeUnit
id_inletBoiler Inlet IDinteger-
id_outletBoiler Outlet IDinteger-
solverClass of the Solversolver-
specific_heat_capacitySpecific Heat Capacity of the Boiler (without fluid)doubleJ/(K.kg)
massMass of the Boiler (without fluid)doublekg
specific_heat_capacity_fluidSpecific Heat Capacity of the FluiddoubleJ/(K.kg)
mass_fluidMass of Fluid inside the Boilerdoublekg
powerPower of the BoilerdoubleW
mass_flow_rateMass Flow Rate of the Boilerdoublekg/s
statusStatus of the Boiler (ON/OFF)boolean-
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Pipe

Another element in the model is the pipe. The input values of the pipe class are the id of inlet, the id of outlet, the id of zone, the solver, specific heat capacity of the pipe wall, density of the pipe wall, specific heat capacity of the fluid, density of the fluid, mass flow rate of the fluid, inner heat transfer coefficient, outer heat transfer coefficient, thermal conductivity of the tube wall, inner radius of the pipe, outer radius of the pipe, and length of the pipe. The inlet and outlet of the pipe are the elements which are connected to the pipe. The zone which is in contact with the outer side of the pipe is also the argument of the class.

Equations

Schematic Equations

Variables

SymbolDescriptionUnit
hHeat Transfer CoefficientW/(m<sup>2</sup>K)
rRadiusm
DDiameterm
kThermal ConductivityW.m<sup>-1</sup>.K<sup>-1</sup>
LLengthm
Uequivalent heat transfer coefficientW/(m<sup>2</sup>K)
NuNusselt Number-
ReReynolds Number-
PrPrandtl Number-
RaRayleigh Number-
gGravitational Accelerationm/s<sup>2</sup>
&‌beta;Coefficient of Volume Expansion1/K
&‌nu;Kinematic Viscositym<sup>2</sup>/s
&‌mu;Dynamic Viscositykg·m<sup>−1</sup>·s<sup>−1</sup>
SubscriptDescription
tPipe
t,fFluid inside Pipe
t,iPipe Inlet
t,oPipe Outlet
t,inPipe Inner Side
t,outPipe Outer Side

Code

Construction
pipe = Pipe(id_inlet, id_outlet, id_zone, solver, specific_heat_capacity, density, specific_heat_capacity_fluid, density_fluid, mass_flow_rate,thermal_conductivity,thermal_conductivity_fluid,radius_inner,radius_outer,length,dynamic_viscosity_fluid,dynamic_viscosity_air,density_air,specific_heat_capacity_air,thermal_conductivity_air);
InputDescriptionTypeUnit
id_inletPipe Inlet IDinteger-
id_outletPipe Outlet IDinteger-
id_zoneZone IDinteger-
solverClass of the Solversolver-
specific_heat_capacitySpecific Heat Capacity of the Pipe (without fluid)doubleJ/(K.kg)
densityDensity of the Pipe (without fluid)doublekg/m<sup>3</sup>
specific_heat_capacity_fluidSpecific Heat Capacity of the FluiddoubleJ/(K.kg)
density_fluidDensity of Fluid inside the Pipedoublekg/m<sup>3</sup>
mass_flow_rateMass Flow Rate of the Pipedoublekg/s
thermal_conductivityThermal Conductivity of the PipedoubleW.m<sup>-1</sup>.K<sup>-1</sup>
thermal_conductivity_fluidThermal Conductivity of the FluiddoubleW.m<sup>-1</sup>.K<sup>-1</sup>
radius_innerInner Radius of the Pipedoublem
radius_outerOuter Radius of the Pipedoublem
lengthLength of the Pipedoublem
dynamic_viscosity_fluidDynamic Viscosity of the FluiddoubleN·s/m<sup>2</sup>
dynamic_viscosity_airDynamic Viscosity of the AirdoubleN·s/m<sup>2</sup>
density_airDensity of the Airdoublekg/m<sup>3</sup>
specific_heat_capacity_airSpecific Heat Capacity of the AirdoubleJ/(K.kg)
thermal_conductivity_airThermal Conductivity of the AirdoubleW.m<sup>-1</sup>.K<sup>-1</sup>
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Radiator

The input values of the radiator class are the id of inlet, the id of outlet, the id of zone, the solver, specific heat capacity of the radiator except containing fluid, mass of the radiator except containing fluid, specific heat capacity of the fluid, mass of fluid, mass flow rate of the fluid, heat transfer coefficient of the radiator to the zone, the surface of the radiator which is in contact to the air of the zone.

Equations

Schematic Equations

Variables

SubscriptDescription
rRadiator
r,fFluid inside Radiator
r,iRadiator Inlet
r,oRadiator Outlet
zZone

Code

Construction
radiator = Radiator(id_inlet, id_outlet, id_zone, solver, specific_heat_capacity, mass, specific_heat_capacity_fluid, mass_fluid, mass_flow_rate,heat_transfer_coefficient,surface);
InputDescriptionTypeUnit
id_inletRadiator Inlet IDinteger-
id_outletRadiator Outlet IDinteger-
id_zoneZone IDinteger-
solverClass of the Solversolver-
specific_heat_capacitySpecific Heat Capacity of the Radiator (without fluid)doubleJ/(K.kg)
massMass of the Radiator (without fluid)doublekg
specific_heat_capacity_fluidSpecific Heat Capacity of the FluiddoubleJ/(K.kg)
mass_fluidMass of Fluid inside the Radiatordoublekg
mass_flow_rateMass Flow Rate of the Radiatordoublekg/s
heat_transfer_coefficientHeat Transfer Coefficient of the RadiatordoubleW/(m<sup>2</sup>K)
surfaceSurface of the Radiatordoublem<sup>2</sup>
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Mixer

The mixer is an element that works as a mixer or manifold. It can mix multiple flowing fluids to multiple outlets. For the input arguments of the related class, there are the ids of inlets, the ids outlets, the solver, specific heat capacities of the inlets, mass flow rates of the inlets, and the fractions of outlets.

Equations

Schematic Equations

Variables

SubscriptDescription

Code

Construction
mixer = Mixer(id_inlets, id_outlets, solver, specific_heat_capacity_inlets, mass_flow_rate_inlets, fracrion_outlets);
InputDescriptionTypeUnit
id_inletsArray of Mixer Inlet IDarray(integer)-
id_outletsArray of Mixer Outlet IDarray(integer)-
solverClass of the Solversolver-
specific_heat_capacity_inletsSpecific Heat Capacity of the Mixer Inletsarray(double)J/(K.kg)
mass_flow_rate_inletsMass Flow Rate of the Mixer Inletsarray(double)kg/s
fracrion_outletsHeat Transfer Coefficient of the Radiatorarray(double)W/(m<sup>2</sup>K)
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Zone

The zone class contains arguments including the id of the zone, the ids of neighbor zones as an array, the ids of radiators inlets as an array, the ids radiators outlets as an array, the solver, thickness of walls as an array, surface of the walls as an array, thickness of the windows as an array, surface of the windows as an array, surface of radiators as an array, heat transfer coefficient radiators as an array, density of the air, volume of the air, specific heat capacity of the air, density of the wall, volume of the wall, specific heat capacity of the wall, mass of the equipment, specific heat capacity of the equipment, thermal conductivity of the wall, thermal conductivity of the window.

Equations

Equations

Variables

SubscriptDescription

Code

Construction
zone = Zone(id_zone, id_zones, id_radiator_inlets, id_radiator_outlets, solver, thickness_walls, surface_walls, thickness_windows, surface_windows, surface_radiators, heat_transfer_coefficient_radiators, density_air, volume_air, specific_heat_capacity_air, density_wall, volume_wall, specific_heat_capacity_wall, mass_equipment, specific_heat_capacity_equipment, thermal_conductivity_wall, thermal_conductivity_window);
InputDescriptionTypeUnit
id_zoneZone IDinteger-
id_zonesArray of Neigthbors' Zones IDsarray(integer)-
id_radiator_inletsArray of Radiators Inlets IDsarray(integer)-
id_radiator_outletsArray of Radiators Outlets IDsarray(integer)-
solverClass of the Solversolver-
thickness_wallsArray of Walls Thicknessesarray(double)m
surface_wallsArray of Walls Surfacesarray(double)m<sup>2</sup>
thickness_windowsArray of Windows Thicknessesarray(double)m
surface_windowsArray of Windows Surfacesarray(double)m<sup>2</sup>
surface_radiatorsArray of Radiators Surfacesarray(double)m<sup>2</sup>
heat_transfer_coefficient_radiatorsArray of Heat Transfer Coefficient of Radiatorsarray(double)W/(m<sup>2</sup>K)
density_airAir Densitydoublekg/m<sup>3</sup>
volume_airVolume of the Airdoublem<sup>3</sup>
specific_heat_capacity_airAir Specific Heat CapacitydoubleJ/(K.kg)
density_wallWall Densitydoublekg/m<sup>3</sup>
volume_wallVolume of the Walldoublem<sup>3</sup>
specific_heat_capacity_wallWall Heat Transfer CoefficientdoubleJ/(K.kg)
mass_equipmentMass of Equipmentdoublekg
specific_heat_capacity_equipmentEquipment Specific Heat CapacitydoubleJ/(K.kg)
thermal_conductivity_wallWall Thermal ConductivitydoubleW.m<sup>-1</sup>.K<sup>-1</sup>
thermal_conductivity_windowWindow Thermal ConductivitydoubleW.m<sup>-1</sup>.K<sup>-1</sup>
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Same

Code

Construction
same = Same(id_1, id_2, solver);
InputDescriptionTypeUnit
id_1First Element IDinteger-
id_2Second Element IDinteger-
solverClass of the Solversolver-
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

HeatExchanger

The class of heat exchanger contains the id of supply inlet, the id of supply outlet, the id of demand inlet, the id of demand outlet, the solver, specific heat capacity of the supply, specific heat capacity of the demand, mass flow rate of the supply, mass flow rate of the demand, heat transfer coefficient of the heat exchanger, and contact surface of the heat exchanger as inputs.

Equations

Equations

Variables

VariableDescription
R<sub>c</sub>Capacity Ratio
NTUNumber of Transfer Units
?Effectiveness
SubscriptDescription
sSupply
dDemand
iInlet
oOutlet
minMinimum
maxMaximum

Code

Construction
heatExchanger = HeatExchanger(id_supply_inlet, id_supply_outlet, id_demand_inlet, id_demand_outlet, solver, specific_heat_capacity_supply, specific_heat_capacity_demand, mass_flow_rate_supply, mass_flow_rate_demand, heat_transfer_coefficient, surface);
InputDescriptionTypeUnit
id_supply_inletSupply Inlet Element IDinteger-
id_supply_outletSupply Outlet Element IDinteger-
id_demand_inletDemand Inlet Element IDinteger-
id_demand_outletDemand Outlet Element IDinteger-
solverClass of the Solversolver-
specific_heat_capacity_supplySpecific Heat Capacity of the SupplydoubleJ/(K.kg)
specific_heat_capacity_demandSpecific Heat Capacity of the DemanddoubleJ/(K.kg)
mass_flow_rate_supplyMass Flow Rate of the Supplydoublekg/s
mass_flow_rate_demandMass Flow Rate of the Demanddoublekg/s
heat_transfer_coefficientHeat Transfer Coefficient of the Heat ExchangerdoubleW/(m<sup>2</sup>K)
surfaceSurface of the Heat Exchangerdoublem<sup>2</sup>
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Chiller

The chiller class needs the following arguments as input: the id of condenser inlet, the id of condenser outlet, the id evaporator inlet, the id of evaporator outlet, the solver, specific heat capacity of the fluid, the cooling power, the coefficient of performance, mass flow rate of the condenser, mass flow rate of the evaporator, and the status of chiller.

Equations

Equations

Variables

VariableDescription
Q.Heat Transfer Rate
PElectrical Power (input)
COPCoefficient of Performance
CWater Specific Heat Capacity
SubscriptDescription
eEvaporator
cCondenser
iInlet
oOutlet

Code

Construction
chiller = Chiller(id_condenser_inlet, id_condenser_outlet, id_evaporator_inlet, id_evaporator_outlet, solver, specific_heat_capacity_fluid, power, coefficient_of_performance, mass_flow_rate_condenser, mass_flow_rate_evaporator, status);
InputDescriptionTypeUnit
id_condenser_inletCondenser Inlet Element IDinteger-
id_condenser_outletCondenser Outlet Element IDinteger-
id_evaporator_inletEvaporator Inlet Element IDinteger-
id_evaporator_outletEvaporator Outlet Element IDinteger-
solverClass of the Solversolver-
specific_heat_capacity_fluidSpecific Heat Capacity of WaterdoubleJ/(K.kg)
powerElectrical PowerdoubleW
coefficient_of_performanceCoefficient of Performancedouble-
mass_flow_rate_condenserMass Flow Rate of the Condenserdoublekg/s
mass_flow_rate_evaporatorMass Flow Rate of the Evaporatordoublekg/s
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

FanCoil

The fan coil class contains the id of heating inlet, the id of heating outlet, the id of cooling inlet, the id of cooling outlet, the id of air inlet, the id of air outlet, the id of zone which under effect, the solver, specific heat capacity of the air, specific heat capacity of the cooling fluid, specific heat capacity of the heating fluid, mass flow rate of the air, mass flow rate of the cooling, mass flow rate of the heating, status of the heating system, status of the cooling system, heat transfer coefficient of the heating coil, heat transfer coefficient of the cooling coil, surface of the heating coil, and surface of the cooling coil.

Equations

Equations

Variables

VariableDescription
C.Capacitance Flows
ZCapacitance Flows Ratio
NTUNumber of Transfer Unit
?Effectiveness
SubscriptDescription
aAir
wHeating Water
minMinimum
maxMaximum
iInlet
oOutlet

Code

Construction
fanCoil = FanCoil(id_heating_inlet, id_heating_outlet, id_cooling_inlet, id_cooling_outlet, id_air_inlet, id_air_outlet, id_zone, solver, specific_heat_capacity_air, specific_heat_capacity_cooling, specific_heat_capacity_heating, mass_flow_rate_air, mass_flow_rate_cooling, mass_flow_rate_heating, status_heating, status_cooling, heat_transfer_coefficient_heating, heat_transfer_coefficient_cooling, surface_heating, surface_cooling);
InputDescriptionTypeUnit
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

AirHeatExchanger

Next, air heat exchanger class needs data of the id of supply inlet, the id of supply outlet, the id of exhaust inlet, the id of exhaust outlet, the solver, nominal mass flow rate of the supply, specific heat capacity of the supply, specific heat capacity of the exhaust, mass flow rate of the supply, mass flow rate of the exhaust, sensible effectiveness of 75%, sensible effectiveness of 100%, latent effectiveness of 75%, and latent effectiveness of 100% as inputs.

Equations

Equations

Variables

VariableDescription
C.Capacitance Flows
HXAverage Operating Volumetric to Nominal Supply Air Flow Rate
?Effectiveness
avgAverage
Q.Heat Transfer Rate
SubscriptDescription
sensibleSensible
operatingOperating
75% flow75% Flow Rate
100% flow100% Flow Rate
sSupply
eExhaust
iInlet
oOutlet
minMinimum

Code

Construction
airHeatExchanger = AirHeatExchanger(id_supply_inlet, id_supply_outlet, id_exhaust_inlet, id_exhaust_outlet, solver, mass_flow_rate_supply_nominal, specific_heat_capacity_supply, specific_heat_capacity_exhaust, mass_flow_rate_supply, mass_flow_rate_exhaust, sensible_effectiveness_75, sensible_effectiveness_100, latent_effectiveness_75, latent_effectiveness_100);
InputDescriptionTypeUnit
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Constant

Equations

Variables

VariableDescription
SubscriptDescription

Code

Construction
constant = Constant(id, solver, temperature);
InputDescriptionTypeUnit
idElement IDinteger-
solverClass of the Solversolver-
temperatureThe Constant TemperaturedoubleK
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the Solversolver-

Controllers Classes

SetpointController

Code

Construction
setpointController = SetpointController(minimum, maximum, mode, status);
InputDescriptionTypeUnit
minimumMinimum TemperaturedoubleK
minimumMaximum TemperaturedoubleK
modeHeating (=1) or Cooling (=2) Modesinteger-
statusStatus of the Controllerboolean-
Check
status = check(obj, temperature);
InputDescriptionTypeUnit
temperatureTemperaturedoubleK
statusStatus of the Controllerboolean-

Solvers Classes

Solver

The solver class inputs include time step, matrix size, and initial temperature. There is a freedom of use of multiple solvers for the model in order to solve the equations in different implicit level. For instance, in this project for each water loop separate solver will be considered.

Equations

Equations

Code

Construction
Solver(time_step, matrix_size, initial_temperature)
InputDescriptionTypeUnit
time_stepTime Stepdoubles
matrix_sizeNumber of Variables of System of Linear Equationsinteger-
initial_temperatureArray of Initial Temperaturesarray(double)K
Iterate
[solver, boilers, pipes, radiators, mixers, zones, sames, heatExchangers, chillers, fanCoils] = solver.iterate(boilers, pipes, radiators, mixers, zones, sames, heatExchangers, chillers, fanCoils);

Bridge

This class connects two different elements in different solvers, which has same temperatures.

Code

Construction
bridge = Bridge(id, id_bridge, solver, solver_bridge);
InputDescriptionTypeUnit
idElement ID in the first solverinteger-
id_bridgeElement ID in the second solverinteger-
solverClass of the first Solversolver-
solver_bridgeClass of the second Solversolver-
Create Matrix
create(solver)
InputDescriptionTypeUnit
solverClass of the first Solversolver-

License

GNU GENERAL PUBLIC LICENSE Version 2, June 1991