This is the python script used to generate the pictures for article 79649
#!/usr/bin/env python3
# ================================================================
# This script generates pictures for article 79649
#
# Written by Randy S (2022)
# ================================================================
import numpy as np
import scipy.integrate as integrate
import matplotlib.pyplot as plotter
import sys
global numdims
num = 30 # number of grid-points in the vector-field pictures
# ===================================================================
def get_xbeta( x, y ):
return 2*x + y - x*y
# ===================================================================
def get_ybeta( x, y ):
return (4-numdims)*y - 3*y*y
# ===================================================================
def get_fixed_points():
global numdims
if numdims == 4:
x = np.array( [0, 0] )
y = np.array( [0, 0] )
else:
x = np.array( [0, 1/(1-(6.0/(4-numdims)))] )
y = np.array( [0, (4-numdims)/3.0] )
if 0: # check
print( 'Should be zero:', 2*x+y-x*y )
print( 'Should be zero:', (4-numdims)*y-3*y*y )
return x, y
# ===================================================================
def finishPlotting( ax, filename ):
# https://stackoverflow.com/questions/3899980/how-to-change-the-font-size-on-a-matplotlib-plot
fs = 16
for item in ([ax.title,
ax.xaxis.label,
ax.yaxis.label] +
ax.get_xticklabels() + ax.get_yticklabels() ):
item.set_fontsize(fs)
if 1:
# Save picture to file
fig = plotter.gcf()
filename += '.pdf'
print( 'Writing ' + filename )
# fig.tight_layout()
fig.savefig(filename, bbox_inches='tight')
print( 'Closed ' + filename )
# Show the picture on the screen
plotter.show()
# ===================================================================
def showFunction( filename ):
xfp, yfp = get_fixed_points()
# https://stackoverflow.com/questions/32462881/add-colorbar-to-existing-axis
fig, ax = plotter.subplots()
# https://matplotlib.org/3.5.0/tutorials/text/usetex.html
plotter.rcParams.update({
"text.usetex": True,
"font.family": "Helvetica"
})
# choose the range to show for each axis
if numdims <= 4:
xmin = -0.35
xmax = 0.15
ymin = -0.1
ymax = 0.4
if 0: # closeup for d = 3.9
xmin = -0.035
xmax = 0.015
ymin = -0.01
ymax = 0.04
else:
xmin = -0.15
xmax = 0.35
ymin = -0.4
ymax = 0.1
# show the axes
plotter.plot( [xmin,xmax], [0,0], color='gray' )
plotter.plot( [0,0], [ymin,ymax], color='gray' )
# show the fixed points
for k in range(len(xfp)):
plotter.plot( xfp[k], yfp[k], 'ob' )
# show the arrows
x,y = np.meshgrid(np.linspace( xmin, xmax, num ), \
np.linspace( ymin, ymax, num ))
xbeta = get_xbeta( x, y )
ybeta = get_ybeta( x, y )
if normalize:
amp = 1/np.sqrt(xbeta**2 + ybeta**2)
else:
amp = 1
plotter.quiver( x, y, amp*xbeta, amp*ybeta )
# control the number of tick-marks
plotter.locator_params(axis='x', nbins=5)
plotter.locator_params(axis='y', nbins=5)
# label the graph
ax.set_xlabel( r'$g_2$' )
ax.set_ylabel( r'$g_4$' )
title = r'$d=' + str(numdims) + '$'
if normalize:
title += ', normalized'
ax.set_title( title )
finishPlotting( ax, filename )
# ===================================================================
# Main program
if len(sys.argv) < 4:
print( 'Usage:' )
print( ' 79649f.py numdims normalize filename' )
print( 'with' )
print( ' numdims = number of spacetime dimensions' )
print( ' normalize = 0 or 1' )
print( ' filename (without extension -- .pdf will be appended)' )
sys.exit()
# inputs from command-line
numdims = float(sys.argv[1]) # number of spacetime dimensions
normalize = int(sys.argv[2]) # 0 or 1
filename = sys.argv[3]
showFunction( filename )