| Author |
Comment/Response |
Fraser
|
04/04/12 6:56pm
I'm struggling to recreate a MatLab file in Mathematica. While it is extremely basic, I'm unable to replicate the numerical integration in Mathematica.
Would someone be able to give me some pointers?
The MatLab file is attached, but the text is below.
Thank-you for any assistance / pointers.
Fraser
% APOLLO 13 SEPARATION
clear all
%DEFINITIONS
%D,L0 diameter and length of tunnel
%m1,m2 masses of CM and LM
%p0,rho0,T0 initial state of tunnel gas
%astar,rhostar, choked flow sound speed and density
%m=mass of gas in tunnel
%v1,v2 speeds of the CM and LM
%x separation distance
% DC discharge coefficient
%DATA
D= 1.29;%m
L0=0.54; %m
m2= 4547;%kg
m1= 5809;%kg
DC=0.85
R=259.8;%J/kg/degK
gamma=1.4; % for O2
T0= 223;%degK
p0= 1.34E4;% N/m^2; approx 2psi
rho0=p0/R/T0; %kg/m^3; approx 2/10 atm
rhostar=.6339*rho0;
astar=17.41*sqrt(T0);%m/s
%INITIAL VALUES
p=p0;
x=0;
S=0;
A = pi*D^2/4;
v1=0;
v2=0;
V0=A*L0;
m0=rho0*V0;
m=m0
N=1;
t(N)=0;
X(N)=0
%SOLVE EQUATIONS
A = pi*D^2/4;
f=p*A;
v1dot = f/m1;
v2dot=f/m2;
xdot=v1+v2;
V=V0+A*x;
Vdot=A*xdot;
mdot=-DC*S*rhostar*astar;
dt=.001; %sec.
%stop
while p/p0>.01
f=p*A;
v1dot = f/m1;
v1=v1+v1dot*dt;
v2dot=f/m2;
v2=v2+v2dot*dt;
xdot=v1+v2;
x=x+xdot*dt;
S=pi*D*x;
mdot=-DC*S*rhostar*astar;
m=m+mdot*dt;
rho=m/V;
p=p0*(rho/rho0)^gamma;%adiabatic expansion
v(N)=v1+v2;
P(N)=p;
X(N)=x;
XX=10*X;
t(N)=N*dt;
N=N+1;
end
v(N-1)
hold off
figure(1);
plot(t',P/p0')
xlabel('TIME,sec.')
ylabel('PRESSURE, p/p0')
figure(2)
hold off
plot(t',v');
xlabel('TIME,sec.')
ylabel('VELOCITY, m/s')
text (150,0.4 ,'x=5.25 cm.')
figure (3)
plot(t',v', t',P/p0', t',XX, 'linewidth',4)
xlabel('TIME,sec.')
text(0.09,0.58,'SEPARATION ')
text (0.09,0.53, 'SPEED, m/s.' )
text(0.09,0.39,'(SEPARATION ')
text (0.09,0.34, 'DIST.)/10, cm.' )
text(0.06,0.75, 'PRESSURE, p/po')
title('APOLLO13-LUNAR MODULE SEPARATION;p0=2psi')
Attachment: Apollo 13.m, URL: , |
|