In [2]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
In [3]:
def f1_numpy(r, u, c):
return (r*c**2)/2 + (u*c**4)/4
In [4]:
n = 2
In [5]:
T = np.linspace(-n,n,101)
In [6]:
fig1 = plt.figure(figsize=(11,8))
ax1 = fig1.gca()
plt.plot(T, f1_numpy(1, 1, T))
plt.xlabel('c', fontsize=14)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=14)
ax1.yaxis.set_label_coords(0.53,1)
ax1.xaxis.set_label_coords(1.03,0.22)
ax1.spines['left'].set_position('zero')
ax1.spines['right'].set_color('none')
ax1.spines['top'].set_color('none')
ax1.spines['bottom'].set_position('zero')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
plt.ylim(-0.5,2)
yticks1 = ax1.yaxis.get_major_ticks()
yticks1[1].label1.set_visible(False);
In [7]:
fig2 = plt.figure(figsize=(11,8))
ax2 = fig2.gca()
# ax2.get_yticklabels()[0].set_visible(False)
plt.plot(T, f1_numpy(-1, 1, T))
plt.xlabel('c', fontsize=16)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=16)
ax2.yaxis.set_label_coords(0.53,1)
ax2.xaxis.set_label_coords(1.03,0.22)
ax2.spines['left'].set_position('zero')
ax2.spines['bottom'].set_position('zero')
ax2.spines['right'].set_color('none')
ax2.spines['top'].set_color('none')
ax2.xaxis.set_ticks_position('bottom')
ax2.yaxis.set_ticks_position('left')
yticks2 = ax2.yaxis.get_major_ticks()
yticks2[1].label1.set_visible(False);
In [8]:
def c1(r,u):
a = []
for i in r:
if i < 0:
a.append(np.sqrt(-i/u))
else:
a.append(0)
return np.array(a)
In [9]:
x = np.linspace(0,2,100)
In [10]:
plt.figure(figsize=(11,8))
plt.plot(x, c1(x-0.5,1),label='+')
plt.plot(x, -c1(x-0.5,1),label='-')
plt.xlabel('T',fontsize=16)
plt.ylabel('c',fontsize=16,rotation='horizontal')
plt.gca().spines['right'].set_color('none')
plt.gca().spines['top'].set_color('none')
plt.gca().spines['bottom'].set_position('zero')
plt.gca().xaxis.set_ticks_position('bottom')
plt.gca().yaxis.set_ticks_position('left')
plt.legend(fontsize=18)
plt.gca().annotate('$\mathregular{T_{C}}$', xy=(0.51, 0.01), xytext=(0.6, 0.15), arrowprops=dict(facecolor='black',width=1,headwidth=7),fontsize=16)
xticks3 = plt.gca().xaxis.get_major_ticks()
xticks3[0].label1.set_visible(False)
plt.gca().xaxis.set_label_coords(1.03,0.515)
plt.gca().yaxis.set_label_coords(0.025,0.99);
In [11]:
def f2_numpy(r, u, v, c):
return (r*c**2)/2 - (abs(u)*c**4)/4 + (abs(v)*c**6)/6
In [15]:
fig3 = plt.figure(figsize=(11,8))
ax3 = fig3.gca()
plt.plot(T, f2_numpy(1, -1, 1, T))
plt.xlabel('c', fontsize=14)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=14)
ax3.yaxis.set_label_coords(0.53,1)
ax3.xaxis.set_label_coords(1.03,0.22)
ax3.spines['left'].set_position('zero')
ax3.spines['right'].set_color('none')
ax3.spines['top'].set_color('none')
ax3.spines['bottom'].set_position('zero')
ax3.xaxis.set_ticks_position('bottom')
ax3.yaxis.set_ticks_position('left')
plt.ylim(-0.05,0.2), plt.xlim(-1.5,1.5)
yticks3 = ax3.yaxis.get_major_ticks()
yticks3[1].label1.set_visible(False);
In [16]:
fig4 = plt.figure(figsize=(11,8))
ax4 = fig4.gca()
plt.plot(T, f2_numpy(0.23, -1, 1, T))
plt.xlabel('c', fontsize=14)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=14)
ax4.yaxis.set_label_coords(0.53,1)
ax4.xaxis.set_label_coords(1.03,0.22)
ax4.spines['left'].set_position('zero')
ax4.spines['bottom'].set_position('zero')
ax4.spines['right'].set_color('none')
ax4.spines['top'].set_color('none')
ax4.xaxis.set_ticks_position('bottom')
ax4.yaxis.set_ticks_position('left')
plt.ylim(-0.05,0.2), plt.xlim(-1.5,1.5)
yticks4 = ax4.yaxis.get_major_ticks()
yticks4[1].label1.set_visible(False);
In [17]:
fig5 = plt.figure(figsize=(11,8))
ax5 = fig5.gca()
plt.plot(T, f2_numpy(0.187302, -1, 1, T))
plt.xlabel('c', fontsize=14)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=14)
ax5.yaxis.set_label_coords(0.53,1)
ax5.xaxis.set_label_coords(1.03,0.22)
ax5.spines['left'].set_position('zero')
ax5.spines['bottom'].set_position('zero')
ax5.spines['right'].set_color('none')
ax5.spines['top'].set_color('none')
ax5.xaxis.set_ticks_position('bottom')
ax5.yaxis.set_ticks_position('left')
plt.ylim(-0.05,0.2), plt.xlim(-1.5,1.5)
yticks5 = ax5.yaxis.get_major_ticks()
yticks5[1].label1.set_visible(False);
In [18]:
fig6 = plt.figure(figsize=(11,8))
ax6 = fig6.gca()
plt.plot(T, f2_numpy(0.15, -1, 1, T))
plt.xlabel('c', fontsize=14)
plt.ylabel('f', rotation='horizontal',verticalalignment='center', fontsize=14)
ax6.yaxis.set_label_coords(0.53,1)
ax6.xaxis.set_label_coords(1.03,0.22)
ax6.spines['left'].set_position('zero')
ax6.spines['bottom'].set_position('zero')
ax6.spines['right'].set_color('none')
ax6.spines['top'].set_color('none')
ax6.xaxis.set_ticks_position('bottom')
ax6.yaxis.set_ticks_position('left')
plt.ylim(-0.05,0.2), plt.xlim(-1.5,1.5)
yticks6 = ax6.yaxis.get_major_ticks()
yticks6[1].label1.set_visible(False);
The solutions for $c_{min}$:
$c_{min} = \pm\sqrt{\dfrac{|u| \pm \sqrt{|u|^{2} - 4r(T)|v|}}{2|v|}}$
Conditions for the following cell:
$c_{min,+} = \pm\sqrt{\dfrac{|u| + \sqrt{|u|^{2} - 4r(T)|v|}}{2|v|}}$ for $\sqrt{|u| + \sqrt{|u|^{2} - 4r(T)|v|}}, \sqrt{|u|^{2} - 4r(T)|v|} > 0$
$c_{min,-} = \pm\sqrt{\dfrac{|u| - \sqrt{|u|^{2} - 4r(T)|v|}}{2|v|}}$ for $\sqrt{|u| - \sqrt{|u|^{2} - 4r(T)|v|}}, \sqrt{|u|^{2} - 4r(T)|v|} > 0$
$c_{min} = 0$ otherwise
In [19]:
#might not be the best code to use
def c2(r, u, v):
a = []
for i in r:
if (abs(u)-np.sqrt(abs(u)**2-4*i*abs(v)) > 0) and (np.sqrt(abs(u)**2-4*i*abs(v)) > 0):
a.append(np.sqrt((abs(u)-np.sqrt(abs(u)**2-4*i*abs(v)))/(2*abs(v))))
elif (abs(u)+np.sqrt(abs(u)**2-4*i*abs(v)) > 0) and (np.sqrt(abs(u)**2-4*i*abs(v)) > 0):
a.append(np.sqrt((abs(u)+np.sqrt(abs(u)**2-4*i*abs(v)))/(2*abs(v))))
else:
a.append(np.NaN)
return np.array(a)
In [20]:
s = np.linspace(-1,5,1000)
In [21]:
plt.figure(figsize=(11,8))
plt.scatter(s, c2(s,-1,1),label='+',facecolors='none', edgecolors='b')
plt.scatter(s, -c2(s,-1,1),label='-',facecolors='none', edgecolors='g')
plt.xlabel('T',fontsize=18)
plt.ylabel('c',fontsize=18,rotation='horizontal')
plt.xlim(-1,0.5)
plt.gca().spines['right'].set_color('none')
plt.gca().spines['top'].set_color('none')
plt.gca().spines['bottom'].set_position('zero')
plt.gca().xaxis.set_ticks_position('bottom')
plt.gca().yaxis.set_ticks_position('left')
plt.legend(fontsize=18)
xticks7 = plt.gca().xaxis.get_major_ticks()
xticks7[0].label1.set_visible(False)
plt.gca().xaxis.set_label_coords(1.05,0.52)
plt.gca().yaxis.set_label_coords(0.03,0.99);
In [33]:
plt.figure(figsize=(11,8))
plt.plot(s,np.sqrt((abs(-1)+np.sqrt(abs(-1)**2-4*s*abs(1)))/(2*abs(1))),c='b',label='$\mathregular{c_{min,+}}$')
plt.plot(s,np.sqrt((abs(-1)-np.sqrt(abs(-1)**2-4*s*abs(1)))/(2*abs(1))),c='g',label='$\mathregular{c_{min,-}}$')
# plt.plot(s,-np.sqrt((abs(-1)+np.sqrt(abs(-1)**2-4*s*abs(1)))/(2*abs(1))),c='b')
# plt.plot(s,-np.sqrt((abs(-1)-np.sqrt(abs(-1)**2-4*s*abs(1)))/(2*abs(1))),c='g')
plt.plot((1/4)*np.ones(10),np.linspace(-1.5,1.5,10),'--k')
plt.plot(np.zeros(10),np.linspace(-1.5,1.5,10),'--k')
plt.plot((3/16)*np.ones(10),np.linspace(-1.5,1.5,10),'--k')
plt.xlabel('r',fontsize=18)
plt.ylabel('c',fontsize=18,rotation='horizontal')
plt.xlim(-0.5,0.5), plt.ylim(0,1.5)
plt.gca().spines['right'].set_color('none')
plt.gca().spines['top'].set_color('none')
plt.gca().spines['bottom'].set_position('zero')
plt.gca().xaxis.set_ticks_position('bottom')
plt.gca().yaxis.set_ticks_position('left')
plt.legend(fontsize=18)
xticks8 = plt.gca().xaxis.get_major_ticks()
xticks8[0].label1.set_visible(False)
plt.gca().xaxis.set_label_coords(1.05,0.01)
plt.gca().yaxis.set_label_coords(0.03,0.99)
plt.gca().annotate('$\mathregular{r_{2} = \ 0}$', xy=(-0.01, 0.5), xytext=(-0.2, 0.5), arrowprops=dict(facecolor='black',width=1,headwidth=4),fontsize=16)
plt.gca().annotate('$\mathregular{r_{1} = \ \\frac{|u|^{2}}{4|v|}}$', xy=(0.26, 0.5), xytext=(0.36, 0.5), arrowprops=dict(facecolor='black',width=1,headwidth=4),fontsize=16)
plt.gca().annotate('$\mathregular{r_{T} = \ \\frac{3|u|^{2}}{16|v|}}$', xy=(0.18, 1.2), xytext=(0.01, 1.3), arrowprops=dict(facecolor='black',width=1,headwidth=4),fontsize=16);
In [ ]: