You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 46 Next »

This page describes the process of running an XAL model of the LCLS accelerator, and uploading that model to Oracle, from where it can be accessed by Matlab and Java applications through AIDA.

Run a model

To run an XAL model, you can use the interactive matlab scripts xalRunModel.m or xalGetModel.m. These can be run directly from matlab, or from lclshome (as described below). The basic process is the same in either case - xalGetModel additionally plots dispersion, betas, and energy.
Summary of running the model:

  • Select a beamline to be modelled
  • Decide whether to run extant or design model
  • If "extant", run LEM lite, to check energy profile
  • Run the XAL model
  • [IF you ran xalGetModel, then inspect the model plots ]

  • Run the XA XML Writer (to create the model upload file)
  • Upload the model to the database
    Note: there is no "back" facility. Just abort (ctrl-c to get to the matlab prompt, and start over).

Running a model in detail

  • From lclshome -> User Dev Displays panel.
  • Run one of the matlab scripts xalRunModel or xalGetModel.
    • xalGetModel.

      • Select a beamline.
        For example, select "Cathode to Dump" This runs the LCLS "Full Machine" model, from the LCLS Cathode to the main Dump. See Why are all models from Cathode to some location.

      • Select whether to "Run extant machine or design model? (x/d) [d]:".
        Running the "design" model (choice "d") causes the XAL model to be run with the element setpoint values in the model input files. Those design setpoint values are, to the extent possible, identical to the MAD design. Running the "extant" model (choice "x") will cause the model execution to first replace the design values of beamline devices, with the actual readback values, as acquired through EPICS and AIDA, prior to running the envelope tracker. That is, "extant" is equivalent to what was called "DATABASE" in the SLC modelling system; it describes the extant machine at the time the model is run.
        Unable to render embedded object: File (xalGetModelextant) not found.

      • Check the initial conditions which will be used for the model run. These are presently taken from the SLC marker point 80. You can check these at any time with AIDAWeb (MARK:VX80:80//twiss MODE=5; the values are Energy (GeV), psix, betax (m), alphax , etax (m), etax', psiy, betay (m), alphay, etay (m), etay')

        If these appear fine, then confirm to continue.

      • Run "LEM Lite". This will calculate and display the fudge factors and predicted energy. When it has completed, check in particular that the final energy at the undulator (see Energy comlumn, and the row of output labelled "BSY") is reasonable, e.g. 9.25 GeV.
    • xalGetModel

Model Notes

Why are all models from Cathode to some location?

Note that all models require the model to be run from the Cathode to some beam destination, rather than allowing sections to be run independently. This is so that, for now, we can guarantee that physics computations carried out from a number of different devices throughout the machine, are carried out from consistent models made from the same initial conditions. With this technique all devices towards the photon end of the machine, must have been modeled by a model run that incorporated upstream devices. A simple example being Rmat A to B from a corrector in the injection line, to a BPM in the

Differences between XAL and MAD models.

Which devices are not modelled.
What is not modelled as it is in MAD.

Copy the file to the following directory. It's necessary to copy it to here because it has to be in a directory that can be accessed by the web browser used in the following step. Note, this directory name starts /u1, but when we do the file upload from lcls-prod02 it will start /mccfs2, that's because on lcls-prod02 the directory is accessed through an NFS server mount.

Put XAL XML files here on slc:

/u1/lcls/physics/onlinemodel/xal

Upload the files.

Start a browser

Start a browser on lcls-prod02, such as by hitting the browser icon on a control room OPI. The reason it's important to run the browser on lcls-prod02, is that the browser has to be able to access a URL in the SLAC internet space, and simultaneously access the filesystem directory where the models have been put. Don't complain to me about this complexity, talk to the Controls Department Systems Group. It should of course be that any browser should be able to access LCLS model data output.

So, either, on lcls-prod02:

kinit (to get a token, which is necessary to start firefox)
firefox &

or, go to a control room OPI and use the icon in the taskbar at the bottom o the screen to launch firefox. This will launch the special firefox on lcls-prod02, from where you can upload the model xml files in the nxt step.

Use APEX to upload the file.

In the browser launched on lcls-prod02, browse to this URL:

https://oraweb.slac.stanford.edu/apex/slacprod/f?p=400

Supply your Windows username and password to login to APEX. Don't tell firefox to remember your password.

Once you're in the application you should see "Select Device File" and "Select Elements File". When a file has been entered for BOTH of these, and you have selected a hardware file and initial conditions file, you can hit "Submit" at the bottom of the dialog screen to start the process of Upload into Oracle.

The following helps with the buttons on the above dialog window.

"Select Device File".

You can either enter a full filename by hand, or use the filebrowser, to browse to /mccfs2/u1/lcls/physics/onlinemodel/xal and select the Devices file, eg "modelDevices.xml", select it, and hit Open icon in the filebrowser dialog to make the selection. (It's a bit confusing using the word "Open" to mean "Select" - talk to Oracle about that - they went cheap and used the firefox file selection widget, designed for selecting a file to open, but they use it to mean "select").

"Select Elements File".

In the filebrowser, browse to /mccfs2/u1/lcls/physics/onlinemodel/xal and select the file "modelOutput.xml".

Select a Hardware File and a Initial Conditions File

Pull-down and select a Hardware file, like "hw_file1", and pull-down the Initial Conditions and select "ic_file1". At the time of writing these are placeholders, any of the values in the pull-downs may be used, but you must select a value before the Submit button will work.

Start the upload to Oracle

Hit "Submit".

Update the AIDA Directory service

Having uploaded a new model, we have to tell Aida to update its database of the names of XAL modelled devices. We will teach first aidadev, then aidaprod databases. These are, respectively, the Oracle usernames (ie subschema) of the Aida directory services used on the aida development and production networks.

Log into an AFS Solaris machine like tersk02, and set up the cdsoft environment

ssh -l<your-username> tersk09
tersk> source /afs/slac/g/cd/soft/dev/script/ENVS.csh

Enter sqlplus for user AIDADEV on database SLACPROD (SLACPROD will be set by sourcing ENVS.csh above).

sqlplus AIDADEV/<aidadbpassword> 

Run the updating procedure. This will look in the ELEMENT_MODELS which was updated by the APX load above, and, for every row that has a match in LCLS_ELEMENTS, it will update Aida's directory service with a name composed of the EPICS name of the device + '//twiss' and '//R', and tell Aida that that device's model is to be acquired from the XAL Aida data provider (service id 202).

aida_xal_names_update takes an optional parameter, to specify whether or not to set the service-id to 202 of names it finds to be already in the aida directory. The default (or "N") is not to set the service-id (that is, leave names which are in both the SLC namespace and EPICS name, assigned to the SLC modelling environment (service id 63). If given, and valued "Y", all names modelled by XAL will be assigned to the XAL model service id (202). That is, while we're testing XAL, use the default; when we're sure about XAL, with an EXTANT machine model, and a plan for what to do when devices for like the end station need model, then use Y to switch all modelling of those devices over to XAL.

SQL> exec aida_xal_names_update [Y];

PL/SQL procedure successfully completed.   <-- you should see this

It should tale only a few seconds.

You can see which names are assigned to the XAL model server by AIDA, use the following sql script

SQL> @show_IA_given_serviceid 202

Now go over and update the AIDAPROD names too (don't wait, all names should be in sync), run aida_all_changes again, and verify the names added again.

SQL> connect aidaprod/<aidadbpassword>
Connected.
SQL> exec aida_xal_names_update [Y];
SQL> @show_IA_given_serviceid 202

Test the upload by asking Aida to retrieve the model parameters (twiss or R) of a device in the model file uploaded. This link takes you to the AidaWeb modelling page, from where you can as for teh names of devices (eg 'BPMS:%//twiss' will return the names of all modelled BPMS, or 'BPMS:IN20:521//twiss' will return model for that device.

https://seal.slac.stanford.edu/aidaweb/modelling.jsp

Developers Guide

At the time of writing (31/Jul/08), Elie's upload parser has some restrictions:
Syntax and constraints of the modelOutput xml files:

  1. the xml header <?xml..> must be on a single record at the top of teh file, followed by a LF.
  2. the <model_output> element tag must be on a record on its own
  3. Each <element> element must be composed of a single record (no CR or LN)
  4. There must be no NaN attribute values. Twiss params (or R matrix elements) that don't have a good value must have some numeric value.
  • No labels