Parfor Loop & EnergyPlus Co-Simulation
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB Parallel Server dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!