|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
function varargout = cry_sim(varargin)
% CRY_SIM Application M-file for cry_sim.fig
% FIG = CRY_SIM launch cry_sim GUI.
% CRY_SIM('callback_name', ...) invoke the named callback.
% Last Modified by GUIDE v2.0 11-Jul-2003 17:34:08
if nargin == 0 % LAUNCH GUI
fig = openfig(mfilename,'reuse');
% Generate a structure of handles to pass to callbacks, and store it.
handles = guihandles(fig);
guidata(fig, handles);
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
if (nargout)
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
else
feval(varargin{:}); % FEVAL switchyard
end
catch
disp(lasterr);
end
end
% --------------------------------------------------------------------
function varargout = listbox1_Callback(h, eventdata, handles, varargin)
global lselect %lselect is used for a symbol of distribution function
listnum1=get(handles.listbox1,'value'); %list{index_selected}
switch listnum1
case 1%'Normal Distribution'
lselect=1;
set([handles.text28,handles.edit3,],'visible','on');
case 4%'Log Normal Distribution'
lselect=4;
set([handles.text28,handles.edit3,],'visible','on');
case 7%'Gamma Distribution'
lselect=7;
set([handles.text28,handles.edit3,],'visible','on');
case 10%'Uniform Distribution'
lselect=10;
set([handles.text28,handles.edit3,],'visible','on');
case 13%'Exponenetial Distribution'
lselect=13;
set([handles.text28,handles.edit3,],'visible','off');
case 2%'Normal Distribution'
lselect=1;
set([handles.text28,handles.edit3,],'visible','on');
case 5%'Log Normal Distribution'
lselect=4;
set([handles.text28,handles.edit3,],'visible','on');
case 8%'Gamma Distribution'
lselect=7;
set([handles.text28,handles.edit3,],'visible','on');
case 11%'Uniform Distribution'
lselect=10;
set([handles.text28,handles.edit3,],'visible','on');
case 14%'Exponenetial Distribution'
lselect=13;
set([handles.text28,handles.edit3,],'visible','off');
end
% --------------------------------------------------------------------
function varargout = listbox4_Callback(h, eventdata, handles, varargin)
global gselect % gselect is used for a symbol of distribution function
listnum4=get(handles.listbox4,'value'); %list{index_selected}
switch listnum4
case 1%'Normal Distribution'
gselect=1;
set([handles.text26,handles.edit10,],'visible','on');
case 4%'Log Normal Distribution'
gselect=4;
set([handles.text26,handles.edit10,],'visible','on');
case 7%'Gamma Distribution'
gselect=7;
set([handles.text26,handles.edit10,],'visible','on');
case 10%'Uniform Distribution'
gselect10;
set([handles.text26,handles.edit10,],'visible','on');
case 13%'Exponenetial Distribution'
gselect=13;
set([handles.text26,handles.edit10,],'visible','off');
case 2%'Normal Distribution'
gselect=1;
set([handles.text26,handles.edit10,],'visible','on');
case 5%'Log Normal Distribution'
gselect=4;
set([handles.text26,handles.edit10,],'visible','on');
case 8%'Gamma Distribution'
gselect=7;
set([handles.text26,handles.edit10,],'visible','on');
case 11%'Uniform Distribution'
gselect=10;
set([handles.text26,handles.edit10,],'visible','on');
case 14%'Exponenetial Distribution'
gselect=13;
set([handles.text26,handles.edit10,],'visible','off');
end
% --------------------------------------------------------------------
function varargout = edit1_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit2_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit3_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit8_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit9_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit10_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit11_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = pushbutton3_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)
global l_mu l_d l_a l_b g_mu g_d g_a g_b cn g_mean lselect gselect mdl l crystallization_time gmu
l_mu=str2Num(get(handles.edit2,'string')); % get different parameters for size distribution
l_cv=str2Num(get(handles.edit3,'string'));
g_d=str2Num(get(handles.edit10,'string')); % get different parameters for growth rate distribution
g_mean=str2Num(get(handles.edit11,'string')); % get crystallization parameters such as growth rate and crystallization time
crystallization_time=str2Num(get(handles.edit19,'string'));
l=linspace(0,2500,251); % divide size aix into 250 peaces
switch gselect % create a grwoth rate distribution function
case 1
g=linspace(0,15*g_d,51); % divide growth rate aix into 50 peaces according different g_d
fg=normpdf(g,1,g_d);
case 4
g=linspace(0,15*g_d,51); % divide growth rate aix into 50 peaces according different g_d
g_d=sqrt(log(1+g_d^2));
g_mu=-g_d^2/2;
fg=lognpdf(g,g_mu,g_d);
case 7
g_a=1/g_d^2;
g_b=g_d^2;
g=linspace(0,10*g_d,51); % divide growth rate aix into 50 peaces according different g_d
fg=gampdf(g,g_a,g_b);
case 10
g=linspace(0,3,31); % divide growth rate aix into 30 peaces
g_a=1-sqrt(3)*g_d;
g_b=g_a+sqrt(12)*g_d;
fg=unifpdf(g,g_a,g_b);
case 13
g=linspace(0,10,51); % divide growth rate aix into 50 peaces
fg=exppdf(g,1);
end
switch lselect % create a size distribution function
case 1
fl=normpdf(l,l_mu,l_cv*l_mu);
case 4
l_d=sqrt(log(1+l_cv^2));
l_mu=log(l_mu)-0.5*l_d^2;
fl=lognpdf(l,l_mu,l_d);
case 7
l_d=l_cv*l_mu;
l_b=l_d^2/l_mu;
l_a=l_mu/l_b;
fl=gampdf(l,l_a,l_b);
case 10
l_d=l_cv*l_mu;
l_a=l_mu-sqrt(3)*l_d;
l_b=l_a+sqrt(12)*l_d;
fl=unifpdf(l,l_a,l_b);
case 13
fl=exppdf(l,l_mu);
end
dt=5; % create time interval (/minute)
Crystal_Number=9.3667e+10; % set crystal number
g_length=length(g); % get the lenth of g
dg=g(2)-g(1);
l_length=length(l); % get the lenth of l
dl=l(2)-l(1); % calculate the lenth of size interval
flg=fg'*fl; % create joint distribution of growth rate and crystal size
for i=1:g_length % creat crys_number which is a matrix which element is the crystal number in cell (ij)
for j=1:l_length
crys_number(i,j)=Crystal_Number*flg(i,j)*dg*dl;
end
end
h1=figure(1); %output figures
subplot(2,2,1);
plot(l,fl);
h2=figure(2);
subplot(2,2,1);
contour(l,g,flg);
h3=figure(3); % xlabel is the crystal size distribution, ylabel is the crystal growth rate distribution
subplot(2,2,1);
mesh(l,g,flg);
total_step=linspace(0,0,g_length); %set initial value of growth steps
delta_l=linspace(0,0,g_length);
g_growth=g_mean*g;
for t=dt:dt:crystallization_time % loop begin
for i=1:g_length
delta_l(i)=delta_l(i)+g_growth(i)*dt; %calculate the ith level crystal growth;
step(i)=fix(delta_l(i)/dl);
total_step(i)=total_step(i)+step(i);
if step(i)>0 %Begin to recalculate crys_number
for j=l_length:-1:l_length-step(i) % move the crystals of cell(i,l_length-step(i)) to cell(i,l_length-1) to cell(i,l_length)
crys_number(i,l_length)=crys_number(i,l_length)+crys_number(i,j);
end
for j=l_length-step(i):-1:step(i)+1 % move the crystals of cell(i,l_length-step(i)-1) to cell(i,l_length-step(i)) and so on.
crys_number(i,j)=crys_number(i,j-step(i));
end
for j=total_step(i):-1:1 % cleanup the crystals of cell(i,1) to cell(i,total_step(i))
crys_number(i,j)=0;
end
delta_l(i)=delta_l(i)-step(i)*dl;
end
end
nl=linspace(0,0,l_length); % recalculate the crystal number in one size interval
for j=1:l_length
for i=1:g_length
nl(j)=nl(j)+crys_number(i,j);
end
end
for j=1:l_length % recalculate the size distribution function
fl(j)=nl(j)/(Crystal_Number*dl);
end
for i=1:g_length % recalculate joint distribution of growth rate and crystal size
for j=1:l_length
flg(i,j)=crys_number(i,j)/(Crystal_Number*dg*dl);
end
end
% recalculate crystal mass X in weight
crys_mu_3=0;
for j=1:l_length
crys_mu_3=crys_mu_3+fl(j)*l(j)^3*dl;
end
X3(t/dt)=pi*1.585*Crystal_Number*crys_mu_3*1e-15/6;
if ((t-crystallization_time/2)<=2.5)
h1=figure(1); % xlabel is the crystal size range, and ylabel is the crystal size distribution
subplot(2,2,2);
plot(l,fl);
h2=figure(2);
subplot(2,2,2);
contour(l,g,flg);
h3=figure(3); % xlabel is the crystal size distribution, ylabel is the crystal growth rate distribution
subplot(2,2,2);
mesh(l,g,flg);
end
if (t==crystallization_time)
h1=figure(1); % xlabel is the crystal size range, and ylabel is the crystal size distribution
subplot(2,2,3);
plot(l,fl);
h2=figure(2); % xlabel is the crystal size range, and ylabel is the crystal number is each interval
subplot(2,2,3);
contour(l,g,flg);
h3=figure(3); % xlabel is the crystal size distribution, ylabel is the crystal growth rate distribution
subplot(2,2,3);
mesh(l,g,flg);
end
%h5=figure(5);
%plot(time,crys_content_value);
xlabel('crystal size')
ylabel('growth rate')
end
h4=figure(4);
plot(X3);
xlabel('time--minute')
ylabel('Crystal Mass (kg)')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------
function varargout = pushbutton5_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit14_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit15_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit16_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit17_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit18_Callback(h, eventdata, handles, varargin)
% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit19_Callback(hObject, eventdata, handles)
% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit19 as text
% str2double(get(hObject,'String')) returns contents of edit19 as a double
% --------------------------------------------------------------------
function varargout = edit21_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = Untitled_1_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit23_Callback(h, eventdata, handles, varargin)
|
|