class EnergyPlus::SlabIdfFile
Public Class Methods
new(path)
click to toggle source
# File lib/energyplus/SlabIdfFile.rb, line 25 def initialize(path) @path = Pathname.new(path) @initialized = false @text = "" init end
Public Instance Methods
savefileas(path)
click to toggle source
# File lib/energyplus/SlabIdfFile.rb, line 32 def savefileas(path) File.open(path, "w") do |f| f << @text end end
setSetpoints(cdd, hdd)
click to toggle source
function to alter input based on options
# 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
Private Instance Methods
init()
click to toggle source
# File lib/energyplus/SlabIdfFile.rb, line 68 def init @initialized = true if @path.exist? File.open(@path) do |f| @text = f.read end end end