In [6]:
"""
Example 7
- double-pulse SASE FEL by inserting a chicane to tune the delay in between
- visualize the growth of temporal profile
"""
import sys
isjupyter = "ipykernel" in sys.modules
import simplex
if isjupyter:
simplex.Start(mode="c")
import plotly.io as pio
pio.renderers.default = "notebook" # to enable exporting as an HTML file
from IPython.display import display, HTML
else:
simplex.Start()
# open "sample.json" in the current directory
simplex.Open("sample_sase.json")
# setup chicane parameters
simplex.Set("chicane", "chicaneon", True)
simplex.Set("chicane", "delay", 10)
simplex.Set("chicane", "chpos", 5)
# expand the temporal window
simplex.Set("condition", "simrange", [-1e-6, 5e-6])
simplex.StartSimulation(folder="./output", prefix="sample7", serial=1)
# rearrange the macroparticle distribution to be consistent with the extinction of microbunching
simplex.Set("chicane", "rearrange", True)
simplex.StartSimulation(folder="./output", prefix="sample7", serial=2)
if isjupyter:
display(HTML("<h2>Example of double-pulse SASE FEL"))
simplex.PostProcessCLI.Plot(data=["sample7-1", "sample7-2"], item="Temporal Profile")
else:
# compare the two schemes
simplex.PostProcess.SelectData("sample7-1")
simplex.PostProcess.Plot("Temporal Profile")
simplex.PostProcess.ComparativePlot("sample7-2")
simplex.PostProcess.SetSlide(-1)
if not isjupyter:
input("Completed. Press enter to exit. ")
simplex.Exit()
Example of double-pulse SASE FEL
In [ ]: