Created
December 20, 2017 22:26
-
-
Save Mahdisadjadi/925af38c5c932754a381a3bd70b2c03a to your computer and use it in GitHub Desktop.
Generate a picture of a symmetric one-dimensional double-well pontetial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This code generates a picture of a symmetric | |
one-dimensional double-well pontetial. | |
Mahdi Sadjadi, 2017. | |
''' | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FuncFormatter, MaxNLocator | |
for param in ['axes.labelsize','xtick.labelsize','ytick.labelsize']: | |
plt.rcParams[param] = 15 | |
f = lambda x: (16/(0.5)**4) * ((x-1/2)**2 - (0.5)**2/4)**2 | |
fig,ax = plt.subplots(1,1,figsize=(7,7)) | |
x = np.linspace(0,1,100) | |
ax.plot(x,f(x),'-k',lw=2) | |
x = np.linspace(0.,0.55,100) | |
fprime = lambda x: 0.5 * 128 * (x - 1/4)**2 | |
ax.plot(x,fprime(x),color='darkred',linestyle='--',lw=2) | |
x = np.linspace(0.45,1,100) | |
fprime = lambda x: 0.5 * 128 * (x - 3/4)**2 | |
ax.plot(x,fprime(x),color='darkred',linestyle='--',lw=2) | |
ax.annotate('', xy=(0.25, 8.1), xycoords='data', xytext=(0.75, 8.1), textcoords='data',arrowprops={'lw':2,'arrowstyle': '<->'}) | |
ax.annotate('d', xy=(0.5, 8), xycoords='data',xytext=(0.5, 8), textcoords='offset points',fontsize=20) | |
ax.annotate('', xy=(0.5, 1), xycoords='data', xytext=(0.5, 0), textcoords='data',arrowprops={'lw':2,'arrowstyle': '<->'}) | |
ax.annotate(r'$V_0$', xy=(0.51, 0.42), xycoords='data',xytext=(0.5, 1), textcoords='offset points',fontsize=20) | |
ax.vlines(0.25, 0, 10, linestyles='dashed') | |
ax.vlines(0.75, 0, 10, linestyles='dashed') | |
ax.yaxis.set_ticks([]) | |
ax.xaxis.set_ticks([]) | |
ax.set_xlim(0,1) | |
ax.set_ylim(-0.01,10) | |
ax.set_xlabel('x') | |
ax.set_ylabel('V(x)') | |
plt.tight_layout() | |
plt.savefig('./double_well.pdf',dpi=100) | |
plt.show(fig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment