100% found this document useful (2 votes)
283 views14 pages

Development of A Solver For The Heat Equation Using MATLAB

This document summarizes a report on solving the flow in a lid-driven cavity and developing a solver for the heat equation using MATLAB. The author used a collocated grid arrangement and pressure correction technique to solve the incompressible Navier-Stokes equations for lid-driven cavity flow. Root mean square velocity values were calculated at different grid points and time steps to assess flow stability. The three grid sizes showed convergence of the velocity components as the mesh was refined. Steadiness was achieved when the RMS value reached 1e-7, indicating a steady state was reached at 6.5 seconds.

Uploaded by

Manan Academy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (2 votes)
283 views14 pages

Development of A Solver For The Heat Equation Using MATLAB

This document summarizes a report on solving the flow in a lid-driven cavity and developing a solver for the heat equation using MATLAB. The author used a collocated grid arrangement and pressure correction technique to solve the incompressible Navier-Stokes equations for lid-driven cavity flow. Root mean square velocity values were calculated at different grid points and time steps to assess flow stability. The three grid sizes showed convergence of the velocity components as the mesh was refined. Steadiness was achieved when the RMS value reached 1e-7, indicating a steady state was reached at 6.5 seconds.

Uploaded by

Manan Academy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 14

Solving the Flow in a Lid-Driven Cavity and Development of a Solver for

the Heat Equation using MATLAB.


By: Isreal Iyiola Morawo.
Introduction:
I used a collocated grid arrangement in this report to solve the incompressible Navier-Stokes equation using a
pressure correction technique for a flow in a Lid-driven cavity. In addition, I performed stability analysis for
integrating the convection and diffusion terms of the NS Equation over a transient state and finally coupling the
energy equation in the Navier-Stokes equations while treating temperature as a passive quantity.
Review:

From the above equation, the fluid density is ⍴, the thermodynamic pressure is p, the kinematic viscosity
is v, and the horizontal and vertical components of velocity are u and v, respectively. The term "thermal
diffusivity" is used in the Heat equation (is defined as the ratio of the time derivative of temperature to its
curvature, quantifying the rate at which temperature concavity is "smoothed out"). Note that the body-force term
is absent from the Navier-Stokes equations and that the flow is only driven by the pressure and shear
forces. Solving these equations presents a challenge as there is no separate equation for the pressure term.
Both of the momentum equations include a term for the pressure gradient. Since we lack dynamic
equations for both pressure and density, the continuity equation turns into a kinematic constraint on the
velocity field. This is not a problem for compressible fluids because the equation of state is used to connect
the fluid's pressure and density. Since density does not function as a state variable in the equation of state,
we are unable to apply it to incompressible fluids.
Generally, there are two methods for solving this kind of problem. The first is coupling the velocity and
pressure terms in the continuity equation by introducing some artificial "compressibility." The main
drawback of this approach is finding the “right” compressibility factor's value, which causes convergence
issues for truly incompressible flows. The alternative strategy is to satisfy the incompressible constraint
by using pressure-correction methods, which iteratively correct pressure and velocities. For this project,
we would be using the pressure projection method. Without taking into account the pressure gradient term,
the projection method first evolves the velocity only by the advection and diffusion term. The updated
intermediate velocity field is incompressible, so the constraint is not satisfied. Once the pressure gradient
term has been resolved, the updated velocities are then verified to satisfy the incompressible constraint.
In order to satisfy the incompressible constraint, the non-zero divergence portion of velocity (∇ · u ≠ 0) is
corrected or "projected out" by including the pressure term. We chose a collocated grid for this problem
because it is easier to implement body-fitted grids, more accurate for boundary condition implementation,
and fluid-solid interactions are common in all commercial and production research codes due to collocated
setup. However, a very wide pressure stencil is used when solving the pressure using the collocated
scheme. Additionally, the pressure points are decoupled, which allows the pressure field to oscillate.
Figure 1: A collocated grid scheme: The uw, ue, vn, and vs are just pointing out the midpoint positions of the
corresponding edges and storing no value.
Additionally, the energy equation simulates the temperature variation that occurs within some flows as a
result of the fluid's motion. Variations in the fluid's density and viscosity are negligible for low-
temperature changes (∆T < 20K in the air), and as a result, buoyancy forces are also negligible. This
suggests that the flow field controls temperature distribution while temperature has little impact on the
flow field (one-way coupled).

Figure 2: A diagrammatic representation of the Lid-driven problem


Problem setup
The lid-driven cavity flow is a frequently employed test case for comparing a code for incompressible fluid
flow. It is sometimes called shear–driven flow due to the nature of the setup. Simple two-dimensional
geometry and straightforward boundary conditions characterize the problem. The typical scenario has a
fluid inside a square domain with Dirichlet boundary conditions on all four sides, three of which are
stationary and one of which is moving. The upper wall of the cavity, which is sliding at a constant speed
(u = (uwall, 0)), causes the fluid inside of the cavity to move, creating viscous stresses that resemble Couette
flow. The constant diffusion of kinetic energy introduced by the moving wall maintains the flow within
the lid-driven rectangular two-dimensional cavity.

This energy is initially contained in a thin, fluid layer next to the moving boundary that is viscous. A
steady state laminar flow results from the redistribution of energy reaching equilibrium over a period of
time that depends on the Reynolds number. The horizontal and vertical components of velocity represent
the convection of the fluid particles, and the kinematic viscosity represents the diffusion of momentum
from the lid to the cavity, according to the Navier-Stokes equations. The thermal diffusivity in the heat
equation illustrates how heat is diffused, and the velocity components show how heat is convected.
The following assumptions were made for this problem:
i. Fluid density = 1kgm-3
ii. Fluid viscosity µ = 0.01.
iii. Sliding wall velocity = 1ms-1
iv. No slip boundary condition left, right, and bottom wall and constant velocities of 0.
v. Simulations were conducted for the 129 x 129 (F) , 65 x 65 (M) and 33 x 33 (C)
For the part II of the problem (The Heat Equation)
i. Thermal conductivity = 0.1
ii. Ttop = 15oC , Tc = 5OC, Thot = 0oC
Result and Discussion
Steadiness
By the rule of thumb when the velocity is constant over time, a steady state is reached.
To use the root mean square (RMS) value of velocity to assess the stability of a lid-driven flow in a
collocated grid system, you can follow these steps:
i. Set up the numerical simulation of the lid-driven flow using a collocated grid system. This
will involve defining the grid spacing, the time step, and the boundary conditions for the flow.
ii. Solve the governing equations for the flow using a suitable numerical method. This will
typically involve solving the Navier-Stokes equations, which describe the motion of a fluid
under the influence of various forces.
iii. Calculate the RMS value of the velocity at each grid point in the domain. To do this, you will
need to compute the average velocity over a series of time steps, and then take the square root
of the average of the squares of the velocity values.
iv. Use the RMS velocity values to assess the stability of the flow. If the RMS velocity values are
relatively small and uniform throughout the domain, the flow is likely to be stable. On the
other hand, if the RMS velocity values are large and vary significantly from one grid point to
another, the flow may be unstable.
v. Repeat the simulation for different values of the grid spacing, time step, and other parameters,
and use the RMS velocity values to determine the optimal settings for the simulation.
vi. It's important to note that the RMS velocity is just one factor that can be used to assess the
stability of a lid-driven flow. Other factors, such as the Reynolds number and the shear stress
at the walls, may also be important in determining the stability of the flow.
I followed the above step and steadiness was taken into consideration when the RMS value reached an
order of magnitude 1e-7. The rms value of the velocity difference reached a value of 1.4735e-07 at time
6.5 seconds using a time step size of 0.001 seconds and varying the number of time steps (6500). This was
examined for a position at a height of 0.78125 meters above the ground. Additionally, this was checked
for various positions, and those revealed even lower RMS values. As a result, according to the chosen
criteria, the steady state is reached at time 6.5 seconds.
Convergence: The three grid sizes' center-line velocities are plotted to examine the convergence. The
velocities are shown in a table below.

Figure 3: The horizontal and vertical velocity components at x = 0.5m for the coarse mesh

Figure 4: The horizontal and vertical velocity components at x = 0.5m for the Medium mesh
Figure 5: The horizontal and vertical velocity components at x = 0.5m for the fine mesh.

The cavity's middle is the main area of interest because this is where the code's output deviates from the
actual result the most. It can be seen that the curves obtained for the velocity components become
smoother as the mesh is finer. More importantly, as seen from the plots below, the solution gets closer to
the exact values as the mesh is refined more thoroughly.

Figure 6: A plot of the vertical component of the velocity with the cavity length showing the comparison of the exact
solution (from Ghia et al) and solution at different mesh sizes.
Figure 7: A plot of the height of the lid–driven cavity and the horizontal component of the velocity showing the
comparison of the exact solution (from Ghia et al) and solution at different mesh sizes.

Analysis of Stability
a) Because the Navier-Stokes equations contain convective and diffusive terms, our discretization
should be within the convective and diffusive stability limits. Our time step size should be less
than the critical time step sizes based on these limits, or the code will fail. To check for stability
limits based on convective and diffusive stability limits, the following code segment was added. If
the time step size selected is greater than the one based on the stability limits, the code will be
stopped automatically.

The coarse grid viscosity was varied after the uwall = 1 and time step size of 0.005 seconds were set. The
code was observed to stop after reaching a value of 0.0432.
Following that, the dynamic viscosity was set to 0.01, and the time step size was set to 0.005 seconds.
The value of Uwall was then varied for three different mesh sizes. The maximum allowable Uwall value
(before the first NaN result is observed) is shown in tabular form below. (The characteristics length is 1m,
which is the length of the flow field)
b) The Peclet number (Pe) is a dimensionless number that compares the relative importance of
advective transport to diffusive transport in a system. It is often used in fluid dynamics, heat and
mass transfer, and other fields to describe the relative importance of convective transport to
diffusive transport. The Peclet number is defined as the product of the characteristic velocity (U)
and the characteristic length (h) divided by the coefficient of molecular diffusion (v). In the case
you have given, the Peclet number is defined as Pe = Uh/2v, where U is the wall velocity, h is the
characteristic length of the system (such as the grid size in a computational fluid dynamics
simulation), and v is the coefficient of molecular diffusion. If the Peclet number is large, it indicates
that advective transport is dominant over diffusive transport. In this case, the maximum allowed
wall velocity will be determined by the balance between advective and diffusive transport in the
system. If the Peclet number is small, it indicates that diffusive transport is dominant over
advective transport. In this case, the maximum allowed wall velocity will be limited by the
coefficient of molecular diffusion and the characteristic length of the system. It is important to
note that the value of the Peclet number can vary significantly depending on the specific
properties of the system being studied, including the characteristics of the fluid, the geometry of
the system, and the boundary conditions. In the context of a lid-driven cavity flow, the Péclet
number can be used to assess the stability of the flow and the accuracy of the numerical solution.
If the Péclet number is small, then the flow is dominated by diffusive transport and the numerical
solution is likely to be accurate. If the Péclet number is large, then the flow is dominated by
convective transport and the numerical solution may be less accurate. It is important to note that
the Péclet number is only one factor that can affect the stability and accuracy of the numerical
solution. Other factors, such as the grid resolution and the choice of the numerical scheme, can
also influence the stability and accuracy of the solution. From table 1, making the mesh finer
allows the simulation to run at a higher lid velocity. On successively refined meshes, the Peclet
Number of the calculated flow increases. This is because, as the mesh is refined, the grid size
decreases by a factor of two, but the maximum allowable lid velocity does not.
Type of Mesh Maximum Allowable Uwall Peclet Number
Coarse Mesh (C) 7.42500 371.20
Medium Mesh (M) 10.4700 523.50
Fine Mesh (F) 11.3500 567.50
Table 1: A table of the maximum allowable wall velocity for each of the mesh type.
Even for very small values of lid velocity, the code for the fine mesh blows up. As a result, in order to run
the code for the fine mesh, the time step size must be reduced.

c) We can implement a CFL condition because the Navier-Stokes Equations include a convection
term. The Courant-Friedrichs-Lewy (CFL) condition states that the distance that any
information travels within the mesh during the time step length must be less than the distance
between mesh elements. In other words, information from a specific cell or mesh element must
only reach its immediate neighbors. If the courant number exceeds the unit value, the
information jumps to the next cell, causing instabilities that propagate throughout the domain
and cause divergence. The CFL condition for the code is provided in the code segment below.
The courant number limit is assumed to be 1 in this segment, and the code will be terminated if the
courant number of our flow exceeds our limit.
2.0 Solving the Energy Equations

To run a simulation to reach a steady state for the energy equation inputed in the velocity obtained from
the Navier-Stokes equations using a collocated grid for lid-driven flow in MATLAB, Follow the
following steps.

1. Set up your simulation environment in MATLAB. This includes defining your grid size,
boundary conditions, and initial conditions for your simulation.
2. Write a function to solve the Navier-Stokes equations for the velocity field. This function
should take in the grid size, boundary conditions, and initial conditions as inputs and return
the velocity field as an output.
3. Write a function to solve the energy equation using the velocity field obtained from the
Navier-Stokes equations. This function should take in the grid size, boundary conditions, and
initial conditions as inputs, as well as the velocity field obtained from the Navier-Stokes
equations. It should return the energy field as an output.
4. Write a loop to iterate through the simulation until steady state is reached. This loop should
call the Navier-Stokes and energy equation functions in each iteration, using the output from
the previous iteration as the input for the current iteration. You can set a tolerance level to
determine when steady state has been reached.
5. Visualize the results of your simulation by plotting the velocity and energy fields obtained
from the Navier-Stokes and energy equations.

The Navier-Stokes equation's numerical solution was used to modify the MATLAB code so that it can
also solve the energy/heat equation. When the difference in temperature after the time step does not
significantly change over time, this is the criterion used to evaluate the steadiness of the temperature
field. When the RMS difference value in the code reaches a magnitude of 1e-7, we assume steadiness.
Utilizing this standard. It has been noted that steadiness takes 5 seconds to develop.

Figure 8: Visualization of the contour of the temperature profile of the coarse mesh.
Figure 8: Temperature along the centerline geometry for the coarse mesh (33 x33)

Figure 9: Temperature along the centerline geometry for the Medium mesh (65 x65)
Figure 9: Temperature along the centerline geometry for the Fine mesh (128 x 128)

The temperature profiles along the midline are shown in the above diagram. We noticed convergence as
the mesh was successively refined, just like the velocity field. This is further supported by the
temperature reading at the cavity's geometric center, as shown in the table below.

Mesh Type Temperature


Coarse Mesh (C) 6.9524
Medium Mesh (M) 7.1111
Fine Mesh (F) 7.1813

Table 2: Temperature at the Geometric center for the C, M and F mesh sizes.

Conclusion
In the lid-driven cavity flow, the top boundary of the cavity is subjected to a constant translational
velocity, while the other boundaries are stationary. This results in the development of complex flow
patterns within the cavity, with vortices and eddies forming near the corners and shear layers developing
along the moving boundary. To solve the Navier-Stokes equations for this flow, a numerical method such
as the finite difference method was used from the code extract that was given in the project file. I used a
collocated grid system (as given in the problem statement), where the velocity components are located at the
same grid points as the pressure. This can be advantageous because it allows for a more straightforward
implementation of the pressure-velocity coupling terms in the equations. To solve the equations, an
iterative process is typically used, where an initial guess for the velocity and pressure fields is made and
the equations are solved to update the fields at each time step. The process is repeated until the solution
converges to a steady state or a desired time point is reached and for this problem, the steady state was
gotten around 6.5 seconds. One of the challenges I faced in solving the Navier-Stokes equations for lid-
driven cavity flow using a collocated grid system is the need to enforce the boundary conditions
accurately. The moving boundary and the no-slip conditions at the walls must be implemented carefully
to avoid numerical errors that can propagate through the solution. Overall, the use of a collocated grid
system and numerical methods such as the finite difference method can be an effective way to solve the
Navier-Stokes equations for lid-driven cavity flow, but care must be taken to ensure accurate and stable
solutions.
Additionally, by definition, as the mesh is refined, the size of the cells decreases, which allows for a more
detailed representation of the flow within the cavity. This can lead to a more accurate solution, as the flow
can be more accurately represented on a finer mesh. However, it is important to note that refining the
mesh can also increase the computational cost of the simulation. Therefore, it is generally necessary to
balance the need for accuracy with the computational resources available. The result in figure 3 – 7
explains this explicitly. Also, I had a problem with the fine mesh because the solutions were blowing up,
but I later had to increase dt with respect to nstep and had a better result.
Furthermore, The advective and diffusive limits were used to perform a stability analysis. These limits
specify critical time step sizes beyond which the code fails. Based on these limits, the maximum kinematic
viscosity was calculated to be 0.0432. The maximum allowable value of lid velocity was calculated for
different mesh sizes in the stability analysis is observed that as the mesh is refined, the value of the
maximum allowable lid velocity increases and based on this the Peclet Number was seen to be increasing
as the mesh become finer and this shows that an accurate representation of the heat transfer process was
gotten and also show that an increase in the relative importance of the convective heat transfer compared
to the conductive heat transfer. A CFL condition was also added to check for the user-defined velocity
and grid size, which is critical for flows with convection terms. Also it can be seen that the peclet numbers
are high showing that the convective term is dominant in this problem
Finally, a MATLAB code was created to solve the energy equation numerically using the same velocity
field generated by the Navier-Stokes equations. Using the same criterion used for velocity field steadiness,
the temperature field reached a steady state at time of 5.1 seconds, and the temperature at the center lines
was plotted. The temperature contour shows that the temperature distribution is not symmetric about
the line x =0.5m, which is due to the advection of the temperature caused by the asymmetric velocity field.
Appendix
% MECH 479-CFD: Projection method for Incompressible NS Equations
% Two-dimensional driven cavity problem
% Projection method in primitive variables on a colocated mesh
% Input parameters and meshing
clear all
nx=33; % X-direction points
ny=33; % Y-direction points
dt=0.001; % Time step size
nstep=5100; % Number of time steps
mu=0.01; % Dynamic viscosity
maxit=100; % SOR iterations
beta=1.2; % SOR parameter
h=1/nx; % Unfirom grid size
time=0; % Initialize time
a=0.1; % Thermal Diffusivity

% Reynolds number is 100

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Meshing
figure(1)
[x,y] = meshgrid(0:h:1,0:h:1);
plot(x,y,y,x);

% Initialize vectors
u=zeros(nx,ny);
v=zeros(nx,ny);
p=zeros(nx,ny);
T = zeros(nx,ny); % Temperature vector
us = u(1:nx,ny-1); % Vectors to check for steadiness
Ts = T(1:nx,ny-1); % Temperature vector to check for steadiness
u_diff = zeros(nx,1); % Vectors to check for steadiness
T_diff = zeros(nx,1); % Temperature vector to check for steadiness
% Temporary velocity
ut=zeros(nx,ny);
vt=zeros(nx,ny);
% Lid velocity
u(2:nx-1,ny)=1;
% Temperature Boundary Conditions
T(nx,1:ny)=15; % Temperature at top wall
T(2:nx-1,1)=5; % Temperature at left wall
T(2:nx-1,ny)=5; % Temperature at right wall

% Advective and deffisivity stability condition:


% tcri_a = 2*mu/max(max(u))^2;
%
% tcri_d = 1/4 * h^2/mu;
%
% if dt > tcri_a || dt > tcri_d
% fprintf(2, 'the value of dt will make the system unstable.' )
% return;
% end

% q = ((max(max(u))*dt)/h) ; % CFL Condition


% if q > 1
% fprintf(2,'The Courant Number exceeds unity')
% return;
% end

% Time loop for solving the flow


for is=1:nstep
% predicted velocities are found by (Step 1)
for i=2:nx-1,
for j=2:ny-1
% temporary u-velocity
ut(i,j)=u(i,j)+ dt*(-(0.5/h)*(u(i,j)*(u(i+1,j)-u(i-1,j))+v(i,j)*(u(i,j+1)-u(i,j-
1)))...
+(mu/h^2)*(u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1)-4*u(i,j))); % does not
contain pressure terms
% temporary v-velocity
vt(i,j)=v(i,j)+dt*(-(0.5/h)*(u(i,j)*(v(i+1,j)-v(i-1,j))+v(i,j)*(v(i,j+1)-v(i,j-
1)))...
+ (mu/h^2)*(v(i+1,j)+v(i-1,j)+v(i,j+1)+v(i,j-1)-4*v(i,j)));
% The Energy Equation
T(i,j)=T(i,j)+ dt*(-(0.5/h)*(u(i,j)*(T(i+1,j)-T(i-1,j))+v(i,j)*(T(i,j+1)-T(i,j-
1)))...
+(a/h^2)*(T(i+1,j)+T(i-1,j)+T(i,j+1)+T(i,j-1)-4*T(i,j)));
end
end
vt(2:nx-1,1)=(mu*dt/h^2)*(v(2:nx-1,3)-2*v(2:nx-1,2));
vt(2:nx-1,ny)=(mu*dt/h^2)*(v(2:nx-1,ny-2)-2*v(2:nx-1,ny-1));
ut(1,2:ny-1)=(mu*dt/h^2)*(u(3,2:ny-1)-2*u(2,2:ny-1));
ut(nx,2:ny-1)=(mu*dt/h^2)*(u(nx-2,2:ny-1)-2*u(nx-1,2:ny-1));
%
for it=1:maxit % solving for pressure (Step 2)
p(2:nx-1,1)=p(2:nx-1,2)+(h/dt)*vt(2:nx-1,1);
p(2:nx-1,ny)=p(2:nx-1,ny-1)-(h/dt)*vt(2:nx-1,ny);
p(1,2:ny-1)=p(2,2:ny-1)+(h/dt)*ut(1,2:ny-1);
p(nx,2:ny-1)=p(nx-1,2:ny-1)-(h/dt)*ut(nx,2:ny-1);
% Pressure solver via Gauss-Seidel/SOR iterations
for i=2:nx-1,for j=2:ny-1
p(i,j)=beta*0.25*(p(i+1,j)+p(i-1,j)+p(i,j+1)+p(i,j-1)...
- (0.5*h/dt)*(ut(i+1,j)-ut(i-1,j)+vt(i,j+1)-vt(i,j-1)))+(1-beta)*p(i,j);
end,end
p(floor(nx/2),floor(ny/2))=0.0;
% Set the pressure in the center. Needed since bc is not incorporated into eq
end
% correct the velocity: (Step 3)
u(2:nx-1,2:ny-1)=ut(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(3:nx,2:ny-1)-p(1:nx-2,2:ny-1));
v(2:nx-1,2:ny-1)=vt(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(2:nx-1,3:ny)-p(2:nx-1,1:ny-2));

% u_temp = u(1:nx,25); % Vector to check for steadiness, change the column value for
different positions
% us = [us u_temp];
% u_diff = us(1:nx,is+1)-us(1:nx,is); % Difference of velocities at the next time
step
% rms_u = rms(u_diff); % RMS Value

T_temp = T(1:nx,25); % Vector to check for steadiness, change the column value for
different positions
Ts = [Ts T_temp];
T_diff = Ts(1:nx,is+1)-Ts(1:nx,is);
rms_T = rms(T_diff); % RMS value for temperature

% increment time
time=time+dt

%plot the results


% figure(2);
% hold off,quiver(flipud(rot90(u)),flipud(rot90(v)),'r');
% hold on;axis([1 nx 1 ny]);
% axis square,pause(0.01)
% colorbar;

figure(3); %Temperature Contour


hold off,contourf(1:nx,1:ny,T);
hold on;
pause(0.01)
colorbar;

end

T_mid_line = T(nx/2,1:ny);
T_mid_line2 = T(1:nx,ny/2);

figure(4)
plot(T_mid_line,1:ny,'r',LineWidth=1,LineStyle='-');
grid on;
xlabel('Temperature along line y=0.5m');
ylabel('Number of grid Points');
title('Temperature along line y=0.5m');

figure(5)
plot(T_mid_line2,1:ny,'g',LineWidth=1,LineStyle='-.');
grid on;
xlabel('Temperature along line x=0.5m');
ylabel('Number of grid Points');
title('Temperature along line x=0.5m');

% post-processing
% plot(10*u(floor(ny/2),1:nx)+floor(nx/2),1:nx, 'linewidth', 3),hold on;
% plot([1,nx],[floor(ny/2),floor(ny/2)]),plot([floor(nx/2),floor(nx/2)],[1,ny])
% plot(10*v(1:nx,floor(ny/2))+floor(ny/2), '-.r','linewidth', 3);
% axis square,axis([1,nx, 1,ny])
% xlabel('x')
% ylabel('y')

You might also like