Skip to content
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
13 changes: 7 additions & 6 deletions examples/element_internal_record/000_internal_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ class TestElementRecord(xo.HybridClass):
# element number.

track_method_source = r'''
/*gpufun*/
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0){
#include "xtrack/headers/track.h"

GPUFUN
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0)
{
// Extract the record and record_index
TestElementRecordData record = TestElementData_getp_internal_record(el, part0);
RecordIndex record_index = NULL;
if (record){
if (record) {
record_index = TestElementRecordData_getp__index(record);
}

int64_t n_kicks = TestElementData_get_n_kicks(el);
printf("n_kicks %d\n", (int)n_kicks);

//start_per_particle_block (part0->part)
START_PER_PARTICLE_BLOCK(part0, part);

for (int64_t i = 0; i < n_kicks; i++) {
double rr = 1e-6 * RandomUniform_generate(part);
Expand All @@ -72,8 +74,7 @@ class TestElementRecord(xo.HybridClass):
}
}


//end_per_particle_block
END_PER_PARTICLE_BLOCK;
}
'''

Expand Down
8 changes: 5 additions & 3 deletions examples/element_internal_record/001_multirecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class TestElementRecord(xo.HybridClass):
# code of the beam element.

TestElement_track_method_source = r'''
/*gpufun*/
#include "xtrack/headers/track.h"

GPUFUN
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0){

// Extract the record and record_index
Expand All @@ -60,7 +62,7 @@ class TestElementRecord(xo.HybridClass):
int64_t n_kicks = TestElementData_get_n_kicks(el);
printf("n_kicks %d\n", (int)n_kicks);

//start_per_particle_block (part0->part)
START_PER_PARTICLE_BLOCK(part0, part);

// Record in table1 info about the ingoing particle
if (record){
Expand Down Expand Up @@ -106,7 +108,7 @@ class TestElementRecord(xo.HybridClass):
}
}

//end_per_particle_block
END_PER_PARTICLE_BLOCK;
}
'''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class TestElementRecord(xo.HybridClass):
# code of the beam element.

TestElement_track_method_source = r'''
/*gpufun*/
#include "xtrack/headers/track.h"

GPUFUN
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0){

// Extract the record and record_index
Expand All @@ -59,7 +61,7 @@ class TestElementRecord(xo.HybridClass):
int64_t n_kicks = TestElementData_get_n_kicks(el);
// printf("n_kicks %d\n", (int)n_kicks);

//start_per_particle_block (part0->part)
START_PER_PARTICLE_BLOCK(part0, part);

// Record in table1 info about the ingoing particle
if (record){
Expand Down Expand Up @@ -105,7 +107,7 @@ class TestElementRecord(xo.HybridClass):
}
}

//end_per_particle_block
END_PER_PARTICLE_BLOCK;
}
'''

Expand Down
11 changes: 7 additions & 4 deletions examples/random_number_generator/001_usage_in_beam_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ class TestElement(xt.BeamElement):

_extra_c_sources = [
'''
/*gpufun*/
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0){
//start_per_particle_block (part0->part)
#include "xtrack/headers/track.h"

GPUFUN
void TestElement_track_local_particle(TestElementData el, LocalParticle* part0)
{
START_PER_PARTICLE_BLOCK(part0, part);
double rr = !!GENERATOR!!_generate(part);
LocalParticle_set_x(part, rr);
//end_per_particle_block
END_PER_PARTICLE_BLOCK;
}
'''.replace('!!GENERATOR!!', generator_to_test)
]
Expand Down
20 changes: 10 additions & 10 deletions examples/spin_lep/chirp_kicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class VerticalChirpKicker(xt.BeamElement):

_extra_c_sources =['''

#include <headers/track.h>
#include <beam_elements/elements_src/track_magnet.h>
#include "xtrack/headers/track.h"
#include "xtrack/beam_elements/elements_src/track_magnet.h"

/*gpufun*/
GPUFUN
void VerticalChirpKicker_track_local_particle(
VerticalChirpKickerData el, LocalParticle* part0){

VerticalChirpKickerData el, LocalParticle* part0)
{
double const k0sl = VerticalChirpKickerData_get_k0sl(el);
double const q_start = VerticalChirpKickerData_get_q_start(el);
double const q_end = q_start + VerticalChirpKickerData_get_q_span(el);
double const num_turns = VerticalChirpKickerData_get_num_turns(el);
double const length = VerticalChirpKickerData_get_length(el);

//start_per_particle_block (part0->part)
START_PER_PARTICLE_BLOCK(part0, part);
double const at_turn = LocalParticle_get_at_turn(part);
if (at_turn < num_turns){
if (at_turn < num_turns) {
// integrating to get the instantaneous phase
double const phi = 2 * PI * q_start * at_turn
+ PI * (q_end - q_start) / ((double) num_turns) * ((double) at_turn * at_turn);
Expand All @@ -60,9 +60,9 @@ class VerticalChirpKicker(xt.BeamElement):
0, // frame curvature
length,
length // lpath - same for a thin element
);
#endif
);
#endif
}
//end_per_particle_block
END_PER_PARTICLE_BLOCK;
}
''']
60 changes: 58 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
[build-system]
build-backend = 'setuptools.build_meta'
requires = [
'setuptools >= 43.0.0',
'numpy',
'setuptools >= 61.0.0',
]

[project]
name = "xtrack"
dynamic = ["version"]
description = "Tracking library for particle accelerators"
readme = "README.md"
requires-python = ">=3.9"
license = { text = "Apache-2.0" }
authors = [
{ name = "G. Iadarola et al." }
]
dependencies = [
"numpy>=1.0",
"pandas>=2.0",
"scipy",
"tqdm",
"requests",
"xobjects",
"xdeps",
]

[project.urls]
"Homepage" = "https://xsuite.readthedocs.io/"
"Bug Tracker" = "https://github.com/xsuite/xsuite/issues"
"Documentation" = "https://xsuite.readthedocs.io/"
"Source Code" = "https://github.com/xsuite/xtrack"
"Download" = "https://pypi.python.org/pypi/xtrack"

[project.optional-dependencies]
tests = [
"cpymad",
"nafflib",
"PyHEADTAIL",
"pytest",
"pytest-mock",
"pymadng",
"requests-mock",
"tfs-pandas",
]
notebooks = [
"jupyter",
"ipympl",
"xplt"
]

[tool.setuptools.packages.find]
where = ["."]
include = ["xtrack", "ducktrack"]

[tool.setuptools.dynamic]
version = { attr = "xtrack._version.__version__" }

[tool.setuptools]
include-package-data = true

[project.entry-points.xobjects]
include = "xtrack"
56 changes: 0 additions & 56 deletions setup.py

This file was deleted.

90 changes: 0 additions & 90 deletions tests/test_atomic_add.py

This file was deleted.

Loading