Plot_me.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import numpy as np
3 import matplotlib.pyplot as plt
4 from matplotlib import cm
5 # Import the WinNet python plot-routine
6 # Note that you can also just append the path to your .bashrc
7 import sys
8 sys.path.append('../../bin')
9 from class_files.winnet_class import winnet
10 
11 # Create figures to plot at
12 fig_neutron_dens = plt.figure()
13 ax_neutron_dens = fig_neutron_dens.gca()
14 
15 fig_chart,ax_chart = plt.subplots(1,3,figsize=(15,4),sharex=True,sharey=True)
16 plt.subplots_adjust(hspace=0,wspace=0)
17 
18 
19 # Setup for nuclear chart plot
20 lw = 0.1 # use a small linewidth for the nuclei-rectangle
21 min_X = 1e-10 # Min of mass fraction
22 max_X = 1e-4 # Max of mass fraction
23 cmap = cm.jet # Use the jet colormap
24 
25 # X(H) = 20%
26 w = winnet('./i_h20.dat/')
27 w.read_mainout()
28 t,n_dens = w.get_mainout_time(), w.get_mainout_yn()
29 n_dens = n_dens * 1.e4 * 6.022140857e23
30 ax_neutron_dens.plot(t,n_dens,label='X(H)=20%',c="b",ls='-.')
31 # Plot the path in the nuclear chart
32 w.plot_nuclear_chart_at(1e4,figure=ax_chart[0],axes_label=False,element_labels=False,fig_is_ax=True,
33  colorbar=False,min_X=min_X,max_X=max_X,cmap= cmap,nuclei_linewidths=lw)
34 
35 # X(H) = 10%
36 w = winnet('./i_h10.dat/')
37 w.read_mainout()
38 t,n_dens = w.get_mainout_time(), w.get_mainout_yn()
39 n_dens = n_dens * 1.e4 * 6.022140857e23
40 ax_neutron_dens.plot(t,n_dens,label='X(H)=10%',c="g",ls='--')
41 # Plot the path in the nuclear chart
42 w.plot_nuclear_chart_at(1e4,figure=ax_chart[1],axes_label=False,element_labels=False,fig_is_ax=True,
43  colorbar=False,min_X=min_X,max_X=max_X,cmap= cmap,nuclei_linewidths=lw)
44 
45 
46 
47 # X(H) = 5%
48 w = winnet('./i_h05.dat/')
49 w.read_mainout()
50 t,n_dens = w.get_mainout_time(), w.get_mainout_yn()
51 n_dens = n_dens * 1.e4 * 6.022140857e23
52 ax_neutron_dens.plot(t,n_dens,label='X(H)=5%',c="r",ls='-')
53 # Plot the path in the nuclear chart
54 w.plot_nuclear_chart_at(1e4,figure=ax_chart[2],axes_label=False,element_labels=False,fig_is_ax=True,colorbar=True,
55  colorbar_position=[0.27, 0.85, 0.5, 0.025],colorbar_inset=True,min_X=min_X,max_X=max_X
56  ,cmap= cmap,nuclei_linewidths=lw)
57 
58 
59 # General setup for the neutron density plot
60 ax_neutron_dens.set_title(r"Without $^{13}$N($p, \gamma $)$^{14}$O rate!")
61 ax_neutron_dens.set_yscale('log')
62 ax_neutron_dens.set_xscale('log')
63 ax_neutron_dens.set_xlim(1.e3,1.e6)
64 ax_neutron_dens.set_ylim(1.e11,1.e16)
65 ax_neutron_dens.set_xlabel('Time [s]')
66 ax_neutron_dens.set_ylabel(r'Neutron density [cm$^{-3}$]')
67 ax_neutron_dens.legend()
68 ax_neutron_dens.grid()
69 
70 # General setup for the nuclear chart plot
71 ax_chart[0].set_xlim(16,129)
72 ax_chart[0].set_ylim(12,75)
73 ax_chart[0].text(0.22,0.92,"X(H)=20%",transform=ax_chart[0].transAxes,ha='right')
74 ax_chart[1].text(0.22,0.92,"X(H)=10%",transform=ax_chart[1].transAxes,ha='right')
75 ax_chart[2].text(0.22,0.92,"X(H)=5%",transform=ax_chart[2].transAxes ,ha='right')
76 fig_chart.text(0.5,0.1,"Neutron number",ha='center')
77 ax_chart[0].set_ylabel("Proton number")
78 
79 # Save the neutron density plot
80 # Compare this plot with the one from Dardelet et al 2015, Fig. 1
81 fig_neutron_dens.savefig('Neutron_density_iprocess_dardelet.pdf',bbox_inches="tight")
82 
83 # Save the path in the nuclear chart
84 fig_chart.savefig('Path_iprocess_dardelet.pdf',bbox_inches="tight")
85 
86 plt.show()