import numpy as np
from matplotlib import pyplot as plt
import matplotlib as mpl

mpl.rcParams.update({'font.size':18})

fusnrg = np.genfromtxt('fusnrg.dat')

deutnrg = np.genfromtxt('fdeutnrg.dat')
tritnrg = np.genfromtxt('ftritnrg.dat')
thenrg = np.genfromtxt('f3henrg.dat')
neutnrg = np.genfromtxt('neutnrg.dat')
thermnrg = np.genfromtxt('thermalnrg.dat')

n = fusnrg.shape[0]

print(n)

plt.plot(fusnrg[:,0]/1e-12,fusnrg[:,1],'k',lw=2.0,label='Fusion')
plt.plot(deutnrg[:,0]/1e-12,deutnrg[:,1],'g',lw=2.0,label='D KE')
plt.plot(tritnrg[:,0]/1e-12,tritnrg[:,1],'b',lw=2.0,label='T KE')
plt.plot(thenrg[:,0]/1e-12,thenrg[:,1],'r',lw=2.0,label='He-3 KE')
plt.plot(neutnrg[:,0]/1e-12,neutnrg[:,1],'m',lw=2.0,label='Neutron KE')
plt.plot(thermnrg[:,0]/1e-12,thermnrg[:,1],'tab:orange',lw=2.0,label = 'Thermal')
#plt.plot(neutnrg[:,0]/1e-12,neutnrg[:,1]+thenrg[:,1],'c',lw=2.0)
#plt.plot(fusnrg[:,0]/1e-12,fusnrg[:,1]+deutnrg[0,1],'k--',lw=2.0)
plt.xlabel(r'$t$ (ps)')
plt.ylabel(r'$U$')
plt.grid()
plt.legend(loc='upper left')
plt.show()


plt.plot(fusnrg[:,0]/1e-12,fusnrg[:,1]/deutnrg[0,1],'k',lw=2.0,label='Fusion')
plt.xlabel(r'$t$ (ps)')
plt.ylabel(r'$G$')
plt.grid()
plt.show()

plt.semilogy(fusnrg[:,0]/1e-12,fusnrg[:,1]/deutnrg[0,1],'k',lw=2.0,label='Fusion')
plt.xlabel(r'$t$ (ps)')
plt.ylabel(r'$G$')
plt.grid()
plt.show()

print(fusnrg[n-1,1]/deutnrg[0,1])