Skip to content

Commit 192d718

Browse files
authored
Merge pull request #17 from xsuite/release/v0.3.0
Release 0.3.0
2 parents 5f29566 + a737d86 commit 192d718

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1711660
-864302
lines changed
8.33 MB
Binary file not shown.
1.37 MB
Binary file not shown.
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# copyright ############################### #
22
# This file is part of the Xboinc Package. #
3-
# Copyright (c) CERN, 2023. #
3+
# Copyright (c) CERN, 2024. #
44
########################################### #
55

66
import subprocess
@@ -16,35 +16,37 @@
1616
# Create simulation input
1717
num_turns = 20
1818
num_particles = 5000
19-
line = xt.Line.from_json(xc._pkg_root.parent / 'examples' / 'machines' / f'lhc_run3_b1.json')
20-
coll_manager = xc.CollimatorManager.from_yaml(xc._pkg_root.parent / 'examples' / 'colldb' / f'lhc_run3.yaml', line=line, beam=1)
19+
line = xt.Line.from_json(xb._pkg_root.parent / 'tests' / 'data' / 'lhc_2024_30cm_b1.json')
20+
coll_manager = xc.CollimatorManager.from_yaml(xb._pkg_root.parent / 'tests' / 'data' / 'lhc_run3.yaml', line=line, beam=1)
2121
coll_manager.install_everest_collimators()
2222
coll_manager.build_tracker()
2323
coll_manager.set_openings()
2424
part = coll_manager.generate_pencil_on_collimator('tcp.c6l7.b1', num_particles=num_particles)
2525
coll_manager.enable_scattering()
26-
xb.SimConfig.build(line=line, particles=part, num_turns=num_turns, filename='xboinc_input.bin', checkpoint_every=5)
26+
input = xb.XbInput(line=line, particles=part, num_turns=num_turns, checkpoint_every=5)
27+
input.to_binary('xboinc_input.bin')
2728

2829

2930
# Run xboinc
3031
cmd = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
3132
arch = cmd.stdout.decode('UTF-8').strip().lower()
3233
cmd = subprocess.run(['uname', '-s'], stdout=subprocess.PIPE)
3334
thisos = cmd.stdout.decode('UTF-8').strip().lower()
34-
exec_files = list(Path.cwd().glob(f'xboinc_{xb.app_version}-*'))
35-
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
35+
exec_files = list((Path.cwd().parent / 'executables').glob(f'xboinc_{xb.app_version}-*'))
36+
exec_files += list((Path.cwd().parent / 'executables').glob(f'xboinc_test_{xb.app_version}-*'))
37+
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
3638
if len(exec_files)==0 or not exec_files[0].exists():
3739
raise ValueError("No executable found")
3840
exec_file = exec_files[0]
39-
cmd = subprocess.run(exec_file)
41+
cmd = subprocess.run([exec_file, '--verbose', '1'])
4042
if cmd.returncode != 0:
4143
raise RuntimeError(f"Tracking failed.")
4244

4345

4446
# Read output
45-
filename = 'sim_state_out.bin'
46-
sim_state = xb.SimState.from_binary(filename)
47-
part = sim_state.particles
48-
_ = coll_manager.lossmap(part, file=Path(path_out,f'lossmap_B1H.json'))
49-
summary = coll_manager.summary(part, file=Path(path_out,f'coll_summary_B1H.out'))
47+
filename = 'xboinc_state_out.bin'
48+
xb_state = xb.XbState.from_binary(filename)
49+
part = xb_state.particles
50+
_ = coll_manager.lossmap(part, file=Path('lossmap_B1H.json'))
51+
summary = coll_manager.summary(part, file=Path('coll_summary_B1H.out'))
5052
print(summary)
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# copyright ############################### #
22
# This file is part of the Xboinc Package. #
3-
# Copyright (c) CERN, 2023. #
3+
# Copyright (c) CERN, 2024. #
44
########################################### #
55

66
import subprocess
@@ -17,32 +17,33 @@
1717
line = xt.Line(elements=[
1818
xt.Drift(length=1.0), xt.Multipole(knl=[1e-6]), xt.Drift(length=1.0)])
1919
particles = xp.Particles(mass0=xp.PROTON_MASS_EV, p0c=7e12, x=[1e-6,2e-6,3e-6])
20-
xb.SimConfig.build(line=line, particles=particles, num_turns=num_turns,
21-
filename='xboinc_input.bin')
20+
input = xb.XbInput(line=line, particles=particles, num_turns=num_turns)
21+
input.to_binary('xboinc_input.bin')
2222

2323

2424
# Run xboinc
2525
cmd = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
2626
arch = cmd.stdout.decode('UTF-8').strip().lower()
2727
cmd = subprocess.run(['uname', '-s'], stdout=subprocess.PIPE)
2828
thisos = cmd.stdout.decode('UTF-8').strip().lower()
29-
exec_files = list(Path.cwd().glob(f'xboinc_{xb.app_version}-*'))
30-
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
29+
exec_files = list((Path.cwd().parent / 'executables').glob(f'xboinc_{xb.app_version}-*'))
30+
exec_files += list((Path.cwd().parent / 'executables').glob(f'xboinc_test_{xb.app_version}-*'))
31+
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
3132
if len(exec_files)==0 or not exec_files[0].exists():
3233
raise ValueError("No executable found")
3334
exec_file = exec_files[0]
34-
cmd = subprocess.run(exec_file)
35+
cmd = subprocess.run([exec_file, '--verbose', '1'])
3536
if cmd.returncode != 0:
3637
raise RuntimeError(f"Tracking failed.")
3738

3839

3940
# Read output
40-
filename = 'sim_state_out.bin'
41-
sim_state = xb.SimState.from_binary(filename)
42-
particles = sim_state.particles
41+
filename = 'xboinc_state_out.bin'
42+
xb_state = xb.XbState.from_binary(filename)
43+
particles = xb_state.particles
4344

4445
assert np.all(particles.s == 0)
4546
assert np.all(particles.at_turn == num_turns)
46-
assert sim_state.i_turn == num_turns
47+
assert xb_state.i_turn == num_turns
4748

4849
print('All checks passed!')

examples/timing.py renamed to examples/low_level_api/timing.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import xtrack as xt
77
import xboinc as xb
88

9-
line = xt.Line.from_json('../tests/data/sequence_lhc_run3_b1.json')
9+
line = xt.Line.from_json(xb._pkg_root.parent / 'tests' / 'data' / 'lhc_2024_30cm_b1.json')
1010
line.build_tracker()
1111
file_in = Path('xboinc_input.bin')
12-
file_out = Path('sim_state_out.bin')
12+
file_out = Path('xboinc_state_out.bin')
1313

1414
num_part = 200
1515
num_turns = 50
@@ -19,17 +19,27 @@
1919
y_norm=np.random.normal(0, 10, num_part),
2020
nemitt_x=3.5e-6, nemitt_y=3.5e-6)
2121

22-
xb.SimConfig.build(filename=file_in, num_turns=num_turns, line=line,
23-
particles=part, checkpoint_every=checkpoint_every)
22+
input = xb.XbInput(num_turns=num_turns, line=line, particles=part, checkpoint_every=checkpoint_every)
23+
input.to_binary(file_in)
2424

2525
print("")
26+
cmd = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
27+
arch = cmd.stdout.decode('UTF-8').strip().lower()
28+
cmd = subprocess.run(['uname', '-s'], stdout=subprocess.PIPE)
29+
thisos = cmd.stdout.decode('UTF-8').strip().lower()
30+
exec_files = list((Path.cwd().parent / 'executables').glob(f'xboinc_{xb.app_version}-*'))
31+
exec_files += list((Path.cwd().parent / 'executables').glob(f'xboinc_test_{xb.app_version}-*'))
32+
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
33+
if len(exec_files)==0 or not exec_files[0].exists():
34+
raise ValueError("No executable found")
35+
exec_file = exec_files[0]
2636
now = time.time()
27-
cmd = subprocess.run(['running/xboinc_0.1-x86_64-pc-linux-gnu'])
37+
cmd = subprocess.run([exec_file, '--verbose', '1'])
2838
print(f"Tracking with executable: done in {time.time()-now:.1f}s")
2939
line.track(part, num_turns=num_turns, time=True)
3040
print(f"Tracking from within python: done in {line.time_last_track:.1f}s.")
3141

32-
exec_part = xb.SimState.from_binary(file_out).particles
42+
exec_part = xb.XbState.from_binary(file_out).particles
3343
assert np.all(part.state == exec_part.state)
3444
assert np.allclose(part.x, exec_part.x, rtol=1e-10)
3545
assert np.allclose(part.px, exec_part.px, rtol=1e-10)

examples/register.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# copyright ############################### #
22
# This file is part of the Xboinc Package. #
3-
# Copyright (c) CERN, 2023. #
3+
# Copyright (c) CERN, 2024. #
44
########################################### #
55

66
import xboinc as xb

examples/results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
# copyright ############################### #
2+
# This file is part of the Xboinc Package. #
3+
# Copyright (c) CERN, 2024. #
4+
########################################### #
5+
16
import xboinc as xb
27

38
list_of_succeeded_jobs = []
4-
user='ddicroce'
9+
user='sixtadm'
510
study_name='example_study'
611
for new_particles, jobinfo in xb.RetrieveJobs(user=user, study_name=study_name):
712
print(jobinfo)
-278 KB
Binary file not shown.
-344 KB
Binary file not shown.
-384 KB
Binary file not shown.

0 commit comments

Comments
 (0)