# -*- coding: utf-8 -*-
"""
__author__ = "Konstantin Klementiev", "Roman Chernikov"
__date__ = "2020-01-22"
Created with xrtQook
"""
import numpy as np
import sys
sys.path.append(r"/mnt/LSDF/anka-nc-cluster/home/ws/cc1372/.local/lib/python2.7/site-packages")
import xrt.backends.raycing.sources as rsources
import xrt.backends.raycing.screens as rscreens
import xrt.backends.raycing.materials as rmats
import xrt.backends.raycing.oes as roes
import xrt.backends.raycing.apertures as rapts
import xrt.backends.raycing.run as rrun
import xrt.backends.raycing as raycing
import xrt.plotter as xrtplot
import xrt.runner as xrtrun
CVD = rmats.Material(
elements=r"C",
kind=r"plate",
rho=3.52,
name=r"Diamond plate")
Si111 = rmats.CrystalSi(
hkl=[1, 1, 1],
name=r"Si111")
def build_beamline():
P23_Main = raycing.BeamLine(
alignE=10000)
P23_Main.Undulator = rsources.Undulator(
bl=P23_Main,
name=r"P23",
center=[0, 0, 0],
eE=6.083,
eSigmaX=156.1,
eSigmaZ=6.9,
eEpsilonX=1.2,
eEpsilonZ=0.012,
betaX=20.1,
betaZ=3.97,
distE=r"eV",
eMin=4855,
eMax=4866,
nrays=10000,
#xPrimeMax= 0.25,
#zPrimeMax= 0.25,
xPrimeMaxAutoReduce= False,
zPrimeMaxAutoReduce = False,
K=2.68,
period=31.4,
n=63)
P23_Main.FEMask = rapts.RectangularAperture(
bl=P23_Main,
name=r"Frontend Mask",
center=[0, 40000, 0],
opening=[-12, 12, -5, 5])
P23_Main.DiamondFilter = roes.Plate(
bl=P23_Main,
name=r"Diamond Filter",
center=[0, 47600, 0],
material=CVD,
pitch=1.57079632679,
limPhysX=[-5, 5],
limOptX=[-5, 5],
limPhysY=[-5, 5],
limOptY=[-5, 5],
t=0.05)
P23_Main.SSRL_DCM = roes.DCM(
bl=P23_Main,
name=r"SSRL channel cut DCM",
center=[0, 57000, r"auto"],
bragg=[4861.64],
material=Si111,
material2=Si111,
fixedOffset=20)
P23_Main.SampleScreen = rscreens.Screen(
bl=P23_Main,
name=r"Sample",
center=[0, 60000, r"auto"])
return P23_Main
def run_process(P23_Main):
UndulatorbeamGlobal01 = P23_Main.Undulator.shine()
FEMaskbeamLocal01 = P23_Main.FEMask.propagate(
beam=UndulatorbeamGlobal01)
C_FilterbeamGlobal01, C_FilterbeamLocal101, CVDFilterAbsorbedPower = P23_Main.DiamondFilter.double_refract(
beam=UndulatorbeamGlobal01,
returnLocalAbsorbed=0)
SSRL_DCMbeamGlobal01, SSRL_DCMbeamLocal101, SSRL_DCMbeamLocal201 = P23_Main.SSRL_DCM.double_reflect(
beam=C_FilterbeamGlobal01)
SampleScreenFootprint = P23_Main.SampleScreen.expose(
beam=SSRL_DCMbeamGlobal01)
outDict = {
'UndulatorbeamGlobal01': UndulatorbeamGlobal01,
'FEMaskbeamLocal01': FEMaskbeamLocal01,
'C_FilterbeamGlobal01': C_FilterbeamGlobal01,
'C_FilterbeamLocal101': C_FilterbeamLocal101,
'CVDFilterAbsorbedPower': CVDFilterAbsorbedPower,
'SSRL_DCMbeamGlobal01': SSRL_DCMbeamGlobal01,
'SSRL_DCMbeamLocal101': SSRL_DCMbeamLocal101,
'SSRL_DCMbeamLocal201': SSRL_DCMbeamLocal201,
'SampleScreenFootprint': SampleScreenFootprint}
return outDict
rrun.run_process = run_process
def define_plots():
plots = []
plot01 = xrtplot.XYCPlot(
beam=r"UndulatorbeamGlobal01",
xaxis=xrtplot.XYCAxis(
label=r"x"),
yaxis=xrtplot.XYCAxis(
label=r"z"),
caxis=xrtplot.XYCAxis(
label=r"energy",
unit=r"eV"),
aspect=r"auto",
title=r"01 - P23 undulator source",
fluxFormatStr=r"%g")
plots.append(plot01)
plot02 = xrtplot.XYCPlot(
beam=r"UndulatorbeamGlobal01",
xaxis=xrtplot.XYCAxis(
label=r"x",limits=[-1, 1]),
yaxis=xrtplot.XYCAxis(
label=r"z",limits=[-0.2, 0.2]),
caxis=xrtplot.XYCAxis(
label=r"energy",
unit=r"eV"),
title=r"02 - P23 Undulator total power",
fluxKind='power')
plots.append(plot02)
plot03 = xrtplot.XYCPlot(
beam=r"CVDFilterAbsorbedPower",
xaxis=xrtplot.XYCAxis(
label=r"x"),
yaxis=xrtplot.XYCAxis(
label=r"y"),
caxis=xrtplot.XYCAxis(
label=r"energy",
unit=r"eV"),
title=r"03 - CVD Filter Absorbed Power",
fluxKind=r"power",
fluxFormatStr=r"%g")
plots.append(plot03)
plot05 = xrtplot.XYCPlot(
beam=r"SampleScreenFootprint",
xaxis=xrtplot.XYCAxis(
label=r"x"),
yaxis=xrtplot.XYCAxis(
label=r"z"),
caxis=xrtplot.XYCAxis(
label=r"energy",
unit=r"eV",
limits=[4820,4890],
offset=0),
title=r"05 - Sample",
fluxFormatStr=r"%g")
plots.append(plot05)
return plots
def main():
P23_Main = build_beamline()
E0 = 0.5 * (P23_Main.Undulator.eMin +
P23_Main.Undulator.eMax)
P23_Main.alignE=E0
plots = define_plots()
xrtrun.run_ray_tracing(
plots=plots,
repeats=20,
backend=r"raycing",
beamLine=P23_Main)
if __name__ == '__main__':
main()