Modeling Accelerator Facility

One of the key features of phantasy is to abstract the accelerator devices into hierarchical structure, which opens the portal for the high-level object-oriented controls way, and based on which, modularized high-level controls software could be developed.

Configuration Files

Currently, phantasy uses (at most) seven (7) types of configuration files to describe the entire accelerator, including device abstraction, online-modeling, controls PV management, etc., among which, the file to integrate the EPICS channels or PV names with accelerator layout is very important. The full list of configuration file types are:

Type Name

File name [1]

Description

Machine configuration

phantasy.ini

Global configuration for loading specific machine

Device/Model configuration

phantasy.cfg

Configuration for physics models and devices

Channels configuration

channels.csv

Includes EPICS PV names and device properties

Layout configuration

layout.csv

Devices geometrical layout configuration

Settings configuration

settings.csv

Initial settings for physics models

Unit scaling configuration

unicorn.xlsx

Scaling laws for physics/engineering units conversion

Machine configuration

Machine configuration file (typical name: phantasy.ini) is the main file that used by phantasy MachinePortal class to instantiate the seleted accelerator and specific segment, which is machine and segment parameter of MachinePortal initialization method, respectively.

Channels configuration

Generally, each device can have one or more than one PV names, which depends on the number of fields to be controlled, please note for this high-level physics controls framework, the only interested fields are physics related, e.g. one solenoid usually only has one field to control (read and write), that is the current applied on the device, while the RF cavity should have both phase and amplitude of electric field to control. In this configuration file, all these information should be included, togther with other general meta-information as device position, length, type, etc.

Simple Example

Here is a simple example of channels.csv (HERE) to describe the PV names in a machine named simple_machine, of segment name TEST:

Table Title

PV

elemField_eng

elemField_phy

elemHandle

elemIndex

elemLength

elemName

elemPosition

elemType

machine

physicsName

physicsType

pvPolicy

FE_SCS1:PSOL_D0704:I_CSET

I

B

setpoint

1

0.3998

FE_SCS1:SOLR_D0704

0.3998

SOL

LIVE

solenoid

SOL_S4b

DEFAULT

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSOL_D0704:I_RSET

I

B

readset

1

0.3998

FE_SCS1:SOLR_D0704

0.3998

SOL

LIVE

solenoid

SOL_S4b

DEFAULT

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSOL_D0704:I_RD

I

B

readback

1

0.3998

FE_SCS1:SOLR_D0704

0.3998

SOL

LIVE

solenoid

SOL_S4b

DEFAULT

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ1_D0726:V_CSET

V

V

setpoint

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ1_D0726:V_RSET

V

V

readset

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ1_D0726:V_RD

V

V

readback

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ2_D0726:V_CSET

V

V

setpoint

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ2_D0726:V_RSET

V

V

readset

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

FE_SCS1:PSQ2_D0726:V_RD

V

V

readback

2

0.2052

FE_SCS1:QHE_D0726

2.5275

EQUAD

LIVE

ES_quad_X

QUAD_Q7

EQUAD

phantasy.sys.FE

phantasy.sub.SCS1

LEBT

LINAC

While the machine configuration for this example is:

[COMMON]
segments: TEST
default_segment: TEST
root_data_dir: /tmp/phantasy_data

[TEST]
cfs_url: channels.csv
cfs_tag: LINAC
cfs_property_names: elem*, pvPolicy
#settings_file: settings.json
#layout_file: layout.csv
#config_file: phantasy.cfg

The typical snippet to abstract the whole segment could be:

>>> from phantasy import MachinePortal
>>> mp = MachinePortal(machine='simple_machine', segment='TEST')
>>> lat = mp.work_lattice_conf
>>> for e in lat:
>>>     print(e)
0001 | FE_SCS1:SOLR_D0704   SOL       0.00  [m] 0.399800 [m]
0002 | FE_SCS1:QHE_D0726    EQUAD     2.32  [m] 0.205200 [m]

All the devices could be reached via mp.work_lattice_conf.

Footnotes