# Using the Virtac Before reading this document, ensure that the Virtac has been either been installed using pip or you are able to run the docker image. ## Setting your CA port If you are running ```virtac``` within Diamond, you will need to change your CA ports so that the PVs created by ```virtac``` do not clash with the PVs for the real machine. If you pip installed ```virtac``` this can be done by running the following commands in your terminal: :::{code-block} bash $ export EPICS_CA_SERVER_PORT=8064 $ export EPICS_CA_REPEATER_PORT=8065 ::: The docker image uses these ports by default so you can skip this step. But if you wish to change them to something else, you can run the container using either podman or docker as such: :::{code-block} bash podman run -it --network=host -e EPICS_CA_SERVER_PORT=8064 -e EPICS_CA_REPEATER_PORT=8065 ghcr.io/diamondlightsource/virtac:latest ::: ## Running the Virtac The Virtac is run using its command line interface which has the following options: ```{program-output} virtac -h ``` If you have installed the Virtac with pip, then you should be able to activate your virtual environment and run the Virtac with: :::{code-block} bash virtac ::: If you wish to use the container, then ensure that you have a working podman or docker install and then run the Virtac with: :::{code-block} bash podman run -it --network=host ghcr.io/diamondlightsource/virtac:latest ::: Running the Virtac with the default arguments will output the following to the terminal: :::{code-block} bash 2025-09-08 13:50:09,572 Ring mode not specified, using default: I04 Starting PV creation. Virtac stats: Tune feedbacks is enabled Emittance calculations are enabled PV monitoring is enabled Total pvs: 4477 ReadSimPV pvs: 3352 ReadWriteSimPV pvs: 978 RefreshPV pvs: 138 BasePV pvs: 1 MonitorPV pvs: 4 SummationPV pvs: 1 CollationPV pvs: 2 InversionPV pvs: 1 INFO: PVXS QSRV2 is loaded, permitted, and ENABLED. Starting iocInit ############################################################################ ## EPICS 7.0.7.1-DEV ## Rev. 7.0.7.99.1.2 ## Rev. Date 7.0.7.99.1.2 ############################################################################ iocRun: All initialization complete Python 3.11.11 (main, Mar 18 2025, 03:29:18) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> ::: ## Interactive shell commands Most users will not need to touch the interactive shell, and now know all they need to start using the Virtac and reading/writing to it using the PV interface. But for completeness, there are is some additional functionality that you can access from the python interactive shell: - dbl() which lists all of the Virtac's PVs - server.print_virtac_stats() which prints information about the Virtac, you can pass in an integer verbosity value with bigger numbers printing more information. - server.disable_monitoring() and server.enable_monitoring() which allow you to pause/resume PVs which monitor other PVs. For more advanced users, you can also directly interact with the pytac lattice if you want to, here are a few useful commands used for the I04 lattice: :::{code-block} bash >>>server.lattice.get_value('emittance') array([2.692426e-09, 0.000000e+00]) >>>server.lattice.get_all_families() {'d10_9', 'q2be', 'spacer', 'd13_1', 'd1s4ba', 'd1yad1ya', 'drift', 'd3aa', 'shim', 'source', 'tempdrift', 'd13_2', 'd09_8', 'd154bar', 'q1ab', 'd104baa', 'dhs4bar3', 's2c', 'd4b', 'd2yb', 'q2ab', 'd1aa', 'drbm4bar2', 'd13_10', 'd1d2', 'drbm4bal1', 'q3b', 'd4bb', 'd10_2', 'quadrupole', 'drbm4bal2', 'd2yc', 'd104bac', 'dhs4bal2', 'mpw12', 'd054bal', 'dlbm4bal2', 'd4a', 'd5b', 'q1be', 'mpw45', 'd1m4ba', 'bpm10', 'd13_13', 'bbvmxl', 'q2b', 'q4e', 'd104ba0r', 'dk4bas21', 'd13_14', 'vtrim', 'wiggler', 'd13_7', 'd10_6', 'bend', 'dlbm4ba0', 'pad', 'd09_14', 'd20_2', 'd09_10', 's1be', 'dk4bas22', 's2d', 'd6bb', 'dbpm', 'd20_1', 'dlbm4ba1', 'u23b', 'd154bal', 'd09_1', 'squad', 'd10_7', 's1b', 'd3a', 'q3d', 'd2xr', 'vstr', 'kd1', 'hstr', 'd6b4ba0', 'd10_4', 'dhs4bar1', 'di05', 'd10_8', 'bump', 'd6b', 'd2b', 'd10_5', 'd4b4ba0', 's3e', 'd13_9', 'q2d', 'dk4bas20', 'd1m4bal1', 's1a', 'q1b', 'dlb4bal', 'sextupole', 'd1a', 'd104bab', 's1c', 'ap', 'aperture', 'q1d', 'qm13', 'd2ya', 's2a', 'd4ba', 'd6ba', 'dhs4ba', 'd09_12', 'dsext', 'htrim', 'd2b4ba', 's4e', 'dlb4bar', 'mpw15', 'qm09', 'rf', 'bpm', 'd054ba', 'd13_5', 'd2a', 'd4ab', 'bbvmxs', 'd104bar', 'd104ba1', 'd09_9', 'hu64', 'bb', 'u21', 'd3b4bar', 'd13_8', 'd3ab', 'd1x', 'd13_3', 'u27', 'd3b', 'd10_1', 'ux', 'd1m4bal2', 'drbm4bar1', 'hchica', 'd104ba0', 's2be', 'dk4bas23', 'd09_6', 'd1y', 'drift_s2a', 'rfcavity', 'd2xl', 'dhs4bar2', 'drift_drift_s2a', 'u23a', 'd3b4ba', 'd13_12', 'd09_5', 'dhs4bal1', 'q3e', 'd09_2', 'd10_3', 'd09_3', 's1d', 's2b', 'd4aa', 'd1yb', 'd104bad', 'hpmu', 'q1ad', 'd1ab', 'drbm4ba2', 'dlbm4bal1', 'd09_7', 'q2ad', 'd09_13', 'd13_6', 'bumpss'} >>>server.lattice.get_fields() {'live': dict_keys(['beam_current', 'emittance_x', 'emittance_y', 'tune_x', 'tune_y', 's_position', 'energy']), 'simulation': ['chromaticity_x', 'chromaticity_y', 'chromaticity', 'eta_prime_x', 'eta_prime_y', 'dispersion', 'emittance_x', 'emittance_y', 'emittance', 'closed_orbit', 'eta_x', 'eta_y', 'energy', 'phase_x', 'phase_y', 's_position', 'tune_x', 'tune_y', 'alpha', 'beta', 'tune', 'm66', 'x', 'y', 'mu']} >>>server.lattice.get_elements() [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ] # Gets the x and y positions from all bpms >>>server.lattice.get_value('x') array([-1.17040134e-07, -1.17040134e-07, 6.54012412e-08, ..., -3.53143434e-07, -2.99481510e-07, -2.99481510e-07], shape=(2190,)) >>>server.lattice.get_value('y') array([0., 0., 0., ..., 0., 0., 0.], shape=(2190,)) # Print info about element id 4 >>>server.lattice[4] # Get the b1 value of element 4 >>>server.lattice[4].get_value('b1') np.float64(70.96502212959372) :::