Reputation: 29
I am trying to construct a plot like what in the following picture:
I can plot each profile separtly; this code to plot the boundary layer:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,10,1000)
U=0.5
nu=15.89*10**-6
delta=5/np.sqrt(U/(nu*x))
plt.plot(x,delta)
plt.xlim(0,10)
plt.ylim(0,0.12)
plt.grid()
plt.show()
, this one to plot the velocity profile:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,10,31)
eta = np.linspace(0,10,31)
U=0.5
nu=15.89*10**-6
y = eta/np.sqrt(U/(nu*2))
fp=np.array([0, 0.066513, 0.132974, 0.199252, 0.265127, 0.330298, 0.394392, 0.456971, 0.517552, 0.575633, 0.630712, 0.682317, 0.73004, 0.773553, 0.812637, 0.847192, 0.877241, 0.902924, 0.924491, 0.942275, 0.956661, 0.968092, 0.976998, 0.98379, 0.98889, 0.992639, 0.995322, 0.997228, 0.998547, 0.999438, 1.000034])
u = fp*U
plt.plot(u,y)
plt.grid()
plt.show()
I have tried to combine both plots in one graph, as in the picture, but I could not. Would you please suggest how I can do it.
Upvotes: 0
Views: 1991
Reputation: 80409
You could add a position to the u-values of the second plot. The two other curves can be drawn in a similar way.
With the default scaling, the 3 curves are quite high compared to the delta
curve. Interpolating the value at the given positions, one could scale the new curves with the height of the delta
curve:
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(12, 4))
x = np.linspace(0.001, 10, 1000)
U = 0.5
nu = 15.89 * 10 ** -6
delta = 5 / np.sqrt(U / (nu * x))
ax.plot(x, delta, color='dodgerblue')
eta = np.linspace(0, 10, 31)
fp = np.array([0, 0.066513, 0.132974, 0.199252, 0.265127, 0.330298, 0.394392, 0.456971, 0.517552, 0.575633, 0.630712, 0.682317, 0.73004, 0.773553, 0.812637, 0.847192, 0.877241, 0.902924, 0.924491, 0.942275, 0.956661, 0.968092, 0.976998, 0.98379, 0.98889, 0.992639, 0.995322, 0.997228, 0.998547, 0.999438, 1.000034])
u = fp * U
for position in [1, 3, 6, 9]:
y = eta / np.sqrt(U / (nu * position))
# scaling = 0.6
scaling = np.interp(position, x, delta) / y.max()
ax.plot(u + position, y * scaling, color='purple')
ax.plot([position, position], [0, y.max() * scaling], color='black')
ax.set_xlim(0, 10)
ax.set_ylim(0, 0.12)
ax.grid()
plt.show()
PS: The following change would draw the curves as given (without scaling), and then extend them till some desired height:
desired_height = 0.12
for position in [1, 3, 6, 9]:
y = eta / np.sqrt(U / (nu * position))
ax.plot(np.append(u + position, (u + position)[-1] ), np.append(y, desired_height), color='purple')
ax.plot([position, position], [0, desired_height], color='black')
Upvotes: 1