Skip to content

Commit

Permalink
prepared for merging with master
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-tomin committed Dec 21, 2022
1 parent 0b0f64d commit 2cc7802
Show file tree
Hide file tree
Showing 39 changed files with 925 additions and 1,044 deletions.
2 changes: 1 addition & 1 deletion demos/ebeam/da_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

cell = (D1, Q1, D2, Q2, D3, Q3, D4, B, D5, SD, D5, SF, D6, Q4, D6, SF, D5, SD,D5, B, D4, Q3, D3, Q2, D2, Q1, D1)
ring = cell
method = {"Sextupole": KickTM}
method = {Sextupole: KickTM}
lat = MagneticLattice(ring, method=method)


Expand Down
6 changes: 4 additions & 2 deletions demos/ebeam/dba_match.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import matplotlib.pyplot as plt

from ocelot.gui import *
from ocelot import *
from pylab import *
Expand Down Expand Up @@ -54,7 +56,7 @@
#vars = [q1,q2,q3]


match(lat, constr, vars, tw0)
match(lat, constr, vars, tw0, max_iter=5000)


tws=twiss(lat, tw0, nPoints = 1000)
Expand All @@ -64,7 +66,7 @@
ax = f.add_subplot(211)
ax.set_xlim(0, lat.totalLen)

f.canvas.set_window_title('Betas [m]')
plt.title('Betas [m]')
p1, = plt.plot(s, [p.beta_x for p in tws], lw=2.0)
p2, = plt.plot(s, [p.beta_y for p in tws], lw=2.0)
plt.grid(True)
Expand Down
26 changes: 13 additions & 13 deletions demos/ebeam/dba_track_ellipse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__author__ = 'Sergey Tomin'


from pylab import *
import matplotlib.pyplot as plt
from ocelot import *
from ocelot.cpbd.optics import *
from ocelot.cpbd.transformations.second_order import SecondTM
Expand Down Expand Up @@ -30,30 +30,30 @@
lat = MagneticLattice(cell, method=method)


t = linspace(0, 2*pi, num = 100)
x, xp = 0.1*cos(t), 0.1*sin(t)
t = np.linspace(0, 2*pi, num = 100)
x, xp = 0.1*np.cos(t), 0.1*np.sin(t)
plist = []
for xi, xpi in zip(x, xp):
plist.append(Particle(x=xi, px=xpi))


plot(x, xp)
plt.plot(x, xp)
navi = Navigator(lat)
dz = 10.
tracking_step(lat, plist, dz=dz, navi=navi)


x2 = [f.x for f in plist] #map(lambda f: f.x, plist)
xp2 = [f.px for f in plist] #map(lambda f: f.px, plist)
suptitle("Tracking with sextupoles")
subplot(121)
plt.suptitle("Tracking with sextupoles")
plt.subplot(121)
plt.title("S = 0 m")
plt.plot(x, xp, "r.-", label = "X")
plt.xlabel("X, m")
plt.ylabel("Xp, rad")
plt.grid(True)

subplot(122)
plt.subplot(122)
plt.title("S = 10 m")
plt.plot(x2, xp2, "r.-", label = "X")
#plt.legend()
Expand All @@ -68,13 +68,13 @@
element.k2 = 0.
lat.update_transfer_maps()

t = linspace(0, 2*pi, num = 100)
x, xp = 0.1*cos(t), 0.1*sin(t)
t = np.linspace(0, 2*pi, num = 100)
x, xp = 0.1*np.cos(t), 0.1*np.sin(t)
plist = []
for xi, xpi in zip(x,xp):
plist.append(Particle(x = xi, px= xpi))

plot(x, xp)
plt.plot(x, xp)
navi = Navigator(lat)
dz = 10.
tracking_step(lat, plist, dz = dz, navi = navi)
Expand All @@ -85,15 +85,15 @@
plt.plot(x, xp, "r.-", label = "X")


suptitle("Tracking without sextupoles")
subplot(121)
plt.suptitle("Tracking without sextupoles")
plt.subplot(121)
plt.title("S = 0 m")
plt.plot(x, xp, "r.-", label = "X")
plt.xlabel("X, m")
plt.ylabel("Xp, rad")
plt.grid(True)

subplot(122)
plt.subplot(122)
plt.title("S = 10 m")
plt.plot(x2, xp2, "r.-", label = "X")
#plt.legend()
Expand Down
4 changes: 3 additions & 1 deletion demos/ebeam/rf_twiss.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import matplotlib.pyplot as plt

from ocelot import *
from ocelot.gui import *
import numpy as np
Expand Down Expand Up @@ -67,7 +69,7 @@
ax = f.add_subplot(211)
ax.set_xlim(0, lat.totalLen)

f.canvas.set_window_title('Betas [m]')
plt.title('Betas [m]')
s = [p.s for p in tws]
p1, = plt.plot(s, [p.beta_x for p in tws], lw=2.0)
p2, = plt.plot(s, [p.beta_y for p in tws], lw=2.0)
Expand Down
2 changes: 1 addition & 1 deletion demos/ebeam/twiss_sase3.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def delta_e(delta_length, total_length):
ax = f.add_subplot(211)
ax.set_xlim(0, lat.totalLen)

f.canvas.set_window_title('Betas [m]')
plt.title('Betas [m]')
s = [p.s for p in tws]
p1, = plt.plot(s, [p.beta_x for p in tws], lw=2.0)
p2, = plt.plot(s, [p.beta_y for p in tws], lw=2.0)
Expand Down
113 changes: 49 additions & 64 deletions demos/ipython_tutorials/1_introduction.ipynb

Large diffs are not rendered by default.

103 changes: 39 additions & 64 deletions demos/ipython_tutorials/2_tracking.ipynb

Large diffs are not rendered by default.

65 changes: 23 additions & 42 deletions demos/ipython_tutorials/3_space_charge.ipynb

Large diffs are not rendered by default.

116 changes: 39 additions & 77 deletions demos/ipython_tutorials/4_wake.ipynb

Large diffs are not rendered by default.

45 changes: 15 additions & 30 deletions demos/ipython_tutorials/5_CSR.ipynb

Large diffs are not rendered by default.

46 changes: 18 additions & 28 deletions demos/ipython_tutorials/6_coupler_kick.ipynb

Large diffs are not rendered by default.

56 changes: 22 additions & 34 deletions demos/ipython_tutorials/7_lattice_design.ipynb

Large diffs are not rendered by default.

32 changes: 13 additions & 19 deletions demos/ipython_tutorials/8_laser_heater.ipynb

Large diffs are not rendered by default.

141 changes: 100 additions & 41 deletions demos/ipython_tutorials/9_thz_source.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions demos/ipython_tutorials/R_matrices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -2885,7 +2885,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
180 changes: 103 additions & 77 deletions demos/ipython_tutorials/accelerator_optim.ipynb

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions demos/ipython_tutorials/parameter-scanner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,25 @@
},
{
"cell_type": "code",
"execution_count": 73,
"execution_count": 1,
"id": "18e9cd9b",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'chicane'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/var/folders/cc/dy7fm0252g93vyzv0sjtvkbw0000gn/T/ipykernel_9162/441098987.py\u001b[0m in \u001b[0;36m<cell line: 5>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mchicane\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mzeuthen\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mzeuthen_beam\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mocelot\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'chicane'"
]
}
],
"source": [
"import sys\n",
"sys.path.append(\"/Users/tomins/Nextcloud/DESY/repository/ocelot\")\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from chicane import zeuthen, zeuthen_beam\n",
Expand Down Expand Up @@ -676,7 +690,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 2cc7802

Please sign in to comment.