Module: Models::HeatLossable
Overview
ActiveSupport::Concern mixin: heat lossable.
Constant Summary
HeatLossableConstants::BTU_PER_HOUR_PER_WATT, HeatLossableConstants::HIGH_U_VALUE_THRESHOLD, HeatLossableConstants::HLC_PRIMARY_OK_THRESHOLD, HeatLossableConstants::INFILTRATION_AREA_FACTORS, HeatLossableConstants::INFILTRATION_FIREPLACE_FACTORS, HeatLossableConstants::INFILTRATION_SEALING_FACTORS, HeatLossableConstants::PIE_CHART_FLAG_COLORS, HeatLossableConstants::PIE_CHART_OK_COLORS
Instance Method Summary
collapse
Instance Method Details
#children_heat_loss_recursive(inside_temperature, outside_temperature, res) ⇒ Object
29
30
31
32
33
34
|
# File 'app/concerns/models/heat_lossable.rb', line 29
def children_heat_loss_recursive(inside_temperature, outside_temperature, res)
heat_loss_children.each do |c|
res = c.self_and_children_heat_loss_recursive(inside_temperature, outside_temperature, res)
end
res
end
|
#get_children_heat_loss(inside_temperature, outside_temperature) ⇒ Object
36
37
38
|
# File 'app/concerns/models/heat_lossable.rb', line 36
def get_children_heat_loss(inside_temperature, outside_temperature)
heat_loss_children.to_a.sum { |c| c.get_self_and_children_heat_loss(inside_temperature, outside_temperature) }
end
|
#get_heat_loss(inside_temperature, outside_temperature) ⇒ Object
52
53
54
55
|
# File 'app/concerns/models/heat_lossable.rb', line 52
def get_heat_loss(inside_temperature, outside_temperature)
effective_area = area - heat_loss_children.to_a.sum(&:area)
effective_area * (inside_temperature - outside_temperature) * get_u_value
end
|
#get_self_and_children_heat_loss(inside_temperature, outside_temperature) ⇒ Object
17
18
19
|
# File 'app/concerns/models/heat_lossable.rb', line 17
def get_self_and_children_heat_loss(inside_temperature, outside_temperature)
get_heat_loss(inside_temperature, outside_temperature) + get_children_heat_loss(inside_temperature, outside_temperature)
end
|
#get_u_value ⇒ Object
57
58
59
|
# File 'app/concerns/models/heat_lossable.rb', line 57
def get_u_value
user_u_value || insulation_type&.u_value
end
|
#heat_loss_children ⇒ Object
40
41
42
|
# File 'app/concerns/models/heat_lossable.rb', line 40
def heat_loss_children
[]
end
|
#heat_loss_children_recursive(res) ⇒ Object
44
45
46
47
48
49
50
|
# File 'app/concerns/models/heat_lossable.rb', line 44
def heat_loss_children_recursive(res)
res += heat_loss_children
heat_loss_children.each do |c|
res = c.heat_loss_children_recursive(res)
end
res
end
|
#insulation_type ⇒ Object
61
62
63
|
# File 'app/concerns/models/heat_lossable.rb', line 61
def insulation_type
send("#{self.class.to_s.tableize.singularize}_insulation_type")
end
|
#reset_room_last_heat_loss ⇒ Object
65
66
67
68
69
70
|
# File 'app/concerns/models/heat_lossable.rb', line 65
def reset_room_last_heat_loss
logger.info "reset_room_last_heat_loss: self.class.to_s: #{self.class}"
logger.info "reset_room_last_heat_loss: self.class.to_s != 'RoomConfiguration': #{self.class.to_s != 'RoomConfiguration'}"
room_configuration.update_column(:last_heat_loss, nil)
true
end
|
#self_and_children_heat_loss_recursive(inside_temperature, outside_temperature, res) ⇒ Object
21
22
23
24
25
26
27
|
# File 'app/concerns/models/heat_lossable.rb', line 21
def self_and_children_heat_loss_recursive(inside_temperature, outside_temperature, res)
res << { object: self, heat_loss: get_heat_loss(inside_temperature, outside_temperature) }
heat_loss_children.each do |c|
res = c.self_and_children_heat_loss_recursive(inside_temperature, outside_temperature, res)
end
res
end
|