Practice 3: Gauge preheating

SetDirectory[NotebookDirectory[]]

Volume Averages

strm=OpenRead["./average_scale_factor.txt"];  (*Opens file to read data from*)
(*Skip[strm,String,1];*)  (* If you add headers to the text files, uncomment this to skip the first line *)
NumColumns=4;  (*Number of columns in file*)
scale=ReadList[strm,Table[Number,{NumColumns}]];  (*Reads data and creates table*)

sfIn=Interpolation[Table[{scale[[i,1]],scale[[i,2]]},{i,1,Length[scale]}]];   
(*Creates interpolation from columns 1 and 2*)

; (*Column structure of file "average_scalar_0.txt"*)

strm=OpenRead["./average_norm_cmplx_scalar_0.txt"]; (*Opens file to read data from*)
NumColumns=7;  (*Number of columns in file*)

means0=ReadList[strm,Table[Number,{NumColumns}],RecordLists->True];
(*Reads data and creates table*)

(*NOTE: Sometimes "nans" get produced in the last two columns, which the ReadList function cannot read. They must be transformed to "0" in the text file to make it work.*)

f0phiIn=Interpolation[Table[{means0[[i,1]][[1]],means0[[i,1]][[2]]},{i,1,Length[means0]}]];
(*Creates interpolation from columns 1 and 2*)

FinalTime=means0[[-1,1]][[1]] ; (*Final time of simulation*)

(* Volume average of inflation *)
Plot[f0phiIn[t],{t,0,FinalTime},ImageSize->400,
PlotStyle->{{Thick,Darker[Blue]}},Frame->True,PlotRange->All,FrameLabel->{Style[(OverTilde[η]),FontSize->16,Black],Style[OverTilde["<|ϕ|>"],FontSize->16,Black]},FrameTicksStyle->Directive[Black,14]
]

rms0In=Interpolation[Table[{means0[[i,1]][[1]],means0[[i,1]][[6]]},{i,1,Length[means0]}]];
(*Creates interpolation from columns 1 and 6*)

(* rms of inflaton (including conformal transformation) *)
LogPlot[sfIn[t]*rms0In[t],{t,0,FinalTime},ImageSize->400,
PlotStyle->{{Thick,Darker[Blue]}},Frame->True,PlotRange->All,FrameLabel->{Style[(OverTilde[η]),FontSize->16,Black],Style["a*rms((OverTilde[ϕ]))",FontSize->16,Black]},FrameTicksStyle->Directive[Black,14]
]

strm=OpenRead["./average_norm_U1_0.txt"]; (*Opens file to read data from*)
NumColumns=7;  (*Number of columns in file*)

meansU1=ReadList[strm,Table[Number,{NumColumns}],RecordLists->True];
(*Reads data and creates table*)

(*NOTE: Sometimes "nans" get produced in the last two columns, which the ReadList function cannot read. They must be transformed to "0" in the text file to make it work.*)

EampIn=Interpolation[Table[{meansU1[[i,1]][[1]],meansU1[[i,1]][[2]]},{i,1,Length[meansU1]}]];

Plot[EampIn[t],{t,0,FinalTime},ImageSize->400,
PlotStyle->{{Thick,Darker[Blue]}},Frame->True,PlotRange->All,FrameLabel->{Style[(OverTilde[η]),FontSize->16,Black],Style[OverTilde["<|E|>"],FontSize->16,Black]},FrameTicksStyle->Directive[Black,14]
]

BampIn=Interpolation[Table[{meansU1[[i,1]][[1]],meansU1[[i,1]][[3]]},{i,1,Length[meansU1]}]];

Plot[BampIn[t],{t,0,FinalTime},ImageSize->400,
PlotStyle->{{Thick,Darker[Blue]}},Frame->True,PlotRange->All,FrameLabel->{Style[(OverTilde[η]),FontSize->16,Black],Style[OverTilde["<|B|>"],FontSize->16,Black]},FrameTicksStyle->Directive[Black,14]
]

Energies

strm=OpenRead["./average_energies.txt"];
NumColumns=7;
energy=ReadList[strm,Table[Number,{NumColumns}]];

(* Creates an interpolating function for each energy component*)
Kin0=Interpolation[Table[{energy[[i,1]],energy[[i,2]]},{i,1,Length[energy]}]]; (*Kinetic inflation*)
Grad0=Interpolation[Table[{energy[[i,1]],energy[[i,3]]},{i,1,Length[energy]}]]; (*Gradient inflaton *)
Elec=Interpolation[Table[{energy[[i,1]],energy[[i,4]]},{i,1,Length[energy]}]]; (*Electric field*)
Mag=Interpolation[Table[{energy[[i,1]],energy[[i,5]]},{i,1,Length[energy]}]]; (*Magnetic field*)
Pot=Interpolation[Table[{energy[[i,1]],energy[[i,6]]},{i,1,Length[energy]}]]; (*Inflaton potential *)
ETot=Interpolation[Table[{energy[[i,1]],energy[[i,7]]},{i,1,Length[energy]}]];  (* Sum of components*)
resc=4; (* Coefficient for conformal rescaling *)
(* Plot of energy components with conformal rescaling *)
LogPlot[{Kin0[t]*sfIn[t]^resc,Grad0[t]*sfIn[t]^resc,Elec[t]*sfIn[t]^resc,Mag[t]*sfIn[t]^resc,Pot[t]*sfIn[t]^resc,ETot[t]*sfIn[t]^resc},{t,0,FinalTime},

PlotStyle->{{Thick,Darker[Blue]},{Thick,Lighter[Lighter[Blue]]},{Thick,Red},{Thick,Orange},{Thick,Darker[Green]},{Thick,Purple},{Thick,Black}},

ImageSize->450,PlotRange->{10^(-15),10},Frame->True,FrameLabel->{Style[OverTilde[η],FontSize->16,Black],Style["(a^4)"OverTilde["ρ"],FontSize->16,Black]},FrameTicksStyle->Directive[Black,16],PlotLegends->"Expressions"]

Spectra

SpectraU1 = Import["./spectra_norm_U1_0.txt","Table"];
SpectraΦ = Import["./spectra_norm_cmplx_scalar_0.txt","Table"];
SpectraTimes = Import["./average_spectra_times.txt","Table"];
(*For Practice 4 you can can use this to plot GWs spectra*)
(*Spectragws= Import["./spectra_gws.txt","Table"];*)

SpectraU1=Partition[SpectraU1,Round[Length[SpectraU1]/Length[SpectraTimes]]];
SpectraΦ=Partition[SpectraΦ,Round[Length[SpectraΦ]/Length[SpectraTimes]]];
(*Spectragws=Partition[Spectragws,Round[Length[Spectragws]/Length[SpectraTimes]]];*)

ListLogLogPlot[Table[Sort[Select[SpectraU1[[i]],#≠{}&]][[All,1;;2;;1]],{i,1,Length[SpectraU1],1}],Joined->True,PlotRange->{{.7,.6*0.5*(Sqrt[3])*256},{10,(10^14)}},PlotStyle->Table[{Hue[0+7/10*((i)/Length[SpectraU1])],Thickness[0.002]},{i,1,Length[SpectraU1],1}],GridLines->{{0.2,0.5},{}},GridLinesStyle->Directive[Gray,Thick],FrameLabel->{Style["(OverTilde[k])",FontSize->30,Black],Style["((OverTilde[k])^3)|(OverTilde[(Subscript[E, k])])((|)^2)((OverTilde[k]))",FontSize->30,Black]}, Frame->True,FrameStyle->Directive[Black,Thick],FrameTicksStyle->Directive[Black,30],ImageSize->1000]

ListLogLogPlot[Table[Sort[Select[SpectraU1[[i]],#≠{}&]][[All,1;;3;;2]],{i,1,Length[SpectraU1],1}],Joined->True,PlotRange->{{.7,.6*0.5*(Sqrt[3])*256},{10,5*(10^12)}},PlotStyle->Table[{Hue[0+7/10*((i)/Length[SpectraU1])],Thickness[0.002]},{i,1,Length[SpectraU1],1}],GridLines->{{0.2,0.5},{}},GridLinesStyle->Directive[Gray,Thick], FrameLabel->{Style["(OverTilde[k])",FontSize->30,Black],Style["((OverTilde[k])^3)|(OverTilde[(Subscript[B, k])])((|)^2)((OverTilde[k]))",FontSize->30,Black]}, Frame->True,FrameStyle->Directive[Black,Thick],FrameTicksStyle->Directive[Black,30],ImageSize->1000]

ListLogLogPlot[Table[Sort[Select[SpectraΦ[[i]],#≠{}&]][[All,1;;2;;1]],{i,1,Length[SpectraΦ],2}],Joined->True,PlotRange->{{.7,.6*0.5*(Sqrt[3])*256},{(10^(-20)),(10^(-4))}},PlotStyle->Table[{Hue[0+7/10*((i)/Length[SpectraΦ])],Thickness[0.002]},{i,1,Length[SpectraΦ],2}],GridLines->{{0.2,0.5},{}},GridLinesStyle->Directive[Gray,Thick],FrameLabel->{Style["(OverTilde[k])",FontSize->30,Black],Style["(Subscript[(OverTilde[Δ]), (OverTilde[ϕ])])((OverTilde[k]))",FontSize->30,Black]}, Frame->True,FrameStyle->Directive[Black,Thick],FrameTicksStyle->Directive[Black,30],ImageSize->1000]

ListLogLogPlot[Table[Sort[Select[Spectragws[[i]],#≠{}&]][[All,1;;2;;1]],{i,1,Length[Spectragws]}],Joined->True,PlotRange->{{.7,.6*0.5*(Sqrt[3])*256},{10^-13,2*10^-5}},PlotStyle->Table[{Hue[0+6/10*((i)/Length[Spectragws])],Thickness[0.002]},{i,1,Length[Spectragws]}],GridLines->{{0.2,0.5},{}},GridLinesStyle->Directive[Gray,Thick],FrameLabel->{Style["(OverTilde[k])",FontSize->30,Black],Style["(Subscript[Ω, GW])((OverTilde[k]))",FontSize->30,Black]}, Frame->True,FrameStyle->Directive[Black,Thick],FrameTicksStyle->Directive[Black,30],ImageSize->1000]