Parfor Loop & EnergyPlus Co-Simulation
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello everyone,
I'm trying to run a parfor loop to run the EnergyPlus toolbox co-simulation a bit faster (EnergyPlus Co-Simulation). I tried a lot but I'm getting an error that I'm unable to solve.
Below is my code:
ep=[];
tStart = tic;
i=0;
HVACEnergy = array2table(zeros(25,8));
Blg_Electricity = array2table(zeros(25,8));
Total_Energy = array2table(zeros(25,8));
parfor c=1:8
%%
t = getCurrentTask();
d = fullfile(tempdir, sprintf('worker_%d', t.ID));
if ~exist(d, 'dir'), mkdir(d); end
%%
ep = mlep;
ep.workDir = d;
% Building simulation file
ep.idfFile = 'C:\Users\mak19\Desktop\UBC_PhD\Trial_Two\6-Modeling\1-Trial_One\4-IHDX\DD_Winter_EE.idf';
% Weather file
ep.epwFile = 'C:\Users\mak19\Desktop\UBC_PhD\Trial_Two\6-Modeling\1-Trial_One\4-IHDX\CAN_BC_Kamloops.718870_CWEC.epw';
% Initialize
ep.initialize;
% Simulation length
endTime = 1*24*60*60; %[s]
% Logging
VN = ep.outputSigName;
VN{3} = 'HVAC_Energy';
VN{4} = 'Total_Building_Electricity';
VN{5} = 'Total_Electricity';
logTable = table('Size',[0, 1 + ep.nOut],...
'VariableTypes',repmat({'double'},1,1 + ep.nOut),...
'VariableNames',[{'Time'}; VN]);
% Start co-simulation
ep.start;
iLog = 1;
%%
% The simulation loop
t = 0;
while t < endTime
% Prepare inputs (possibly from last outputs)
u = [20 24 1 1 1 1 1 1 1];
% Get outputs from EnergyPlus
[y, t] = ep.read;
% Send inputs to EnergyPlus
ep.write(u,t);
% Log
logTable(iLog, :) = num2cell([t y(:)']);
iLog = iLog + 1;
i=i+1;
end
% Stop co-simulation process
%%
ep.stop;
%%
delete(ep)
%
HVACEnergy(:,c) = logTable(:,4);
Blg_Electricity(:,c)=logTable(:,5);
Total_Energy(:,c)=logTable(:,6);
end
TotalTime = toc(tStart);
And this is the error I'm getting:
Error using mlep/acceptSocket (line 1144)
Java exception occurred:
java.net.SocketTimeoutException: Accept timed out
at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:135)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
Error in mlep/start (line 289)
obj.acceptSocket;
Many thanks in advance.
Mohamad
댓글 수: 0
채택된 답변
Raymond Norris
2021년 6월 18일
I would suggest trying this first with a pool size of 1. If it works, then my guess is that mlep only allows one connection at a time.
댓글 수: 9
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!