energyplus 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/energyplus.rb +13 -0
- data/lib/energyplus/DDYFile.rb +176 -0
- data/lib/energyplus/EpErrFile.rb +123 -0
- data/lib/energyplus/EpImfFile.rb +93 -0
- data/lib/energyplus/EpwFile.rb +120 -0
- data/lib/energyplus/EsoFile.rb +129 -0
- data/lib/energyplus/IdfObject.rb +55 -0
- data/lib/energyplus/KmlFile.rb +168 -0
- data/lib/energyplus/ResultsLog.rb +99 -0
- data/lib/energyplus/SchedulesCSV.rb +169 -0
- data/lib/energyplus/SlabGtpFile.rb +100 -0
- data/lib/energyplus/SlabIdfFile.rb +78 -0
- data/lib/energyplus/StatFile.rb +192 -0
- data/lib/energyplus/version.rb +22 -0
- metadata +77 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
|
22
|
+
class DictionaryEntry
|
23
|
+
attr_reader :id, :key, :var_name, :units, :interval
|
24
|
+
def initialize(id,key,var_name,units,interval)
|
25
|
+
@id,@key,@var_name,@units,@interval = id,key,var_name,units,interval
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Variable
|
30
|
+
# attr_reader :data
|
31
|
+
def initialize(dictionary_entry,data,timestamps)
|
32
|
+
@dictionary_entry = dictionary_entry
|
33
|
+
@data = data
|
34
|
+
@timestamps = timestamps
|
35
|
+
end
|
36
|
+
|
37
|
+
def name
|
38
|
+
return @dictionary_entry.var_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def key
|
42
|
+
return @dictionary_entry.key
|
43
|
+
end
|
44
|
+
|
45
|
+
def id
|
46
|
+
return @dictionary_entry.id
|
47
|
+
end
|
48
|
+
|
49
|
+
def units
|
50
|
+
return @dictionary_entry.units
|
51
|
+
end
|
52
|
+
|
53
|
+
def interval
|
54
|
+
return @dictionary_entry.interval
|
55
|
+
end
|
56
|
+
|
57
|
+
def values
|
58
|
+
@data.map { |entry| entry[1] }
|
59
|
+
end
|
60
|
+
|
61
|
+
def hours
|
62
|
+
@timestamps.map { |entry| entry[5] }
|
63
|
+
end
|
64
|
+
|
65
|
+
def days
|
66
|
+
@timestamps.map { |entry| entry[1] }
|
67
|
+
end
|
68
|
+
|
69
|
+
def months
|
70
|
+
@timestamps.map { |entry| entry[2] }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class EpEsoFile
|
75
|
+
def initialize(path)
|
76
|
+
File.open(path) do |f|
|
77
|
+
@variables = nil
|
78
|
+
# first six lines are discarded
|
79
|
+
6.times {f.gets}
|
80
|
+
@text = f.read
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def dictionary
|
85
|
+
return @text.match(/(.*?)(End\sof\sData\sDictionary)/m)[1]
|
86
|
+
end
|
87
|
+
|
88
|
+
def data
|
89
|
+
return @text.match(/(End\sof\sData\sDictionary)(.*?)(End\sof\sData)/m)[2]
|
90
|
+
end
|
91
|
+
|
92
|
+
def dictionary_entries
|
93
|
+
dictionary_entries = []
|
94
|
+
dictionary.split("\n").each do |entry|
|
95
|
+
interval = entry.match(/(!)(\w+)(\s*)/)[2].strip
|
96
|
+
fields = entry.match(/(.*?)(!)/)[1].split(',')
|
97
|
+
id = fields[0]
|
98
|
+
key,var_name = fields[2,3] if fields[1] =~ /2/
|
99
|
+
key,var_name = nil, fields[2] if fields[1] =~ /1/
|
100
|
+
units = var_name.match(/(.*?)(\[)(.*?)(\])/)[3]
|
101
|
+
var_name = $1.strip
|
102
|
+
dictionary_entries << DictionaryEntry.new(id,key,var_name,units,interval)
|
103
|
+
end
|
104
|
+
return dictionary_entries
|
105
|
+
end
|
106
|
+
|
107
|
+
def variables
|
108
|
+
unless @variables
|
109
|
+
@variables = []
|
110
|
+
text = data
|
111
|
+
dictionary_entries.each do |dictionary_entry|
|
112
|
+
if dictionary_entry.interval =~ /Hourly/
|
113
|
+
timestamps = text.scan(/^2,.*?,\s0\.00,60\.00,.*/).map { |entry| entry.split(',') }
|
114
|
+
elsif dictionary_entry.interval =~ /TimeStep/
|
115
|
+
timestamps = text.scan(/^2,.*/).reject { |entry| entry =~ /^2,.*?,\s0\.00,60\.00,.*/}.map { |entry| entry.split(',') }
|
116
|
+
elsif dictionary_entry.interval =~ /Daily/
|
117
|
+
timestamps = text.scan(/^3,/).map { |entry| entry.split(',') }
|
118
|
+
elsif dictionary_entry.interval =~ /Monthly/
|
119
|
+
timestamps = text.scan(/^4,/).map { |entry| entry.split(',') }
|
120
|
+
end
|
121
|
+
var_data = text.scan(Regexp.new("^#{dictionary_entry.id},.*")).map { |entry| entry.split(',') }
|
122
|
+
@variables << Variable.new(dictionary_entry,var_data,timestamps)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
return @variables
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end #module
|
@@ -0,0 +1,55 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
|
22
|
+
class IdfObject
|
23
|
+
attr_accessor :type, :fields, :comment
|
24
|
+
|
25
|
+
def initialize(object_type, object_fields, object_comment)
|
26
|
+
@type = object_type
|
27
|
+
@fields = object_fields
|
28
|
+
@comment = object_comment
|
29
|
+
end
|
30
|
+
|
31
|
+
def fieldValue(fieldIdx)
|
32
|
+
fieldValue = @fields[fieldIdx].split(',')
|
33
|
+
fieldValue = fieldValue[0].split(';')[0].gsub(" ", "")
|
34
|
+
|
35
|
+
return fieldValue.to_f
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def fieldString(fieldIdx)
|
40
|
+
fieldString = @fields[fieldIdx].split(',')
|
41
|
+
fieldString = fieldString[0].split(';')[0].gsub(" ", "")
|
42
|
+
|
43
|
+
return fieldString
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
string = ''
|
49
|
+
string << @comment + "\n" if @comment
|
50
|
+
string << @type + "\n"
|
51
|
+
@fields.each { |field| string << field + "\n" }
|
52
|
+
string << "\n"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end #module
|
@@ -0,0 +1,168 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
|
21
|
+
module EnergyPlus
|
22
|
+
|
23
|
+
require 'pathname'
|
24
|
+
require 'csv'
|
25
|
+
require 'builder'
|
26
|
+
|
27
|
+
class KmlFile
|
28
|
+
attr_accessor :data
|
29
|
+
|
30
|
+
def initialize(path)
|
31
|
+
@path = path
|
32
|
+
@data = []
|
33
|
+
|
34
|
+
@region_lu = Hash.new("regions")
|
35
|
+
@region_lu["1_africa_wmo_region_1"] = "Africa, WMO Region 1"
|
36
|
+
@region_lu["2_asia_wmo_region_2"] = "Asia, WMO Region 2"
|
37
|
+
@region_lu["3_south_america_wmo_region_3"] = "South America, WMO Region 3"
|
38
|
+
@region_lu["4_north_and_central_america_wmo_region_4"] = "North and Central America, WMO Region 4"
|
39
|
+
@region_lu["5_southwest_pacific_wmo_region_5"] = "Southwest Pacific Ocean, WMO Region 5"
|
40
|
+
@region_lu["6_europe_wmo_region_6"] = "Europe, WMO Region 6"
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def savefile
|
45
|
+
kmlfile = File.new(@path, 'w')
|
46
|
+
kmlxml = Builder::XmlMarkup.new(:target => kmlfile, :indent=>2)
|
47
|
+
|
48
|
+
#setup the xml/kml file
|
49
|
+
kmlxml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
50
|
+
kmlxml.kml("xmlns" => "http://www.opengis.net/kml/2.2") {
|
51
|
+
kmlxml.Document {
|
52
|
+
kmlxml.name "EnergyPlus Weather Data"
|
53
|
+
kmlxml.visibility "0"
|
54
|
+
kmlxml.description {
|
55
|
+
kmlxml.cdata!("<img src=\"kml/ep_header6.png\" width=280><p>Weather data for use with EnergyPlus building energy simulation software (http://www.energyplus.gov).<p>Locations are organized by World Meteorological Organization (WMO) region, country, and state/province. Download individual weather data files through links in each location description.")
|
56
|
+
}
|
57
|
+
kmlxml.LookAt {
|
58
|
+
kmlxml.longitude "-105"
|
59
|
+
kmlxml.latitude "15"
|
60
|
+
kmlxml.altitude "0"
|
61
|
+
kmlxml.range "15000000"
|
62
|
+
kmlxml.tilt "6.880472140100155e-015"
|
63
|
+
kmlxml.heading "4.971764876159099e-015"
|
64
|
+
kmlxml.altitudeMode "relativeToGround"
|
65
|
+
}
|
66
|
+
kmlxml.Style("id" => "weatherlocation_normal") {
|
67
|
+
kmlxml.IconStyle {
|
68
|
+
kmlxml.scale "0.6"
|
69
|
+
kmlxml.Icon {
|
70
|
+
kmlxml.href "kml/E+_logo.png"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
kmlxml.BalloonStyle {
|
74
|
+
kmlxml.text {
|
75
|
+
kmlxml.cdata!("<b><font color=\"#CC0000\" size=\"+3\">$[name]</font></b><br/><font>$[description]</font>")
|
76
|
+
}
|
77
|
+
kmlxml.bgColor "ffffffbb"
|
78
|
+
}
|
79
|
+
}
|
80
|
+
kmlxml.StyleMap("id" => "weatherlocation") {
|
81
|
+
kmlxml.Pair {
|
82
|
+
kmlxml.key "normal"
|
83
|
+
kmlxml.styleUrl "#weatherlocation_normal"
|
84
|
+
}
|
85
|
+
kmlxml.Pair {
|
86
|
+
kmlxml.key "highlight"
|
87
|
+
kmlxml.styleUrl "#weatherlocation_hiliteicon"
|
88
|
+
}
|
89
|
+
}
|
90
|
+
kmlxml.Style("id" => "weatherlocation_hiliteicon") {
|
91
|
+
kmlxml.IconStyle {
|
92
|
+
kmlxml.scale "0.9"
|
93
|
+
kmlxml.Icon {
|
94
|
+
kmlxml.href "kml/E+_logo.png"
|
95
|
+
}
|
96
|
+
kmlxml.hotSpot {
|
97
|
+
kmlxml.x "0.5"
|
98
|
+
kmlxml.y "0.5"
|
99
|
+
kmlxml.xunits "fraction"
|
100
|
+
kmlxml.yunits "fraction"
|
101
|
+
}
|
102
|
+
kmlxml.BalloonStyle {
|
103
|
+
kmlxml.text {
|
104
|
+
kmlxml.cdata!("<b><font color=\"#CC0000\" size=\"+3\">$[name]</font></b> <br/><font>$[description]</font>")
|
105
|
+
}
|
106
|
+
kmlxml.bgColor "ffffffbb"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
#write out each location
|
112
|
+
#the data is stored in a custom format that is two layers dep using the DataHash.rb
|
113
|
+
#file that Nicholas Long wrote
|
114
|
+
|
115
|
+
@data.each do |region|
|
116
|
+
kmlxml.Folder {
|
117
|
+
kmlxml.name @region_lu[region.name]
|
118
|
+
kmlxml.visibility "0"
|
119
|
+
kmlxml.description {
|
120
|
+
kmlxml.cdata!("<img src=\"kml/ep_header7.png\" align=right>")
|
121
|
+
}
|
122
|
+
|
123
|
+
region.data.each do |country|
|
124
|
+
kmlxml.Folder {
|
125
|
+
kmlxml.name country.name
|
126
|
+
kmlxml.visibility "0"
|
127
|
+
country.data.each do |state|
|
128
|
+
if state != "" && state != "-" then
|
129
|
+
kmlxml.Folder {
|
130
|
+
kmlxml.name state.name
|
131
|
+
kmlxml.visibility "0"
|
132
|
+
state.data.each do |weather|
|
133
|
+
weather.toKml(kmlxml)
|
134
|
+
end
|
135
|
+
}
|
136
|
+
else
|
137
|
+
state.data.each do |weather|
|
138
|
+
weather.toKml(kmlxml)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
}
|
143
|
+
end
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
@data.each do |reg|
|
149
|
+
puts reg.name
|
150
|
+
reg.data.each do |reg_data|
|
151
|
+
puts " #{reg_data.name}"
|
152
|
+
reg_data.data.each do |reg_data_2|
|
153
|
+
puts " #{reg_data_2.name}"
|
154
|
+
reg_data_2.data.each do |reg_data_3|
|
155
|
+
puts " #{reg_data_3.path}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
end
|
168
|
+
end #module
|
@@ -0,0 +1,99 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
|
22
|
+
require 'pathname'
|
23
|
+
|
24
|
+
class ResultsLog
|
25
|
+
def initialize(path)
|
26
|
+
@path = Pathname.new(path)
|
27
|
+
@entries = []
|
28
|
+
@initialized = false
|
29
|
+
@valid = false
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_entries(*search_terms)
|
33
|
+
init if not @initialized
|
34
|
+
entries = @entries.select do |entry|
|
35
|
+
found = true
|
36
|
+
search_terms.each do |search_term|
|
37
|
+
if not entry[:description] =~ Regexp.new(search_term)
|
38
|
+
found = false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
found
|
42
|
+
end
|
43
|
+
return entries
|
44
|
+
end
|
45
|
+
|
46
|
+
def find_entry(*search_terms)
|
47
|
+
return find_entries(*search_terms).first
|
48
|
+
end
|
49
|
+
|
50
|
+
def entries
|
51
|
+
init if not @initialized
|
52
|
+
return @entries
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid?
|
56
|
+
init if not @initialized
|
57
|
+
return @valid
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def init
|
63
|
+
@initialized = true
|
64
|
+
|
65
|
+
if @path.exist?
|
66
|
+
File.open(@path) do |f|
|
67
|
+
text = f.read
|
68
|
+
@entries = parse_entries(text)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
total_site_energy = find_entry('Total Energy','Total Site Energy')
|
73
|
+
if not total_site_energy.nil?
|
74
|
+
if total_site_energy[:value].to_f > 0
|
75
|
+
@valid = true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def parse_entries(text)
|
81
|
+
entries = []
|
82
|
+
lines = text.split("\n")
|
83
|
+
lines.each do |line|
|
84
|
+
entry = Hash.new
|
85
|
+
begin
|
86
|
+
entry[:units] = line.match(/\[(.*?)\]/)[1]
|
87
|
+
rescue
|
88
|
+
entry[:units] = ''
|
89
|
+
end
|
90
|
+
entry[:description] = line.match(/(.*?),/)[1].sub(/\[.*?\]/,'').strip
|
91
|
+
entry[:value] = line.match(/,(.*)/)[1]
|
92
|
+
entries << entry
|
93
|
+
end
|
94
|
+
return entries
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end #module
|