% Electrical heating of a busbar solved with the LiveLink for SolidWorks % and the LiveLink for MATLAB. % % This model analyzes the resistive heating of a busbar designed to conduct % a direct current from a transformer to an electric device. Some geometry % parameters are set with MATLAB variables and automatically updated in % Solidworks. The instructions below assume that you have installed the % LiveLink for Solidworks Model Library. % NOTE: This models requires that you have the file busbar_assembly.SLDASM % open in Solidworks. % Use CTRL+SHIFT+ENTER keys to run the script in sequence. %% % Load the model busbar_llsw.mph that contains the initial settings. model = mphload('busbar_llsw'); % Display the current geometry mphgeom(model) %% % Update the parameters list in the CAD package cad = model.geom('geom1').feature('cad1'); cad.updateCadParamTable(true, true); % Change the value of the busbar length. model.param.set('LL_D1_Extrude1_busbar_sldprt',50); % Display the updated geometry. mphgeom(model) %% % Add the width busbar parameter in the list of parameters to synchronize % with the CAD package. cad = model.geom('geom1').feature('cad1'); cad.setIndex('param', 'D2@Sketch1@busbar.sldprt', 1); cad.setIndex('paramexpr', 'LL_D2_Sketch1_busbar_sldprt', 1); % Set a coarser mesh. mesh1_size = model.mesh('mesh1').feature('size'); mesh1_size.set('custom', 'off'); mesh1_size.set('hauto', '7'); % Deactivate the parametric sweep feature. model.study('std1').feature('param').active(false); % Set the solution data set and update the second plot group. dset1 = model.result.dataset('dset1'); dset1.selection.geom('geom1', 3); dset1.selection.set(1); pg = model.result('pg2'); pg.set('data', 'dset1'); pg.set('titleactive', 'on'); pg.feature('surf1').set('rangecoloractive', 'off'); %% % Define parameters values that define the geometry. L = 40:30:130; size_L = size(L,2); wbb = 50:25:150; size_wbb = size(wbb,2); % Start the first loop that runs over the busbar length. for j = 1:size_L % Update the busbar length parameter. model.param.set('LL_D1_Extrude1_busbar_sldprt',L(j)); % Start the first loop that runs over the busbar width. for i = 1:size_wbb % Create a progress bar. str = sprintf('Iteration No %d...', (j-1)*size_wbb+i); h = waitbar(0,str); waitbar(((j-1)*size_wbb+i)/(size_L*size_wbb), h); % Update the busbar width parameter. model.param.set('LL_D2_Sketch1_busbar_sldprt',wbb(i)); % Run the solver with the updated parameters. model.sol('sol1').run; % Evaluate the average temperature in domain 1. T_av(i,j) = mphmean(model,'T','volume','selection',1); % Delete the waitbar. delete(h) end % Display the 3D temperature plot for each busbar length parameter % values. str = sprintf('L=%d, wbb=%d',L(j),wbb(i)); pg.set('title',str); subplot(2,2,j) mphplot(model,'pg2','rangenum',1) end %% % Create a structured mesh grid using the geometry parameters used in the % analysis. [xx,yy] = meshgrid(L,wbb); % Display the average temperature in a surface plot. figure h = surf(xx,yy,T_av); % Change the view angle in the figure . view(140,10) % Set figure label. xlabel('L[mm]'); ylabel('wbb[mm]'); zlabel('T[K]');