answer.name];

saveas(handles.figure1,filename,'fig')

end

% --- Executes on button press in save_front.

function save_front_Callback(hObject, eventdata, handles)

answer=inputdlg('Save as:','Save');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

filename=['Save_data

answer.name '.jpg'];

I=getframe(handles.axes4);

imwrite(I.cdata,filename,'Quality', 100)

end

% --- Executes on button press in save_profile.

function save_profile_Callback(hObject, eventdata, handles)

answer=inputdlg('Save as:','Save');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

filename=['Save_data

answer.name '.jpg'];

I=getframe(handles.axes3);

imwrite(I.cdata,filename,'Quality', 100)

end

% Executes in menu exit

function Exit_Callback(hObject, eventdata, handles)

close

% Executes in menu properties

function Properties_Callback(hObject, eventdata, handles)

Parameters

% Executes in menu AdvOptions

function AdvOptions_Callback(hObject, eventdata, handles)

Options

% Executes in menu Run

function Run_Callback(hObject, eventdata, handles)

execute_Callback(hObject, eventdata, handles)

% Executes in push Results

function Results_Callback(hObject, eventdata, handles)

Graphics

% Executes in menu value

function value_Callback(hObject, eventdata, handles)

Parameter_values

% Executes in change option in intensity_bottom

function intensity_bottom_SelectionChangeFcn(hObject,

eventdata, handles)

if get(handles.specify_I,'value')==1

set(handles.intensity,'enable','on');

else

set(handles.intensity,'enable','off');

set(handles.intensity,'string','');

end

% Executes in change option in finish_bottom

function finish_bottom_SelectionChangeFcn(hObject, eventdata,

handles)

if get(handles.time,'value')==1

set(handles.t_limit,'enable','on');

else

set(handles.t_limit,'enable','off');

set(handles.t_limit,'string','');

end

% --- Executes on button press in execute.

function execute_Callback(hObject, eventdata, handles)

tic

global Eps Cp_water Cp_methanol k_cool ro_glass Cp_glass

ro_sil

global Cp_sil Cond ro x_w_m U I_real T_out T_cool T_ini

DeltaT0 k_max

global h_cool dz dy dx ny nz A_y A_z Den Q t_limit reach Q1

Q2 DZ1 DZ2

global z y Length popstencil time Temp T t pp j_int1

k_control i j_int2

U=str2double(get(handles.voltage,'string'));

if get(handles.specify_I,'value')==1

I_real=str2double(get(handles.intensity,'string'));

else

I_real=(U*Cond*0.001*0.065*Eps)/0.2;

end

T_out=str2double(get(handles.airtemperature,'string'));

T_cool=str2double(get(handles.coolingtemperature,'string'));

T_ini=str2double(get(handles.initialtemperature,'string'));

Length=0.2;

t_limit=str2double(get(handles.t_limit,'string'));

%Messages for input failure

if ~isnan(U) && ~isnan(I_real) && ~isnan(T_out) &&

~isnan(T_cool) && ~isnan(T_ini)

if U>=0 && I_real>=0

if get(handles.time,'value')==0 ||

(get(handles.time,'value')==1 && ~isnan(t_limit) &&

t_limit>=0)

set(handles.voltage,'enable','inactive')

set(handles.intensity,'enable','inactive')

set(handles.airtemperature,'enable','inactive')

set(handles.coolingtemperature,'enable','inactive')

set(handles.initialtemperature,'enable','inactive')

set(handles.specify_I,'enable','inactive')

set(handles.calc_I,'enable','inactive')

set(handles.time,'enable','inactive')

set(handles.steady,'enable','inactive')

set(handles.t_limit,'enable','inactive')

set(handles.execute,'enable','off')

set(handles.execute,'BackgroundColor',[0.9 0.9 0.9])

set(handles.Setting,'enable','off')

set(handles.Results,'enable','on')

set(handles.prop,'enable','on')

set(handles.save_profile,'enable','on')

set(handles.save_front,'enable','on')

%Heat transfer coefficient, cooling exchange:

Deq=2*0.0054*0.001/(0.0054+0.001);

u_inf=0.84;

Pr_cool=4180*1.3E-3/k_cool;

Re_cool=1000*u_inf*Deq/1.3E-3;

Gz_cool=Re_cool*Pr_cool*(Deq/Length);

if Re_cool>10000

Nu_cool=3.66+0.085*Gz_cool/(1+0.047*Gz_cool^0.66);

else

Nu_cool=4.36;

end

h_cool=k_cool*Nu_cool/Deq; %W/(m2*K)

dy=diff(y);

dz=diff(z);

% Heat Generation

A_y=dx*dz;

A_z=dx*dy;

Cond=I_real*0.2/(U*0.001*0.065*Eps);

Length_heat=(0.856636*U/1000+2.403893*I_real*1000-

2.15892*(I_real*1000)^2+0.416072*(I_real*1000)^3-0.2179)/100;

if Length_heat<0.015

Length_heat=0;

elseif Length_heat>0.07

Length_heat=0;

end

if Length_heat==0

DeltaT0=0;

else

DeltaT0=5.567703-3.54284*U/1000-

3.56301*I_real*1000+1.96067*U*I_real+0.418898*(U/1000)^3-

0.07157*(U/1000)^4;

end

k_max=1;

while z(k_max)<Length_heat

k_max=k_max+1;

end

DZ1=sum(dz(1:k_max-1));

DZ2=sum(dz(k_max:end));

Q=zeros(ny,nz);

Q_joule=U*I_real;

Q1=Q_joule*DZ1/Length;

Q2=Q_joule*(1-DZ1/Length);

%Joules/Kelvin: Liquid and glass

J_K_M=Cp_methanol*Eps*ro*x_w_m; %Methanol

J/(K*m3)

J_K_W=Cp_water*Eps*ro*(1-x_w_m); %Water, "

J_K_S=Cp_sil*(1-Eps)*ro_sil; %Silica, "

V_c=zeros(ny,nz);

for j=1:ny

if y(j)-0.01<1E-8 %Mathematical failure if condition

is y(j)==0.01 !!!

j_int1=j;

elseif y(j)-0.011<1E-8

j_int2=j-1;

end

for k=1:nz

V_c(j,k)=dx*dz(k)*dy(j);

if y(j)>=0.01-1E-8 && y(j)<0.011-1E-8

Den(j,k)=(J_K_M+J_K_W+J_K_S)*V_c(j,k);

%Denominator Heat balance, Liquid

if k>=1 && k<k_max

Q(j,k)=Q1*dz(k)*dy(j)/(DZ1*0.001);

elseif k>=k_max

Q(j,k)=Q2*dz(k)*dy(j)/(DZ2*0.001);

end

else

Den(j,k)=Cp_glass*V_c(j,k)*ro_glass;

%Denominator Heat Balance, Glass

end

end

end

%Solver

T=zeros(ny,nz,2);

T(:,:,1)=ones(ny,nz,1)*T_ini;

t_inc=0.0002;

t=zeros(1,2);

time=zeros(200,1);

Temp=zeros(ny,nz,200);

time(1)=t(1);

Temp(:,:,1)=T(:,:,1);

pp=1;

i=1;

nstep=1;

INC=zeros(ny,nz);

Y=1;

be=0;

fail=0;

do=0;

reach=0;

in=0;

save1=0;

save2=0;

save3=0;

if DZ1==0

k_control=1;

else

k_control=k_max-2;

end

if get(handles.time,'value')==1

t_limit=str2double(get(handles.t_limit,'string'));

while t(i)<t_limit

i=i+1;

nstep=nstep+1;

t(i)=t(i-1)+t_inc;

k1=t_inc*derivative(T(:,:,i-1));

k2=t_inc*derivative(T(:,:,i-1)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,i-1)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,i-1)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,i-1)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,i-

1)+(1631/55296)*k1+(175/512)*k2+(575/13824)*k3+(44275/110592)

*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,i-

1)+k1*2825/27648+k3*18575/48384+k4*13525/55296+k6*1/4+277/143

36*k5;

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

gru=max(max(max(T)))-min(min(min(T)));

if gru~=0

Delta0=gru*1E-6*ones(size(Delta1));

else

Delta0=1E-5*ones(size(Delta1));

end

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

if (min(min(abs(INC))))<1

fail=fail+1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

%Next step

if i==2

nstep=nstep+1;

i=1;

t(i)=t(2)+t_inc;

k1=t_inc*derivative(T(:,:,2));

k2=t_inc*derivative(T(:,:,2)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,2)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,2)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,2)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,2)+(1631/55296)*k1+(175/512)*k2+(57

5/13824)*k3+(44275/110592)*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,2)+k1*2825/27648+k3*18575/48384+k4*13525/55296

+k6*1/4+277/14336*k5;

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

if (min(min(abs(INC))))<1

fail=fail+1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

end

end

else

while Y>0.01

i=i+1;

nstep=nstep+1;

t(i)=t(i-1)+t_inc;

k1=t_inc*derivative(T(:,:,i-1));

k2=t_inc*derivative(T(:,:,i-1)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,i-1)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,i-1)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,i-1)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,i-

1)+(1631/55296)*k1+(175/512)*k2+(575/13824)*k3+(44275/110592)

*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,i-

1)+k1*2825/27648+k3*18575/48384+k4*13525/55296+k6*1/4+277/143

36*k5;

if mod(round(t(i)),20)==0 && be==0

be=1;

T_ref1=T(:,:,i);

elseif mod(round(t(i)),20)==0 && be==2

be=0;

T_ref2=T(:,:,i);

Y=max(max(abs(T_ref2-T_ref1)));

end

if mod(round(t(i)),20)==0

elseif be==1

be=2;

end

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

gru=max(max(max(T)))-min(min(min(T)));

if gru~=0

Delta0=gru*1E-6*ones(size(Delta1));

else

Delta0=1E-5*ones(size(Delta1));

end

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

if (min(min(abs(INC))))<1

fail=fail+1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

if i==2

nstep=nstep+1;

i=1;

t(i)=t(2)+t_inc;

k1=t_inc*derivative(T(:,:,2));

k2=t_inc*derivative(T(:,:,2)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,2)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,2)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,2)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,2)+(1631/55296)*k1+(175/512)*k2+(57

5/13824)*k3+(44275/110592)*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,2)+k1*2825/27648+k3*18575/48384+k4*13525/55296

+k6*1/4+277/14336*k5;

if mod(round(t(i)),20)==0 && be==0

be=1;

T_ref1=T(:,:,i);

elseif mod(round(t(i)),20)==0 && be==2

be=0;

T_ref2=T(:,:,i);

Y=max(max(abs(T_ref2-T_ref1)));

end

if mod(round(t(i)),20)==0

elseif be==1

be=2;

end

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

if (min(min(abs(INC))))<1

fail=fail+1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

if t(i)>1800

Y=0;

msgbox('Simulation was stopped when time was 1800

seconds, for avoiding an endless loop','Error','warn')

end

end

end

end

set(handles.t_limit,'string',t(i))

set(handles.intensity,'string',round(I_real*1E6)/1E6)

%Temperature profile, steady state

T_prof=T(1:ny,1:nz,1)';

Y=y(1:ny)+diff(y)/2;

Z=z(1:nz)+diff(z)/2;

[y,z]=meshgrid(Y,Z); %Array

subplot(handles.profile)

surf(y(1:nz,1:ny),z(1:nz,1:ny),T_prof,'EdgeColor','none');xla

bel('y');ylabel('z');zlabel('Temperature');rotate3d on

%Frontal view

if popstencil==1

dy=0.015/ny;

dz=0.2/nz;

dx=0.065;

y=0:dy:0.015;

z=0:dz:0.2;

x=0:dx:0.065;

else

dy=0.00025;

dz=0.004;

dx=0.065;

x=0:dx:0.065;

y=[0 dy/2 dy:dy:4*dy 6*dy 8*dy:3*dy:32*dy 34*dy

36*dy:dy:39*dy 39.5*dy 40*dy:dy/4:44*dy 44.5*dy

45*dy:dy:48*dy 50*dy:2*dy:56*dy 57*dy:dy:59*dy 59.5*dy

60*dy];

z=[0 dz/10 dz/5:dz/5:dz 1.5*dz:0.5*dz:10*dz

11*dz:dz:19*dz 20*dz:3*dz:50*dz];

end

Ti(1:nz,1)=T(j_int1,1:nz,1);

Ti(1:nz,2)=T(j_int1,1:nz,1);

Z=z(1:nz)+diff(z)/2;

subplot(handles.front_im)

[x,z]=meshgrid(x,Z);

surface(x(1:nz,:),z(1:nz,:),(min(min(Ti))-

0.5)*ones(size(Ti)),'EdgeColor','none')

surface(x(1:nz,:),z(1:nz,:),Ti,'EdgeColor','none');xlabel('x'

);ylabel('z');zlabel('Temperature');colorbar

if popstencil==1

z=0:dz:0.2;

x=0:dx:0.065;

else

x=0:dx:0.065;

z=[0 dz/10 dz/5:dz/5:dz 1.5*dz:0.5*dz:10*dz

11*dz:dz:19*dz 20*dz:3*dz:50*dz];

end

else

msgbox('Time must be a real positive number, your suggestion

is physically imposible.','Input error','error')

end

else

msgbox('Sorry, but both voltage and electrical current must

be positive','Input error','error')

end

else

msgbox('Please, make sure you fill all the required

fields.','Input error','error')

end

toc

function varargout = Parameter_Study(varargin)

% Last Modified by GUIDE v2.5 29-Jul-2011 14:57:48

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn',

@Parameter_Study_OpeningFcn, ...

'gui_OutputFcn',

@Parameter_Study_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State,

varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Parameter_Study is made visible.

function Parameter_Study_OpeningFcn(hObject, eventdata,

handles, varargin)

global ratio k_g Eps k_sil Cp_water Cp_methanol k_air Cp_air

ro_air k_cool

global ro_glass Cp_glass ro_sil Cp_sil Cond ro x_w_m nu k_liq

nu_air

global h_air last matrix vary numberfile totalcases

numberfile=0;

totalcases=0;

set(handles.k_glass,'string',k_g)

set(handles.ro_glass,'string',ro_glass)

set(handles.Cp_glass,'string',Cp_glass)

set(handles.k_out,'string',k_air)

set(handles.ro_air,'string',ro_air)

set(handles.Cp_air,'string',Cp_air)

set(handles.k_sil,'string',k_sil)

set(handles.ro_sil,'string',ro_sil)

set(handles.Cp_sil,'string',Cp_sil)

set(handles.Cp_water,'string',Cp_water)

set(handles.Cp_methanol,'string',Cp_methanol)

set(handles.Cond,'string',Cond)

set(handles.Eps,'string',Eps)

set(handles.k_cool,'string',k_cool)

set(handles.ro_mix,'string',ro);

set(handles.x_w_m,'string',x_w_m);

set(handles.nu_mix,'string',nu);

set(handles.k_mix,'string',k_liq);

set(handles.nu_air,'string',nu_air);

set(handles.h_air,'string',h_air);

switch ratio

case 4

set(handles.popup_ratio,'value',1)

case 6

set(handles.popup_ratio,'value',2)

case 8

set(handles.popup_ratio,'value',3)

case 'Other'

set(handles.popup_ratio,'value',4)

end

last=zeros(1,24);

matrix=0;

vary=0;

% Choose default command line output for Parameter_Study

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% --- Outputs from this function are returned to the command

line.

function varargout = Parameter_Study_OutputFcn(hObject,

eventdata, handles)

varargout{1} = handles.output;

% --- Executes on button press in push_std.

function push_std_Callback(hObject, eventdata, handles)

global k_g_std Eps_std k_sil_std Cp_water_std Cp_methanol_std

k_air_std

global Cp_air_std ro_air_std k_cool_std ro_glass_std

Cp_glass_std

global ro_sil_std Cp_sil_std Cond_std nu_air_std h_air_std

set(handles.k_glass,'string',num2str(k_g_std))

set(handles.ro_glass,'string',num2str(ro_glass_std))

set(handles.Cp_glass,'string',num2str(Cp_glass_std))

set(handles.k_out,'string',num2str(k_air_std))

set(handles.ro_air,'string',num2str(ro_air_std))

set(handles.Cp_air,'string',num2str(Cp_air_std))

set(handles.k_sil,'string',num2str(k_sil_std))

set(handles.ro_sil,'string',num2str(ro_sil_std))

set(handles.Cp_sil,'string',num2str(Cp_sil_std))

set(handles.Cp_water,'string',num2str(Cp_water_std))

set(handles.Cp_methanol,'string',num2str(Cp_methanol_std))

set(handles.Cond,'string',num2str(Cond_std))

set(handles.popup_ratio,'value',2)

set(handles.Eps,'string',num2str(Eps_std))

set(handles.k_cool,'string',num2str(k_cool_std))

set(handles.ro_mix,'string',850)

set(handles.x_w_m,'string',0.8)

set(handles.nu_mix,'string',1.4E-3)

set(handles.k_mix,'string',0.27)

set(handles.ro_mix,'enable','off')

set(handles.x_w_m,'enable','off')

set(handles.nu_mix,'enable','off')

set(handles.k_mix,'enable','off')

set(handles.nu_air,'string',num2str(nu_air_std))

set(handles.h_air,'string',num2str(h_air_std));

% --- Executes on selection change in popup_ratio.

function popup_ratio_Callback(hObject, eventdata, handles)

switch get(hObject,'Value')

case 1

set(handles.ro_mix,'string',866);

set(handles.x_w_m,'string',0.735);

set(handles.nu_mix,'string',1.6E-3);

set(handles.k_mix,'string',0.29);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 2

set(handles.ro_mix,'string',850);

set(handles.x_w_m,'string',0.8);

set(handles.nu_mix,'string',1.4E-3);

set(handles.k_mix,'string',0.27);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 3

set(handles.ro_mix,'string',840);

set(handles.x_w_m,'string',0.84);

set(handles.nu_mix,'string',1.25E-3);

set(handles.k_mix,'string',0.26);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 4

set(handles.ro_mix,'string','');

set(handles.x_w_m,'string','');

set(handles.nu_mix,'string','');

set(handles.k_mix,'string','');

set(handles.ro_mix,'enable','on');

set(handles.x_w_m,'enable','on');

set(handles.nu_mix,'enable','on');

set(handles.k_mix,'enable','on');

end

% --- Executes on button press in push_apply.

function push_apply_Callback(hObject, eventdata, handles)

global ratio k_g_ Eps_ k_sil_ Cp_water_ Cp_methanol_ k_air_

Cp_air_ ro_air_ k_cool_

global ro_glass_ Cp_glass_ ro_sil_ Cp_sil_ Cond_ ro_ x_w_m_

nu_ k_liq_ nu_air_ U_

global T_out_ T_cool_ t_limit_ vary h_air_ matrix last

switch get(handles.popup_ratio,'value')

case 1

ratio=4;

case 2

ratio=6;

case 3

ratio=8;

case 4

ratio='Other';

end

column='';

U_=str2double(get(handles.voltage,'string'));

if isnan(U_)

vary(1)=1;

column=[column; 'Potential applied '];

end

T_out_=str2double(get(handles.airtemperature,'string'));

if isnan(T_out_)

vary(2)=1;

column=[column; 'Air temperature '];

end

T_cool_=str2double(get(handles.coolingtemperature,'string'));

if isnan(T_cool_)

vary(3)=1;

column=[column; 'Cooling temperature'];

end

t_limit_=str2double(get(handles.t_limit,'string'));

if isnan(t_limit_)

vary(4)=1;

column=[column; 'Transcurred time '];

end

k_g_=str2double(get(handles.k_glass,'string'));

if isnan(k_g_)

vary(5)=1;

column=[column; 'Glass conductivity '];

end

ro_glass_=str2double(get(handles.ro_glass,'string'));

if isnan(ro_glass_)

vary(6)=1;

column=[column; 'Glass density '];

end

Cp_glass_=str2double(get(handles.Cp_glass,'string'));

if isnan(Cp_glass_)

vary(7)=1;

column=[column; 'Glass Cp '];

end

k_air_=str2double(get(handles.k_out,'string'));

if isnan(k_air_)

vary(8)=1;

column=[column; 'Air conductivity '];

end

ro_air_=str2double(get(handles.ro_air,'string'));

if isnan(ro_air_)

vary(9)=1;

column=[column; 'Air density '];

end

Cp_air_=str2double(get(handles.Cp_air,'string'));

if isnan(Cp_air_)

vary(10)=1;

column=[column; 'Air Cp '];

end

k_sil_=str2double(get(handles.k_sil,'string'));

if isnan(k_sil_)

vary(11)=1;

column=[column; 'Silica conductivity'];

end

ro_sil_=str2double(get(handles.ro_sil,'string'));

if isnan(ro_sil_)

vary(12)=1;

column=[column; 'Silica density '];

end

Cp_sil_=str2double(get(handles.Cp_sil,'string'));

if isnan(Cp_sil_)

vary(13)=1;

column=[column; 'Silica Cp '];

end

Cp_water_=str2double(get(handles.Cp_water,'string'));

if isnan(Cp_water_)

vary(14)=1;

column=[column; 'Water Cp '];

end

Cp_methanol_=str2double(get(handles.Cp_methanol,'string'));

if isnan(Cp_methanol_)

vary(15)=1;

column=[column; 'Methanol Cp '];

end

Cond_=str2double(get(handles.Cond,'string'));

if isnan(Cond_)

vary(16)=1;

column=[column; 'Electric conductiv.'];

end

ro_=str2double(get(handles.ro_mix,'string'));

if isnan(ro_)

vary(17)=1;

column=[column; 'Liquid density '];

end

x_w_m_=str2double(get(handles.x_w_m,'string'));

if isnan(x_w_m_)

vary(18)=1;

column=[column; 'Meth. mass fraction'];

end

nu_=str2double(get(handles.nu_mix,'string'));

if isnan(nu_)

vary(19)=1;

column=[column; 'Liquid viscosity '];

end

k_liq_=str2double(get(handles.k_mix,'string'));

if isnan(k_liq_)

vary(20)=1;

column=[column; 'Liquid conductivity'];

end

Eps_=str2double(get(handles.Eps,'string'));

if isnan(Eps_)

vary(21)=1;

column=[column; 'Porosity '];

end

k_cool_=str2double(get(handles.k_cool,'string'));

if isnan(k_cool_)

vary(22)=1;

column=[column; 'Cooling conductiv. '];

end

h_air_=str2double(get(handles.h_air,'string'));

if isnan(h_air_)

vary(23)=1;

column=[column; 'Air convection coef'];

end

nu_air_=str2double(get(handles.nu_air,'string'));

if isnan(nu_air_)

vary(24)=1;

column=[column; 'Air viscosity '];

else

vary(24)=0;

end

set(handles.tab,'ColumnName',column);

set(handles.list,'string',column);

matrix=0;

last=zeros(1,24);

set(handles.tab,'Data',matrix);

% --- Executes on button press in push_cancel.

function push_cancel_Callback(hObject, eventdata, handles)

close

% --- Executes on button press in push_add.

function push_add_Callback(hObject, eventdata, handles)

global last matrix vary totalcases

last(get(handles.list,'value'))=last(get(handles.list,'value'

))+1;

matrix(last(get(handles.list,'value')),get(handles.list,'valu

e'))=str2double(get(handles.add,'string'));

set(handles.tab,'Data',matrix);

totalcases=1;

for i=1:sum(vary)

totalcases=totalcases*last(i);

end

message=['With the specified conditions, it is necessary to

simulate ' num2str(totalcases) ' cases.'];

set(handles.cases,'string',message);

set(handles.add,'string','');

% --- Executes on button press in push_clear.

function push_clear_Callback(hObject, eventdata, handles)

global last matrix vary

matrix(1:last(get(handles.list,'value')),get(handles.list,'va

lue'))=zeros(1:last(get(handles.list,'value')),1);

last(get(handles.list,'value'))=0;

set(handles.tab,'Data',matrix);

totalcases=1;

for i=1:sum(vary)

totalcases=totalcases*last(i);

end

message=['With the specified conditions, it is necessary to

simulate ' num2str(totalcases) ' cases.'];

set(handles.cases,'string',message);

set(handles.add,'string','');

% --- Executes on selection change in popup_stencil.

function popup_stencil_Callback(hObject, eventdata, handles)

switch get(handles.popup_stencil,'value')

case 1

set(handles.ny,'enable','on')

set(handles.nz,'enable','on')

case 2

set(handles.ny,'enable','off')

set(handles.nz,'enable','off')

set(handles.ny,'string',52)

set(handles.nz,'string',44)

end

% --- Executes on button press in execute.

function execute_Callback(hObject, eventdata, handles)

global k_g_ Eps_ k_sil_ Cp_water_ Cp_methanol_ k_air_ Cp_air_

ro_air_

global ro_glass_ Cp_glass_ ro_sil_ Cp_sil_ Cond_ ro_ x_w_m_

nu_ k_liq_ nu_air_

global T_out_ T_cool_ T_ini t_limit_ h_air_ matrix last k_mix

U_

global Eps Cp_water Cp_methanol k_cool ro_glass Cp_glass

ro_sil k_cool_

global Cp_sil Cond ro x_w_m U I_real T_out T_cool numberfile

global h_cool dz dy dx ny nz A_y A_z Den Q t_limit totalcases

global z y Length popstencil time Temp T t pp

if totalcases==0

msgbox('You have to specify a value for all

parameters.','Input error','warn')

else

if get(handles.popup_stencil,'value')==2 ||

(get(handles.popup_stencil,'value')==1 &&

str2double(get(handles.ny,'string'))>0 &&

str2double(get(handles.nz,'string'))>1 &&

mod(str2double(get(handles.ny,'string')),15)==0)

answer=inputdlg('Save cases as:','Save');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

save_as=['Save_data

answer.name];

i=1;

if isnan(U_)

U_=matrix(:,i);

aa=last(i);

i=i+1;

else

aa=1;

end

if isnan(T_out_)

T_out_=matrix(:,i);

ab=last(i);

i=i+1;

else

ab=1;

end

if isnan(T_cool_)

T_cool_=matrix(:,i);

ac=last(i);

i=i+1;

else

ac=1;

end

if isnan(t_limit_)

t_limit_=matrix(:,i);

ad=last(i);

i=i+1;

else

ad=1;

end

if isnan(k_g_)

k_g_=matrix(:,i);

ae=last(i);

i=i+1;

else

ae=1;

end

if isnan(ro_glass_)

ro_glass_=matrix(:,i);

af=last(i);

i=i+1;

else

af=1;

end

if isnan(Cp_glass_)

Cp_glass_=matrix(:,i);

ag=last(i);

i=i+1;

else

ag=1;

end

if isnan(k_air_)

k_air_=matrix(:,i);

ah=last(i);

i=i+1;

else

ah=1;

end

if isnan(ro_air_)

ro_air_=matrix(:,i);

ai=last(i);

i=i+1;

else

ai=1;

end

if isnan(Cp_air_)

Cp_air_=matrix(:,i);

aj=last(i);

i=i+1;

else

aj=1;

end

if isnan(k_sil_)

k_sil_=matrix(:,i);

ak=last(i);

i=i+1;

else

ak=1;

end

if isnan(ro_sil_)

ro_sil_=matrix(:,i);

al=last(i);

i=i+1;

else

al=1;

end

if isnan(Cp_sil_)

Cp_sil_=matrix(:,i);

am=last(i);

i=i+1;

else

am=1;

end

if isnan(Cp_water_)

Cp_water_=matrix(:,i);

an=last(i);

i=i+1;

else

an=1;

end

if isnan(Cp_methanol_)

Cp_methanol_=matrix(:,i);

ao=last(i);

i=i+1;

else

ao=1;

end

if isnan(Cond_)

Cond_=matrix(:,i);

ap=last(i);

i=i+1;

else

ap=1;

end

if isnan(ro_)

ro_=matrix(:,i);

aq=last(i);

i=i+1;

else

aq=1;

end

if isnan(x_w_m_)

x_w_m_=matrix(:,i);

ar=last(i);

i=i+1;

else

ar=1;

end

if isnan(nu_)

nu_=matrix(:,i);

as=last(i);

i=i+1;

else

as=1;

end

if isnan(k_liq_)

k_liq_=matrix(:,i);

at=last(i);

i=i+1;

else

at=1;

end

if isnan(Eps_)

Eps_=matrix(:,i);

au=last(i);

i=i+1;

else

au=1;

end

if isnan(k_cool_)

k_cool_=matrix(:,i);

av=last(i);

i=i+1;

else

av=1;

end

if isnan(h_air_)

h_air_=matrix(:,i);

aw=last(i);

i=i+1;

else

aw=1;

end

if isnan(nu_air_)

nu_air_=matrix(:,i);

ax=last(i);

else

ax=1;

end

ny=str2double(get(handles.ny,'string'));

nz=str2double(get(handles.nz,'string'));

for ba=1:aa

for bb=1:ab

for bc=1:ac

for bd=1:ad

for be=1:ae

for bf=1:af

for bg=1:ag

for bh=1:ah

for bi=1:ai

for bj=1:aj

for bk=1:ak

for bl=1:al

for bm=1:am

for bn=1:an

for bo=1:ao

for bp=1:ap

for bq=1:aq

for br=1:ar

for bs=1:as

for bt=1:at

for bu=1:au

for bv=1:av

for bw=1:aw

for bx=1:ax

tic

switch get(handles.popup_stencil,'value')

case 1

dy=0.015/ny;

dz=0.2/nz;

dx=0.065;

y=0:dy:0.015; % Y position vector, m

z=0:dz:0.2; % Z position vector, m

popstencil=1;

case 2

dy=0.00025;

dz=0.004;

dx=0.065;

y=[0 dy/2 dy:dy:4*dy 6*dy 8*dy:3*dy:32*dy 34*dy

36*dy:dy:39*dy 39.5*dy 40*dy:dy/4:44*dy 44.5*dy

45*dy:dy:48*dy 50*dy:2*dy:56*dy 57*dy:dy:59*dy 59.5*dy

60*dy];

z=[0 dz/10 dz/5:dz/5:dz 1.5*dz:0.5*dz:10*dz

11*dz:dz:19*dz 20*dz:3*dz:50*dz];

popstencil=2;

end

numberfile=numberfile+1;

U=U_(ba);

T_out=T_out_(bb);

T_cool=T_cool_(bc);

t_limit=t_limit_(bd);

k_g=k_g_(be);

ro_glass=ro_glass_(bf);

Cp_glass=Cp_glass_(bg);

k_air=k_air_(bh);

ro_air=ro_air_(bi);

Cp_air=Cp_air_(bj);

k_sil=k_sil_(bk);

ro_sil=ro_sil_(bl);

Cp_sil=Cp_sil_(bm);

Cp_water=Cp_water_(bn);

Cp_methanol=Cp_methanol_(bo);

Cond=Cond_(bp);

ro=ro_(bq);

x_w_m=x_w_m_(br);

nu=nu_(bs);

k_liq=k_liq_(bt);

Eps=Eps_(bu);

k_cool=k_cool_(bv);

h_air=h_air_(bw);

nu_air=nu_air_(bx);

T_ini=T_cool*0.8+T_out*0.2;

I_real=(U*Cond*0.001*0.065*Eps)/0.2;

Length=0.2;

if get(handles.volint,'value')==1

R=30E-6; %Particle radio, m

dr=1E-7;

r=0;

area_k=0;

i=1;

func=zeros(1,100);

while r<=R

func(i)=r/((R-(R^2-r^2)^0.5)/k_liq+(R^2-

r^2)^0.5/k_sil); %Function for integration

if i>1

increase=func(i-1)*dr+(func(i)-func(i-1))*dr/2;

area_k=area_k+increase;

end

i=i+1;

r=r+dr;

end

k_mix=(2/R)*area_k;

else

k_mix=k_liq*Eps+k_sil*(1-Eps);

end

%Heat transfer coefficient, cooling exchange:

Deq=2*0.0054*0.001/(0.0054+0.001);

u_inf=0.84;

Pr_cool=4180*1.3E-3/k_cool;

Re_cool=1000*u_inf*Deq/1.3E-3;

Gz_cool=Re_cool*Pr_cool*(Deq/Length);

if Re_cool>10000

Nu_cool=3.66+0.085*Gz_cool/(1+0.047*Gz_cool^0.66);

else

Nu_cool=4.36;

end

h_cool=k_cool*Nu_cool/Deq; %W/(m2*K)

dy=diff(y);

dz=diff(z);

% Heat Generation

A_y=dx*dz;

A_z=dx*dy;

Cond=I_real*0.2/(U*0.001*0.065*Eps);

Length_heat=(0.856636*U/1000+2.403893*I_real*1000-

2.15892*(I_real*1000)^2+0.416072*(I_real*1000)^3-0.2179)/100;

if Length_heat<0.015

Length_heat=0;

elseif Length_heat>0.07

Length_heat=0;

end

if Length_heat==0

DeltaT0=0;

else

DeltaT0=5.567703-3.54284*U/1000-

3.56301*I_real*1000+1.96067*U*I_real+0.418898*(U/1000)^3-

0.07157*(U/1000)^4;

end

k_max=1;

while z(k_max)<Length_heat

k_max=k_max+1;

end

DZ1=sum(dz(1:k_max-1));

DZ2=sum(dz(k_max:end));

Q=zeros(ny,nz);

Q_joule=U*I_real;

Q1=Q_joule*DZ1/Length;

Q2=Q_joule*(1-DZ1/Length);

%Joules/Kelvin: Liquid and glass

J_K_M=Cp_methanol*Eps*ro*x_w_m; %Methanol

J/(K*m3)

J_K_W=Cp_water*Eps*ro*(1-x_w_m); %Water, "

J_K_S=Cp_sil*(1-Eps)*ro_sil; %Silica, "

V_c=zeros(ny,nz);

for j=1:ny

if y(j)-0.01<1E-8 %Mathematical failure if condition

is y(j)==0.01 !!!

j_int1=j;

elseif y(j)-0.011<1E-8

j_int2=j-1;

end

for k=1:nz

V_c(j,k)=dx*dz(k)*dy(j);

if y(j)>=0.01-1E-8 && y(j)<0.011-1E-8

Den(j,k)=(J_K_M+J_K_W+J_K_S)*V_c(j,k);

%Denominator Heat balance, Liquid

if k>=1 && k<k_max

Q(j,k)=Q1*dz(k)*dy(j)/(DZ1*0.001);

elseif k>=k_max

Q(j,k)=Q2*dz(k)*dy(j)/(DZ2*0.001);

end

else

Den(j,k)=Cp_glass*V_c(j,k)*ro_glass;

%Denominator Heat Balance, Glass

end

end

end

%Solver

T=zeros(ny,nz,2);

T(:,:,1)=ones(ny,nz,1)*T_ini;

t_inc=0.0002;

t=zeros(1,2);

time=zeros(200,1);

Temp=zeros(ny,nz,200);

time(1)=t(1);

Temp(:,:,1)=T(:,:,1);

pp=1;

i=1;

INC=zeros(ny,nz);

do=0;

save1=0;

save2=0;

save3=0;

if DZ1==0

k_control=1;

else

k_control=k_max-2;

end

while t(i)<t_limit

i=i+1;

t(i)=t(i-1)+t_inc;

k1=t_inc*derivative(T(:,:,i-1));

k2=t_inc*derivative(T(:,:,i-1)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,i-1)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,i-1)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,i-1)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,i-

1)+(1631/55296)*k1+(175/512)*k2+(575/13824)*k3+(44275/110592)

*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,i-

1)+k1*2825/27648+k3*18575/48384+k4*13525/55296+k6*1/4+277/143

36*k5;

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

gru=max(max(max(T)))-min(min(min(T)));

if gru~=0

Delta0=gru*1E-6*ones(size(Delta1));

else

Delta0=1E-5*ones(size(Delta1));

end

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

if i==2

i=1;

t(i)=t(2)+t_inc;

k1=t_inc*derivative(T(:,:,2));

k2=t_inc*derivative(T(:,:,2)+(1/5)*k1);

k3=t_inc*derivative(T(:,:,2)+(3/40)*k1+(9/40)*k2);

k4=t_inc*derivative(T(:,:,2)+(3/10)*k1-

(9/10)*k2+(6/5)*k3);

k5=t_inc*derivative(T(:,:,2)-(11/54)*k1+(5/2)*k2-

(70/27)*k3+(35/27)*k4);

k6=t_inc*derivative(T(:,:,2)+(1631/55296)*k1+(175/512)*k2+(57

5/13824)*k3+(44275/110592)*k4+(253/4096)*k5);

T(:,:,i)=T(:,:,2)+k1*2825/27648+k3*18575/48384+k4*13525/55296

+k6*1/4+277/14336*k5;

Delta1=(37/378-2825/27648)*k1+(250/621-

18575/48384)*k3+(125/594-13525/55296)*k4-

277/14336*k5+(512/1771-1/4)*k6;3E-4;

for j=1:ny

for k=1:nz

if Delta1(j,k)==0

INC(j,k)=1E50;

else

INC(j,k)=Delta0(j,k)/Delta1(j,k);

end

end

end

t_inc=t_inc*(min(min(abs(INC)))).^0.2;

if t_inc>1

t_inc=1;

end

%Data record

if t(i)<=2

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>2 && t(i)<=200 && save1==0 &&

mod(round(t(i)),2)==0

save1=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>200 && t(i)<=600 && save2==0 &&

mod(round(t(i)),4)==0

save2=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

elseif t(i)>600 && save3==0 && mod(round(t(i)),10)==0

save3=1;

pp=pp+1;

time(pp)=t(i);

Temp(:,:,pp)=T(:,:,i);

end

if mod(round(t(i)),2)==0

elseif save1==1;

save1=0;

end

if mod(round(t(i)),4)==0

elseif save2==1;

save2=0;

end

if mod(round(t(i)),10)==0

elseif save3==1;

save3=0;

end

%Control of the difference in heat generation:

if DeltaT0 ~=0 && mod(round(t(i)),2)==0 && do==0 &&

round(t(i))>0

do=1;

in=in+1;

Q=heat_rest(k1);

end

if mod(round(t(i)),2)==0

elseif do==1

do=0;

end

end

end

%Temperature profile, steady state

T_prof=T(1:ny,1:nz,1)';

clear Y

clear Z

Y=y(1:ny)+diff(y)/2;

Z=z(1:nz)+diff(z)/2;

[y,z]=meshgrid(Y,Z); %Array

figure

surf(y(1:nz,1:ny),z(1:nz,1:ny),T_prof,'EdgeColor','none');xla

bel('y');ylabel('z');zlabel('Temperature');rotate3d on

filename=[save_as num2str(numberfile) 'figure.fig'];

saveas(gcf,filename,'fig');

close

filename=[save_as num2str(numberfile) 'data.xls'];

xlswrite(filename,T(:,:,1),'Temperature in blocks')

variablename={'Potential applied '; 'Air temperature ';

'Cooling temperature'; 'Transcurred time '; 'Glass

conductivity '; 'Glass density '; 'Glass Cp ';

'Air conductivity '; 'Air density '; 'Air Cp

'; 'Silica conductivity'; 'Silica density '; 'Silica Cp

'; 'Water Cp '; 'Methanol Cp '; 'Electric

conductiv.'; 'Liquid density '; 'Meth. mass fraction';

'Liquid viscosity '; 'Liquid conductivity'; 'Porosity

'; 'Cooling conductiv. '; 'Air convection coef'; 'Air

viscosity '; 'Electric current '};

xlswrite(filename,variablename,'Parameters','B1:B25');

variablevalue=[U; T_out; T_cool; t_limit; k_g; ro_glass;

Cp_glass; k_air; ro_air; Cp_air; k_sil; ro_sil; Cp_sil;

Cp_water; Cp_methanol; Cond; ro; x_w_m; nu; k_liq; Eps;

k_cool; h_air; nu_air; I_real];

xlswrite(filename,variablevalue,'Parameters','A1:A25');

toc

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

end

set(handles.execute,'enable','off')

msgbox('Parameters Study finished','Done')

else

msgbox('Fixed Size Stencil requires that the number of

points along y-axis to be a multiple of 15. Any natural

number bigger than 1 is valid along z-axis.','Error','warn')

end

end

end

function varargout = Parameters(varargin)

% Last Modified by GUIDE v2.5 19-Jul-2011 05:02:48

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @parameters_OpeningFcn,

...

'gui_OutputFcn', @parameters_OutputFcn,

...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State,

varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Parameters is made visible.

function parameters_OpeningFcn(hObject, eventdata, handles,

varargin)

global ratio k_g Eps k_sil Cp_water Cp_methanol k_air Cp_air

ro_air k_cool

global ro_glass Cp_glass ro_sil Cp_sil Cond ro x_w_m nu k_liq

nu_air

set(handles.k_glass,'string',k_g)

set(handles.ro_glass,'string',ro_glass)

set(handles.Cp_glass,'string',Cp_glass)

set(handles.k_out,'string',k_air)

set(handles.ro_air,'string',ro_air)

set(handles.Cp_air,'string',Cp_air)

set(handles.k_sil,'string',k_sil)

set(handles.ro_sil,'string',ro_sil)

set(handles.Cp_sil,'string',Cp_sil)

set(handles.Cp_water,'string',Cp_water)

set(handles.Cp_methanol,'string',Cp_methanol)

set(handles.Cond,'string',Cond)

set(handles.Eps,'string',Eps)

set(handles.k_cool,'string',k_cool)

set(handles.ro_mix,'string',ro);

set(handles.x_w_m,'string',x_w_m);

set(handles.nu_mix,'string',nu);

set(handles.k_mix,'string',k_liq);

set(handles.nu_air,'string',nu_air);

switch ratio

case 4

set(handles.popup_ratio,'value',1)

case 6

set(handles.popup_ratio,'value',2)

case 8

set(handles.popup_ratio,'value',3)

case 'Other'

set(handles.popup_ratio,'value',4)

end

% Choose default command line output for parameters

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% --- Outputs from this function are returned to the command

line.

function varargout = parameters_OutputFcn(hObject, eventdata,

handles)

varargout{1} = handles.output;

% --- Executes on button press in push_std.

function push_std_Callback(hObject, eventdata, handles)

global k_g_std Eps_std k_sil_std Cp_water_std Cp_methanol_std

k_air_std

global Cp_air_std ro_air_std k_cool_std ro_glass_std

Cp_glass_std

global ro_sil_std Cp_sil_std Cond_std nu_air_std

set(handles.k_glass,'string',num2str(k_g_std))

set(handles.ro_glass,'string',num2str(ro_glass_std))

set(handles.Cp_glass,'string',num2str(Cp_glass_std))

set(handles.k_out,'string',num2str(k_air_std))

set(handles.ro_air,'string',num2str(ro_air_std))

set(handles.Cp_air,'string',num2str(Cp_air_std))

set(handles.k_sil,'string',num2str(k_sil_std))

set(handles.ro_sil,'string',num2str(ro_sil_std))

set(handles.Cp_sil,'string',num2str(Cp_sil_std))

set(handles.Cp_water,'string',num2str(Cp_water_std))

set(handles.Cp_methanol,'string',num2str(Cp_methanol_std))

set(handles.Cond,'string',num2str(Cond_std))

set(handles.popup_ratio,'value',2)

set(handles.Eps,'string',num2str(Eps_std))

set(handles.k_cool,'string',num2str(k_cool_std))

set(handles.ro_mix,'string',850)

set(handles.x_w_m,'string',0.8)

set(handles.nu_mix,'string',1.4E-3)

set(handles.k_mix,'string',0.27)

set(handles.ro_mix,'enable','off')

set(handles.x_w_m,'enable','off')

set(handles.nu_mix,'enable','off')

set(handles.k_mix,'enable','off')

set(handles.nu_air,'string',num2str(nu_air_std))

%Executes when change popup_ratio

function popup_ratio_Callback(hObject, eventdata, handles)

switch get(hObject,'Value')

case 1

set(handles.ro_mix,'string',866);

set(handles.x_w_m,'string',0.735);

set(handles.nu_mix,'string',1.6E-3);

set(handles.k_mix,'string',0.29);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 2

set(handles.ro_mix,'string',850);

set(handles.x_w_m,'string',0.8);

set(handles.nu_mix,'string',1.4E-3);

set(handles.k_mix,'string',0.27);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 3

set(handles.ro_mix,'string',840);

set(handles.x_w_m,'string',0.84);

set(handles.nu_mix,'string',1.25E-3);

set(handles.k_mix,'string',0.26);

set(handles.ro_mix,'enable','off');

set(handles.x_w_m,'enable','off');

set(handles.nu_mix,'enable','off');

set(handles.k_mix,'enable','off');

case 4

set(handles.ro_mix,'string','');

set(handles.x_w_m,'string','');

set(handles.nu_mix,'string','');

set(handles.k_mix,'string','');

set(handles.ro_mix,'enable','on');

set(handles.x_w_m,'enable','on');

set(handles.nu_mix,'enable','on');

set(handles.k_mix,'enable','on');

end

% --- Executes on button press in push_apply.

function push_apply_Callback(hObject, eventdata, handles)

global ratio k_g Eps k_sil Cp_water Cp_methanol k_air Cp_air

ro_air k_cool

global ro_glass Cp_glass ro_sil Cp_sil Cond ro x_w_m nu k_liq

nu_air

switch get(handles.popup_ratio,'value')

case 1

ratio=4;

case 2

ratio=6;

case 3

ratio=8;

case 4

ratio='Other';

end

k_g=str2double(get(handles.k_glass,'string'));

ro_glass=str2double(get(handles.ro_glass,'string'));

Cp_glass=str2double(get(handles.Cp_glass,'string'));

k_air=str2double(get(handles.k_out,'string'));

ro_air=str2double(get(handles.ro_air,'string'));

Cp_air=str2double(get(handles.Cp_air,'string'));

k_sil=str2double(get(handles.k_sil,'string'));

ro_sil=str2double(get(handles.ro_sil,'string'));

Cp_sil=str2double(get(handles.Cp_sil,'string'));

Cp_water=str2double(get(handles.Cp_water,'string'));

Cp_methanol=str2double(get(handles.Cp_methanol,'string'));

Cond=str2double(get(handles.Cond,'string'));

ro=str2double(get(handles.ro_mix,'string'));

x_w_m=str2double(get(handles.x_w_m,'string'));

nu=str2double(get(handles.nu_mix,'string'));

k_liq=str2double(get(handles.k_mix,'string'));

Eps=str2double(get(handles.Eps,'string'));

k_cool=str2double(get(handles.k_cool,'string'));

nu_air=str2double(get(handles.nu_air,'string'));

if isnan(k_g) || isnan(ro_glass) || isnan(Cp_glass) ||

isnan(k_air) || isnan(ro_air) || isnan(Cp_air) ||

isnan(k_sil) || isnan(ro_sil) || isnan(Cp_sil) ||

isnan(Cp_water) || isnan(Cp_methanol) || isnan(Cond) ||

isnan(ro) || isnan(x_w_m) || isnan(nu) || isnan(k_liq) ||

isnan(Eps) || isnan(k_cool) || isnan(nu_air)

msgbox('Please, make sure all fields are specified, or

the simulation will not run properly','Error','warn')

else

close

end

% --- Executes on button press in push_cancel.

function push_cancel_Callback(hObject, eventdata, handles)

close

function varargout = Options(varargin)

% Last Modified by GUIDE v2.5 19-Jul-2011 04:44:52

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @Options_OpeningFcn, ...

'gui_OutputFcn', @Options_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State,

varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Options is made visible.

function Options_OpeningFcn(hObject, eventdata, handles,

varargin)

global ny nz popstencil k_mixcalc h_air

set(handles.ny,'string',num2str(ny))

set(handles.nz,'string',num2str(nz))

set(handles.popup_stencil,'value',popstencil)

set(handles.h_air,'string',h_air)

if ny==52

set(handles.ny,'enable','off')

set(handles.nz,'enable','off')

else

set(handles.ny,'enable','on')

set(handles.nz,'enable','on')

end

if k_mixcalc==2

set(handles.simpave,'value',1)

end

% Choose default command line output for Options

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% --- Outputs from this function are returned to the command

line.

function varargout = Options_OutputFcn(hObject, eventdata,

handles)

varargout{1} = handles.output;

% --- Executes on selection change in popup.

function popup_stencil_Callback(hObject, eventdata, handles)

switch get(handles.popup_stencil,'value')

case 1

set(handles.ny,'enable','on')

set(handles.nz,'enable','on')

case 2

set(handles.ny,'enable','off')

set(handles.nz,'enable','off')

set(handles.ny,'string',52)

set(handles.nz,'string',44)

end

% --- Executes on button press in push_apply.

function push_apply_Callback(hObject, eventdata, handles)

global ny nz dy dz dx y z x k_mix k_liq k_sil Eps popstencil

k_mixcalc

global Cp_air nu_air k_air Length h_air

if get(handles.popup_stencil,'value')==2 ||

(get(handles.popup_stencil,'value')==1 &&

str2double(get(handles.ny,'string'))>0 &&

str2double(get(handles.nz,'string'))>0 &&

mod(str2double(get(handles.ny,'string')),15)==0)

if get(handles.volint,'value')==1

R=30E-6; %Particle radio, m

dr=1E-7;

r=0;

area_k=0;

i=1;

while r<=R

func(i)=r/((R-(R^2-r^2)^0.5)/k_liq+(R^2-

r^2)^0.5/k_sil); %Function for integration

if i>1

increase=func(i-1)*dr+(func(i)-func(i-1))*dr/2;

area_k=area_k+increase;

end

i=i+1;

r=r+dr;

end

k_mix=(2/R)*area_k;

k_mixcalc=1;

else

k_mix=k_liq*Eps+k_sil*(1-Eps);

k_mixcalc=2;

end

if get(handles.estimate_kair,'value')==1

Pr_air=Cp_air*nu_air/k_air;

Gr_air=(9.81*3.43E-3*6*Length^3)/((15.11E-6)^2);

Nu_air=0.68+(0.67*(Pr_air*Gr_air)^0.25)/((1+(0.492/Pr_air)^(9

/16))^(4/9));

h_air=k_air*Nu_air/Length;

else

h_air=str2double(get(handles.h_air,'string'));

end

ny=str2double(get(handles.ny,'string'));

nz=str2double(get(handles.nz,'string'));

switch get(handles.popup_stencil,'value')

case 1

dy=0.015/ny;

dz=0.2/nz;

dx=0.065;

y=0:dy:0.015; % Y position vector, m

z=0:dz:0.2; % Z position vector, m

x=0:dx:0.065;

popstencil=1;

close

case 2

dy=0.00025;

dz=0.004;

dx=0.065;

x=0:dx:0.065;

y=[0 dy/2 dy:dy:4*dy 6*dy 8*dy:3*dy:32*dy 34*dy

36*dy:dy:39*dy 39.5*dy 40*dy:dy/4:44*dy 44.5*dy

45*dy:dy:48*dy 50*dy:2*dy:56*dy 57*dy:dy:59*dy 59.5*dy

60*dy];

z=[0 dz/10 dz/5:dz/5:dz 1.5*dz:0.5*dz:10*dz

11*dz:dz:19*dz 20*dz:3*dz:50*dz];

popstencil=2;

close

end

else

msgbox('For using Fixed Size Stencil, the value of

variable ny must be a multiple of 15','Error','warn')

end

% --- Executes on button press in push_cancel.

function push_cancel_Callback(hObject, eventdata, handles)

close

% --- Executes on selection change in h_calc.

function h_calc_SelectionChangeFcn(hObject, eventdata,

handles)

if get(handles.estimate_kair,'value')==1

set(handles.h_air,'enable','off')

set(handles.h_air,'string','')

else

set(handles.h_air,'enable','on')

end

% --- Executes on selection change in k_calc.

function k_calc_SelectionChangeFcn(hObject, eventdata,

handles)

function varargout = Graphics(varargin)

% Last Modified by GUIDE v2.5 20-Jul-2011 06:20:24

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @Graphics_OpeningFcn,

...

'gui_OutputFcn', @Graphics_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State,

varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Graphics is made visible.

function Graphics_OpeningFcn(hObject, eventdata, handles,

varargin)

global T ny nz data

T_data=zeros(ny,nz);

for j=1:ny

for k=1:nz

T_data(j,k)=T(j,k,1);

end

end

data=0;

set(handles.table_temp,'Data',T_data(:,:))

set(handles.block,'visible','on')

data=[0;0];

set(handles.table_graph,'Data',data)

% Choose default command line output for Graphics

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% --- Outputs from this function are returned to the command

line.

function varargout = Graphics_OutputFcn(hObject, eventdata,

handles)

varargout{1} = handles.output;

% --- Executes on selection change in popup.

function popup_Callback(hObject, eventdata, handles)

subplot(handles.figure);title('');xlabel('');ylabel('')

cla

set(handles.add,'enable','off')

set(handles.add,'value',0)

data=[0;0];

set(handles.table_graph,'Data',data)

switch get(hObject,'value')

case 1

set(handles.block,'visible','on')

set(handles.line,'visible','off')

set(handles.setj,'visible','off')

set(handles.setk,'visible','off')

set(handles.k,'enable','on')

set(handles.j,'enable','on')

case 2

set(handles.block,'visible','off')

set(handles.line,'visible','on')

set(handles.setj,'visible','on')

set(handles.setk,'visible','on')

set(handles.setj,'value',1)

set(handles.setk,'value',0)

set(handles.j,'string','')

set(handles.k,'string','')

set(handles.k,'enable','off')

end

% --- Executes during object creation, after setting all

properties.

function popup_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in represent.

function represent_Callback(hObject, eventdata, handles)

global T Temp time y z ny nz pp data

j=str2double(get(handles.j,'string'));

k=str2double(get(handles.k,'string'));

if get(handles.popup,'value')==2 || (~isnan(j) && ~isnan(k)

&& j>0 && j<=ny && k>0 && k<=nz && mod(j,1)==0 &&

mod(k,1)==0)

if (~isnan(j) && j>0 && j<=ny && mod(j,1)==0) ||

(~isnan(k) && k>0 && k<=nz && mod(k,1)==0)

if get(handles.add,'value')==0

hold off

data=[j;k];

color='blue';

col=1;

else

hold on

[row,col]=size(data);

data(1,col+1)=j;

data(2,col+1)=k;

if mod(col+4,5)==0

color='green';

elseif mod(col+3,5)==0

color='red';

elseif mod(col+2,5)==0

color='yellow';

elseif mod(col+1,5)==0

color='black';

elseif mod(col,5)==0

color='blue';

end

end

switch get(handles.popup,'value')

case 1

for i=1:pp

Temp_plot(i)=Temp(j,k,i);

time_(i)=time(i);

end

plot(time_,Temp_plot,'Color',color);title('Temperature over

time');xlabel('Time (s)');ylabel('Temperature (ºC)')

case 2

if get(handles.setj,'value')==1

j=str2double(get(handles.j,'string'));

for k=1:nz

Temp_plot(k)=T(j,k,1);

end

Z=z(1:nz)+diff(z)/2;

plot(Z,Temp_plot);title('Temperature along z-

axis');xlabel('z (m)');ylabel('Temperature (ºC)')

else

k=str2double(get(handles.k,'string'));

for j=1:ny

Temp_plot(j)=T(j,k,1);

end

Y=y(1:ny)+diff(y)/2;

plot(Y,Temp_plot);title('Temperature along y-

axis');xlabel('y (m)');ylabel('Temperature (ºC)')

end

end

set(handles.add,'enable','on')

set(handles.table_graph,'Data',data(:,:))

if col==4

set(handles.add,'enable','off')

set(handles.add,'value',0)

end

else

msgbox('Not a valid value of j or k','Input

error','error')

end

else

msgbox('Not a valid value of j or k','Input

error','error')

end

% --- Executes on button press in clear.

function clear_Callback(hObject, eventdata, handles)

subplot(handles.figure);title('');xlabel('');ylabel('')

cla

set(handles.add,'enable','off')

set(handles.add,'value',0)

% --- Executes on button press in add.

function add_Callback(hObject, eventdata, handles)

% --- Executes on button press in setj.

function setj_Callback(hObject, eventdata, handles)

if get(hObject,'value')==1

set(handles.setk,'value',0)

set(handles.k,'enable','off')

set(handles.k,'string','')

set(handles.j,'enable','on')

end

if get(hObject,'value')==0

set(handles.setk,'value',1)

set(handles.k,'enable','on')

set(handles.j,'string','')

set(handles.j,'enable','off')

end

% --- Executes on button press in setk.

function setk_Callback(hObject, eventdata, handles)

if get(hObject,'value')==1

set(handles.setj,'value',0)

set(handles.j,'enable','off')

set(handles.j,'string','')

set(handles.k,'enable','on')

end

if get(hObject,'value')==0

set(handles.setj,'value',1)

set(handles.j,'enable','on')

set(handles.k,'string','')

set(handles.k,'enable','off')

end

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

close

% --- Executes on button press in export_excel.

function export_excel_Callback(hObject, eventdata, handles)

global Eps Cp_water Cp_methanol k_cool ro_glass Cp_glass

ro_sil ro_air

global Cp_sil Cond ro x_w_m U T_out T_cool ny nz t_limit T

k_g k_air Cp_air

global k_sil nu k_liq h_air nu_air

answer=inputdlg('Input the Excel file name','Export');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

filename=['Save_data

answer.name];

for j=1:ny

for k=1:nz

T_(j+1,k+1)=T(j,k,1);

T_(1,k+1)=k;

T_(j+1,1)=j;

end

end

xlswrite(filename,T_,'Temperature')

variablename={'Potential applied '; 'Air temperature

'; 'Cooling temperature'; 'Transcurred time '; 'Glass

conductivity '; 'Glass density '; 'Glass Cp ';

'Air conductivity '; 'Air density '; 'Air Cp

'; 'Silica conductivity'; 'Silica density '; 'Silica Cp

'; 'Water Cp '; 'Methanol Cp '; 'Electric

conductiv.'; 'Liquid density '; 'Meth. mass fraction';

'Liquid viscosity '; 'Liquid conductivity'; 'Porosity

'; 'Cooling conductiv. '; 'Air convection coef'; 'Air

viscosity '};

xlswrite(filename,variablename,'Parameters','B1:B24');

variablevalue=[U; T_out; T_cool; t_limit; k_g; ro_glass;

Cp_glass; k_air; ro_air; Cp_air; k_sil; ro_sil; Cp_sil;

Cp_water; Cp_methanol; Cond; ro; x_w_m; nu; k_liq; Eps;

k_cool; h_air; nu_air];

xlswrite(filename,variablevalue,'Parameters','A1:A24');

end

% --- Executes on button press in save_case.

function save_case_Callback(hObject, eventdata, handles)

answer=inputdlg('Save as:','Save');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

filename=['Save_data

answer.name];

saveas(handles.graphics,filename,'fig')

end

% --- Executes on button press in save_image.

function save_image_Callback(hObject, eventdata, handles)

answer=inputdlg('Save as:','Save');

fields='name';

if ~isempty(answer)

answer=cell2struct(answer,fields);

filename=['Save_data