新浪博客

调用EnergyPlus运行的2种方法

2016-07-24 20:25阅读:
方法1,运行EnergyPlus安装目录下的RunEPlus.bat文件,主要更改Input_path和weather_path地址为目标文件夹下。
例如使用ruby调用使用system ('C:/EnergyPlusV8-3-0/RunEPlus.bat work in2'),其中work.idf是idf文件,in2.epw是气象文件,如果运行发现无法找到work.idf后者in2.epw,则在更改一下RunEPlus.bat文件夹下的Input_path和weather_path路径为本文件夹路径
方法2,使用代码将Energy+.idd、in.idf(输入idf保存这个格式)和in.epw(气象文件另存为in.epw)文件保存到当前文件夹,然后调用energyplus.exe即可运行。
Ruby代码如下:
current_workdir_idf_path = current_workdir +'/work.idf'
in_idf_path = current_workdir +'/in.idf'
#in_idf = File.new (in_idf_path, 'w')
workdir_idf = File.new(current_workdir_idf_path, 'w')
new_idf_array.each { |line|
workdir_idf.puts(line)
}
#IO.copy_stream(workdir_idf,in_idf)
workdir_idf.close
#in_idf.close
idd_path = EPlus_path + '/Energy+.idd'
weather_path = Optifile + '/Nanjing.epw'
FileUtils.cp(current_workdir_idf_path,in_idf_path)
FileUtils.cp(idd_path,current_workdir+'/Energy+.idd')
FileUtils.cp(weather_pat
h,current_workdir+'/in.epw')
if (not File.exists?(idd_path))
puts 'Cannot locate the input data dictionary (IDD) in the EnergyPlus directory. Correct the EXE path and try again.'
end
#run in.idf
expandobjects_path = EPlus_path + '/ExpandObjects.exe'
energyplus_path = EPlus_path + '/energyplus.exe'
Dir.chdir('#{current_workdir}')
system('#{expandobjects_path}')
File.rename('in.idf', 'in.idf.original')
File.rename('expanded.idf', 'in.idf')
system('#{energyplus_path}')

我的更多文章

下载客户端阅读体验更佳

APP专享