Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mbtrack2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PA
Collective Effects
mbtrack2
Commits
9399d5e2
Commit
9399d5e2
authored
3 years ago
by
Alexis GAMELIN
Browse files
Options
Downloads
Patches
Plain Diff
Add methods to check and modify sampling for WakePotential class
parent
6fe4d1a0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tracking/wakepotential.py
+36
-0
36 additions, 0 deletions
tracking/wakepotential.py
with
36 additions
and
0 deletions
tracking/wakepotential.py
+
36
−
0
View file @
9399d5e2
...
...
@@ -65,6 +65,10 @@ class WakePotential(Element):
Calculate the loss factor and kick factor from the wake potential and
compare it to a reference value assuming a Gaussian bunch computed in
the frequency domain.
check_sampling()
Check if the wake function sampling is uniform.
reduce_sampling(factor)
Reduce wake function samping by an integer factor.
"""
...
...
@@ -74,6 +78,7 @@ class WakePotential(Element):
self
.
n_types
=
len
(
self
.
wakefield
.
wake_components
)
self
.
ring
=
ring
self
.
n_bin
=
n_bin
self
.
check_sampling
()
def
charge_density
(
self
,
bunch
):
"""
...
...
@@ -527,7 +532,38 @@ class WakePotential(Element):
columns
=
column
,
index
=
index
)
return
loss_data
def
check_sampling
(
self
):
"""
Check if the wake function sampling is uniform.
Raises
------
ValueError
"""
for
wake_type
in
self
.
types
:
idx
=
getattr
(
self
.
wakefield
,
wake_type
).
data
.
index
diff
=
idx
[
1
:]
-
idx
[:
-
1
]
result
=
np
.
all
(
np
.
isclose
(
diff
,
diff
[
0
],
atol
=
1e-15
))
if
result
is
False
:
raise
ValueError
(
"
The wake function must be uniformly sampled.
"
)
def
reduce_sampling
(
self
,
factor
):
"""
Reduce wake function samping by an integer factor.
Used to reduce computation time for long bunches.
Parameters
----------
factor : int
"""
for
wake_type
in
self
.
types
:
idx
=
getattr
(
self
.
wakefield
,
wake_type
).
data
.
index
[::
factor
]
getattr
(
self
.
wakefield
,
wake_type
).
data
=
getattr
(
self
.
wakefield
,
wake_type
).
data
.
loc
[
idx
]
self
.
check_sampling
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment