elif opt == '-y': log_y = True # Check for mandatory arguments. if index == None: print 'Error: No polytropic index supplied!' sys.exit(1) if nsteps == None: print 'Error: No step number supplied!' sys.exit(1) # Initialize the polytrope. rho_0 = 150.0 pressure_0 = 10**17.369 radius = 6.95508e10 star = Polytrope(nsteps, index, rho_0, pressure_0, radius) # Run the solver and plot the results. indices = range(1, index+1) + [1.5] indices.sort() for index in indices: star.update_index(index) star.rk4_outward() radpts = star.radpts / star.radius density = star.density / star.rho_0 plot_label = r'$n = ' + str(index) + '$' plt.plot(radpts, density, label=plot_label) axes = plt.axes() plt.xlabel(r'$R / R_*$') plt.ylabel(r'$\rho / \rho_c$')
elif opt == '-y': log_y = True # Check for mandatory arguments. if index == None: print 'Error: No polytropic index supplied!' sys.exit(1) if nsteps == None: print 'Error: No step number supplied!' sys.exit(1) # Initialize the polytrope. rho_0 = 150.0 pressure_0 = 10**17.369 radius = 6.95508e10 star = Polytrope(nsteps, index, rho_0, pressure_0, radius) # Run the solver and plot the results. star.rk4_outward() radpts = star.radpts / star.radius density = star.density / star.rho_0 # Plot the results. axes = plt.axes() plt.plot(radpts, density, label='Numerical solution') plt.xlabel(r'$R / R_*$') plt.ylabel(r'$\rho / \rho_c$') if star.index == int(star.index): plt.title(r'$n = ' + str(int(star.index)) + '$') else: plt.title(r'$n = ' + str(star.index) + '$')