Problem using Parallel processing.

2 visualizaciones (últimos 30 días)
joshua Abam
joshua Abam el 31 de Mzo. de 2020
I have a challenge I am facing at the moment and I need some new ideas.
I am trying to run this code using parallel computing, however I am having error using parfor due to
the inclusion of global variable as such i am considering using spmd however i don't seem to know how to
to go about it. can I use parfor if not then how can i use spmd.
global environment_wavedirection; %Using global to define the wave direction
dTheta = 45;
MaxTheta=360-dTheta; %The max angle not including 360 degree
kn = 1; %Define the load case exposure for the number of caese
D_total = 0; %Define the initial value of Total fatigue
WaveDirection = environment_wavedirection; %wave direction for each time
RefCurrentDirection = environment_wavedirection;
WindDirection = environment_wavedirection;
% Run the global wave direction from 0 to max angle with dtheta as difference
for environment_wavedirection = 0:dTheta:MaxTheta
%% Run both the statics and dynamics analysis
model.CalculateStatics; %Run the static analysis in preparation for dynamics
model.RunSimulation; %Run the Dynamic simulation for result extraction and
% for preparation of fatigue analysis
% Save each simulation based on the inputed angle in sequence
model.SaveSimulation(sprintf('scrresponse%d.sim',environment_wavedirection));
% Call for fatigue analysis to commence the process
fatigue = ofxFatigueAnalysis;
% %fatigue.Load('waomoscrlengthfatigue.ftg')
% %or
% %ofxFatigueAnalysis.Load('waomoscrlength.sim')
% Define the General parameter before starting the fatigue analysis
LoadCaseCount = 2; %Define the number of load cases for the analysis
LoadCaseFileName(1) = case01(x); %Define the case file in the folder
% %which calls and run and save the simulation file
%from which results are extracted, while maintaining
% %the global variable inside the casefile
LoadCaseLineName(1) = ('SCRmodel'); %Define the name of the line as found in the casefile
PeriodFrom(1) = Ti; %Define the initial time of the asefile
PeriodTo(1) = Tf; %Define the final time of the casefile
%Define the exposed time accoding to the number for loop
ExposedTime1 = 5768*[0.2326,0.2552,0.0234,0.0014,0.0062,0.0868,0.2108,0.1836];
%Define the actual exposure time base on Kn according to the loop
LoadCaseExposureTime(1) = ExposedTime1(kn);
LoadCaseFileName(2) = case02(x); %Define the case file in the folder
% %which calls and run and save the simulation file
%from which results are extracted, while maintaining
% %the global variable inside the casefile
LoadCaseLineName(2) = ('SCRmodel'); %Define the name of the line as found in the casefile
PeriodFrom(2) = Ti; %Define the initial time of the asefile
PeriodTo(2) = Tf; %Define the final time of the casefile
%Define the exposed time accoding to the number for loop
ExposedTime2 = 19898.8*[0.2326,0.2552,0.0234,0.0014,0.0062,0.0868,0.2108,0.1836];
%Define the actual exposure time base on Kn according to the loop
LoadCaseExposureTime(2) = ExposedTime2(kn);
D_fat = xlsread(result,1,'B8'); %read the D_fat from the first.
D_total = D_total + D_fat; %add D_fat to the existing D_total
kn = kn+1; %use kn+1 as the next step
end

Respuestas (0)

Categorías

Más información sobre Parallel Computing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by