function varargout = faxinyundong(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @faxinyundong_OpeningFcn, ...
'gui_OutputFcn', @faxinyundong_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
function faxinyundong_OpeningFcn(hObject, eventdata, handles, varargin)
guidata(hObject, handles);
function varargout = faxinyundong_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
global J
global dt
global UU
global XX
global MM_3
global PP
M_f=str2num(cell2mat(get(handles.edit1,'string')));
K_s=str2num(cell2mat(get(handles.edit3,'string')));
z_0=str2num(cell2mat(get(handles.edit2,'string')));
c=20;str2num(cell2mat(get(handles.edit4,'string')));
V_0=str2num(cell2mat(get(handles.edit5,'string')));
D_in=str2num(cell2mat(get(handles.edit6,'string')));
S_in=pi*D_in^2/4;%入口面积,腔内面积
D_out=str2num(cell2mat(get(handles.edit7,'string')));
S_out=pi*D_out^2/4;%出口面积
Cq_1=str2num(cell2mat(get(handles.edit8,'string')));
Cq_2=str2num(cell2mat(get(handles.edit9,'string')));
R=str2num(cell2mat(get(handles.edit10,'string')));
M_r=str2num(cell2mat(get(handles.edit11,'string')));
k=str2num(cell2mat(get(handles.edit12,'string')));
Rg=R/M_r;%气体常数
Cp=Rg*k/(k-1);%等压比热
P=str2num(cell2mat(get(handles.edit13,'string')));
P_1=str2num(get(handles.edit18,'string'));
T_1=str2num(get(handles.edit17,'string'));
T=str2num(cell2mat(get(handles.edit14,'string')));
T_2=str2num(cell2mat(get(handles.edit15,'string')));
P_2=str2num(cell2mat(get(handles.edit16,'string')));
t=0; %将运行时长赋予0
a=0; %加速度为0
U=0; %速度为0
X=0; %位移为0
J=0; %设置一个数,每运行一次+1,方便将每次的结果按顺序储存以作图
M_3=P*V_0/Rg/T_1; %初始腔内质量
dt=0.00001;%计算步长
flag1=true;
while flag1 %仅在位移小于0时停止循环
J=J+1; %利用此数,使得每运行一次的结果存入矩阵下一位
a=(P*S_in-c*U-K_s*(X+z_0))/M_f; %计算加速度变化量
dX=U*dt+1/2*a*dt^2;%计算位移变化量,因为此时位移为上一段速度,故先算
X=X+dX; %计算位移
XX(J)=X;%将位移存入矩阵第J位
dU=a*dt; %计算速度变化量
U=U+dU; %计算速度
UU(J)=U;%将速度存入矩阵第J位
if (P/P_2)>(2/(k+1))^(k/(k-1))%计算入口气体流量
C_m1=sqrt(2*k*((P/P_2)^(2/k)-(P/P_2)^((k+1)/k))/Rg/(k-1));
else
C_m1=sqrt(k*(2/(k+1))^((k+1)/(k-1))/Rg);
end
if (P_2/P)>(2/(k+1))^(k/(k-1))%计算出口气体流量
C_m2=sqrt(2*k*((P_2/P)^(2/k)-(P_2/P)^((k+1)/k))/Rg/(k-1));
else
C_m2=sqrt(k*(2/(k+1))^((k+1)/(k-1))/Rg);
end
m_1=S_in*Cq_1*C_m1*P_2/sqrt(T_1);%腔内流入气体质量
mm_1(J)=m_1;%腔内流入气体质量储存矩阵
m_2=S_out*Cq_2*C_m2*P_2/sqrt(T);%腔内流出气体质量
mm_2(J)=m_2;%腔内流出气体质量储存矩阵
dp=k*(Rg*T_1*m_1/V_0-Rg*T*m_2/V_0+P*S_in*U/V_0);%腔内压强变化量
P=P+dp;%腔内压强
PP(J)=P;%腔内压强储存矩阵
M_3=M_3+m_1-m_2;%腔内气体质量
MM_3(J)=M_3;%腔内气体质量储存矩阵
dT=(Cp*T_1*m_1-Cp*T*m_1+P*U*S_in+Rg*T*(m_1-m_2))/(M_3*Cp-M_3*Rg);%腔内温度变化量
T=T+dT;%腔内温度
TT(J)=T;%腔内温度储存矩阵
if X<0||X==0%若位移小于等于0,停止循环
flag1=false;
end
end
TTT=(dt:dt:dt*J)';
array=([TTT UU' XX' MM_3' PP']);
set(handles.uitable1,'Data',array);
function pushbutton2_Callback(hObject, eventdata, handles)
faxinyundong_1
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
function edit3__CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
function edit5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
function edit7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
function edit8_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
function edit9_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
function edit10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
function edit11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
function edit12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit13_Callback(hObject, eventdata, handles)
function edit13_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit14_Callback(hObject, eventdata, handles)
function edit14_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit15_Callback(hObject, eventdata, handles)
function edit15_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit16_Callback(hObject, eventdata, handles)
function edit16_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit17_Callback(hObject, eventdata, handles)
function edit17_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit18_Callback(hObject, eventdata, handles)
function edit18_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObj