initial vorticity field
for i = 2:nx+2 for j = 2:ny+2
w[i,j] = exp(-pi*((x[i-1]-xc1)^2 + (y[j-1]-yc1)^2)) +
exp(-pi*((x[i-1]-xc2)^2 + (y[j-1]-yc2)^2))
end end
end
```
The vortex-merger problem has the periodic domain and hence we use fast Fourier transform (FFT) Poisson solver discussed in Section 6.1.1 to get the streamfunction from vorticity field at every time step. The Julia function for FFT Poisson solver is outlined in Listing 18. The evolution of the merging process for two vortices into a single vortex is displayed in Figure 26. If we let the simulation run for some more time, we will see a single vortex getting formed.

✝ ✆

**Figure 26.** Evolution of the vorticity field at three time steps during the co-rotating vortex interaction. The solution is computed using second-order explicit solver.

We compare the computational time required for two-dimensional incompressible Navier-Stokes solver in Julia with Python code. We use two versions of Python code. In the first version, we use for loop similar to the way we write Julia code. The Python code for computing the right hand side term using Arakawa numerical scheme is given in Listing 30. The other version is the vectorized version which speeds up the code without using any loops and is given in Listing 31. In vectorization, several operations such as multiplication, addition, division are performed over a vector at the same time. From Table 3, we can easily see the benefit of Julia over Python for computationally intensive problems like the ones encountered in CFD applications.

**return** f

**Table 3.** Comparison of CPU time for Julia and Python version of Navier-Stokes solver for grid resolution *Nx* = 128 and *Ny* = 128. We note that the codes are written mostly for the pedagogical purpose and the CPU time may not be the optimal time that can be achieved for each of the programming languages.


**Listing 30.** Computation of right hand side function in Python without vectorization. ✞ ☎

```