File: test_ellipse_2.py

package info (click to toggle)
python-xrt 1.6.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,572 kB
  • sloc: python: 59,424; xml: 4,786; lisp: 4,082; sh: 22; javascript: 18; makefile: 17
file content (169 lines) | stat: -rw-r--r-- 4,277 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# -*- coding: utf-8 -*-
"""

__author__ = "Konstantin Klementiev", "Roman Chernikov"
__date__ = "2021-09-18"

Created with xrtQook




"""

import numpy as np
import sys
sys.path.append(r"c:\Ray-tracing")
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


def build_beamline():
    beamLine = raycing.BeamLine()

    beamLine.geometricSource01 = rsources.GeometricSource(
        bl=beamLine,
        name=None,
        center=[0, 0, 0],
        dx=0.1,
        dz=0.1,
        dzprime=0.001,
        energies=[1.0])

    beamLine.oe01 = roes.OE(
        bl=beamLine,
        name=None,
        center=[0, 1000, 0],
        pitch=r"45deg",
        positionRoll=r"90deg")

    beamLine.screen00 = rscreens.Screen(
        bl=beamLine,
        center=[500, 1000, 0],
        x=[0, -1, 0])

    beamLine.ellipticalMirrorParam01 = roes.EllipticalMirrorParam(
        bl=beamLine,
        name=None,
        center=[1000, 1000, 0],
        pitch=r"45deg",
        yaw=r"-89.9deg",
        limPhysX=[-20.0, 20.0],
        limPhysY=[-20.0, 20.0],
        p=2000,
        pAxis=[1, 0, 0],
        isCylindrical=True)

    beamLine.screen01 = rscreens.Screen(
        bl=beamLine,
        name=None,
        center=[1000, 1000, 1000],
        x=[0, -1, 0],
        z=[-1, 0, 0])

    return beamLine


def run_process(beamLine):
    geometricSource01beamGlobal01 = beamLine.geometricSource01.shine()

    oe01beamGlobal01, oe01beamLocal01 = beamLine.oe01.reflect(
        beam=geometricSource01beamGlobal01)

    screen02beamLocal01 = beamLine.screen00.expose(
        beam=oe01beamGlobal01)

    ellipticalMirrorParam01beamGlobal01, ellipticalMirrorParam01beamLocal01 = beamLine.ellipticalMirrorParam01.reflect(
        beam=oe01beamGlobal01)

    screen01beamLocal01 = beamLine.screen01.expose(
        beam=ellipticalMirrorParam01beamGlobal01)

    outDict = {
        'geometricSource01beamGlobal01': geometricSource01beamGlobal01,
        'oe01beamGlobal01': oe01beamGlobal01,
        'oe01beamLocal01': oe01beamLocal01,
        'screen02beamLocal01': screen02beamLocal01,
        'ellipticalMirrorParam01beamGlobal01': ellipticalMirrorParam01beamGlobal01,
        'ellipticalMirrorParam01beamLocal01': ellipticalMirrorParam01beamLocal01,
        'screen01beamLocal01': screen01beamLocal01}
    return outDict


rrun.run_process = run_process



def define_plots():
    plots = []

    plot01 = xrtplot.XYCPlot(
        beam=r"oe01beamLocal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"y"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        title=r"plot01")
    plots.append(plot01)

    plot02 = xrtplot.XYCPlot(
        beam=r"ellipticalMirrorParam01beamLocal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"y"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        title=r"plot02")
    plots.append(plot02)

    plot03 = xrtplot.XYCPlot(
        beam=r"screen01beamLocal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"z"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        title=r"plot03")
    plots.append(plot03)

    plot04 = xrtplot.XYCPlot(
        beam=r"screen02beamLocal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"z"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        title=r"plot04")
    plots.append(plot04)
    return plots


def main():
    beamLine = build_beamline()
    E0 = list(beamLine.geometricSource01.energies)[0]
    beamLine.alignE=E0
    plots = define_plots()
    xrtrun.run_ray_tracing(
        plots=plots,
        backend=r"raycing",
        beamLine=beamLine)


if __name__ == '__main__':
    main()