Code covered by the BSD License  

Highlights from
Co-Blade: Software for Analysis and Design of Composite Blades

image thumbnail

Co-Blade: Software for Analysis and Design of Composite Blades

by

 

18 Sep 2012 (Updated )

Analysis and design of composite blades for wind and hydrokinetic turbines

plotLaminaStrain(iSIM, SIM, BLADE, WEB, MATS, Panel, LaminaSS, OUT)
function plotLaminaStrain(iSIM, SIM, BLADE, WEB, MATS, Panel, LaminaSS, OUT)

%% re-assign some structure variable names (for convenience)
NUM_SEC    = BLADE.NUM_SEC;
BLD_LENGTH = BLADE.BLD_LENGTH;
aeroTwst   = BLADE.aeroTwst;
nWebs      = WEB.nWebs;
matID      = MATS.matID;    
matName    = MATS.matName; 

%%
convStrain = 1e6;           % conversion factor for strains (converts m to micro-m)
d2r        = pi/180;        % convert degrees to radians

matID_used = [];            % material identification numbers for materials that were actually used
for i = 1:NUM_SEC
    matID_t = unique( cat(1, Panel(i).Top.matID{:}) );
    matID_b = unique( cat(1, Panel(i).Bot.matID{:}) );
    if isempty(Panel(i).Web.matID)
        matID_w = [];
    else
        matID_w = unique( cat(1, Panel(i).Web.matID{:}) );
    end
    
    matID_used = unique( [matID_used; matID_t; matID_b; matID_w] );
end

nMats = numel(matID);   % number of materials listed in the materials file
cmap  = lines(nMats);	% creates a nMats-by-3 set of colors from the lines colormap
az    = 45;             % azimuth of view for the 3D plots
el    = 10;             % elevation of the view for 3D plots

%% 1st principal strains
if OUT.PLOT_E11
    figTitle = [SIM.case{iSIM} ' lamina 1st principal strains'];    
    fig = figure('name', figTitle, ...
                 'color', 'white', ...
                 'units','normalized',...
                 'outerposition',[0.1 0.1 0.8 0.8]);
    % create axes
    ha    = zeros(4,1);
    ha(1) = axes('position', [0.10  0.1  0.2  0.8]);
    ha(2) = axes('position', [0.35  0.1  0.2  0.8]);
    ha(3) = axes('position', [0.60  0.1  0.2  0.8]);
    ha(4) = axes('position', [0.8   0.1  0.2  0.8]);

    for i = 1:NUM_SEC

        c_vec = [cos(aeroTwst(i)*d2r); sin(aeroTwst(i)*d2r)];           % unit vector pointing in direction of chordline towards the TE

        % top panels
        subplot(ha(1))
        le    = [Panel(i).Top.xs{1}(1);     Panel(i).Top.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Top.xs{end}(end); Panel(i).Top.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Top.nPanels  
            r   = [Panel(i).Top.xs{j} - le(1), Panel(i).Top.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Top.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Top.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Top(j).e_11_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Top.matID{j}(k),:))
            end
        end

        % bottom panels
        subplot(ha(2))
        le    = [Panel(i).Bot.xs{1}(1);     Panel(i).Bot.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Bot.xs{end}(end); Panel(i).Bot.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Bot.nPanels  
            r   = [Panel(i).Bot.xs{j} - le(1), Panel(i).Bot.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Bot.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Bot.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Bot(j).e_11_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Bot.matID{j}(k),:))
            end
        end

        % web panels
        subplot(ha(3))
        for j = 1:nWebs(i)

            w   = Panel(i).Web.s{j}(end);
            s_w = Panel(i).Web.s{j} ./ w;
            z_L = Panel(i).Web.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Web.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, s_w, LaminaSS(i).Web(j).e_11_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Web.matID{j}(k),:))
            end
        end

    end

    % set axis labels and scale
    ttl = {'Top Panels','Bottom Panels','Web Panels'};
    for i = 1:3
        xlabel(ha(i), 'z/L')
        if i == 3
            ylabel(ha(i), 's/L_w')
        else
            ylabel(ha(i), 'x/c')
        end
        if i == 1
            zlabel(ha(i), '\epsilon_{11}, (\mu-m/m)')
        end
        xlim(ha(i), [0 1])
        ylim(ha(i), [0 1])
        title(ha(i), ttl(i))
        view(ha(i), az,el)    
    end

    % create legend
    subplot(ha(4))
    for i = 1:numel(matID_used)
       hold on
       plot(0, 0, 'Color', cmap(matID_used(i),:));  % just need to create dummy data points, so a legend can be created
    end
    legend(matName(matID_used), 'Location', 'West', 'FontName', 'times', 'FontSize', 12)
    axis off
    
    if OUT.SAVE_PLOTS
        savePlots(fig, figTitle, OUT.SAVE_FIG_FMT)
    end
                    
end
%% 2nd principal strains
if OUT.PLOT_E22
    figTitle = [SIM.case{iSIM} ' lamina 2nd principal strains'];    
    fig = figure('name', figTitle, ...
                 'color', 'white', ...
                 'units','normalized',...
                 'outerposition',[0.1 0.1 0.8 0.8]);

    % create axes
    ha    = zeros(4,1);
    ha(1) = axes('position', [0.10  0.1  0.2  0.8]);
    ha(2) = axes('position', [0.35  0.1  0.2  0.8]);
    ha(3) = axes('position', [0.60  0.1  0.2  0.8]);
    ha(4) = axes('position', [0.8   0.1  0.2  0.8]);

    for i = 1:NUM_SEC

        c_vec = [cos(aeroTwst(i)*d2r); sin(aeroTwst(i)*d2r)];           % unit vector pointing in direction of chordline towards the TE

        % top panels
        subplot(ha(1))
        le    = [Panel(i).Top.xs{1}(1);     Panel(i).Top.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Top.xs{end}(end); Panel(i).Top.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Top.nPanels  
            r   = [Panel(i).Top.xs{j} - le(1), Panel(i).Top.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Top.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Top.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Top(j).e_22_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Top.matID{j}(k),:))
            end
        end

        % bottom panels
        subplot(ha(2))
        le    = [Panel(i).Bot.xs{1}(1);     Panel(i).Bot.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Bot.xs{end}(end); Panel(i).Bot.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Bot.nPanels  
            r   = [Panel(i).Bot.xs{j} - le(1), Panel(i).Bot.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Bot.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Bot.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Bot(j).e_22_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Bot.matID{j}(k),:))
            end
        end

        % web panels
        subplot(ha(3))
        for j = 1:nWebs(i)

            w   = Panel(i).Web.s{j}(end);
            s_w = Panel(i).Web.s{j} ./ w;
            z_L = Panel(i).Web.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Web.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, s_w, LaminaSS(i).Web(j).e_22_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Web.matID{j}(k),:))
            end
        end

    end

    % set axis labels and scale
    ttl = {'Top Panels','Bottom Panels','Web Panels'};
    for i = 1:3
        xlabel(ha(i), 'z/L')
        if i == 3
            ylabel(ha(i), 's/L_w')
        else
            ylabel(ha(i), 'x/c')
        end
        if i == 1
            zlabel(ha(i), '\epsilon_{22}, (\mu-m/m)')
        end
        xlim(ha(i), [0 1])
        ylim(ha(i), [0 1])
        title(ha(i), ttl(i));
        view(ha(i), az,el)    
    end

    % create legend
    subplot(ha(4))
    for i = 1:numel(matID_used)
       hold on
       plot(0, 0, 'Color', cmap(matID_used(i),:));  % just need to create dummy data points, so a legend can be created
    end
    legend(matName(matID_used), 'Location', 'West')
    axis off

    if OUT.SAVE_PLOTS
        savePlots(fig, figTitle, OUT.SAVE_FIG_FMT)
    end
    
end
%% principal shear strains
if OUT.PLOT_E12
    figTitle = [SIM.case{iSIM} ' lamina principal shear strains'];    
    fig = figure('name', figTitle, ...
                 'color', 'white', ...
                 'units','normalized',...
                 'outerposition',[0.1 0.1 0.8 0.8]);

    % create axes
    ha    = zeros(4,1);
    ha(1) = axes('position', [0.10  0.1  0.2  0.8]);
    ha(2) = axes('position', [0.35  0.1  0.2  0.8]);
    ha(3) = axes('position', [0.60  0.1  0.2  0.8]);
    ha(4) = axes('position', [0.8   0.1  0.2  0.8]);

    for i = 1:NUM_SEC

        c_vec = [cos(aeroTwst(i)*d2r); sin(aeroTwst(i)*d2r)];           % unit vector pointing in direction of chordline towards the TE

        % top panels
        subplot(ha(1))
        le    = [Panel(i).Top.xs{1}(1);     Panel(i).Top.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Top.xs{end}(end); Panel(i).Top.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Top.nPanels  
            r   = [Panel(i).Top.xs{j} - le(1), Panel(i).Top.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Top.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Top.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Top(j).e_12_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Top.matID{j}(k),:))
            end
        end

        % bottom panels
        subplot(ha(2))
        le    = [Panel(i).Bot.xs{1}(1);     Panel(i).Bot.ys{1}(1)];     % position vector of the LE
        te    = [Panel(i).Bot.xs{end}(end); Panel(i).Bot.ys{end}(end)]; % position vector of the TE
        c     = norm(te - le);                                          % "chord length"
        for j = 1:Panel(i).Bot.nPanels  
            r   = [Panel(i).Bot.xs{j} - le(1), Panel(i).Bot.ys{j} - le(2)];
            x_c = (r * c_vec) ./ c;
            z_L = Panel(i).Bot.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Bot.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, x_c, LaminaSS(i).Bot(j).e_12_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Bot.matID{j}(k),:))
            end
        end

        % web panels
        subplot(ha(3))
        for j = 1:nWebs(i)

            w   = Panel(i).Web.s{j}(end);
            s_w = Panel(i).Web.s{j} ./ w;
            z_L = Panel(i).Web.zs{j} ./ BLD_LENGTH;

            nLam = Panel(i).Web.nLam(j);
            for k = 1:nLam
                hold on
                plot3(z_L, s_w, LaminaSS(i).Web(j).e_12_maxabs{k} .* convStrain, 'Color', cmap(Panel(i).Web.matID{j}(k),:))
            end
        end

    end

    % set axis labels and scale
    ttl = {'Top Panels','Bottom Panels','Web Panels'};
    for i = 1:3
        xlabel(ha(i), 'z/L')
        if i == 3
            ylabel(ha(i), 's/L_w')
        else
            ylabel(ha(i), 'x/c')
        end
        if i == 1
            zlabel(ha(i), '|\gamma_{12}|, (\mu-rad)')
        end
        xlim(ha(i), [0 1])
        ylim(ha(i), [0 1])
        title(ha(i), ttl(i));
        view(ha(i), az,el)    
    end

    % create legend
    subplot(ha(4))
    for i = 1:numel(matID_used)
       hold on
       plot(0, 0, 'Color', cmap(matID_used(i),:));  % just need to create dummy data points, so a legend can be created
    end
    legend(matName(matID_used), 'Location', 'West')
    axis off

    if OUT.SAVE_PLOTS
        savePlots(fig, figTitle, OUT.SAVE_FIG_FMT)
    end

end

end % function plotLaminaStrain

Contact us