Skip to content

Commit

Permalink
Merge pull request #2144 from NREL/2129_radiance_server_perf
Browse files Browse the repository at this point in the history
2129 radiance server perf
  • Loading branch information
rpg777 committed Mar 11, 2016
2 parents 83d1498 + 822a038 commit 031c546
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 18 deletions.
70 changes: 62 additions & 8 deletions openstudiocore/src/pat_app/Measures/RadianceMeasure/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ def arguments(model)
debug_mode = OpenStudio::Ruleset::OSArgument::makeBoolArgument('debug_mode', false)
debug_mode.setDisplayName('Debug Mode')
debug_mode.setDefaultValue('false')
debug_mode.setDescription('Generates additional log messages, images for each window group, and saves all window group output.')
debug_mode.setDescription('Generate additional log messages, images for each window group, and save all window group output.')
args << debug_mode

cleanup_data = OpenStudio::Ruleset::OSArgument::makeBoolArgument('cleanup_data', false)
cleanup_data.setDisplayName('Cleanup Data')
cleanup_data.setDefaultValue('false')
cleanup_data.setDescription('Delete Radiance input and (most) output data, post-simulation (lighting schedules are passed to OpenStudio model (and daylight metrics are passed to OpenStudio-server, if applicable)')
args << cleanup_data

return args

end
Expand Down Expand Up @@ -125,6 +131,17 @@ def OS.linux
end


# check for number of rmtxop processes
def merge_count()
if OS.windows
# TODO: properly handle the Windows case
# TODO: possibly add count as a user option
return 1
else
return `pgrep rmtxop`.split.size
end
end

def run(model, runner, user_arguments)
super(model, runner, user_arguments)

Expand All @@ -143,6 +160,7 @@ def run(model, runner, user_arguments)
use_cores = runner.getStringArgumentValue('use_cores', user_arguments)
rad_settings = runner.getStringArgumentValue('rad_settings', user_arguments)
debug_mode = runner.getBoolArgumentValue('debug_mode',user_arguments)
cleanup_data = runner.getBoolArgumentValue('cleanup_data',user_arguments)

# Energyplus "pre-run" model dir
epout_dir = 'eplus_preprocess'
Expand Down Expand Up @@ -214,12 +232,10 @@ def which(cmd)
perlExtension = ""
catCommand = "cat"
osQuote = "\'"
rt_io_format = "-ff"
if OS.windows #/mswin/.match(RUBY_PLATFORM) || /mingw/.match(RUBY_PLATFORM)
perlExtension = ".pl"
catCommand = "type"
osQuote = "\""
rt_io_format = "-fa"
end

## END Radiance Utilities
Expand Down Expand Up @@ -696,9 +712,14 @@ def runSimulation(t_space_names_to_calculate, t_sqlFile, t_simCores, t_options_s
# if row.split(",")[2] == "n/a" || row.split(",")[2] == "AlwaysOff"
# keep header, convert to illuminance, but no transpose
### foo (-ff)

while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
rad_command = "dctimestep output/dc/#{wg}.vmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - > output/ts/#{wg}.ill"
exec_statement(rad_command, runner)

else

# do all controlled window groups
Expand All @@ -708,6 +729,10 @@ def runSimulation(t_space_names_to_calculate, t_sqlFile, t_simCores, t_options_s
# make single phase illuminance sched for each state
states = ["clear", "tinted"]
states.each_index do |i|
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
print_statement("Calculating annual iluminance for window group '#{wg}', state: #{states.index(states[i])} (switchable glazing - #{states[i]})", runner)
### foo (-ff)
exec_statement("dctimestep output/dc/#{wg}_#{states[i]}.vmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - > output/ts/#{wg}_#{states.index(states[i])}.ill", runner)
Expand All @@ -722,6 +747,10 @@ def runSimulation(t_space_names_to_calculate, t_sqlFile, t_simCores, t_options_s

wgXMLs.each_index do |i|
#rad_command = "dctimestep output/dc/#{wg}.vmx bsdf/#{wgXMLs[i].strip} output/dc/#{wg}.dmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - > output/ts/#{wg}_INDEX#{wgXMLs.index[i]}_#{wgXMLs[i].split[0]}.ill"
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
print_statement("Calculating annual iluminance for window group '#{wg}', state: #{wgXMLs.index(wgXMLs[i])} (BSDF filename: '#{wgXMLs[i].split[0]}'):", runner)
rad_command = "dctimestep output/dc/#{wg}.vmx bsdf/#{wgXMLs[i].strip} output/dc/#{wg}.dmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - > output/ts/#{wg}_#{wgXMLs.index(wgXMLs[i])}.ill"
### orig ^^^
Expand All @@ -737,8 +766,11 @@ def runSimulation(t_space_names_to_calculate, t_sqlFile, t_simCores, t_options_s

# get annual values for window control sensors (note: convert to illuminance, no transpose, strip header)
### foo leave at -fa
exec_statement("dctimestep output/dc/window_controls.vmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - | getinfo - > output/ts/window_controls.ill", runner)

while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
exec_statement("dctimestep output/dc/window_controls.vmx annual-sky.mtx | rmtxop -fa -c 47.4 120 11.6 - | getinfo - > output/ts/window_controls.ill", runner)
print_statement("Blending window group results per shade control schedule", runner)

# do that window group/state merge thing
Expand Down Expand Up @@ -847,20 +879,36 @@ def runSimulation(t_space_names_to_calculate, t_sqlFile, t_simCores, t_options_s
exit false
elsif mergeWindows.size == 1
# go straight to final building results file format
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
print_statement("Finalizing output...", runner)
exec_statement("rmtxop -fa #{mergeWindows[0]} -t | getinfo - > output/merged_space.ill", runner)
else
# make initial building results from first window group
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
print_statement("Starting final building illumimance file with #{mergeWindows[0]}...", runner)
exec_statement("rmtxop -fa #{mergeWindows[0]} -t > output/final_merge.tmp", runner)
# add remaining groups, one at a time
mergeWindows[1..-1].each do |merge|
print_statement("adding #{merge}...", runner)
temp_fname = rand(36**15).to_s(36)
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
exec_statement("rmtxop -fa output/final_merge.tmp + #{merge} -t > #{temp_fname}", runner)
FileUtils.mv temp_fname, 'output/final_merge.tmp'
end
# strip header
while merge_count() > 2
puts "waiting in rmtxop queue..."
sleep(5)
end
print_statement("Finalizing output...", runner)
exec_statement("rmtxop -fa output/final_merge.tmp -t | getinfo - > output/merged_space.ill", runner)
FileUtils.rm 'output/final_merge.tmp'
Expand Down Expand Up @@ -2086,12 +2134,12 @@ def genImages(radPath, runner, site_latitude, site_longitude, site_meridian, cat
print_statement("added glare sensor '#{sensor}' to calculation points", runner)
f.write IO.read(sensor)
end
else
print_statement("no glare sensors found in model", runner)
end
end
end

print_statement("Warning: 'Cleanup data' option was selected; will delete ancilary Radiance data and all Radiance input files, post-simulation.",runner) if debug_mode && cleanup_data

# get the daylight coefficient matrices
calculateDaylightCoeffecients(radPath, sim_cores, catCommand, options_tregVars,
options_klemsDensity, options_skyvecDensity, options_dmx, options_vmx, rad_settings, procsUsed, runner, debug_mode)
Expand Down Expand Up @@ -2129,6 +2177,12 @@ def genImages(radPath, runner, site_latitude, site_longitude, site_meridian, cat
rm_list = "output/ts/m_*.ill", "output/ts/window_controls.ill", "output/ts/WG*.ill", "octrees/*.oct", "output/ts/*.shd"
FileUtils.rm Dir.glob(rm_list)
end
if cleanup_data
print_statement("Deleting most Radiance I/O to preserve disk space...", runner)
print_statement("WARN: deleting debug files because 'Cleanup data' option was selected!",runner) if debug_mode
clean_list = "bsdf", "materials", "numeric", "octrees", "options", "scene", "skies", "sql", "views", "wx", "output/dc", "output/ts"
FileUtils.rm_rf(clean_list)
end

# report initial condition of model
daylightAnalysisSpaces = []
Expand Down
39 changes: 29 additions & 10 deletions openstudiocore/src/pat_app/Measures/RadianceMeasure/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>radiance_measure</name>
<uid>1e3cfef8-b051-4e60-8bb0-ed2d29d4f45d</uid>
<version_id>2aaf8284-e7a3-4639-a691-a6871a756431</version_id>
<version_modified>20160310T055441Z</version_modified>
<version_id>6b630f36-de6e-45ea-9fb5-60aaaa1eb6a8</version_id>
<version_modified>20160311T201342</version_modified>
<xml_checksum>381B7733</xml_checksum>
<class_name>RadianceMeasure</class_name>
<display_name>Radiance Daylighting Measure</display_name>
Expand Down Expand Up @@ -74,7 +74,26 @@
<argument>
<name>debug_mode</name>
<display_name>Debug Mode</display_name>
<description>Generates additional log messages, images for each window group, and saves all window group output.</description>
<description>Generate additional log messages, images for each window group, and save all window group output.</description>
<type>Boolean</type>
<required>false</required>
<model_dependent>false</model_dependent>
<default_value>false</default_value>
<choices>
<choice>
<value>true</value>
<display_name>true</display_name>
</choice>
<choice>
<value>false</value>
<display_name>false</display_name>
</choice>
</choices>
</argument>
<argument>
<name>cleanup_data</name>
<display_name>Cleanup Data</display_name>
<description>Delete Radiance input and (most) output data, post-simulation (lighting schedules are passed to OpenStudio model (and daylight metrics are passed to OpenStudio-server, if applicable)</description>
<type>Boolean</type>
<required>false</required>
<model_dependent>false</model_dependent>
Expand Down Expand Up @@ -135,6 +154,12 @@
<usage_type>test</usage_type>
<checksum>13FF1228</checksum>
</file>
<file>
<filename>radiance_measure_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>75766E13</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -144,13 +169,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>024DD994</checksum>
</file>
<file>
<filename>radiance_measure_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>75766E13</checksum>
<checksum>09C4459A</checksum>
</file>
</files>
</measure>

9 comments on commit 031c546

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (rpg777) - i386-Windows-7-VisualStudio-12: OK (2374 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (rpg777) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2327 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (rpg777) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (rpg777) - Win64-Windows-7-VisualStudio-12: OK (2376 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (rpg777) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2331 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (rpg777) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (rpg777) - i386-Windows-7-VisualStudio-12: OK (2372 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (rpg777) - Win64-Windows-7-VisualStudio-12: OK (2374 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (rpg777) - x86_64-MacOS-10.10-clang: OK (2368 of 2397 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.