CMB & LSS Simulation

Baryon Acoustic Oscillations distribution

shell2d[pos_]:=100*Exp[((-(((Sqrt[(((x-pos[[1]]))^2)+(((y-pos[[2]]))^2)+(((rand))^2)]-6))^2))/3)]
Plot3D[rand=0;shell2d[{5,7}],{x,-7,18},{y,-7,18},PlotRange->All]

Cosmic Microwave Background simulation

step=1;
densitylist1=Flatten[Table[{x,y,0},{x,10,90,step},{y,10,90,step}],1];
length=Length[densitylist1];
j=0;
count=0;
baonum=10000;
Dynamic[{count,j}]
Dynamic[cmb]
While[True,count=count+1;
randpos=RandomReal[1,2]*100;
rand=RandomReal[{-10,10}];
fun=shell2d[randpos];
adddensity=Flatten[Table[fun//N,{x,10,90,step},{y,10,90,step}],1];
densitylist=Table[{densitylist1[[i,1]],densitylist1[[i,2]],densitylist1[[i,3]]+adddensity[[i]]},{i,1,length}];
densitylist1=densitylist;
max=Max[Table[densitylist[[i,3]],{i,1,length}]];min=Min[Table[densitylist[[i,3]],{i,1,length}]];If[j>99,j=1;cmb=ListDensityPlot[densitylist,PlotLegends->BarLegend[{Automatic,{min,max}}],ImageSize->Large,ColorFunction->ColorData[{"TemperatureMap",{min,max}}],ColorFunctionScaling->False],j=j+1];If[count>baonum,Break[]]]

Large Scale Structure from CMB

Module[{ϵ=0.8},While[True,struc=Table[If[densitylist[[i,3]]>(min+max)*(ϵ/2),{ColorData["TemperatureMap"][((densitylist[[i,3]]-min)/(max-min))],Disk[{densitylist[[i,1]],densitylist[[i,2]]},step]},Nothing],{i,1,Length[densitylist]}];ϵ=ϵ+0.01;If[((Length[struc])/(Length[densitylist]))<0.2,Break[]]]]
lss=Graphics[struc,ImageSize->Large]