-
Notifications
You must be signed in to change notification settings - Fork 15
/
Boiler.m
85 lines (73 loc) · 3.38 KB
/
Boiler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
classdef Boiler
properties
iteration
id_inlet
id_outlet
time_step
matrix_size
matrix_coefficients
right_hand_side_vector
number_of_equations
specific_heat_capacity
mass
specific_heat_capacity_fluid
mass_fluid
power
temperature_inlet
temperature_outlet
mass_flow_rate
status
end
methods
function obj = Boiler(id_inlet, id_outlet, solver, specific_heat_capacity, mass, specific_heat_capacity_fluid, mass_fluid, power, mass_flow_rate, status)
if nargin > 0
obj.id_inlet = id_inlet;
obj.id_outlet = id_outlet;
obj.time_step = solver.time_step;
obj.matrix_size = solver.matrix_size;
obj.specific_heat_capacity = specific_heat_capacity;
obj.mass = mass;
obj.specific_heat_capacity_fluid = specific_heat_capacity_fluid;
obj.mass_fluid = mass_fluid;
obj.power = power;
obj.mass_flow_rate = mass_flow_rate;
obj.status = status;
obj.iteration = 0;
obj.number_of_equations = 1;
obj.matrix_coefficients = zeros(obj.number_of_equations,solver.matrix_size);
obj.right_hand_side_vector = zeros(obj.number_of_equations,1);
obj.temperature_inlet = solver.temperatures(obj.id_inlet);
obj.temperature_outlet = solver.temperatures(obj.id_outlet);
end
end
% coefficient of inlet temperature of boiler (return fluid)
function c = c_ti(obj)
c = (obj.mass*obj.specific_heat_capacity+obj.mass_fluid*obj.specific_heat_capacity_fluid)/(2*obj.time_step)-obj.mass_flow_rate*obj.specific_heat_capacity_fluid;
end
% coefficient of outlet temperature of boiler (supply fluid)
function c = c_to(obj)
c = (obj.mass*obj.specific_heat_capacity+obj.mass_fluid*obj.specific_heat_capacity_fluid)/(2*obj.time_step)+obj.mass_flow_rate*obj.specific_heat_capacity_fluid;
end
% right-hand coefficient of boiler
function c = c_r(obj)
c = obj.power + (obj.mass*obj.specific_heat_capacity+obj.mass_fluid*obj.specific_heat_capacity_fluid)/(2*obj.time_step)*(obj.temperature_inlet + obj.temperature_outlet);
end
% create matrix of coefficients and right-hand side vector
function obj = create(obj, solver)
obj.iteration = obj.iteration + 1;
obj.temperature_inlet = solver.temperatures(obj.id_inlet);
obj.temperature_outlet = solver.temperatures(obj.id_outlet);
obj.matrix_coefficients = zeros(obj.number_of_equations,obj.matrix_size);
obj.right_hand_side_vector = zeros(obj.number_of_equations,1);
obj.right_hand_side_vector = obj.c_r();
obj.matrix_coefficients(obj.id_inlet) = obj.c_ti();
obj.matrix_coefficients(obj.id_outlet) = obj.c_to();
end
function obj = switch_off(obj)
obj.status = 0;
end
function obj = switch_on(obj)
obj.status = 1;
end
end
end