% clear all % clc % CHANGABLE PARAMETERS % % DENSITY OF PARTICLES % density = [1100 1600 2200 2700 3300]; % % PARTICLE SIZE % particle_size = {'0.01E-6[m]'; '0.05E-6'; '0.1E-6[m]'; '0.5E-6[m]'; '1E-6[m]'; '2E-6[m]'; '3E-6[m]'; '4E-6[m]'; '5E-6[m]' ; '6E-6[m]'; '7E-6[m]'; '8E-6[m]'; '9E-6[m]'; '10E-6[m]' ; '15E-6[m]' ; '50E-6[m]' ; '100E-6[m]'}; num_particles = ['500']; model = mphload('FEM_Final_Sketch_with_Particle_Flow.mph') ModelUtil.showProgress(true) % display the progress bar pwd; currentFolder = pwd; format shortg c=clock; Y = c(1); M = c(2); D = c(3); H = c(4); Mm = c(5); Ss = c(6); % newfolder = strcat('FileCreated_',num2str(Y),'_',num2str(M),'_',num2str(D),'_',num2str(H),'_',num2str(Mm),'_',num2str(Ss)); % mkdir(currentFolder, newfolder); clear Y M D currentFolder c % NUMBER OF PARTICLES % d_array = size(density); p_array = size(particle_size); model.physics('fpt').feature('inl1').set('N', 1, num_particles); t = cputime; for i = 1: d_array(2) % density(i); model.physics('fpt').feature('pp1').set('rhop', 1, density(i)); newdensityoutput = [i, cputime - t] ; for j = 1:p_array(1) % file_name2 = strcat('C:\Users\COMSOL\Desktop\FEM\DataResults\', datestr(date), '_Poin_plot_num_particles_' , num2str(num_particles), '_density_', num2str(density(i)), '_p_size_', particle_size(j), '.xls' ); newparticlesizeoutput = [ particle_size(j), cputime - t] ; model.physics('fpt').feature('pp1').set('dp', 1, particle_size(j)); model.study('std1').run; model.study('std2').run; file_name = strcat('C:\Users\COMSOL\Desktop\FEM\DataResults\', datestr(date),num2str(H),'_',num2str(Mm),'_',num2str(Ss), '_Poin_plot_num_particles_' , num2str(num_particles), '_density_', num2str(density(i)), '_p_size_', particle_size(j), '.txt' ); model.result.export('plot1').set('filename', file_name ); model.result.export('plot1').run; % model.result.export('plot1').set('filename', file_name2 ); % model.result.export('plot1').run; directory_name = 'C:\Users\COMSOL\Desktop\FEM\DataResults\' ; listing = dir(fullfile('C:\Users\COMSOL\Desktop\FEM\DataResults\')); l_array = size(listing); array_counter = 1; c_use = 0; f_counter =1; counter = 0; ct_mid = 0; for ii = 3:l_array(1) % PULL NAME FROM LIST OF NAMES namestring = listing(ii).name ; % MAKE THE NAME A STRING TO BE USED listname(ii) = cellstr((namestring)); % CONCATONATE WITH THE DIRECTORY char(listname(ii)) s = {directory_name, char(listname(ii))}; wholefilename = strcat(s(1),(s(2))); % SAVE FILE NAME INTO AN ARRAY wfn(ii-2) = (wholefilename(1)); % USE THAT NAME TO OPEN INDIVIDUAL FILES TO fid = fopen(char(wfn(ii-2))); % PREVENT ERRORS if fid == -1 else tline =fgets(fid); % counter = 1; s_array = size(s); while (ischar(tline)) use_s = tline; % PRINT ALL OF THE counter = counter +1; sss(counter,1)={tline}; tline = fgets(fid); end end % FIND OUT THE NUMBER OF ROWS IN EACH FILE sss_array = size(sss); % GO THROUGH EACH LINE AND DECIDE IF THAT PARTICLE IS IN THE CENTER ct_top = 0 ; ct_bot = 0; for jj=9:sss_array(1) s_use = char(sss(jj)); n_use = str2num(s_use(52:70)); num_use(jj-8,1) = n_use; if num_use(jj-8,1) < 500 if num_use(jj-8,1) >-500 ct_mid = ct_mid+1; else ct_bot = ct_bot +1; end else ct_top = ct_top + 1; end % COUNT EACH PARTICLE IN THE CENTER if n_use <500 if n_use >-500 c_use(jj) = 1; else c_use(jj) = 7; end else c_use(jj)=5; end end % c_use; % STORE THAT COUNT VALUE INTO A MATRIX % c_mat(ii-2,1) = c_use; org_matrix(ii-2,2) = ct_top; org_matrix(ii-2,3) = ct_mid; org_matrix(ii-2,4) = ct_bot; org_matrix(ii-2,5) = ct_top+ct_mid+ct_bot; ct_mid = 0; % c_use = 0; org_matrix(ii-2,1) = {namestring}; % org_matrix(ii-2,3) = {100*ntc/str2num(num_particles)}; counter =0; end end ModelUtil.remove('model') % remove model because it will be reloaded on every loop end