numerical supersonic aerodynamics of the soyuz/st rocket ...jurzay/soyuzsimulation.pdfsoyuz/st...
TRANSCRIPT
Numerical Supersonic Aerodynamics of the
Soyuz/ST Rocket Fairing
Javier Urzay
2nd November 2004
Abstract
The supersonic blunt-body problem is one of the most classical challenges in CFDof compressible flows. The change of mathematical behavior of the Euler equationsacross transonic flow zones made impossible its solution until a time-dependent ap-proach was first proposed by Moretti and Abbett [1]. The time-dependent approachis based on integrating the unsteady conservation equations until a steady solutionis achieved. In this study, a similar method is employed to compute the solutionof the full Navier-Stokes equations around a rocket fairing using a time-dependentapproach with an explicit method that is second-order accurate in space and time.The grid reproduces the geometry of the rocket fairing and is generated using an ellip-tic transform, which requires integration of two non-linearly coupled elliptic equations.
1 The Soyuz Payload Fairing
The type-ST fairing of the Soyuz rocket consists of a two-halves shell carbon-fiber rein-forced plastic structure [2]. The fairing hosts payloads such as satellites or other spaceinstrumentation. The fairing structure is a cylindrical body attached to a blunt nose thatenables a detached shock and prevents strong aerodynamic heating of the payload. Ithas a 4.110 m external diameter and provides the largest available volume for spacecraftaccommodation in the Soyuz Launch Vehicles family. The Soyuz rocket is based on theoriginal design of Sergei Korolev of the R-7A rocket that put the Sputnik Satellite intoorbit in 1957. A complete family of rockets followed after that included Vostok, Molniya,Voskhod and finally the four-stage Soyuz, which is employed widely in manned and un-manned space missions by the European Space Agency (E.S.A.). The main manufacturersand partner organizations are the Russian Aviation and Space Agency (ROSAVIACOS-MOS), the European Aeronautics, Defense, and Space Company (E.A.D.S), the SamaraSpace Center (TsSKB-Progress) and ArianeSpace.
1
Figure 1: Schematic Soyuz/ST rocket. The spacecraft consists of four stages: Boosters, Core Stage, 3rd Stage, andFregat Upper Stage. The payload fairing sits on top of the rocket hosting the upper stage and satellite payload.
2
2 Grid Generation: The Elliptic Transform
The detailed geometry of the fairing is displayed schematically in figure 2.
Figure 2: Dimensions (mm) of the payload fairing.
Because of the relatively complex geometry, the most appropriate method for con-structing the grid is the elliptic transform. This method solves the coordinates {x, y}as a function of transformed coordinates variables {ξ, η}, whose space corresponds to arectangular domain. To do so, the coupled elliptic and strongly non-linear equations
α∂2x
∂ξ2− 2β
∂2x
∂ξ∂η+ γ
∂2x
∂η2= −
(∂x∂ξ
∂y
∂η− ∂x
∂η
∂y
∂ξ
)2(∂x∂ξP +
∂x
∂ηQ)
α∂2y
∂ξ2− 2β
∂2y
∂ξ∂η+ γ
∂2y
∂η2= −
(∂x∂ξ
∂y
∂η− ∂x
∂η
∂y
∂ξ
)2(∂y∂ξP +
∂y
∂ηQ)
need to be integrated, where the coefficients are given by
α =(∂x∂η
)2+(∂y∂η
)2
β =∂x
∂ξ
∂x
∂η+∂y
∂ξ
∂y
∂η
γ =(∂x∂ξ
)2+(∂y∂ξ
)2.
The functions P and Q force the grid points to be clustered around a point or a line,respectively. In the present configuration, the mesh is forced to be squeezed around theinternal boundary corresponding to the fairing surface, with Q being given by
Q(η) = c · sign(η − ηmin)e−d·|η−ηmin|.
A Gauss-Seidel iteration and a 2nd order accurate discretization in space are employed tosolve the set of elliptic differential equations. The resulting grid is shown in figure 3, whilefigure 4 shows the clustering of points near the neighborhood of the nose to capture theboundary layer.
3
Figure 3: Elliptic grid of the payload fairing (m).
Figure 4: Zoom around the leading nose showing the clustered grid points.
4
3 The Navier-Stokes Equations in Generalized Coordinates
3.1 Formulation
Given the coordinate transformation
x = x(ξ, η)y = y(ξ, η)
the Jacobian J(ξ, η) is defined as
J ≡ ∂(x, y)
∂(ξ, η)≡
∣∣∣∣∣∣∣∣∣∂x
∂ξ
∂y
∂ξ
∂x
∂η
∂y
∂η.
∣∣∣∣∣∣∣∣∣An appropriate change of partial differential operators must be made according to the
change of variables
∂(ϕ)
∂y=
1
J
[(∂y∂η
)∂(ϕ)
∂ξ−(∂y∂ξ
)∂(ϕ)
∂η
]∂(ϕ)
∂x=
1
J
[(∂x∂ξ
)∂(ϕ)
∂η−(∂x∂η
)∂(ϕ)
∂ξ
]for any fluid variable ϕ.
The gas is assumed to be ideal and calorically perfect, with a constant Prandtl numberand temperature-dependent viscosity and thermal conductivity. Using the coordinatetransformation above, the Navier-Stokes equations can be written as
Continuity:
∂ρ
∂t+
1
J
[(∂y∂η
) ∂∂ξ
(ρu)−(∂y∂ξ
) ∂∂η
(ρu) +(∂x∂ξ
) ∂∂η
(ρv)−(∂x∂η
) ∂∂ξ
(ρv)]
= 0 (1)
x-Momentum:
∂
∂t(ρu) +
1
J
[(∂y∂η
) ∂∂ξ
(ρu2 + P − τxx)−(∂y∂ξ
) ∂∂η
(ρu2 + P − τxx)+
+(∂x∂ξ
) ∂∂η
(ρuv − τxy)−(∂x∂η
) ∂∂ξ
(ρuv − τxy)]
= 0 (2)
y-Momentum:
∂
∂t(ρv) +
1
J
[(∂y∂η
) ∂∂ξ
(ρuv − τxy)−(∂y∂ξ
) ∂∂η
(ρuv − τxy)+
+(∂x∂ξ
) ∂∂η
(ρv2 + P − τyy)−(∂x∂η
) ∂∂ξ
(ρv2 + P − τyy)]
= 0 (3)
5
Total Energy:
∂
∂t
[ρ
(e+|v|2
2
)]+
1
J
{(∂y∂η
) ∂∂ξ
[ρ(e+|v|2
2+P
ρ
)u+ qx − uτxx − vτxy
]−(∂y∂ξ
) ∂∂η
[ρ(e+|v|2
2+P
ρ
)u+ qx − uτxx − vτxy
]+
+(∂x∂ξ
) ∂∂η
[ρ(e+|v|2
2+P
ρ
)v + qy − uτxy − vτyy
]−(∂x∂η
) ∂∂ξ
[ρ(e+|v|2
2+P
ρ
)v + qy − uτxy − vτyy
]}= 0 (4)
Equation of State:
P = ρRgT (5)
Local Thermodynamic Equilibrium:
e = cvT (6)
Fourier’s Law:
qx = −k(T )
J
[(∂y∂η
)∂T∂ξ−(∂y∂ξ
)∂T∂η
](7)
qy = −k(T )
J
[(∂x∂ξ
)∂T∂η−(∂x∂η
)∂T∂ξ
](8)
Poisson’s Law:
τxx =2
3
µ(T )
J
[2(∂y∂η
)∂u∂ξ− 2(∂y∂ξ
)∂u∂η
+(∂x∂η
)∂v∂ξ−(∂x∂ξ
)∂v∂η
](9)
τyy =2
3
µ(T )
J
[2(∂x∂ξ
)∂v∂η− 2(∂x∂η
)∂v∂ξ
+(∂y∂ξ
)∂u∂η−(∂y∂η
)∂v∂ξ
](10)
τxy =µ(T )
J
[(∂x∂ξ
)∂u∂η−(∂x∂η
)∂u∂ξ
+(∂y∂η
)∂v∂ξ−(∂y∂ξ
)∂v∂η
](11)
where the second coefficient of viscosity is calculated from the Stokes’ approximationλ = −2
3µ. Additionally, the dynamic viscosity and thermal conductivity variations aregiven by the Sutherland’s Law and the constant Prandtl-number assumption,
µ(T ) = µo
( T
Tref
)3/2Tref + 110
T + 110(12)
k(T ) =µ(T )cpPr
. (13)
6
The system 1-13 represents the full set of conservation equations required to solvethe problem. For numerical integration purposes, it is expedient to reformulate theseequations in terms of the principal fluxes φ , E and F, namely [4]
φ =
ρρuρv
ρ(e+ v2
2
) (14)
E=
ρuρu2 + P − τxxρuv − τxyρ(e+ v2
2 + Pρ
)u+ qx − uτxx − vτxy
(15)
F =
ρvρuv − τxyρv2 + P − τyyρ(e+ v2
2 + Pρ
)v + qy − uτxy − vτyy
. (16)
In these variables, the Navier-Stokes equations become
∂φ
∂t+
1
J
[(∂y∂η
)∂E∂ξ−(∂y∂ξ
)∂E∂η
]+
1
J
[(∂x∂ξ
)∂F∂η−(∂x∂η
)∂F∂ξ
]= 0. (17)
Equation 17 represents the system of conservation equations written in strong conser-vative form, which facilitates the numerical treatment of the shock discontinuities. Theseconsist of discontinuities in the primitive variables ρ, v, P and T , whose values are notdefined at the shock. Conversely, the flux variables E and F are conserved through theshock as prescribed by the integral form of the conservation equations across. As a re-sult, the strong conservative form 17 enhances numerical stability despite the inherentdiscontinuities in the primitive variables.
3.2 Boundary Conditions
The boundary conditions are shown schematically in figure 5.
3.3 Numerical Formulation
A second-order accurate Mac’Cormack’s explicit method is employed to transform (17)into a finite-differences form. The principal flux φ at time t+ ∆t is given by
φt+∆ti,j = φti,j +
1
2
[(∂φ∂t
)ti,j
+( ∂φ∂t
)t+∆t
i,j
](18)
corresponding to a predictor-corrector set. The average derivative in time is composed bytwo terms, namely
(∂φ∂t
)ti,j
=φt+∆ti,j − φti,j
∆t=
1
Ji,j
[(∂y∂η
)i,j
Eti+1,j −Eti,j∆ξ
−(∂y∂ξ
)i,j
Eti,j+1 −Eti,j∆η
]+
+1
Ji,j
[(∂x∂ξ
)i,j
Fti,j+1 − Fti,j∆η
−(∂x∂η
)i,j
Fti+1,j − Fti,j∆ξ
](19)
which represents the linearization of the time derivative at stage t, where both E and F
7
Figure 5: Boundary conditions. The free stream is characterized by the velocity, pressure, temperature and twothermodynamic coefficients. A non-slip condition is used on the fairing surface. The outgoing boundaries employinterpolation from the internal flow field.
are known. The symbol φt+∆ti,j is the predicted flux at step t + ∆t. The above numerical
derivative can be computed from the known step-t conditions. Once the primary variablesρ, u, v, T and the physical properties are predicted, the predicted fluxes E and F are usedfor the corrector derivative,
( ∂φ∂t
)t+∆t
i,j=
1
Ji,j
[(∂y∂η
)i,j
Et+∆t
i,j − Et+∆t
i−1,j
∆ξ−(∂y∂ξ
)i,j
Et+∆t
i,j − Et+∆t
i,j−1
∆η
]+
+1
Ji,j
[(∂x∂ξ
)i,j
Ft+∆t
i,j − Ft+∆t
i,j−1
∆η−(∂x∂η
)i,j
Ft+∆t
i,j − Ft+∆t
i−1,j
∆ξ
]. (20)
The combination of (18), (19) and (20) gives
φt+∆ti,j =
1
2
{φti,j + φt+∆t
i,j +1
Ji,j
[(∂y∂η
)i,j
Et+∆t
i,j − Et+∆t
i−1,j
∆ξ−(∂y∂ξ
)i,j
Et+∆t
i,j − Et+∆t
i,j−1
∆η
]+
+1
Ji,j
[(∂x∂ξ
)i,j
Ft+∆t
i,j − Ft+∆t
i,j−1
∆η−(∂x∂η
)i,j
Ft+∆t
i,j − Ft+∆t
i−1,j
∆ξ
]}(21)
which represents the solution of the principal flux φ in space and time. In order to conservethe second-order accuracy of the numerical method, the shear stresses and heat fluxes arecomputed with second-order central differences.
3.4 CFL Number
A CFL condition for numerical stability is required. This is implemented using two typesof time integration intervals depending on which velocity component is considered, namely
8
∆t1(i,j) =Ji,j
|u · xξ|i,j + |v · yξ|i,j + ai,j√|xξ|2i,j + |yξ|2i,j
and
∆t2(i,j) =Ji,j
|u · xη|i,j + |v · yη|i,j + ai,j√|xη|2i,j + |yη|2i,j
where a is the speed of sound. The imposed time step is the minimum of the two,
∆t = K ∗min(∆t1(i,j),∆t2(i,j))
where K is the CFL number.
4 Integration Results
4.1 Free-Stream Conditions
In this study, the Mach and Reynolds numbers of the free stream are M∞ = 4.54 andReL∞ = 1214, respectively, based on the characteristic fairing length L (see figure 5). Thissurely is an unrealistic value of the Reynolds number that was chosen as a compromisevalue to reduce computational cost. For simplicity, the wall temperature is assumed to beequal to the free-stream temperature, Tw = T∞.
4.2 Integration Parameters
The time step used in the simulations is of order ∆t = 1·10−4s for a scaled-down version ofthe faring length L = 11.3 cm and with a free stream velocity and temperature U∞ = 1500m/s and T∞ = 270K. The CFL Number is K = 5 · 10−3. Under-relaxation factors fordensity, Velocity and temperature (ωρ = ωu = ωv = ωT = 0.3) are needed along witha small amount of artificial viscosity (see refs. [4] and [5], Cx = Cy = 0.01) to preventnumerical oscillations.
4.3 Aerothermal Variables
The bow shock resulting from the numerical integrations can be observed in figures 6-7-9. Because of the low Reynolds-numbers employed, the numerical dissipation and theplotter interpolation, the shock thickness is probably unreal. Nevertheless, the statictemperature increase downstream from the near-normal portion of the shock front andaround the stagnation point is evident. The boundary layer is shown in figures 6 and8. In subsonic flow, the boundary layer thickness is prone to become thinner as velocityincreases, in part because the layer thickness is proportional to the inverse of the root of
Reynolds Number δ ∼ Re−1/2x . On the other hand, at highly supersonic flows (M ∼ 5)
the the boundary layer becomes thicker due to the increase in temperature and viscositycaused by friction heat. As a result, the boundary layer increases with the Mach numberas δ ∼M2Re−1/2.
9
Figure 6: u/U∞ contours for ReL∞ = 1214 and M∞ =4.54.
Figure 7: T/T∞ (non-dimensional Static Temperature)contours for ReL∞ = 1214 and M∞ = 4.54.
Figure 8: Velocity vectors showing theboundary layer.
4.4 The Sonic Line
If the stream deflection angle is larger than a maximum value that depends on the incomingMach number, a detached shock is the only possible solution of the problem [6]. Theresulting bow shock has 90o incidence angle near the stagnation point, which results ina strong shock wave with subsonic flow downstream (see figure 10). At larger distancesfrom the blunt nose, the shock degenerates into a Mach wave or weak shock wave. Theflow remains supersonic downstream from this weak shock wave, even though the normallocal Mach number is always smaller than unity as prescribed by the second principle ofthermodynamics. As a result, both subsonic and supersonic conditions occur downstreamof the bow shock. A transition line, namely the sonic line, where the Mach number isunity M = 1.0, separates both regions, as shown in figure 10. The sonic line is convecteddownstream into the boundary layer.
The structure of the conservation equations changes downstream of the bow shock,which has an important effect for the numerical algorithms. In the regions where su-personic flow occurs, the steady compressible Navier-Stokes equations are hyperbolic. Insubsonic conditions, the equations become elliptic. Because of the coexistence of bothflow regions, it was not possible to write any steady code that integrated simultaneouslyboth supersonic and subsonic flow regions. It was in 1966 when Moretti and Abbett devel-oped a time-dependent approach aimed at obtaining a steady solution at long times usinga time-marching procedure. The unsteady compressible Navier-Stokes equations have a
10
Figure 9: Pressure gradient |∇(P/P∞)| contours showingthe shock front and expansion waves about the round cor-ner.
mixed hyperbolic-parabolic behavior, which leads to well-posed integrations even in thepresence of both supersonic and subsonic flow regions.
5 Comparisons with the Rankine-Hugoniot Solution Nearthe Axis.
The Rankine-Hugoniot jump conditions for normal shocks assume inviscid and steadyflows. These are given by
P2
P1= 1 +
2γ
γ + 1(M2
1 − 1) (22)
T2
T1=
(2γM21 − (γ − 1))(2 + (γ − 1)M2
1 )
(γ + 1)2M21
(23)
U2
U1=
2 + (γ − 1)M21
(γ + 1)M21
, (24)
where (1) and (2) are respectively the gas conditions upstream and downstream the bowshock. In the neighborhood of the axis, where the shock is nearly planar, only smalldiscrepancies between the Rankine-Hugoniot jump conditions and the numerical results ofthe previous section are found, which are mainly caused by the numerical viscosity thattends to increase the shock thickness.
11
Figure 10: Local Mach-number contours along with thesonic line (solid black line).
Figure 11: Rankine-Hugoniot values(dotted line) and computational values(solid line) for the P2/P1 ratio acrossthe normal shock.
Figure 12: Rankine-Hugoniot values(dotted line) and computational values(solid line) for the T2/T1 ratio acrossthe normal shock.
Figure 13: Rankine-Hugoniot values(dotted line) and computational values(solid line) for the U2/U1 ratio acrossthe normal shock.
A Code Structure.
12
Figure 14: Code structure.
13
%-------------------------NUMERICAL CODES (MAIN INTEGRATOR AND GRID GENERATOR)---------------------------
%MAIN PROGRAM.
clc; clear; clf; format long; fprintf(’Numerical simulation of the
Soyuz/ST fairing aerodynamics.\n\n’); fprintf(’Mac‘Cormack
Explicit Algorithm.\n\n’); fprintf(’Time-dependent technique for
steady flow approximation.\n\n’); fprintf(’Press any key to read
and check the grid....\n\n’); pause; fprintf(’Reading
grid....\n\n’);
%Reading mesh:
%-----------------
load x.mat x; load y.mat y; load XIi.mat XIi; load ETAi.mat ETAi;
x=x/1e5; y=y/1e5; %escalado a 1/100 de su tama~no original Lefect=11.3 cm;
XI=XIi; ETA=ETAi; [nxi,neta]=size(x); hxi=1; heta=1; n=neta*nxi;
[x_xi,x_eta,y_xi,y_eta,J]=Metrics(x,y,nxi,neta);
fprintf(’Number of grid points...\n’); disp([n]); fprintf(’Number
of iso-eta lines...\n’); disp([neta]); fprintf(’Number of iso-xi
lines...\n’); disp([nxi]);
figure(1); hold on; title(’Fairing Grid: Elliptic Transform’);
xlabel(’x’); ylabel(’y’); plot(x(1,:),y(1,:));
plot(x(nxi,:),y(nxi,:)); plot(x(:,1),y(:,1));
plot(x(:,neta),y(:,neta)); for i=2:nxi-1; plot(x(i,:),y(i,:)); end
for j=2:neta-1; plot(x(:,j),y(:,j)); end pause(1); hold off;
fprintf(’Done. Grid displayed in figure(1).\n\n’) fprintf(’Press
enter key to read initial conditions...\n\n’); pause;
%Initial conditions:
%-------------------------
fprintf(’Reading initial conditions...\n\n’);
[u, v, P, T, rho, Rg, gamma, cp, Pr, M,
Re,Uo,To,rhoo,L]=initial_conditions(nxi,neta,y_eta);
fprintf(’Done.\n’);
%=================
%ITERATION:
%================
residual_Caux=1.0; residual_xMaux=1.0; residual_yMaux=1.0;
residual_Eaux=1.0; ITE=0; residual=1.0; tol=1e-3; ITEMAX=1000;
residualmax=1e20;
%==========================
K=0.005; %Courant
Cx=0.01; Cy=0.01; %Artificial Viscosity
wC=0.3; wxM=0.3; wyM=0.3; wE=0.3; %Relaxation Parameters
%==========================
fprintf(’Integration Parameters...\n\n’);
fprintf(’Reynolds#...\n’); disp([Re]); fprintf(’Mach#...\n’);
disp([M]); fprintf(’Courant Number...\n’); disp([K]);
fprintf(’Tolerance...\n’); disp([tol]); fprintf(’Relaxation
factors: Continuity, xMomentum, yMomentum, Energy...’); disp([wC
wxM wyM wE]);
if Cx~=0|Cy~=0;
fprintf(’Artificial Viscosity Cx and Cy...\n’);
disp([Cx Cy]);
end
fprintf(’Ready. Press enter key to iterate.\n’) pause; time=clock;
uaux=u; vaux=v; rhoaux=rho; Taux=T; k=0;
while residual>tol
ITE=ITE+1;
dt=Time_Step(u,v,T,J,x_xi,x_eta,y_xi,y_eta,neta,nxi,...
gamma,Rg,K);
[u,v,P,rho,T,Tauxx,Tauxy,Tauyy,qx,qy]=MacCormack(u,v,P,T,rho,cp,...
gamma,Pr,Rg,neta,nxi,J,x_xi,x_eta,y_xi,y_eta,dt,Cx,Cy);
[residual_C,residual_xM,residual_yM,residual_E,wC,wxM,wyM,wE,residual_Caux,...
residual_xMaux,residual_yMaux,residual_Eaux]=residual(u,v,rho,T,...
uaux,vaux,rhoaux,Taux,Uo,rhoo,To,wC,wxM,wyM,wE,residual_Caux,residual_xMaux,...
residual_yMaux,residual_Eaux,ITE,Cx,Cy);
residual=residual_C+residual_xM+residual_yM+residual_E;
k=k+1;
if k==4;
disp(’ iteration dt Continuity xMomentum yMomentum Energy Total Residual’);
k=0;
end
disp([ITE dt residual_C residual_xM residual_yM...
residual_E residual]);
%Relaxation.
rho=rhoaux+wC*(rho-rhoaux);
u=uaux+wxM*(u-uaux);
v=vaux+wyM*(v-vaux);
T=Taux+wE*(T-Taux);
uaux=u;
vaux=v;
rhoaux=rho;
Taux=T;
%Checking Symmetry:
14
u(nxi:-1:0.5*nxi,:)=u(1:0.5*nxi+1,:);
P(nxi:-1:0.5*nxi,:)=P(1:0.5*nxi+1,:);
T(nxi:-1:0.5*nxi,:)=T(1:0.5*nxi+1,:);
rho(nxi:-1:0.5*nxi+1,:)=rho(1:0.5*nxi,:);
if residual>residualmax; error(’convergence failed’); end
end
time=etime(clock,time);
disp(’The iteration has converged succesfully.’); disp(’Time
employed (s)....’); disp([time]);
-----------------------------------------------------------
function [u, v, P, T, rho, Rg, gamma, cp, Pr, M,
Re,Uo,To,rhoo,L]=initial_conditions(nxi,neta,y_eta);
% Initial conditions.m
% Initial conditions reports about the free stream conditions.
% The gas model considered is an ideal gas, with constant Prandtl Number
% and heat capacities, but variable dynamic viscosity and thermal conductivity.
% Also an initial interpolation on u-velocity is made in order to enhance
% the non-slip condition at the fairing wall.
mo=1.79e-2;
Uo=1500; %m/s;
%Po=75.6; %Pa;
Po=10000;
To=270; Ts=300; %K;
Rg=288.8; %J/KgK
gamma=1.4;
cp=1000; %J/KgK
rhoo=Po/(Rg*To); %Kg/m3
M=Uo/sqrt(gamma*Rg*To);
Pr=0.7; %#Prandtl
L=11.3e-2; R=4.11e-2; Re=rhoo*Uo*L/mo;
v(1:nxi,neta)=0; u(1:nxi,1:neta)=Uo; hu=Uo/(neta-1); U=[0:hu:Uo];
ht=(To-Ts)/(neta-1); t=[Ts:ht:To];
for i=1:nxi;
u(i,1:neta)=U(1:neta);
T(i,1:neta)=t(1:neta);
end
v(1:nxi,1:neta)=0; P(1:nxi,1:neta)=Po; rho(1:nxi,1:neta)=rhoo;
%T(1:nxi,1:neta)=To;
%This initial solution is calculated based on the above boundary
%conditions:
load u.mat u; load T.mat T; load v.mat v; load P.mat P; load
rho.mat rho;
-----------------------------------------------------------------
function dt=Time_Step(u,v,T,J,x_xi,x_eta,y_xi,y_eta,neta,nxi,...
gamma,Rg,K);
a=sqrt(gamma*Rg*T);
for i=1:nxi;
for j=1:neta;
Dt1(i,j)=(abs(u(i,j))*abs(x_xi(i,j)/J(i,j))+abs(v(i,j))*abs(y_xi(i,j)/J(i,j))+...
a(i,j)*abs(1/J(i,j))*sqrt(x_xi(i,j)^2+y_xi(i,j)^2))^(-1);
Dt2(i,j)=(abs(u(i,j))*abs(x_eta(i,j)/J(i,j))+abs(v(i,j))*abs(y_eta(i,j)/J(i,j))+...
a(i,j)*abs(1/J(i,j))*sqrt(x_eta(i,j)^2+y_eta(i,j)^2))^(-1);
end
end
dt1=min(min(K*Dt1)); dt2=min(min(K*Dt2)); dt=max([dt1 dt2]);
------------------------------------------------------------------
function
[u,v,P,rho,T,Tauxx,Tauxy,Tauyy,qx,qy]=MacCormack(u,v,P,T,rho,cp,...
gamma,Pr,Rg,neta,nxi,J,x_xi,x_eta,y_xi,y_eta,dt,Cx,Cy);
%Variables:
U1=zeros(nxi,neta); U2=zeros(nxi,neta); U3=zeros(nxi,neta);
U4=zeros(nxi,neta); U1p=zeros(nxi,neta); U2p=zeros(nxi,neta);
U3p=zeros(nxi,neta); U4p=zeros(nxi,neta); F1=zeros(nxi,neta);
F2=zeros(nxi,neta); F3=zeros(nxi,neta); F4=zeros(nxi,neta);
E1=zeros(nxi,neta); E2=zeros(nxi,neta); E3=zeros(nxi,neta);
E4=zeros(nxi,neta); S1=zeros(nxi,neta); S2=zeros(nxi,neta);
S2=zeros(nxi,neta); S4=zeros(nxi,neta);
cv=cp/gamma;
%Flux initialization:
15
m=Dynamic_Viscosity(T,nxi,neta);
k=Thermal_Conductivity(m,cp,Pr);
Tauxx=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauxy=Stress_Tauxy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauyy=Stress_Tauyy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
[qx,qy]=Heat_Flux(T,k,neta,nxi,J,x_xi,x_eta,y_xi,y_eta);
for i=1:nxi;
for j=1:neta;
et(i,j)=cv*T(i,j)+0.5*(u(i,j)^2+v(i,j)^2); %Total Energy
U1(i,j)=rho(i,j);
U2(i,j)=rho(i,j)*u(i,j);
U3(i,j)=rho(i,j)*v(i,j);
U4(i,j)=rho(i,j)*et(i,j);
E1(i,j)=rho(i,j)*u(i,j);
E2(i,j)=rho(i,j)*u(i,j)^2+P(i,j)-Tauxx(i,j);
E3(i,j)=rho(i,j)*u(i,j)*v(i,j)-Tauxy(i,j);
E4(i,j)=(rho(i,j)*et(i,j)+P(i,j))*u(i,j)-u(i,j)*Tauxx(i,j)-v(i,j)*Tauxy(i,j)+qx(i,j);
F1(i,j)=rho(i,j)*v(i,j);
F2(i,j)=rho(i,j)*u(i,j)*v(i,j)-Tauxy(i,j);
F3(i,j)=rho(i,j)*v(i,j)^2+P(i,j)-Tauyy(i,j);
F4(i,j)=(rho(i,j)*et(i,j)+P(i,j))*v(i,j)-u(i,j)*Tauxy(i,j)-v(i,j)*Tauyy(i,j)+qy(i,j);
end
end
%PREDICTOR STEP:
z=0;
[S1,S2,S3,S4]=Artificial_Viscosity(z,P,U1,U2,U3,U4,U1p,U2p,U3p,U4p,Cx,Cy,nxi,neta);
for i=2:nxi-1;
for j=2:neta-1;
U1p(i,j)=U1(i,j)-(dt/J(i,j))*(y_eta(i,j)*(E1(i+1,j)-E1(i,j))-y_xi(i,j)*(E1(i,j+1)-E1(i,j))-...
x_eta(i,j)*(F1(i+1,j)-F1(i,j))+x_xi(i,j)*(F1(i,j+1)-F1(i,j)))+S1(i,j);
U2p(i,j)=U2(i,j)-(dt/J(i,j))*(y_eta(i,j)*(E2(i+1,j)-E2(i,j))-y_xi(i,j)*(E2(i,j+1)-E2(i,j))-...
x_eta(i,j)*(F2(i+1,j)-F2(i,j))+x_xi(i,j)*(F2(i,j+1)-F2(i,j)))+S2(i,j);
U3p(i,j)=U3(i,j)-(dt/J(i,j))*(y_eta(i,j)*(E3(i+1,j)-E3(i,j))-y_xi(i,j)*(E3(i,j+1)-E3(i,j))-...
x_eta(i,j)*(F3(i+1,j)-F3(i,j))+x_xi(i,j)*(F3(i,j+1)-F3(i,j)))+S3(i,j);
U4p(i,j)=U4(i,j)-(dt/J(i,j))*(y_eta(i,j)*(E4(i+1,j)-E4(i,j))-y_xi(i,j)*(E4(i,j+1)-E4(i,j))-...
x_eta(i,j)*(F4(i+1,j)-F4(i,j))+x_xi(i,j)*(F4(i,j+1)-F4(i,j)))+S4(i,j);
%decoding predicted values:
rho(i,j)=U1p(i,j);
u(i,j)=U2p(i,j)/U1p(i,j);
v(i,j)=U3p(i,j)/U1p(i,j);
T(i,j)=(U4p(i,j)/U1p(i,j)-0.5*(u(i,j)^2+v(i,j)^2))/cv;
P(i,j)=rho(i,j)*Rg*T(i,j);
end
end
%Boundary correction:
[u,v,P,T,rho]=Boundary_Conditions(u,v,P,T,rho,nxi,neta);
%Predicted Fluxes and Properties:
m=Dynamic_Viscosity(T,nxi,neta);
k=Thermal_Conductivity(m,cp,Pr);
Tauxx=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauxy=Stress_Tauxy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauyy=Stress_Tauyy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
[qx,qy]=Heat_Flux(T,k,neta,nxi,J,x_xi,x_eta,y_xi,y_eta);
for i=1:nxi;
for j=1:neta;
et(i,j)=cv*T(i,j)+0.5*(u(i,j)^2+v(i,j)^2); %Total Energy
E1(i,j)=rho(i,j)*u(i,j);
E2(i,j)=rho(i,j)*u(i,j)^2+P(i,j)-Tauxx(i,j);
E3(i,j)=rho(i,j)*u(i,j)*v(i,j)-Tauxy(i,j);
E4(i,j)=(rho(i,j)*et(i,j)+P(i,j))*u(i,j)-u(i,j)*Tauxx(i,j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ho(i,j)=U1(i,j);
u(i,j)=U2(i,j)/U1(i,j);
v(i,j)=U3(i,j)/U1(i,j);
T(i,j)=(U4(i,j)/U1(i,j)-0.5*(u(i,j)^2+v(i,j)^2))/cv;
P(i,j)=rho(i,j)*Rg*T(i,j);
end
end
%Boundary correction:
[u,v,P,T,rho]=Boundary_Conditions(u,v,P,T,rho,nxi,neta);
%FINAL PROPERTIES AT t=t+dt STAGE:
m=Dynamic_Viscosity(T,nxi,neta); k=Thermal_Conductivity(m,cp,Pr);
Tauxx=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauxy=Stress_Tauxy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
Tauyy=Stress_Tauyy(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
[qx,qy]=Heat_Flux(T,k,neta,nxi,J,x_xi,x_eta,y_xi,y_eta);
------------------------------------------------------------
function
[residual_C,residual_xM,residual_yM,residual_E,wC,wxM,wyM,wE,residual_Caux,...
residual_xMaux,residual_yMaux,residual_Eaux,Cx,Cy]=residual(u,v,rho,T,...
uaux,vaux,rhoaux,Taux,Uo,rhoo,To,wC,wxM,wyM,wE,residual_Caux,residual_xMaux,...
residual_yMaux,residual_Eaux,ITE,Cx,Cy);
% Residual monitorizes instantaneously the residuals of Density, xVelocity,
% yVelocity and Temperature. Also enables an active control of the
% convergence and stability varying dynamically the relaxation factors.
residual_C=(norm(rho-rhoaux,inf)+norm(rho-rhoaux,1))/rhoo;
residual_xM=(norm(u-uaux,inf)+norm(u-uaux,1))/Uo;
residual_yM=(norm(v-vaux,inf)+norm(v-vaux,1))/Uo;
residual_E=(norm(T-Taux,inf)+norm(T-Taux,1))/To;
if residual_C>residual_Caux;
wC=wC-0.0000001; Cx=Cx+0.000001; Cy=Cy+0.000001;
end; if residual_xM>residual_xMaux;
wxM=wxM-0.0000001;
end if residual_yM>residual_yMaux;
wyM=wyM-0.0000001;
end if residual_E>residual_Eaux;
wE=wE-0.0000001; Cx=Cx+0.000001; Cy=Cy+0.000001;
end
if residual_C<residual_Caux;
Cx=Cx-0.00001; Cy=Cy-0.000001;
end;
if residual_E<residual_Eaux;
Cx=Cx-0.00001; Cy=Cy-0.000001;
end
if Cx<0|Cy<0;
Cx=0; Cy=0;
end
residual_Caux=residual_C; residual_xMaux=residual_xM;
residual_yMaux=residual_yM; residual_Eaux=residual_E;
if wC<0.01|wxM<0.01|wyM<0.01|wE<0.01;
wC=0.3; wxM=0.3; wyM=0.3; wE=0.3;
end
% if ITE>5;
% %Residual Monitoring
% figure(2);
% subplot(2,2,1), plot(ITE,residual_C); title(’Continuity residual’); hold on
% subplot(2,2,2), plot(ITE,residual_xM); title(’xMomentum residual’); hold on
% subplot(2,2,3), plot(ITE,residual_yM); title(’yMomentum residual’); hold on
% subplot(2,2,4), plot(ITE,residual_E); title(’Energy residual’); hold on
% pause(0.01);
% end
----------------------------------------------------------------------
17
function m=Dynamic_Viscosity(T,nxi,neta);
% Dynamic_Viscosity.m computes the viscosity as a
% function of the temperature. The model employed is
% the Sutherland’s Law. It is convenient to use a
% variable model viscosity in supersonic flow.
% T_oo and m_o are the values of temperature and viscosity
% at sea level.
Too=293; %K
%mo=1.79e-5; %Ns/m2
mo=1.79e-2;
m=zeros(nxi,neta);
m(1:nxi,1:neta)=mo*((T(1:nxi,1:neta)/Too).^(3/2)).*(Too+110)./(T(1:nxi,1:neta)+110);
----------------------------------------------------------------------
function k=Thermal_Conductivity(m,cp,Pr);
% Thermal_Conductivity function calculates
% k with constant Prandtl# assumption.
k=m*cp/Pr;
-----------------------------------------------------------------------
function
Tauxx=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
% Tauxx computes shearing stress using central differences
% (2nd order) at internal points and one-sided 2nd order
% differences at the edges. Tauxx is a (nxi,neta) matrix.
% Its slopes change with time and has not got any boundary
% constraint. Also, the second coefficient of viscosity is
% approximated with the Stokes Law: \lambda=-2m/3.
for i=2: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+1,j)-u(i+2,j))-...
2*y_xi(i,j)*(-3*u(i,j)+4*u(i,j+1)-u(i,j+2))+x_eta(i,j)*(-3*v(i,j)+4*v(i+1,j)-v(i+2,j))-...
x_xi(i,j)*(-3*v(i,j)+4*v(i,j+1)-v(i,j+2)));
i=nxi; j=1;
Tauxx(i,j)=(1/3)*(m(i,j)/J(i,j))*(2*y_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))-...
2*y_xi(i,j)*(-3*u(i,j)+4*u(i,j+1)-u(i,j+2))+x_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))-...
x_xi(i,j)*(-3*v(i,j)+4*v(i,j+1)-v(i,j+2)));
i=1; j=neta;
Tauxx(i,j)=(1/3)*(m(i,j)/J(i,j))*(2*y_eta(i,j)*(-3*u(i,j)+4*u(i+1,j)-u(i+2,j))-...
2*y_xi(i,j)*(3*u(i,j)-4*u(i,j-1)+u(i,j-2))+x_eta(i,j)*(-3*v(i,j)+4*v(i+1,j)-v(i+2,j))-...
x_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+v(i,j-2)));
i=nxi; j=neta;
Tauxx(i,j)=(1/3)*(m(i,j)/J(i,j))*(2*y_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))-...
2*y_xi(i,j)*(3*u(i,j)-4*u(i,j-1)+u(i,j-2))+x_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))-...
x_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+v(i,j-2)));
18
--------------------------------------------------------------------------------
function
Tauxy=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
% Tauxy computes shearing stress using central differences
% (2nd order) at internal points and one-sided 2nd order
% differences at the edges. Tauxy is a (nxi,neta) matrix.
% Its slopes change with time and has not got any boundary
% constraint. Also, the second coefficient of viscosity is
% approximated with the Stokes Law: \lambda=-2m/3.
for i=2:nxi-1;
for j=2:neta-1;
Tauxy(i,j)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))+y_eta(i,j)*(-3*v(i,j)+4*v(i+1,j)-v(i+2,j))-...
y_xi(i,j)*(-3*v(i,j)+4*v(i,j+1)-v(i,j+2)));
i=nxi; j=1;
Tauxy(i,j)=0.5*(m(i,j)/J(i,j))*(-x_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))+x_xi(i,j)*...
(-3*u(i,j)+4*u(i,j+1)-u(i,j+2))+y_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))-...
y_xi(i,j)*(-3*v(i,j)+4*v(i,j+1)-v(i,j+2)));
i=1; j=neta;
Tauxy(i,j)=0.5*(m(i,j)/J(i,j))*(-x_eta(i,j)*(-3*u(i,j)+4*u(i+1,j)-u(i+2,j))+x_xi(i,j)*...
(3*u(i,j)-4*u(i,j-1)+u(i,j-2))+y_eta(i,j)*(-3*v(i,j)+4*v(i+1,j)-v(i+2,j))-...
y_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+v(i,j-2)));
i=nxi; j=neta;
Tauxy(i,j)=0.5*(m(i,j)/J(i,j))*(-x_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))+x_xi(i,j)*...
(3*u(i,j)-4*u(i,j-1)+u(i,j-2))+y_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))-...
y_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+v(i,j-2)));
-----------------------------------------------------------------------------
function
Tauyy=Stress_Tauxx(u,v,m,nxi,neta,J,x_xi,x_eta,y_xi,y_eta);
% Tauyy computes shearing stress using central differences
% (2nd order) at internal points and one-sided 2nd order
% differences at the edges. Tauyy is a (nxi,neta) matrix.
% Its slopes change with time and has not got any boundary
% constraint. Also, the second coefficient of viscosity is
% approximated with the Stokes Law: \lambda=-2m/3.
for i=2:nxi-1;
for j=2:neta-1;
Tauyy(i,j)=(1/3)*(m(i,j)/J(i,j))*(-2*x_eta(i,j)*(v(i+1,j)-v(i-1,j))+...
2*x_xi(i,j)*(v(i,j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+2,j))+...
y_xi(i,j)*(-3*u(i,j)+4*u(i,j+1)-u(i,j+2)));
i=nxi; j=1;
Tauyy(i,j)=(1/3)*(m(i,j)/J(i,j))*(-2*x_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))+...
2*x_xi(i,j)*(-3*v(i,j)+4*v(i,j+1)-v(i,j+2))-y_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))+...
y_xi(i,j)*(-3*u(i,j)+4*u(i,j+1)-u(i,j+2)));
i=1; j=neta;
Tauyy(i,j)=(1/3)*(m(i,j)/J(i,j))*(-2*x_eta(i,j)*(-3*v(i,j)+4*v(i+1,j)-v(i+2,j))+...
2*x_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+v(i,j-2))-y_eta(i,j)*(-3*u(i,j)+4*u(i+1,j)-u(i+2,j))+...
y_xi(i,j)*(3*u(i,j)-4*u(i,j-1)+u(i,j-2)));
i=nxi; j=neta;
Tauyy(i,j)=(1/3)*(m(i,j)/J(i,j))*(-2*x_eta(i,j)*(3*v(i,j)-4*v(i-1,j)+v(i-2,j))+...
2*x_xi(i,j)*(3*v(i,j)-4*v(i,j-1)+3*v(i,j-2))-y_eta(i,j)*(3*u(i,j)-4*u(i-1,j)+u(i-2,j))+...
y_xi(i,j)*(3*u(i,j)-4*u(i,j-1)+u(i,j-2)));
-------------------------------------------------------------------------------------------
function [qx,qy]=Heat_Flux(T,k,neta,nxi,J,x_xi,x_eta,y_xi,y_eta);
% Heat_Flux computes the heat fluxes across the flow field by
% means of 2nd order central differences and one-sided 2nd order
% differences at the edges.
for i=2:nxi-1;
for j=2:neta-1;
qx(i,j)=-0.5*(k(i,j)/J(i,j))*(y_eta(i,j)*(T(i+1,j)-T(i-1,j))-...
y_xi(i,j)*(T(i,j+1)-T(i,j-1)));
qy(i,j)=-0.5*(k(i,j)/J(i,j))*(-x_eta(i,j)*(T(i+1,j)-T(i-1,j))+...
x_xi(i,j)*(T(i,j+1)-T(i,j-1)));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x_eta(i,j)*(-3*T(i,j)+4*T(i+1,j)-T(i+2,j))+...
20
x_xi(i,j)*(-3*T(i,j)+4*T(i,j+1)-T(i,j+2)));
i=nxi; j=1;
qx(i,j)=-0.5*(k(i,j)/J(i,j))*(y_eta(i,j)*(3*T(i,j)-4*T(i-1,j)+T(i-2,j))-...
y_xi(i,j)*(-3*T(i,j)+4*T(i,j+1)-T(i,j+2)));
qy(i,j)=-0.5*(k(i,j)/J(i,j))*(-x_eta(i,j)*(3*T(i,j)-4*T(i-1,j)+T(i-2,j))+...
x_xi(i,j)*(-3*T(i,j)+4*T(i,j+1)-T(i,j+2)));
i=1; j=neta;
qx(i,j)=-0.5*(k(i,j)/J(i,j))*(y_eta(i,j)*(-3*T(i,j)+4*T(i+1,j)-T(i+2,j))-...
y_xi(i,j)*(3*T(i,j)-4*T(i,j-1)+T(i,j-2)));
qy(i,j)=-0.5*(k(i,j)/J(i,j))*(-x_eta(i,j)*(-3*T(i,j)+4*T(i+1,j)-T(i+2,j))+...
x_xi(i,j)*(3*T(i,j)-4*T(i,j-1)+T(i,j-2)));
i=nxi; j=neta;
qx(i,j)=-0.5*(k(i,j)/J(i,j))*(y_eta(i,j)*(3*T(i,j)-4*T(i-1,j)+T(i-2,j))-...
y_xi(i,j)*(3*T(i,j)-4*T(i,j-1)+T(i,j-2)));
qy(i,j)=-0.5*(k(i,j)/J(i,j))*(-x_eta(i,j)*(3*T(i,j)-4*T(i-1,j)+T(i-2,j))+...
x_xi(i,j)*(3*T(i,j)-4*T(i,j-1)+T(i,j-2)));
-----------------------------------------------------------------------
function
[S1,S2,S3,S4]=Artificial_Viscosity(z,P,U1,U2,U3,U4,U1p,U2p,U3p,...
U4p,Cx,Cy,nxi,neta);
S1=zeros(nxi,neta); S2=zeros(nxi,neta); S3=zeros(nxi,neta);
S4=zeros(nxi,neta);
if z==0;
for i=2:nxi-1;
for j=2:neta-1;
S1(i,j)=Cx*abs(P(i+1,j)-2*P(i,j)+P(i-1,j))*(U1(i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j)+P(i-1,j))*(U2p(i+1,j)-2*U2p(i,j)+U2p(i-1,j))/...
(P(i+1,j)+2*P(i,j)+P(i-1,j))+...
Cy*abs(P(i,j+1)-2*P(i,j)+P(i,j-1))*(U2p(i,j+1)-2*U2p(i,j)+U2p(i,j-1))/...
(P(i,j+1)+2*P(i,j)+P(i,j-1));
S3(i,j)=Cx*abs(P(i+1,j)-2*P(i,j)+P(i-1,j))*(U3p(i+1,j)-2*U3p(i,j)+U3p(i-1,j))/...
(P(i+1,j)+2*P(i,j)+P(i-1,j))+...
Cy*abs(P(i,j+1)-2*P(i,j)+P(i,j-1))*(U3p(i,j+1)-2*U3p(i,j)+U3p(i,j-1))/...
(P(i,j+1)+2*P(i,j)+P(i,j-1));
S4(i,j)=Cx*abs(P(i+1,j)-2*P(i,j)+P(i-1,j))*(U4p(i+1,j)-2*U4p(i,j)+U4p(i-1,j))/...
(P(i+1,j)+2*P(i,j)+P(i-1,j))+...
Cy*abs(P(i,j+1)-2*P(i,j)+P(i,j-1))*(U4p(i,j+1)-2*U4p(i,j)+U4p(i,j-1))/...
(P(i,j+1)+2*P(i,j)+P(i,j-1));
end
end
end
---------------------------------------------------------------------------
function [u,v,P,T,rho]=Boundary_Conditions(u,v,P,T,rho,nxi,neta);
% Boundary_Conditions computes the boundary values behind the shock
% interpolating with values of internal points.
21
for j=2:neta-1;
i=1;
u(i,j)=2*u(i+1,j)-u(i+2,j);
v(i,j)=2*v(i+1,j)-v(i+2,j);
P(i,j)=2*P(i+1,j)-P(i+2,j);
T(i,j)=2*T(i+1,j)-T(i+2,j);
rho(i,j)=2*rho(i+1,j)-rho(i+2,j);
i=nxi;
u(i,j)=u(i-(nxi-1),j);
v(i,j)=-v(i-(nxi-1),j);
P(i,j)=P(i-(nxi-1),j);
T(i,j)=T(i-(nxi-1),j);
rho(i,j)=rho(i-(nxi-1),j);
end
for i=1:nxi;
j=1;
P(i,j)=2*P(i,j+1)-P(i,j+2);
rho(i,j)=2*rho(i,j+1)-rho(i,j+2);
end
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
%ELLIPTIC GRID GENERATOR
%INTERNAL BOUNDARY: SOYUZ/ST FAIRING ROCKET
%TYPE-C.
%TEST #2.
%Dimensions in mm.
clc; clear; clf; format long;
%1. COMPUTATIONAL PLANE:
%-------------------------
etamax=100; etamin=1; heta=99; neta=(etamax-etamin)/heta+1;
eta=linspace(etamin,etamax,neta);
ximax=100; ximin=1; hxi=1.0; nxi=(ximax-ximin)/hxi+1;
xi=linspace(ximin,ximax,nxi);
[ETA,XI]=meshgrid(eta,xi);
fprintf(’ELLIPTICAL GRID GENERATOR\n’); fprintf(’Internal
boundary: Soyuz/ST Rocket Fairing\n’) fprintf(’Plotting
successively each boundary...\n\n’)
%2.VARIABLES:
%-------------
x=zeros(nxi,neta); y=zeros(nxi,neta); xhat=zeros(nxi,neta);
yhat=zeros(nxi,neta); alfahat=zeros(nxi,neta);
betahat=zeros(nxi,neta); gammahat=zeros(nxi,neta);
%3.BOUNDARIES:
%-----------------
R=15000; %Surroundings extension.
%1--->2 (Solid surface; eta=etamin);
n1=1; xi1=(n1-1)*hxi; n2=0.25*nxi; xi2=(n2-1)*hxi;
x1=6748; y1=2055; x2=0; y2=2055;
x(1:n2,1)=linspace(x1,x2,n2)’; y(1:n2,1)=2055;
plot(x(1:n2,1),y(1:n2,1),’r’); axis([-35000 20000 -20000 20000]);
title(’Boundary conditions and Interpolated Initial Solution’);
hold on; pause(1);
%2--->3 (Solid surface; eta=etamin);
n3=0.40*nxi; xi3=(n3-1)*hxi;
x3=-3776.85; y3=1148.22;
x(n2:n3,1)=linspace(x2,x3,n3-n2+1)’;
y(n2:n3,1)=tan(13.5*pi/180)*x(n2:n3,1)+2055;
plot(x(n2:n3,1),y(n2:n3,1),’r’); pause(1);
%3--->4 (Solid surface; eta=etamin);
n4=0.60*nxi; xi4=(n4-1)*hxi;
x4=x3; y4=-y3;
alfa3=103.32; alfa4=256.68; halfa=(alfa4-alfa3)*hxi/(xi4-xi3);
alfa=[alfa3:halfa:alfa4]’;
x(n3:n4,1)=1180*cos(alfa(:)*pi/180)-3505;
y(n3:n4,1)=1180*sin(alfa(:)*pi/180);
22
plot(x(n3:n4,1),y(n3:n4,1),’r’); pause(1);
%4--->5 (Solid surface; eta=etamin);
n5=0.75*nxi; xi5=(n5-1)*hxi;
x5=x2; y5=-y2;
x(n4:n5,1)=linspace(x4,x5,n5-n4+1)’;
y(n4:n5,1)=-tan(13.5*pi/180)*x(n4:n5,1)-2055;
plot(x(n4:n5,1),y(n4:n5,1),’r’); pause(1);
%5--->6 (Solid surface; eta=etamin);
n6=nxi; xi6=(n6-1)*hxi;
x6=x1; y6=-y1;
x(n5:n6,1)=linspace(x5,x6,n6-n5+1)’; y(n5:n6,1)=-y1;
plot(x(n5:n6,1),y(n5:n6,1),’r’); pause(1);
%6--->7 (Surroundings; xi=ximax);
n7=n6; xi7=xi6;
x7=x6; y7=-R;
x(nxi,1:neta)=x6; y(nxi,1:neta)=linspace(y6,y7,neta);
plot(x(nxi,:),y(nxi,:)); pause(1);
%7--->8 (Surroundings, eta=etamax);
R1=20000;
n8=1; xi8=(n8-1)*hxi; theta=linspace(90,270,nxi)’;
x(n8:nxi,neta)=R1*cos(pi/180*theta)+x1;
y(n8:nxi,neta)=R*sin(pi/180*theta);
plot(x(n8:nxi,neta),y(n8:nxi,neta)); pause(1);
%8--->9 (Surroundings, xi=ximin)
x(1,1:neta)=x1; y(1,1:neta)=linspace(y1,R,neta);
plot(x(1,1:neta),y(1,1:neta)); pause(1);
%4. INTEGRATION
%-----------------
%------------------------------------------------------
tol=1e-1; ite=0; maxite=50000; error=1.0; errormax=1e20;
w=0.08;
%Initial solution:
etamax=100; etamin=1; heta=1; neta=(etamax-etamin)/heta+1;
eta=linspace(etamin,etamax,neta); [ETAi,XIi]=meshgrid(eta,xi);
n=nxi*neta;
x=interp2(ETA,XI,x,ETAi,XIi);
y=interp2(ETA,XI,y,ETAi,XIi);
for i=2:nxi-1, plot(x(i,:),y(i,:)); end for j=2:neta-1,
plot(x(:,j),y(:,j)); end hold off;
%Clustering Parameters:
a=0; b=0; %P Forcing Function;
c=-0.13; d=0.0001; %Q Forcing Function;
if a~=0|c~=0 ;
fprintf(’Clustering ON\n\n’)
end
fprintf(’Number of mesh points...\n’); disp([n]);
fprintf(’Press enter key to iterate...\n\n’); pause; r=0;
time=clock; while error>tol
ite=ite+1;
xhat=x;
yhat=y;
for j=2:neta-1;
for i=1:nxi-1;
k=0;
if i==1; k=1; end
alfahat(i,j)=0.25*((xhat(i,j+1)-xhat(i,j-1))^2+...
(yhat(i,j+1)-yhat(i,j-1))^2);
betahat(i,j)=0.25*((xhat(i+1,j)-xhat(i-1+k,j))*...
(xhat(i,j+1)-xhat(i,j-1))+...
(yhat(i+1,j)-((-1)^k)*yhat(i-1+k*(nxi-1),j))*...
(yhat(i,j+1)-yhat(i,j-1)));
gammahat(i,j)=0.25*((xhat(i+1,j)-xhat(i-1+k,j))^2+...
(yhat(i+1,j)-((-1)^k)*yhat(i-1+k*(nxi-1),j))^2);
Q(j)=c*sign(eta(j)-etamax)*exp(-d*abs(eta(j)-etamax)); %Forcing Function.
23
J(i,j)=0.25*((xhat(i+1,j)-xhat(i-1+k,j))*...
(yhat(i,j+1)-yhat(i,j-1))-...
(xhat(i,j+1)-xhat(i,j-1))*...
(yhat(i+1,j)-((-1)^k)*yhat(i-1+k*(nxi-1),j)));
A=-0.5*betahat(i,j);
B=alfahat(i,j);
C=0.5*betahat(i,j);
D=gammahat(i,j)+0.5*J(i,j)*Q(j);
E=2*alfahat(i,j)+2*gammahat(i,j);
F=gammahat(i,j)-0.5*J(i,j)*Q(j);
G=0.5*betahat(i,j);
H=alfahat(i,j);
L=-0.5*betahat(i,j);
x(i,j)=(1-k)*(x(i+1,j+1)*A...
+x(i+1,j)*B+...
x(i+1,j-1)*C+...
x(i,j+1)*D+...
x(i,j-1)*F+...
x(i-1+k,j+1)*G+...
x(i-1+k,j)*H+...
x(i-1+k,j-1)*L)/E+k*x1;
y(i,j)=(y(i+1,j+1)*A...
+y(i+1,j)*B...
+y(i+1,j-1)*C...
+y(i,j+1)*D...
+y(i,j-1)*F...
+((-1)^k)*y(i-1+k*(nxi-1),j+1)*G...
+((-1)^k)*y(i-1+k*(nxi-1),j)*H...
+((-1)^k)*y(i-1+k*(nxi-1),j-1)*L)/E;
x(i,j)=xhat(i,j)+w*(x(i,j)-xhat(i,j)); %Successive Overrelaxation;
y(i,j)=yhat(i,j)+w*(y(i,j)-yhat(i,j));
end
x(nxi,j)=x(1,j);
y(nxi,j)=-y(1,j);
end
error=norm((xhat-x),inf)+norm((yhat-y),inf)+norm((xhat-x),1)+norm((yhat-y),1);
% r=r+1;
% if r==4;
% disp(’ Iteration Error ’);
% r=0;
% end
disp([ite error]);
if ite>maxite|error>errormax
error(’the iteration does not converge’);
end
% plot(x(1,:),y(1,:)); hold on
% plot(x(nxi,:),y(nxi,:));
% plot(x(:,1),y(:,1));
% plot(x(:,neta),y(:,neta));
% for i=2:nxi-1, plot(x(i,:),y(i,:)); end
% for j=2:neta-1, plot(x(:,j),y(:,j)); end
% pause(1);
% hold off;
%
end
time=etime(clock,time);
disp(’The iteration has converged succesfully.’); disp(’Time
employed (s)....’); disp([time]);
figure(2); plot(x(1,:),y(1,:)); hold on plot(x(nxi,:),y(nxi,:));
plot(x(:,1),y(:,1)); plot(x(:,neta),y(:,neta));
for i=2:nxi-1, plot(x(i,:),y(i,:)); end
for j=2:neta-1, plot(x(:,j),y(:,j)); end pause(1); hold off;
-------------------------------------------------------------------------
function [x_xi,x_eta,y_xi,y_eta,J]=Metrics(x,y,nxi,neta);
x_xi=zeros(nxi,neta); x_eta=zeros(nxi,neta); y_xi=zeros(nxi,neta);
y_eta=zeros(nxi,neta); J=zeros(nxi,neta);
for i=2:nxi-1;
for j=2:neta-1;
x_xi(i,j)=0.5*(x(i+1,j)-x(i-1,j));
x_eta(i,j)=0.5*(x(i,j+1)-x(i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j)-x(i+2,j));
x_eta(i,j)=0.5*(-3*x(i,j)+4*x(i,j+1)-x(i,j+2));
y_xi(i,j)=0.5*(-3*y(i,j)+4*y(i+1,j)-y(i+2,j));
y_eta(i,j)=0.5*(-3*y(i,j)+4*y(i,j+1)-y(i,j+2));
J(i,j)=x_xi(i,j)*y_eta(i,j)-y_xi(i,j)*x_eta(i,j);
i=1; j=neta; x_xi(i,j)=0.5*(-3*x(i,j)+4*x(i+1,j)-x(i+2,j));
x_eta(i,j)=0.5*(3*x(i,j)-4*x(i,j-1)+x(i,j-2));
y_xi(i,j)=0.5*(-3*y(i,j)+4*y(i+1,j)-y(i+2,j));
y_eta(i,j)=0.5*(3*y(i,j)-4*y(i,j-1)+y(i,j-2));
J(i,j)=x_xi(i,j)*y_eta(i,j)-y_xi(i,j)*x_eta(i,j);
i=nxi; j=1; x_xi(i,j)=0.5*(3*x(i,j)-4*x(i-1,j)+x(i-2,j));
x_eta(i,j)=0.5*(-3*x(i,j)+4*x(i,j+1)-x(i,j+2));
y_xi(i,j)=0.5*(3*y(i,j)-4*y(i-1,j)+y(i-2,j));
y_eta(i,j)=0.5*(-3*y(i,j)+4*y(i,j+1)-y(i,j+2));
J(i,j)=x_xi(i,j)*y_eta(i,j)-y_xi(i,j)*x_eta(i,j);
i=nxi; j=neta; x_xi(i,j)=0.5*(3*x(i,j)-4*x(i-1,j)+x(i-2,j));
x_eta(i,j)=0.5*(3*x(i,j)-4*x(i,j-1)+x(i,j-2));
y_xi(i,j)=0.5*(3*y(i,j)-4*y(i-1,j)+y(i-2,j));
y_eta(i,j)=0.5*(3*y(i,j)-4*y(i,j-1)+y(i,j-2));
J(i,j)=x_xi(i,j)*y_eta(i,j)-y_xi(i,j)*x_eta(i,j);
25
References
[1] Moretti G., and M. Abbett: A Time-Dependent Computational Method for Blunt BodyFlows,” American Instutute of Aeronautics and Astronautics (AIAA) Journal, vol. 4,no. 12, pp. 2136-2141, December 1966.
[2] Starsem, The Soyuz Company: ”Soyuz User’s Manual,” Issue 3, Revision no. 0; April2001.
[3] Thompson J.F., Warsi Z.V.A., and Wayne Mastin C.: ”Numerical Grid Generation:Foundations and Applications,” North-Holland, New York, 1985.
[4] Anderson J.D., Jr.: ”Computational Fluid Dynamics,” McGraw-Hill.
[5] Anderson D.A, Tanhenhill J.C., and Pletcher R.H.: ”Computational Fluid Dynamicsand Heat Transfer,” McGraw-Hill, 1986.
[6] Spurk J.H.: ”Fluid Mechanics,” Springer Verlag, 1997.
[7] Vincenti W., Kruger C.H.,: ”Introduction to Physical Gas Dynamics,” John Wiley &Sons, 1965.
26