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
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 187 188 189 190 191 192 193 194 | |
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
196 197 198 199 200 201 202 203 204 | |
impact.Impact.add_group ¶
add_group(name, **kwargs)
Add a control group. See control.py
Source code in impact/impact.py
206 207 208 209 210 211 212 213 214 215 216 217 218 | |
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
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 758 759 760 761 762 763 764 765 | |
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
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 925 926 927 928 929 930 931 932 | |
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
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | |
impact.Impact.ele_bookkeeper ¶
ele_bookkeeper()
Link .ele = dict to the lattice elements by their 'name' field
Source code in impact/impact.py
319 320 321 322 323 | |
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
357 358 359 360 361 362 363 364 365 366 367 368 | |
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
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
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
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 497 498 499 500 501 502 503 504 | |
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
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 811 812 813 814 815 816 817 818 | |
impact.Impact.load_output ¶
load_output()
Loads stats, slice_info, and particles.
Source code in impact/impact.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
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
996 997 998 999 1000 | |
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
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 1053 1054 1055 1056 1057 1058 1059 1060 | |
impact.Impact.print_lattice ¶
print_lattice()
Pretty printing of the lattice
Source code in impact/impact.py
1062 1063 1064 1065 1066 1067 1068 | |
impact.Impact.run_impact ¶
run_impact(verbose=False, timeout=None)
Runs Impact-T
Source code in impact/impact.py
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 563 564 565 566 567 568 569 570 | |
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
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
impact.Impact.track ¶
track(particles, s=None)
Track a ParticleGroup. An optional stopping s can be given.
Source code in impact/impact.py
937 938 939 940 941 942 943 | |
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
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 987 988 989 990 991 992 993 994 | |
impact.Impact.units ¶
units(key)
pmd_unit of a given key
Source code in impact/impact.py
405 406 407 408 409 410 411 412 413 414 415 416 | |
impact.Impact.vprint ¶
vprint(*args)
verbose print
Source code in impact/impact.py
1070 1071 1072 1073 | |
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
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 692 693 694 695 696 697 698 699 | |