Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sc linedensity interpolation #50

Merged
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0fe80aa
Spacecharge: renaming properties of coasting beam...
aoeftiger Jun 12, 2020
25c7a40
spacecharge: renaming SpaceChargeBunched to SpaceChargeQGaussianProfi…
aoeftiger Jun 12, 2020
ec91688
space charge: copy from SpaceChargeBunched to new interpolated profil…
aoeftiger Jun 12, 2020
7dc1b9b
space charge: fixing hard coded min_sigma_diff
aoeftiger Jun 12, 2020
7daf5c4
space charge: first working interpolation version
aoeftiger Jun 12, 2020
1e4875d
space charge test & examples: update for new QGaussianProfile named c…
aoeftiger Jun 12, 2020
da92ecd
space charge: changing all line_density appearances in ...
aoeftiger Jun 12, 2020
4866d6c
Merge remote-tracking branch 'ao/feature/sc-linedensity-interpolation…
Aug 21, 2020
dc7be9c
interpolated profile SC: adding MAD-X loader and unifying setup_SC_in…
aoeftiger Aug 21, 2020
33f9c35
spacecharge: added semantics in tools and removal of duplicate...
aoeftiger Aug 24, 2020
830b1fc
Merge pull request #2 from aoeftiger/pr37and50
aoeftiger Aug 24, 2020
ad264cd
Merge branch 'master' into feature/sc-linedensity-interpolation
aoeftiger Aug 26, 2020
f766877
elements: register new SpaceChargeInterpolatedProfile
aoeftiger Aug 26, 2020
bc6c303
elements: register new SpaceChargeInterpolatedProfile
aoeftiger Aug 26, 2020
c7bfd79
added helper class to calculate q-gaussian distributions
martinschwinzerl Sep 1, 2020
e08fab8
use proper q-gaussian distribution inside SpaceChargeQGaussianProfile
martinschwinzerl Sep 1, 2020
7aa8265
rename SpaceChargeQGaussianProfile to ScQGaussProfile
martinschwinzerl Sep 1, 2020
c0e3109
add gamma and pow functions to MathlibDefault
martinschwinzerl Sep 1, 2020
794e7b3
update SpaceChargeInterpolatedProfile
martinschwinzerl Sep 1, 2020
a5c0af4
remove not needed lines from the SpaceChargeInterpolatedProfile track…
martinschwinzerl Sep 1, 2020
9a2e2fd
renamed SpaceChargeInterpolatedProfile to ScInterpolatedProfile, cosm…
martinschwinzerl Sep 1, 2020
5089b18
cosmetic changes to ScQGaussProfile
martinschwinzerl Sep 1, 2020
464cf03
linter/cosmetic changes to be_beamfields/tools.py
martinschwinzerl Sep 1, 2020
d5399b0
added method parameter to setup_spacecharge_interpolated_in_line, cos…
martinschwinzerl Sep 1, 2020
7348ad4
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
d9d0fe9
linter/cosmetic changes
martinschwinzerl Sep 1, 2020
409b3c2
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
254d034
linter/cosmetic changes
martinschwinzerl Sep 1, 2020
4e03e43
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
ada75cc
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
d643e1f
linter/cosmetic changes
martinschwinzerl Sep 1, 2020
56de1fb
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
9c3c939
uses upated space-charge element names
martinschwinzerl Sep 1, 2020
724cb1e
linter/cosmetic changes
martinschwinzerl Sep 1, 2020
f796875
Merge remote-tracking branch 'aoeftiger/feature/sc-linedensity-interp…
martinschwinzerl Sep 1, 2020
6c4ef04
Fix wrong attribute name in ScQGaussProfile
martinschwinzerl Sep 2, 2020
4a3a714
Update spacecharge.py
martinschwinzerl Sep 2, 2020
5da8d57
Update qgauss.py
martinschwinzerl Sep 2, 2020
8c0b3c4
fixes bug in calculating sqrt_beta for gaussian distributions
martinschwinzerl Sep 15, 2020
6acd66c
adds cq getter for the Q-Gaussian distribution
martinschwinzerl Sep 15, 2020
4bbfef4
fixes wrong decorator for the setter of q for the QGauss distribution
martinschwinzerl Sep 15, 2020
08f2f69
rename ScCoasting -> SCCoasting
martinschwinzerl Sep 15, 2020
69a1fe2
streamline the SCCoasting track() implementation
martinschwinzerl Sep 15, 2020
56f312b
rename ScQGaussProfile -> SCQGaussProfile
martinschwinzerl Sep 15, 2020
12b7d03
streamline track() implementation for SCQGaussProfile
martinschwinzerl Sep 15, 2020
cdd6d5f
rename ScInterpolatedProfile -> SCInterpolatedProfile
martinschwinzerl Sep 15, 2020
9a1327b
streamline implementation of track() method for SCInterpolatedProfile
martinschwinzerl Sep 15, 2020
655058a
reflect the rename of space-charge class names
martinschwinzerl Sep 15, 2020
71df3b0
adds unit-test for calculating gaussian distributions from QGauss
martinschwinzerl Sep 15, 2020
9098e6c
reflects the renaming of space-charge elements in tests
martinschwinzerl Sep 15, 2020
3c2bb4e
adds block to allow stand-alone running of the test, cosmetic changes
martinschwinzerl Sep 15, 2020
fb4c160
reflects the renaming of the space-charge elements in the examples
martinschwinzerl Sep 15, 2020
8250b8b
Merge pull request #3 from martinschwinzerl/feature/sc-linedensity-in…
aoeftiger Sep 16, 2020
1d342d1
bumps version number
martinschwinzerl Oct 13, 2020
bd06e83
adds method to get the num. indices in a line for given types
martinschwinzerl Oct 14, 2020
b363afe
Merge remote-tracking branch 'mschwinz/feature/sc-linedensity-interpo…
martinschwinzerl Oct 14, 2020
2b96cc9
Merge pull request #4 from martinschwinzerl/feature/sc-linedensity-in…
aoeftiger Oct 14, 2020
7a25d03
Typo in particles.py docstring
aoeftiger Nov 2, 2020
d2fe384
Addressing issue #61: 1. adding kwargs to find_closed_orbit...
aoeftiger Nov 4, 2020
2dd7445
Addressing issue #61: 2. fixing coord to use zeta both times
aoeftiger Nov 4, 2020
ef63efd
Merge branch 'master' into feature/sc-linedensity-interpolation
aoeftiger Nov 4, 2020
730d42a
Fixing test_madx_import for the test_zero_error
aoeftiger Nov 4, 2020
0755d6a
Fixing test_madx_import for new order of arguments
aoeftiger Nov 4, 2020
a52aeb8
new closed_orbit module: add **kwargs for particles...
aoeftiger Nov 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
space charge: copy from SpaceChargeBunched to new interpolated profil…
…e class
  • Loading branch information
aoeftiger committed Jun 12, 2020
commit ec91688eb772740e7f0b84ab19ad9ac03a9bef8e
75 changes: 75 additions & 0 deletions pysixtrack/be_beamfields/spacecharge.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,78 @@ def track(self, p):
p.py = py


class SpaceChargeInterpolatedProfile(Element):
"""Space charge for a bunched beam with discretised profile."""

_description = [
("number_of_particles", "", "Number of particles in the bunch", 0.0),
("line_density_profile", "1/m", "Discretised list of density values with integral normalised to 1", [1.0]),
("dz", "m", "Unit distance between profile points", 0.0),
("z0", "m", "Start position of line density profile", 0.0),
("sigma_x", "m", "Horizontal size of the beam (r.m.s.)", 1.0),
("sigma_y", "m", "Vertical size of the beam (r.m.s.)", 1.0),
("length", "m", "Integration length of space charge kick", 0.0),
("x_co", "m", "Horizontal closed orbit offset", 0.0),
("y_co", "m", "Vertical closed orbit offset", 0.0),
]
_extra = [
("min_sigma_diff", "m", "Threshold to detect round beam", 1e-30),
("enabled", "", "Switch to disable space charge effect", True),
]

def track(self, p):
if self.enabled:
pi = p._m.pi
exp = p._m.exp
sqrt = p._m.sqrt
bunchlength_rms = self.bunchlength_rms
length = self.length
sigma_x = self.sigma_x
sigma_y = self.sigma_y

charge = p.q0 * p.echarge
x = p.x - self.x_co
px = p.px
y = p.y - self.y_co
py = p.py
sigma = p.sigma

chi = p.chi

beta = p.beta0 / p.rvv
p0c = p.p0c * p.echarge

Ex, Ey = get_Ex_Ey_Gx_Gy_gauss(
x,
y,
sigma_x,
sigma_y,
min_sigma_diff=1e-10,
skip_Gs=True,
mathlib=p._m,
)

fact_kick = (
chi
* (charge * p.qratio)
* charge
* (1 - p.beta0 * beta)
/ (p0c * beta)
* length
)

fact_kick *= (
self.number_of_particles
/ (bunchlength_rms * sqrt(2 * pi))
* exp(
-0.5
* (sigma / bunchlength_rms)
* (sigma / bunchlength_rms)
)
)

px += fact_kick * Ex
py += fact_kick * Ey

p.px = px
p.py = py