# Better method for computing streamlines

Can someone suggest a better way to solve for streamlines?

P.S. StreamPlot is not providing accurate results.

Here, velocity is u[x,y] i + v0[x,y] j. p0x[x] is the pressure gradient. The last line in the code is taking too long to execute a simpler solution will be appreciated.

My code is as follows :

B1[x_] = 1 + a*Cos[2*Pi*x];
p0x[x_] = -1/B1[x];
u0[x_, y_] = -p0x[x];
v0[x_, y_] = D[p0x[x], x]*y;
u1[x_, y_] =
λ^2*D[p0x[x], {x, 2}]/2*y^2 - λ^2* D[p0x[x], {x, 2}]/6*(B1[x])^2;
u[x_, y_] = -p0x[x] + δ^2*λ^2*D[p0x[x], {x, 2}]/2*(y^2 - (B1[x])^2/3);
eq = (D[y[x], x] == v0[x, y[x]]/u[x, y[x]]) /. {a -> 0.3, λ -> 1, δ -> 1} ;

sl = DSolve[eq, y[x], x]

• What do you mean writing "StreamPlot is not providing accurate results"? – Alex Trounev Sep 29 '20 at 21:49

Try this

B1[x_] := 1 + a*Cos[2*Pi*x];
p0x[x_] := -1/B1[x];
u0[x_, y_] := -p0x[x];
v0[x_, y_] := D[p0x[x], x]*y;
u1[x_, y_] := \[Lambda]^2*D[p0x[x], {x, 2}]/2*y^2 - \[Lambda]^2*D[p0x[x], {x, 2}]/6*(B1[x])^2;
u[x_, y_] := -p0x[x] + \[Delta]^2*\[Lambda]^2* D[p0x[x], {x, 2}]/2*(y^2 - (B1[x])^2/3);
vels = {u[x, y], v0[x, y]} /. {a -> 0.3, \[Lambda] -> 1, \[Delta] -> 1}

gr0 = StreamPlot[vels, {x, -1, 1}, {y, -1, 1}];
eq = (D[y[x], x] == v0[x, y[x]]/u[x, y[x]]) /. {a -> 0.3, \[Lambda] -> 1, \[Delta] -> 1};
sl = NDSolve[{eq, y[-1] == 0.75}, y[x], {x, -1, 1}][[1]];
gr1 = Plot[Evaluate[y[x] /. sl], {x, -1, 1}, PlotStyle -> {Thick, Red}];
Show[gr0, gr1]


Attached a detailed streamplot around the point $$(0, y(0) = 1.2)$$ for $$\lambda = 2$$

• Hello! Thank you for your solution. Although this still doesn't solve the issue. For the value of lambda =2, NDsolve runs into a singularity around y(0) = 1.2. Further, the stream plot is inaccurate near the boundaries i.e. B_1[x]. I actually tried finding stream potential function and plotted contour plots which gave me some reasonable results. There are still less vortex around B_1[x]. Finding a way to refine the solution further. – Anubhav Kamal Sep 30 '20 at 20:24
• I attached a zoom about the point $(0, y(0) = 1.2), \lambda = 2$ and the stream plot as well as the integrated orbit agree quite well. The problem arises when we try to integrate the orbit out the interval $\approx -0.35< x < \approx 0.35$ which is the region in which this orbit is defined. – Cesareo Sep 30 '20 at 22:47

Do you need an exact, closed-form solution? If not, you might want to use NDSolve instead.

• An exact closed-form solution would be excellent. Although, I believe it is hard to find. NDsolve runs into singularity around the boundary i.e. B1(x). I need a way to find an accurate plot. – Anubhav Kamal Sep 30 '20 at 20:29