API
impact.Impact ¶
Impact(*args, group=None, always_autophase=False, **kwargs)
Bases: CommandWrapper
Files will be written into a temporary directory within workdir. If workdir=None, a location will be determined by the system.
Source code in impact/impact.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
Attributes¶
impact.Impact.cathode_start
property
writable
¶
cathode_start
Returns a bool if cathode_start is requested. Can also be set as a bool.
impact.Impact.total_charge
property
writable
¶
total_charge
Returns the total bunch charge in C. Can be set.
Methods:¶
impact.Impact.add_ele ¶
add_ele(ele)
Adds an element to .lattice
Source code in impact/impact.py
188 189 190 191 192 193 194 195 196 | |
impact.Impact.add_group ¶
add_group(name, **kwargs)
Add a control group. See control.py
Source code in impact/impact.py
198 199 200 201 202 203 204 205 206 207 208 209 210 | |
impact.Impact.archive ¶
archive(h5=None)
Archive all data to an h5 handle or filename.
If no file is given, a file based on the fingerprint will be created.
Source code in impact/impact.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
impact.Impact.autophase ¶
autophase(settings=None, full_output=False)
Calculate the relative phases of each rf element by tracking a single particle. This uses a fast method that operates outside of Impact
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
dict of ele_name:rel_phase_deg |
None
|
|
full_output
|
type of output to return (see Returns) |
False
|
Returns:
| Type | Description |
|---|---|
if full_output = True retuns a dict of:
|
ele_name:info_dict |
Otherwise returns a dict of:
|
ele_name:rel_phase_deg |
which is the same format as settings.
|
|
Source code in impact/impact.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
impact.Impact.autophase_bookkeeper ¶
autophase_bookkeeper()
Searches for 'autophase_deg' attribute in all eles.
If one is found, autophase is called.
If .always_autophase == True, calls autophase is called.
Returns:
| Name | Type | Description |
|---|---|---|
settings |
dict
|
Autophase settings found |
Source code in impact/impact.py
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
impact.Impact.ele_bookkeeper ¶
ele_bookkeeper()
Link .ele = dict to the lattice elements by their 'name' field
Source code in impact/impact.py
311 312 313 314 315 | |
impact.Impact.field ¶
field(z=0, t=0, x=0, y=0, component='Ez')
Return the field component at a longitudinal position z at time t.
Warking: This is based on the parsed fieldmaps, and not calculated directly from Impact. Not all elements/parameters are implemented. Currently x, y must be 0.
Source code in impact/impact.py
349 350 351 352 353 354 355 356 357 358 359 360 | |
impact.Impact.from_tao
classmethod
¶
from_tao(tao, fieldmap_style='fourier', n_coef=30, **kwargs)
Create a complete Impact object from a running Pytao Tao instance.
Wraps impact.interfaces.bmad.impact_from_tao
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tao
|
Tao
|
Initialized Tao object |
required |
fieldmap_style
|
str
|
Style of fieldmap to create. One of: ('fourier', 'derivatives'), by default = 'fourier' |
'fourier'
|
n_coef
|
int
|
a number of fourier (?) coefficients, by default 30 |
30
|
emfield_cartesian_eles
|
str or list[str]
|
Matching string or list of element names to be converted to Impact-T emfield_cartesian elements, by default = "EM_FIELD::*" |
required |
solrf_eles
|
str or list[str]
|
Matching string or list of element names to be converted to Impact-T solrf elements, by default = 'E_GUN::,SOLENOID::,LCAVITY::*' |
required |
quadrupole_eles
|
str or list[str]
|
Matching string or list of element names to be converted to Impact-T quadrupole elements, by default = 'quad::*' |
required |
write_beam_eles
|
str or list[str]
|
Matching string or list of element names to be converted to Impact-T write beam elements. Note that there is a limit to the number of these that can be created. By default = 'monitor::*' |
required |
Returns:
| Type | Description |
|---|---|
Impact
|
Initialized Impact object |
Source code in impact/impact.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | |
impact.Impact.get_executable ¶
get_executable()
Gets the full path of the executable from .command, .command_mpi Will search environmental variables: Impact.command_env='IMPACTT_BIN' Impact.command_mpi_env='IMPACTT_MPI_BIN'
Source code in impact/impact.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
impact.Impact.get_run_script ¶
get_run_script(write_to_path=False, path=None)
Assembles the run script using self.mpi_run string of the form: 'mpirun -n {n} {command_mpi}'
Optionally writes a file 'run' with this line to path.
Source code in impact/impact.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
impact.Impact.load_archive ¶
load_archive(h5, configure=True)
Loads input and output from archived h5 file.
See: Impact.archive
Source code in impact/impact.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | |
impact.Impact.load_output ¶
load_output()
Loads stats, slice_info, and particles.
Source code in impact/impact.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
impact.Impact.old_plot ¶
old_plot(y='sigma_x', x='mean_z', nice=True, include_layout=True)
Simple stat plot
Source code in impact/impact.py
988 989 990 991 992 | |
impact.Impact.plot ¶
plot(y=('sigma_x', 'sigma_y'), x='mean_z', xlim=None, ylim=None, ylim2=None, y2=(), nice=True, include_layout=True, include_labels=False, include_markers=True, include_particles=True, include_field=True, field_t=None, include_legend=True, return_figure=False, tex=True, **kwargs)
Source code in impact/impact.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | |
impact.Impact.print_lattice ¶
print_lattice()
Pretty printing of the lattice
Source code in impact/impact.py
1054 1055 1056 1057 1058 1059 1060 | |
impact.Impact.run_impact ¶
run_impact(verbose=False, timeout=None)
Runs Impact-T
Source code in impact/impact.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
impact.Impact.stat ¶
stat(key)
Array from .output['stats'][key]
Additional keys are avalable: 'mean_energy': mean energy 'Ez': z component of the electric field at the centroid particle 'Bz' z component of the magnetic field at the centroid particle 'cov_{a}__{b}': any symmetric covariance matrix term
Source code in impact/impact.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
impact.Impact.track ¶
track(particles, s=None)
Track a ParticleGroup. An optional stopping s can be given.
Source code in impact/impact.py
929 930 931 932 933 934 935 | |
impact.Impact.track1 ¶
track1(x0=0, px0=0, y0=0, py0=0, z0=0, pz0=1e-15, t0=0, s=None, species=None)
Tracks a single particle with starting coordinates: x0, y0, z0 in meters px0, py0, pz0 in eV/c t0 in seconds
to a position 's' in meters
Used for phasing and scaling elements.
If successful, returns a ParticleGroup with the final particle.
Otherwise, returns None
Source code in impact/impact.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
impact.Impact.units ¶
units(key)
pmd_unit of a given key
Source code in impact/impact.py
397 398 399 400 401 402 403 404 405 406 407 408 | |
impact.Impact.vprint ¶
vprint(*args)
verbose print
Source code in impact/impact.py
1062 1063 1064 1065 | |
impact.Impact.write_input ¶
write_input(input_filename='ImpactT.in', path=None)
Write all input.
If .initial_particles are given,
Source code in impact/impact.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |