Show code cell source
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
import matplotlib.pyplot as plt #used for plots
import cmath as cm #used for complex arithmetic
13.7. JNB Lab Solutions#
13.7.1. Complex Potentials#
Solution to Exercise 1
a)
Show code cell source
# create figure and axes
fig=plt.figure(figsize=(10,5))
plt.xlim=(-1,2)
plt.ylim=(-1,2)
# Set up Plot Grid
x = np.linspace(-1, 1, 250)
y = np.linspace(-1, 1, 250)
X, Y = np.meshgrid(x, y)
#Plot the equipotential lines
ax1 = fig.add_subplot(121)
ax1.set_title('Equipotentials',size=35)
plt.gca().tick_params(labelsize=25)
Z = np.sqrt(X**2+Y**2)
contours=plt.gca().contour(X, Y, Z, levels=np.linspace(0,1,9), colors='red');
plt.gca().clabel(contours, inline=True, fontsize=25)
#Plot the streamlines
ax2 = fig.add_subplot(122)
ax2.set_title('Streamlines',size=35)
plt.gca().tick_params(labelsize=25)
Z = np.arctan2(Y,X)
contours=plt.contour(X, Y, Z, levels=np.linspace(-np.pi,np.pi,9), colors='black');
plt.gca().clabel(contours, inline=True, fontsize=25)
plt.savefig('Source.png')
b)
Show code cell source
# create figure and axes
fig=plt.figure(figsize=(15,15))
plt.xlim=(0,1)
plt.ylim=(0,1)
# Set up Plot Grid
x = np.linspace(0, 1, 250)
y = np.linspace(0, 1, 250)
X, Y = np.meshgrid(x, y)
plt.gca().tick_params(labelsize=25)
Z = (-1/(2*np.pi))*np.sqrt(X**2+Y**2)+(1/(2*np.pi))*np.sqrt((X-1)**2+(Y-1)**2)
contours=plt.gca().contour(X, Y, Z, levels=np.linspace(-1,1,70), colors='red');
plt.gca().clabel(contours, inline=True, fontsize=20)
Z1 = (-1/(2*np.pi))*(np.pi+np.arctan2(Y,X))+(1/(2*np.pi))*(2*np.pi-np.arccos((X-1)/np.sqrt((X-1)**2+(Y-1)**2)))
contours1=plt.contour(X, Y, Z1, levels=np.linspace(-.25,.25,25), colors='black');
#plt.gca().clabel(contours1, inline=True, fontsize=25,color='red')
plt.gca().text(-.025,-.05,'Source',size=25,color='b')
plt.gca().text(0,0,'o',size=25,color='b',ha='center',va='center')
plt.gca().text(.975,1.01,'Sink',size=25,color='b')
plt.gca().text(1,1,'o',size=25,color='b',ha='center',va='center')
plt.savefig('QuarterFiveSpot.png')
C:\Users\pisihara\AppData\Local\Temp\ipykernel_11044\3572428666.py:14: RuntimeWarning: invalid value encountered in divide
Z1 = (-1/(2*np.pi))*(np.pi+np.arctan2(Y,X))+(1/(2*np.pi))*(2*np.pi-np.arccos((X-1)/np.sqrt((X-1)**2+(Y-1)**2)))
13.7.2. Fischer-Calo Contaminant Model#
Solution to Exercise 2
a) \(k=k^*\approx .28\)
Show code cell source
plt.figure(figsize=(20,15))
x = np.linspace(-15, 15, 250)
y = np.linspace(-4, 4, 250)
plt.xlim=[-15, 15]
plt.ylim=[-4,4]
k=.28
k0=-.145
c=717
X, Y = np.meshgrid(x, y)
#Z = k0*X+.3*k*.5*np.log(Y**2+X**2)+.2*k*.5*np.log(Y**2+(X-10.8)**2)+c
#contours=plt.contour(X, Y, Z, levels=np.linspace(700,800,600), colors='red')
Z1 = k0*Y+.3*k*np.arctan2(Y,X)+.2*k*np.arctan2(Y,(X-10.8))
contours1=plt.contour(X, Y, Z1, levels=np.linspace(-10,20,1000), colors='black')
plt.gca().tick_params(labelsize=25)
plt.clabel(contours, inline=True, fontsize=15)
#plot action level (XX) locations
plt.text(0,0,' XX',fontsize=35,color='g', verticalalignment='center')
plt.text(0,0,'o',fontsize=35,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(0,1.25,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(0,1.25,'o',fontsize=30,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(-.2,2.1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-.2,2.1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(6.2,-.3,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(6.2,-.3,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(10.8,0,' XX',fontsize=35,color='green', verticalalignment='center')
plt.text(10.8,0,'o',fontsize=35,color='green', verticalalignment='center',ha='center')
#add labels
plt.xlabel('x',size='35')
plt.ylabel('y',size='35')
plt.text(0,-.4,'EWSL-2',fontsize=35,color='g')
plt.text(10.8,-.4,'EWSL-4',fontsize=35,color='green')
plt.savefig('CriticalIneffectiveSystem.png')
b) \(k=\hat{k}\approx .51\)
Show code cell source
plt.figure(figsize=(20,15))
x = np.linspace(-15, 15, 250)
y = np.linspace(-4, 4, 250)
plt.xlim=[-15, 15]
plt.ylim=[-4,4]
k=.51
k0=-.145
c=717
X, Y = np.meshgrid(x, y)
#Z = k0*X+.3*k*.5*np.log(Y**2+X**2)+.2*k*.5*np.log(Y**2+(X-10.8)**2)+c
#contours=plt.contour(X, Y, Z, levels=np.linspace(700,800,600), colors='red')
Z1 = k0*Y+0*k*np.arctan2(Y,X)+.2*k*np.arctan2(Y,(X-10.8))
contours1=plt.contour(X, Y, Z1, levels=np.linspace(-10,20,1000), colors='black')
plt.gca().tick_params(labelsize=25)
plt.clabel(contours, inline=True, fontsize=15)
#plot action level (XX) locations
plt.text(0,0,' XX',fontsize=35,color='g', verticalalignment='center')
plt.text(0,0,'o',fontsize=35,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(0,1.25,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(0,1.25,'o',fontsize=30,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(-.2,2.1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-.2,2.1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(6.2,-.3,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(6.2,-.3,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(10.8,0,' XX',fontsize=35,color='green', verticalalignment='center')
plt.text(10.8,0,'o',fontsize=35,color='green', verticalalignment='center',ha='center')
#add labels
plt.xlabel('x',size='35')
plt.ylabel('y',size='35')
plt.text(0,-.4,'EWSL-2',fontsize=35,color='g')
plt.text(10.8,-.4,'EWSL-4',fontsize=35,color='green')
plt.savefig('CriticalInefficientSystem.png')
c) It reduces it to \(k^*\approx .25\)
Show code cell source
plt.figure(figsize=(20,15))
x = np.linspace(-15, 15, 250)
y = np.linspace(-4, 4, 250)
plt.xlim=[-15, 15]
plt.ylim=[-4,4]
k=.25
k0=-.145
c=717
X, Y = np.meshgrid(x, y)
#Z = k0*X+.3*k*.5*np.log(Y**2+X**2)+.2*k*.5*np.log(Y**2+(X-10.8)**2)+c
#contours=plt.contour(X, Y, Z, levels=np.linspace(700,800,600), colors='red')
Z1 = k0*Y+.2*k*np.arctan2(Y,X)+.3*k*np.arctan2(Y,(X-10.8))
contours1=plt.contour(X, Y, Z1, levels=np.linspace(-10,20,1000), colors='black')
plt.gca().tick_params(labelsize=25)
plt.clabel(contours, inline=True, fontsize=15)
#plot action level (XX) locations
plt.text(0,0,' XX',fontsize=35,color='g', verticalalignment='center')
plt.text(0,0,'o',fontsize=35,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(0,1.25,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(0,1.25,'o',fontsize=30,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(-.2,2.1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-.2,2.1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(6.2,-.3,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(6.2,-.3,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(10.8,0,' XX',fontsize=35,color='green', verticalalignment='center')
plt.text(10.8,0,'o',fontsize=35,color='green', verticalalignment='center',ha='center')
#add labels
plt.xlabel('x',size='35')
plt.ylabel('y',size='35')
plt.text(0,-.4,'EWSL-2',fontsize=35,color='g')
plt.text(10.8,-.4,'EWSL-4',fontsize=35,color='green')
plt.savefig('CriticalEffectiveReversedRatio.png')
d) It reduces it to \(\hat{k}\approx .34\) (Note: This can be obtained from \((.51)(2/3)\))
Show code cell source
plt.figure(figsize=(20,15))
x = np.linspace(-15, 15, 250)
y = np.linspace(-4, 4, 250)
plt.xlim=[-15, 15]
plt.ylim=[-4,4]
k=.34
k0=-.145
c=717
X, Y = np.meshgrid(x, y)
#Z = k0*X+.3*k*.5*np.log(Y**2+X**2)+.2*k*.5*np.log(Y**2+(X-10.8)**2)+c
#contours=plt.contour(X, Y, Z, levels=np.linspace(700,800,600), colors='red')
Z1 = k0*Y+0*k*np.arctan2(Y,X)+.3*k*np.arctan2(Y,(X-10.8))
contours1=plt.contour(X, Y, Z1, levels=np.linspace(-10,20,1000), colors='black')
plt.gca().tick_params(labelsize=25)
plt.clabel(contours, inline=True, fontsize=15)
#plot action level (XX) locations
plt.text(0,0,' XX',fontsize=35,color='g', verticalalignment='center')
plt.text(0,0,'o',fontsize=35,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(0,1.25,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(0,1.25,'o',fontsize=30,color='g', verticalalignment='center',horizontalalignment='center')
plt.text(-.2,2.1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-.2,2.1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(6.2,-.3,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(6.2,-.3,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-8.1,.9,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(-11.8,1,' XX',fontsize=30,color='g', verticalalignment='center')
plt.text(-11.8,1,'o',fontsize=30,color='g', verticalalignment='center',ha='center')
plt.text(10.8,0,' XX',fontsize=35,color='green', verticalalignment='center')
plt.text(10.8,0,'o',fontsize=35,color='green', verticalalignment='center',ha='center')
#add labels
plt.xlabel('x',size='35')
plt.ylabel('y',size='35')
plt.text(0,-.4,'EWSL-2',fontsize=35,color='g')
plt.text(10.8,-.4,'EWSL-4',fontsize=35,color='green')
plt.savefig('CriticalInefficientReversedSystem.png')