Tutorial 2b: Generating the Synchrotron Matrices
With the Compton matrices generated, we can move on to the Synchrotron matrices.
Generating the Emission Matrices
Particle Names
Synchrotron radiation is an emissive process
using Diplodocus
name1 = "Ele"
name2 = "Ele"
name3 = "Pho"
type = "Sync"where type indicates the type of emissive interaction (see Implemented Collisions).
Momentum Space Grids
The momentum grids are just the same as the Compton matrix setup:
p_low_Ele = -5.0
p_up_Ele = 4.0
p_grid_Ele = "l"
p_num_Ele = 144
u_grid_Ele = "u"
u_num_Ele = 1
h_grid_Ele = "u"
h_num_Ele = 1
p_low_Pho = -18.0
p_up_Pho = 4.0
p_grid_Pho = "l"
p_num_Pho = 352
u_grid_Pho = "u"
u_num_Pho = 1
h_grid_Pho = "u"
h_num_Pho = 1Define External Parameters
For synchrotron radiation we must tell the code what magnetic field strengths to consider. This is done by defining the Ext_sample vector, which for type=Sync is taken to be a vector of magnetic field strengths in SI units, i.e. Tesla. We want to simulate a field with
Ext_sample::Vector{Float64} = [1e-3];
nothing #hideMonte-Carlo Setup
For emissive processes there are fewer incoming particles involved, so we can sample far more incoming points:
numLoss = 256
numGain = 256
numThreads = Threads.nthreads()WARNING
By default this script uses the maximum number of available threads Threads.nthreads(), if you would prefer the scripts to run with fewer threads then modify the variable numThreads to the desired amount.
Unlike binary collisions, we do not need to deploy the importance sample to improve the MC accuracy of emissive processes, this is because there are not dependent variables in the outgoing states, so all states get sampled equally. But for future-proofing, we can still define the scale factors to sample. Here we will just make it sample scale=0.0:
scale = 0.0:0.1:0.0Where to Save the mission Matrices
fileLocation = joinpath(pwd(),"Data","Tutorial2")Final Setup and Running
We can bundle all the above user defined parameters into a tuple called Setup. This is generated by the UserEmissionParameters() function, which reads the above parameters from Main. It also generates the fileName under which the emissive matrices will be saved and stored. This Setup is generated for each Ext value to be sampled and then the Monte-Carlo integration is run for each Ext value using EmissionInteractionIntegration(Setup). The resulting matrices are saved to the fileLocation under the generated fileName:
Ext = 0.0;
for (Ext_idx) in eachindex(Ext_sample)
Ext = Ext_sample[Ext_idx]
println("Running for Ext = $Ext, iteration $Ext_idx out of $(length(Ext_sample))")
(Setup,fileName) = UserEmissionParameters(Ext)
EmissionInteractionIntegration(Setup)
endWARNING
It is not advised to edit fileName as its format is used internally by DiplodocusCollisions and DiplodocusTransport to identify the appropriate collision matrices to load.
Checking the Collision Matrices
Unlike binary processes, particle number is not conserved in an emissive process. Energy should be conserved but currently the change of the electron distribution for synchrotron radiation is included as an analytic force term (see the tutorial 2c.) as such we cannot examine the energy conservation from the emission matrices alone.
Plotting the Spectra
What we can do though is visualise the resulting photon spectrum using the plotting function InteractiveEmissionGainLossPlot from DiplodocusPlots. This creates an interactive plot in which the user can look at different incoming states and view the resulting outgoing spectra. To use this function, first load the file containing the collision matrices using EmissionFileLoad_Matrix:
Ext = Ext_sample[1] # for example
(Setup,fileName) = UserEmissionParameters(Ext);
Output = EmissionFileLoad_Matrix(fileLocation,fileName);
InteractiveEmissionGainLossPlot(Output)This will display the plot in a separate window where you can interact with it. There are sliders for the the discrete bins of the incoming particle's (electron's) momentum p1, and their propagation directions, in spherical polars u (h (
Now on to the simulation itself!