Skip to content

Commit 7d9983b

Browse files
committed
Initial commit of PySSD. One working example in main.py using octupoles.
0 parents  commit 7d9983b

File tree

8 files changed

+715
-0
lines changed

8 files changed

+715
-0
lines changed

Detuning.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import numpy as np
2+
3+
class Detuning:
4+
def __call__(self,jx,jy):
5+
raise NotImplemented;
6+
7+
class LinearDetuning(Detuning):
8+
_startTune = 0.31;
9+
_slopex = 0.0;
10+
_slopey = 0.0;
11+
12+
def __init__(self,startTune,slopex,slopey):
13+
self._startTune = startTune
14+
self._slopex = slopex
15+
self._slopey = slopey
16+
17+
def __call__(self,jx,jy):
18+
return self._startTune + self._slopex*jx+self._slopey*jy
19+
20+
21+
class FootprintDetuning(Detuning):
22+
_footprint = None;
23+
_plane = None;
24+
25+
#0 for H and 1 for V
26+
def __init__(self,footprint,plane=0):
27+
self._footprint = footprint
28+
self._plane = plane
29+
30+
def __call__(self,jx,jy):
31+
sigx = np.sqrt(2.0*jx)
32+
sigy = np.sqrt(2.0*jy)
33+
return self._footprint.getTunesForAmpl(sigx,sigy)[self._plane]

Dispersion.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Dispersion:
2+
_detuning = None;
3+
_distribution = None;
4+
_Q = 0.0;
5+
_epsilon = 1E-6;
6+
7+
def __init__(self, distribution, detuning, Q, epsilon=1E-6):
8+
self._distribution = distribution
9+
self._detuning = detuning
10+
self._Q = Q
11+
self._epsilon = epsilon
12+
13+
def setEpsilon(self,epsilon):
14+
self._epsilon = epsilon
15+
16+
def getEpsilon(self):
17+
return self._epsilon
18+
19+
def getValue(self, jx, jy):
20+
21+
# DI = (
22+
# (jx * self._distribution.getDJx(jx,jy)) /
23+
# (complex(self._Q - self._detuning(jx,jy), self._epsilon))
24+
# )
25+
DI = (
26+
(jx * self._distribution.getDJx(jx, jy)) /
27+
(self._Q - self._detuning(jx, jy) + 1j*self._epsilon)
28+
)
29+
30+
return DI
31+
32+
33+
class RealDispersion(Dispersion):
34+
def __call__(self,jx,jy):
35+
return self.getValue(jx,jy).real
36+
37+
38+
class ImaginaryDispersion(Dispersion):
39+
def __call__(self,jx,jy):
40+
return self.getValue(jx,jy).imag

Distribution.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
from abc import ABCMeta, abstractmethod
3+
4+
5+
class Distribution(object):
6+
__metaclass__ = ABCMeta
7+
8+
@abstractmethod
9+
def getValue(self, jx, jy):
10+
'''Return local pdf'''
11+
pass
12+
13+
@abstractmethod
14+
def getDJx(self, jx, jy):
15+
'''Return derivation by Jx'''
16+
pass
17+
18+
@abstractmethod
19+
def getDJy(self, jx, jy):
20+
'''Return derivation by Jy'''
21+
pass
22+
23+
24+
class BiGaussian(Distribution):
25+
26+
def getValue(self, jx, jy):
27+
'''Return pdf of normal bi-Gaussian'''
28+
return np.exp(-(jx + jy));
29+
30+
def getDJx(self, jx, jy):
31+
return -self.getValue(jx, jy);
32+
33+
def getDJy(self, jx, jy):
34+
return -self.getValue(jx, jy);

0 commit comments

Comments
 (0)