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

Allow Drift(N) and validate Particles kwargs #522

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions xtrack/beam_elements/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Marker(BeamElement):
allow_loss_refinement = True
has_backtrack = True
allow_rot_and_shift = False
_skip_in_repr = ['_dummy']

_extra_c_sources = [
"/*gpufun*/\n"
Expand Down Expand Up @@ -83,6 +84,11 @@ class Drift(BeamElement):
_pkg_root.joinpath('beam_elements/elements_src/drift_elem.h'),
]

def __init__(self, length=None, **kwargs):
if length: # otherwise length cannot be set as a positional argument
kwargs['length'] = length
super().__init__(**kwargs)

@property
def _thin_slice_class(self):
return None
Expand Down
8 changes: 8 additions & 0 deletions xtrack/particles/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ def __init__(
raise NameError('`psigma` is not supported anymore.'
'Please use `pzeta` instead.')

accepted_args = set(self._xofields.keys()) | {
'energy0', 'tau', 'pzeta', 'mass_ratio', 'mass', 'kinetic_energy0',
'_context', '_buffer', '_offset', 'p0',
}
if set(kwargs.keys()) - accepted_args:
raise NameError(f'Invalid argument(s) provided: '
f'{set(kwargs.keys()) - accepted_args}')

per_part_input_vars = (
self.per_particle_vars +
((xo.Float64, 'energy0'),
Expand Down