Class: EnergyPlus::SlabIdfFile

Inherits:
Object
  • Object
show all
Defined in:
lib/energyplus/SlabIdfFile.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SlabIdfFile

Returns a new instance of SlabIdfFile.



25
26
27
28
29
30
# File 'lib/energyplus/SlabIdfFile.rb', line 25

def initialize(path)
  @path = Pathname.new(path)
  @initialized = false
  @text = ""
  init
end

Instance Method Details

#savefileas(path) ⇒ Object



32
33
34
35
36
# File 'lib/energyplus/SlabIdfFile.rb', line 32

def savefileas(path)
   File.open(path, "w") do |f|
     f << @text
   end
end

#setSetpoints(cdd, hdd) ⇒ Object

function to alter input based on options



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
# File 'lib/energyplus/SlabIdfFile.rb', line 39

def setSetpoints(cdd, hdd)
  #options is an array of cdd and hdd... so have to wait the values
  #create a new array with the weighted values
  heatSP = 21  #in deg c
  coolSP = 24  #in deg c

  weight = []
  for i in 1..12
    num = cdd * coolSP + hdd * heatSP
    den = cdd + hdd
    weight[i] = (num) / (den)
  end

  @text.gsub!("%JAN%", sprintf("%.2f", weight[1].to_s))
  @text.gsub!("%FEB%", sprintf("%.2f", weight[2].to_s))
  @text.gsub!("%MAR%", sprintf("%.2f", weight[3].to_s))
  @text.gsub!("%APR%", sprintf("%.2f", weight[4].to_s))
  @text.gsub!("%MAY%", sprintf("%.2f", weight[5].to_s))
  @text.gsub!("%JUN%", sprintf("%.2f", weight[6].to_s))
  @text.gsub!("%JUL%", sprintf("%.2f", weight[7].to_s))
  @text.gsub!("%AUG%", sprintf("%.2f", weight[8].to_s))
  @text.gsub!("%SEP%", sprintf("%.2f", weight[9].to_s))
  @text.gsub!("%OCT%", sprintf("%.2f", weight[10].to_s))
  @text.gsub!("%NOV%", sprintf("%.2f", weight[11].to_s))
  @text.gsub!("%DEC%", sprintf("%.2f", weight[12].to_s))
end