<jupyter_start><jupyter_text>Initial condition: the lamb dipoleThe lamb dipole is an exact solution to the NS equation. If our numerical scheme is accurate enough, the initial condition shouldn't move relative to a frame moving with the dipole (hence the trick of using -U0 as background velocity).<jupyter_code>N = m.nx
R = 1.5
E0 = .5
U = -m.U

import scipy.special as special

x, y = m.x, m.y
x0,y0 = x[N/2,N/2],y[N/2,N/2]

r = np.sqrt( (x-x0)**2 + (y-y0)**2 )
s = np.zeros(r.shape)

for i in range(N):
    for j in range(N):
        if r[i,j] == 0.:
            s[i,j] = 0.
        else:
            s[i,j] = (y[i,j]-y0)/r[i,j]

lam = (pi*1.2197)/R

# Lamb's
C = (-2.*U*lam)/(special.j0(lam*R))
qi = np.zeros_like(r)
qi[r<=R] = C*special.j1(lam*r[r<R])*s[r<R]
m.set_q(qi[np.newaxis])
plt.imshow(m.q[0])
plt.colorbar()
m.run()
plt.imshow(m.q[0])
plt.colorbar()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18924972004479285, 'fraction_numerical': 0.03135498320268757, 'mean_word_length': 3.318840579710145, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '121612', 'license': 'MIT', 'n_tokens_mistral': 425, 'n_tokens_neox': 402, 'n_words': 98, 'path': 'examples/LambDipole.ipynb', 'repo_name': 'houssamyassin/pyqg', 'size': '893'}