from solver import Evolve_RG import numpy as np import matplotlib.pyplot as plt from constants import * from matplotlib import rc rc('font',**{'family':'serif','serif':['Times'],'size':14}) rc('text', usetex=True) env=Evolve_RG.load('example-tstop-universal.pickle') plt.figure(figsize=(12,5.5)) plt.subplot(1,2,1) nfreq=len(env.freqs) tv=env.tv lums=np.zeros_like(env.corrs) plt.plot(tv/Myr,env.synch,ls='--',color='black',label='150 MHz uncorrected') for i in range(nfreq): lums[:,i]=env.synch*(env.freqs[i]/env.nu_ref)**-env.alpha*env.corrs[:,i] plt.plot(tv/Myr,lums[:,i],label='%.0f MHz' % (env.freqs[i]/1e6)) plt.xscale('log') plt.yscale('log') plt.legend(loc=0,fontsize='small') plt.xlabel('Time (Myr)') plt.ylabel('Radio luminosity (W Hz$^{-1}$)') plt.xlim((1,300)) plt.ylim((1e25,3e29)) plt.subplot(1,2,2) for i in range(1,nfreq): plt.plot(tv/Myr,-np.log(lums[:,i]/lums[:,i-1])/np.log(env.freqs[i]/env.freqs[i-1]),label='$\\alpha_{%.0f}^{%.0f}$' % (env.freqs[i]/1e6,env.freqs[i-1]/1e6))
naxes = 4 ylabs = ['Length/kpc', 'Axial ratio', 'Mach number', 'L_150/(W/Hz)'] for i in range(naxes): axes.append(plt.subplot(naxes / 2, naxes / 2, i + 1)) for ax in axes: ax.set_xscale('log') ax.set_yscale('log') tmin = 10**-6 tmax = 300 tv = np.logspace(np.log10(tmin), np.log10(tmax), 100) * Myr env = Evolve_RG('beta', kT=0.86e3 * eV, p0=2e-12, rc=22 * 1.528714 * kpc, beta=0.67, do_adiabatic=False, q=2.1) #env=evolve_rg('universal',M500=1e14) for Q in np.logspace(37.5, 39.5, 5): print('solving for jet power', Q, 'W') env.solve(Q, tv) env.findb() env.findsynch(150e6) env.findcorrection((150e6, )) axes[0].plot(tv / Myr, env.R / kpc, label='Q = %.2g W' % Q) axes[1].plot(tv / Myr, env.rlobe, label='Q = %.2g W' % Q) axes[2].plot(tv / Myr, env.m1, label='Q = %.2g W' % Q) axes[3].plot(env.R / kpc,
axes=[] naxes=4 for i in range(naxes): axes.append(plt.subplot(naxes/2,naxes/2,i+1)) for ax in axes: ax.set_xscale('log') ax.set_yscale('log') tmin=0 tmax=300 tv=np.logspace(-6,np.log10(tmax),100)*Myr #env=evolve_rg('universal',M500=1e14) Q=10**38.5 for i in range(2): env=Evolve_RG('beta',kT=0.86e3*eV,p0=2e-12,rc=22*1.528714*kpc,beta=0.67,do_adiabatic=True,q=2.1) env.solve(Q,tv,tstop=Myr*(tmax-(i*200))) env.findb() env.findsynch(150e6) env.findcorrection((150e6,)) axes[0].plot(tv/Myr,env.R/kpc) axes[1].plot(tv/Myr,env.rlobe,label='i = %i' % i) axes[2].plot(tv/Myr,env.m1) axes[3].plot(env.R/kpc,env.synch*env.corrs[:,0]) env.save('save_tstop_%i.pickle' % i) #axis1.set_ylim(R/kpc/5,5*R/kpc) #axis2.set_ylim(enow/5,enow*20) for ax in axes[0:3]: ax.set_xlim((tmin,tmax))
# Plot a couple of pressure profiles from constants import * from solver import Evolve_RG import numpy as np import os.path xi = 0.4 q = 2.1 labels = ['beta', 'universal'] envs = [ Evolve_RG('beta', kT=2.27e3 * eV, p0=4e-12, rc=30 * kpc, beta=0.67, xi=xi, q=q), Evolve_RG('universal', M500=1e14, xi=xi, q=q) ] tmin = 0 tmax = 300 tv = np.logspace(-5, np.log10(tmax), 100) * Myr Q = 2e39 for env, l in zip(envs, labels): inname = 'example-' + l + '.pickle' outname = 'example-' + l + '-highz.pickle' if os.path.isfile(inname): env = Evolve_RG.load(inname)
plt.xscale('log') plt.yscale('log') plt.figure(4) plt.xscale('log') tmin=0 tmax=300 tv=np.logspace(-6,np.log10(tmax),100)*Myr if highz: g=glob.glob('highz*.pickle') else: g=glob.glob('save_*.pickle') for f in g: sdict={} env=Evolve_RG.load(f) sdict['color']=cm.gist_rainbow((np.log10(env.Q)-36)/4.0) sdict['alpha']=((np.log10(env.m500)-11.5)/3.5)**2.0 plt.figure(1) plt.plot(tv/Myr,env.R/kpc,**sdict) plt.figure(2) plt.plot(env.R/kpc,np.sqrt(env.vl/(np.pi*env.R**3.0)),**sdict) plt.figure(3) plt.plot(env.R/kpc,env.synch*env.corrs[:,0],zorder=2,**sdict) plt.figure(4) plt.plot(env.R/kpc,0.55+np.log(env.corrs[:,0]/env.corrs[:,1])/np.log(1400.0/150.0),**sdict) #axes[3].plot(env.R/kpc,env.synch) #axis1.set_ylim(R/kpc/5,5*R/kpc) #axis2.set_ylim(enow/5,enow*20) xlabels=['t (Myr)','Lobe length (kpc)','Lobe length (kpc)','Lobe length (kpc)']
rc('font', **{'family': 'serif', 'serif': ['Times'], 'size': 14}) rc('text', usetex=True) tmin = 0 tmax = 200 tv = np.logspace(-6, np.log10(tmax), 200) * Myr #env=evolve_rg('universal',M500=1e14) Q = 2e38 envs = [] for beta in [0.55, 0.75, 0.90]: for rc in [20, 30, 40]: outname = 'beta-%.2f-%i.pickle' % (beta, rc) if os.path.isfile(outname): envs.append(Evolve_RG.load(outname)) else: rc *= 2.1 * kpc envs.append( Evolve_RG('beta', kT=2e3 * eV, p0=5.76e-12, rc=rc, beta=beta, qfactor=0.5 * 25 * 730e3, Gamma_j=(5.0 / 3.0))) envs[-1].solve(Q, tv) envs[-1].save(outname) for i in range(2): for env in envs:
naxes=4 plt.figure(figsize=(12,9)) for i in range(naxes): axes.append(plt.subplot(naxes/2,naxes/2,i+1)) for ax in axes: ax.set_xscale('log') axes[0].set_yscale('log') axes[2].set_yscale('log') names=['beta','universal'] colours=['blue','orange'] labels=['$\\beta$ model','Universal'] for n,c,l in zip(names,colours,labels): outname='example-'+n+'.pickle' env=Evolve_RG.load(outname) tv=env.tv axes[0].plot(tv/Myr,env.R/kpc,color=c,label=l+' $R$') rlobep=np.sqrt(env.vl/(4*np.pi*env.R)) axes[0].plot(tv/Myr,env.Rp/kpc,ls=':',color=c,label=l+' $R_\\perp$') axes[0].plot(tv/Myr,rlobep/kpc,ls='--',color=c,label=l+' $R_{\\perp, lobe}$') if n=='universal': axes[0].plot(tv/Myr,40*(tv/Myr)**0.6,ls='-.',color='green',label='$R \propto t^{3/5}$') axes[1].plot(tv/Myr,env.rlobe,color=c) axes[2].plot(tv/Myr,env.m1,color=c) axes[2].plot(tv/Myr,env.mp1,color=c,ls=':') axial=2*rlobep/env.R axes[3].plot(tv/Myr,axial,color=c,label=l) #axis1.set_ylim(R/kpc/5,5*R/kpc) #axis2.set_ylim(enow/5,enow*20)
import pickle import os from constants import * from solver import Evolve_RG if __name__ == '__main__': import sys number = int(sys.argv[1]) - 1 qnum = number // 10 mnum = number % 10 print qnum, mnum tmin = 0 tmax = 500 tv = np.logspace(-6, np.log10(tmax), 100) * Myr Qs = np.logspace(36, 40, 13) masses = np.logspace(13, 15, 10) Q = Qs[qnum] m = masses[mnum] print 'Doing the run for Q=', Q, 'M=', m env = Evolve_RG('universal', M500=m, xi=0.40, q=2.1) outfile = 'save_%.1f_%.1f.pickle' % (np.log10(Q), np.log10(m)) if not os.path.isfile(outfile): print 'solving for', Q, m env.solve(Q, tv) env.findb() env.findsynch(150e6) env.findcorrection((150e6, 1400e6), do_adiabatic=True) env.save(outfile)
import numpy as np from solver import Evolve_RG t = Table.read('source-table.txt', format='ascii') l150 = [] d = [] alpha = [] live = [] remnant = [] u = np.random.uniform(size=len(t)) theta = np.arccos(1 - u) for i, r in enumerate(t): inname = 'run-%i.pickle' % i env = Evolve_RG.load(inname) synch = env.synch[-1] * env.corrs[-1, 0] live.append(synch > 0) l150.append(synch) d.append(env.R[-1]) if synch > 0: alpha.append(0.55 + np.log(env.corrs[-1, 1] / env.corrs[-1, 2]) / np.log(1400.0 / 150.0)) else: alpha.append(np.nan) remnant.append((r['lifetime'] + r['Tstart']) < 1000.0) t['l150'] = l150 t['D'] = d t['alpha'] = alpha t['live'] = live
from solver import Evolve_RG import numpy as np import matplotlib.pyplot as plt from constants import * from matplotlib import rc rc('font',**{'family':'serif','serif':['Times'],'size':14}) rc('text', usetex=True) env=Evolve_RG.load('dwarf.pickle') plt.figure(figsize=(12,10)) plt.subplot(2,2,1) nfreq=len(env.freqs) tv=env.tv lums=np.zeros_like(env.corrs) plt.plot(tv/Myr,env.synch,ls='--',color='black',label='150 MHz uncorrected') for i in range(nfreq): lums[:,i]=env.synch*(env.freqs[i]/env.nu_ref)**-env.alpha*env.corrs[:,i] plt.plot(tv/Myr,lums[:,i],label='%.0f MHz' % (env.freqs[i]/1e6)) plt.xscale('log') plt.yscale('log') plt.legend(loc=0,fontsize='small') plt.xlabel('Time (Myr)') plt.ylabel('Radio luminosity (W Hz$^{-1}$)') plt.subplot(2,2,2) for i in range(1,nfreq): plt.plot(tv/Myr,-np.log(lums[:,i]/lums[:,i-1])/np.log(env.freqs[i]/env.freqs[i-1]),label='$\\alpha_{%.0f}^{%.0f}$' % (env.freqs[i]/1e6,env.freqs[i-1]/1e6)) plt.xscale('log') plt.legend(loc=0,fontsize='small')
import os from constants import * from solver import Evolve_RG if __name__ == '__main__': import sys number = int(sys.argv[1]) - 1 qnum = number // 10 mnum = number % 10 print qnum, mnum tmin = 0 tmax = 500 tv = np.logspace(-6, np.log10(tmax), 100) * Myr Qs = np.logspace(36, 40, 13) masses = np.logspace(13, 15, 10) Q = Qs[qnum] m = masses[mnum] print 'Doing the run for Q=', Q, 'M=', m infile = 'save_%.1f_%.1f.pickle' % (np.log10(Q), np.log10(m)) env = Evolve_RG.load(infile) outfile = 'highz_%.1f_%.1f.pickle' % (np.log10(Q), np.log10(m)) if not os.path.isfile(outfile): print 'solving for', Q, m #env.solve(Q,tv) #env.findb() #env.findsynch(150e6) env.findcorrection((150e6, 1400e6), do_adiabatic=True, z=2) env.save(outfile)
from matplotlib import rc import os.path rc('font', **{'family': 'serif', 'serif': ['Times'], 'size': 14}) rc('text', usetex=True) i = 0 for beta in [0.55, 0.75, 0.90]: for rc in [20, 30, 40]: color = [ 'orange', 'red', 'firebrick', 'yellowgreen', 'lime', 'darkgreen', 'dodgerblue', 'royalblue', 'darkblue' ][i] i += 1 env = Evolve_RG.load('beta-%.2f-%i.pickle' % (beta, rc)) tv = env.tv plt.plot(tv / Myr, env.vl / (kpc**3.0), color=color, ls='--') t = np.loadtxt('/home/mjh/PLUTO/results2/bmb-%i-%i-2s' % (int(beta * 100), rc), skiprows=1) stu = 2.9 slu = 2.1 plt.plot(t[:, 0] * stu, (t[:, 14] + t[:, 1]) * 0.5 * slu**3.0, color=color, label='$\\beta = %.2f$ $r_c=%.0f$ kpc' % (env.beta, env.rc / kpc)) plt.xscale('log')
# Plot a couple of pressure profiles import matplotlib.pyplot as plt from constants import * from solver import Evolve_RG import numpy as np from matplotlib import rc rc('font', **{'family': 'serif', 'serif': ['Times'], 'size': 14}) rc('text', usetex=True) labels = ['$\\beta$ model', 'Universal'] colours = ['blue', 'orange'] envs = [ Evolve_RG('beta', kT=2.27e3 * eV, p0=4e-12, rc=30 * kpc, beta=0.67), Evolve_RG('universal', M500=1e14) ] dist = np.logspace(-3, 3.3, 100) for env, l, c in zip(envs, labels, colours): plt.plot(dist, env.pr(dist * kpc), label=l, color=c) plt.xlabel('Distance (kpc)') plt.ylabel('Pressure (Pa)') plt.xscale('log') plt.yscale('log') plt.legend(loc=0) plt.tight_layout() plt.savefig('prprof.pdf')
from constants import * from matplotlib import rc rc('font', **{'family': 'serif', 'serif': ['Times'], 'size': 14}) rc('text', usetex=True) plt.figure(figsize=(12, 5.5)) done_uncorr = False for name, label in zip( ['example-universal-noad', 'example-universal', 'example-universal-highz'], [ 'Radiative only, $z=0$', 'Radiative + adiabatic, $z=0$', 'Radiative + adiabatic, $z=2$' ]): env = Evolve_RG.load(name + '.pickle') plt.subplot(1, 2, 1) nfreq = len(env.freqs) tv = env.tv lums = np.zeros_like(env.corrs) if not done_uncorr: plt.plot(tv / Myr, env.synch, ls='--', color='black', label='150 MHz uncorrected') for i in range(nfreq): lums[:, i] = env.synch * (env.freqs[i] / env.nu_ref)**-env.alpha * env.corrs[:, i] ploti = 0
# Example dwarf galaxy profile from constants import * from solver import Evolve_RG import numpy as np import os.path xi = 0.4 q = 2.1 env = Evolve_RG('beta', kT=1e4 * boltzmann, p0=10**0.75 * 3.1e-16, rc=0.8 * kpc, beta=0.67, xi=xi, q=q) outname = 'dwarf.pickle' tmin = 0 tmax = 100 tv = np.logspace(-5, np.log10(tmax), 100) * Myr Q = 1e35 env.solve(Q, tv) env.save(outname) env.findb() env.findsynch(150e6) env.findcorrection((150e6, 330e6, 1.4e9, 5e9, 8e9, 15e9), do_adiabatic=True) env.save(outname)
#!/usr/bin/python from solver import Evolve_RG from astropy.table import Table import sys from constants import * import os t = Table.read('source-table.txt', format='ascii') lookback = 1000 n = int(sys.argv[1]) r = t[n] print r env = Evolve_RG('universal', M500=r['M500'], xi=0.40, q=2.1) tlimit = lookback - r['Tstart'] tv = np.logspace(-6, np.log10(tlimit), 100) * Myr outfile = 'run-%i.pickle' % n if not os.path.isfile(outfile): env.solve(r['Q'], tv, tstop=r['lifetime'] * Myr) env.findb() env.findsynch(150e6) env.findcorrection((150e6, 150e6 * (1 + r['z']), 1400e6 * (1 + r['z'])), do_adiabatic=True, z=r['z'], timerange=(99, )) env.save('run-%i.pickle' % n)