Project

General

Profile

function [nVals,aVals,peakVals,computeTime] = paramSweepParallel(nNum,aNum)
% [nVals,aVals,peakVals,computeTime] = paramSweepParallel(nNum,aNum)
%
% This is a parameter sweep study of the effect of the number of elements
% and element cross sectional area on the displacement at the tip of a
% cantilevered truss.
%
% Inputs:
%
% nNum: Number of nodes to try along bottom cord (scalar)
%
% aNum: Number of cross sectional areas to try (scalar)
%
% Outputs:
%
% nVals: vector with the number of nodes tested
%
% aVals: vector of cross sectional areas tested
%
% peakVals: maximum deflection at the truss tip for each combination of
% nVals and aVals
%
% computeTime: parfor-loop computation time
%
%
% Copyright 2015 The MathWorks, Inc.
%

% Two inputs
narginchk(2,2);

%% Initialize Problem

% Vectors of number of elements and cross section areas to sweep
nVals = (1:nNum)+10; % number of segments, start with 11
aVals = linspace(100, 200, aNum); % cross sectional area

% Grid of all combinations
[nGrid, aGrid] = meshgrid(nVals, aVals);

% Peak value results matrix
peakVals = nan(nNum,aNum);

%% Parameter Sweep

t0 = tic;
parfor ii = 1:numel(aGrid)
% Solve ODE
Y = trussCantilever(nGrid(ii),aGrid(ii));
peakVals(ii) = max(Y(:,end));
% Determine peak deflection in Y direction at the tip
end
computeTime = toc(t0);

end
(8-8/12)