In [2]:
from jpype import *
from numpy import *
In [3]:
JAVA_JVM='/usr/lib/jvm/java-1.7.0-oracle-1.7.0.17.x86_64/jre/lib/amd64/server/libjvm.so'
JAVA_OpenXAL='/home/shared/OpenXAL/lib/openxal/openxal.library-1.0.2.jar'
JAVA_ClassPath='-Djava.class.path='+JAVA_OpenXAL
JAVA_Flags='-ea'
In [4]:
startJVM(JAVA_JVM, JAVA_Flags, JAVA_ClassPath)
In [5]:
_XMLDataManager = JClass("xal.smf.data.XMLDataManager")
In [6]:
Accelerator = _XMLDataManager.acceleratorWithPath('/home/shared/OpenXAL/etc/main.xal')

Accelerator Methods:

http://xaldev.sourceforge.net/javadoc/xal/smf/Accelerator.html

In [7]:
print Accelerator.getAllSeqs()
[mebt, GAP1, GAP2, GAP3, dtl, DTL1, DTL2, DTL3, DTL4, DTL5, DTL6, DTL7, DTL8, DTL9, DTL10, DTL11, DTL12, DTL13, DTL14, DTL15, DTL16, DTL17, DTL18, DTL19, DTL20, DTL21, DTL22, DTL23, DTL24, DTL25, DTL26, DTL27, DTL28, DTL29, DTL30, DTL31, DTL32, DTL33, DTL34, DTL35, DTL36, DTL37, DTL38, DTL39, DTL40, DTL41, DTL42, DTL43, DTL44, DTL45, DTL46, DTL47, DTL48, DTL49, DTL50, DTL51, DTL52, DTL53, DTL54, DTL55, DTL56, DTL57, DTL58, DTL59, DTL60, DTL61, DTL62, DTL63, DTL64, DTL65, DTL66, DTL67, DTL68, DTL69, DTL70, DTL71, DTL72, DTL73, DTL74, DTL75, DTL76, DTL77, DTL78, DTL79, DTL80, DTL81, DTL82, DTL83, DTL84, DTL85, DTL86, DTL87, DTL88, DTL89, DTL90, DTL91, DTL92, DTL93, DTL94, DTL95, DTL96, DTL97, DTL98, DTL99, DTL100, DTL101, DTL102, DTL103, DTL104, DTL105, DTL106, DTL107, DTL108, DTL109, DTL110, DTL111, DTL112, DTL113, DTL114, DTL115, DTL116, DTL117, DTL118, DTL119, DTL120, DTL121, DTL122, DTL123, DTL124, DTL125, DTL126, DTL127, DTL128, DTL129, DTL130, DTL131, DTL132, DTL133, DTL134, DTL135, DTL136, DTL137, DTL138, DTL139, DTL140, DTL141, DTL142, DTL143, DTL144, DTL145, DTL146, DTL147, DTL148, DTL149, DTL150, DTL151, DTL152, DTL153, DTL154, DTL155, DTL156, DTL157, DTL158, DTL159, DTL160, DTL161, DTL162, DTL163, DTL164, DTL165, DTL166, DTL167, DTL168, DTL169, DTL170, DTL171, DTL172, DTL173, DTL174, DTL175, DTL176, DTL177, spoke, NC1, NC2, NC3, NC4, NC5, NC6, NC7, NC8, NC9, NC10, NC11, NC12, NC13, NC14, NC15, NC16, NC17, NC18, NC19, NC20, NC21, NC22, NC23, NC24, NC25, NC26, mb, NC27, NC28, NC29, NC30, NC31, NC32, NC33, NC34, NC35, NC36, NC37, NC38, NC39, NC40, NC41, NC42, NC43, NC44, NC45, NC46, NC47, NC48, NC49, NC50, NC51, NC52, NC53, NC54, NC55, NC56, NC57, NC58, NC59, NC60, NC61, NC62, hb, NC63, NC64, NC65, NC66, NC67, NC68, NC69, NC70, NC71, NC72, NC73, NC74, NC75, NC76, NC77, NC78, NC79, NC80, NC81, NC82, NC83, NC84, NC85, NC86, NC87, NC88, NC89, NC90, NC91, NC92, NC93, NC94, NC95, NC96, NC97, NC98, NC99, NC100, NC101, NC102, NC103, NC104, NC105, NC106, NC107, NC108, NC109, NC110, NC111, NC112, NC113, NC114, NC115, NC116, NC117, NC118, NC119, NC120, NC121, NC122, NC123, NC124, NC125, NC126, NC127, NC128, NC129, NC130, NC131, NC132, NC133, NC134, NC135, NC136, NC137, NC138, NC139, NC140, NC141, NC142, NC143, NC144, NC145, NC146, hebt]

In [8]:
print Accelerator.getComboSequences()
[from-mebt]

Sequence Methods:

http://xaldev.sourceforge.net/javadoc/xal/smf/AcceleratorSeq.html

In [9]:
#Sequence = Accelerator.getSequence('mebt')
Sequence = Accelerator.getComboSequence('from-mebt')
In [10]:
Sequence.getNodeCount()
Out[10]:
952
In [11]:
print Sequence.nodes
[QP1, BPM1, TS1-VC, TS1-HC, QP2, QP3, BPM2, TS2-VC, TS2-HC, QP4, GAP1, QP5, BPM3, TS3-VC, TS3-HC, QP6, QP7, GAP2, QP8, BPM4, TS4-VC, TS4-HC, QP9, QP10, BPM5, TS5-VC, TS5-HC, QP11, QP12, BPM6, TS6-VC, TS6-HC, QP13, QP14, BPM7, TS7-VC, TS7-HC, QP15, GAP3, QP16, BPM8, TS8-VC, TS8-HC, QP17, QP18, BPM9, TS9-VC, TS9-HC, QP19, QP20, BPM10, TS10-VC, TS10-HC, QP21, QP22, DTL1, DTL2, TS11-VC, TS11-HC, DTL3, DTL4, TS12-VC, TS12-HC, DTL5, DTL6, DTL7, DTL8, DTL9, DTL10, DTL11, DTL12, DTL13, DTL14, DTL15, DTL16, DTL17, DTL18, DTL19, DTL20, BPM11, DTL21, DTL22, TS13-VC, TS13-HC, DTL23, DTL24, TS14-VC, TS14-HC, DTL25, DTL26, DTL27, DTL28, DTL29, DTL30, DTL31, DTL32, DTL33, DTL34, DTL35, DTL36, DTL37, DTL38, DTL39, DTL40, BPM12, DTL41, DTL42, TS15-VC, TS15-HC, DTL43, DTL44, TS16-VC, TS16-HC, DTL45, DTL46, DTL47, DTL48, DTL49, DTL50, DTL51, DTL52, DTL53, DTL54, DTL55, DTL56, DTL57, DTL58, DTL59, DTL60, BPM13, DTL61, DTL62, DTL63, DTL64, TS17-VC, TS17-HC, DTL65, DTL66, TS18-VC, TS18-HC, DTL67, DTL68, DTL69, DTL70, DTL71, DTL72, BPM14, DTL73, DTL74, TS19-VC, TS19-HC, DTL75, DTL76, TS20-VC, TS20-HC, DTL77, DTL78, DTL79, DTL80, DTL81, DTL82, DTL83, DTL84, BPM15, DTL85, DTL86, TS21-VC, TS21-HC, DTL87, DTL88, TS22-VC, TS22-HC, DTL89, DTL90, DTL91, DTL92, DTL93, DTL94, DTL95, DTL96, BPM16, DTL97, DTL98, DTL99, DTL100, TS23-VC, TS23-HC, DTL101, DTL102, TS24-VC, TS24-HC, DTL103, DTL104, DTL105, DTL106, BPM17, DTL107, DTL108, TS25-VC, TS25-HC, DTL109, DTL110, TS26-VC, TS26-HC, DTL111, DTL112, DTL113, DTL114, DTL115, DTL116, BPM18, DTL117, DTL118, TS27-VC, TS27-HC, DTL119, DTL120, TS28-VC, TS28-HC, DTL121, DTL122, DTL123, DTL124, DTL125, DTL126, BPM19, DTL127, DTL128, DTL129, DTL130, TS29-VC, TS29-HC, DTL131, DTL132, TS30-VC, TS30-HC, DTL133, DTL134, DTL135, DTL136, BPM20, DTL137, DTL138, TS31-VC, TS31-HC, DTL139, DTL140, TS32-VC, TS32-HC, DTL141, DTL142, DTL143, DTL144, BPM21, DTL145, DTL146, TS33-VC, TS33-HC, DTL147, DTL148, TS34-VC, TS34-HC, DTL149, DTL150, DTL151, DTL152, BPM22, DTL153, DTL154, DTL155, DTL156, TS35-VC, TS35-HC, DTL157, DTL158, TS36-VC, TS36-HC, DTL159, DTL160, BPM23, DTL161, DTL162, TS37-VC, TS37-HC, DTL163, DTL164, TS38-VC, TS38-HC, DTL165, DTL166, DTL167, DTL168, BPM24, DTL169, DTL170, TS39-VC, TS39-HC, DTL171, DTL172, TS40-VC, TS40-HC, DTL173, DTL174, DTL175, DTL176, BPM25, DTL177, QP23, ST1-VC, ST1-HC, QP24, ST2-VC, ST2-HC, NC1, NC2, BPM26, QP25, ST3-VC, ST3-HC, QP26, ST4-VC, ST4-HC, NC3, NC4, BPM27, QP27, ST5-VC, ST5-HC, QP28, ST6-VC, ST6-HC, NC5, NC6, BPM28, QP29, ST7-VC, ST7-HC, QP30, ST8-VC, ST8-HC, NC7, NC8, BPM29, QP31, ST9-VC, ST9-HC, QP32, ST10-VC, ST10-HC, NC9, NC10, BPM30, QP33, ST11-VC, ST11-HC, QP34, ST12-VC, ST12-HC, NC11, NC12, BPM31, QP35, ST13-VC, ST13-HC, QP36, ST14-VC, ST14-HC, NC13, NC14, BPM32, QP37, ST15-VC, ST15-HC, QP38, ST16-VC, ST16-HC, NC15, NC16, BPM33, QP39, ST17-VC, ST17-HC, QP40, ST18-VC, ST18-HC, NC17, NC18, BPM34, QP41, ST19-VC, ST19-HC, QP42, ST20-VC, ST20-HC, NC19, NC20, BPM35, QP43, ST21-VC, ST21-HC, QP44, ST22-VC, ST22-HC, NC21, NC22, BPM36, QP45, ST23-VC, ST23-HC, QP46, ST24-VC, ST24-HC, NC23, NC24, BPM37, QP47, ST25-VC, ST25-HC, QP48, ST26-VC, ST26-HC, NC25, NC26, BPM38, QP49, ST27-VC, ST27-HC, QP50, ST28-VC, ST28-HC, NC27, NC28, NC29, NC30, BPM39, QP51, ST29-VC, ST29-HC, QP52, ST30-VC, ST30-HC, NC31, NC32, NC33, NC34, BPM40, QP53, ST31-VC, ST31-HC, QP54, ST32-VC, ST32-HC, NC35, NC36, NC37, NC38, BPM41, QP55, ST33-VC, ST33-HC, QP56, ST34-VC, ST34-HC, NC39, NC40, NC41, NC42, BPM42, QP57, ST35-VC, ST35-HC, QP58, ST36-VC, ST36-HC, NC43, NC44, NC45, NC46, BPM43, QP59, ST37-VC, ST37-HC, QP60, ST38-VC, ST38-HC, NC47, NC48, NC49, NC50, BPM44, QP61, ST39-VC, ST39-HC, QP62, ST40-VC, ST40-HC, NC51, NC52, NC53, NC54, BPM45, QP63, ST41-VC, ST41-HC, QP64, ST42-VC, ST42-HC, NC55, NC56, NC57, NC58, BPM46, QP65, ST43-VC, ST43-HC, QP66, ST44-VC, ST44-HC, NC59, NC60, NC61, NC62, BPM47, QP67, ST45-VC, ST45-HC, QP68, ST46-VC, ST46-HC, NC63, NC64, NC65, NC66, BPM48, QP69, ST47-VC, ST47-HC, QP70, ST48-VC, ST48-HC, NC67, NC68, NC69, NC70, BPM49, QP71, ST49-VC, ST49-HC, QP72, ST50-VC, ST50-HC, NC71, NC72, NC73, NC74, BPM50, QP73, ST51-VC, ST51-HC, QP74, ST52-VC, ST52-HC, NC75, NC76, NC77, NC78, BPM51, QP75, ST53-VC, ST53-HC, QP76, ST54-VC, ST54-HC, NC79, NC80, NC81, NC82, BPM52, QP77, ST55-VC, ST55-HC, QP78, ST56-VC, ST56-HC, NC83, NC84, NC85, NC86, BPM53, QP79, ST57-VC, ST57-HC, QP80, ST58-VC, ST58-HC, NC87, NC88, NC89, NC90, BPM54, QP81, ST59-VC, ST59-HC, QP82, ST60-VC, ST60-HC, NC91, NC92, NC93, NC94, BPM55, QP83, ST61-VC, ST61-HC, QP84, ST62-VC, ST62-HC, NC95, NC96, NC97, NC98, BPM56, QP85, ST63-VC, ST63-HC, QP86, ST64-VC, ST64-HC, NC99, NC100, NC101, NC102, BPM57, QP87, ST65-VC, ST65-HC, QP88, ST66-VC, ST66-HC, NC103, NC104, NC105, NC106, BPM58, QP89, ST67-VC, ST67-HC, QP90, ST68-VC, ST68-HC, NC107, NC108, NC109, NC110, BPM59, QP91, ST69-VC, ST69-HC, QP92, ST70-VC, ST70-HC, NC111, NC112, NC113, NC114, BPM60, QP93, ST71-VC, ST71-HC, QP94, ST72-VC, ST72-HC, NC115, NC116, NC117, NC118, BPM61, QP95, ST73-VC, ST73-HC, QP96, ST74-VC, ST74-HC, NC119, NC120, NC121, NC122, BPM62, QP97, ST75-VC, ST75-HC, QP98, ST76-VC, ST76-HC, NC123, NC124, NC125, NC126, BPM63, QP99, ST77-VC, ST77-HC, QP100, ST78-VC, ST78-HC, NC127, NC128, NC129, NC130, BPM64, QP101, ST79-VC, ST79-HC, QP102, ST80-VC, ST80-HC, NC131, NC132, NC133, NC134, BPM65, QP103, ST81-VC, ST81-HC, QP104, ST82-VC, ST82-HC, NC135, NC136, NC137, NC138, BPM66, QP105, ST83-VC, ST83-HC, QP106, ST84-VC, ST84-HC, NC139, NC140, NC141, NC142, BPM67, QP107, ST85-VC, ST85-HC, QP108, ST86-VC, ST86-HC, NC143, NC144, NC145, NC146, BPM68, QP109, ST87-VC, ST87-HC, QP110, ST88-VC, ST88-HC, QP111, ST89-VC, ST89-HC, BPM69, QP112, ST90-VC, ST90-HC, QP113, ST91-VC, ST91-HC, BPM70, QP114, ST92-VC, ST92-HC, QP115, ST93-VC, ST93-HC, BPM71, QP116, ST94-VC, ST94-HC, QP117, ST95-VC, ST95-HC, BPM72, QP118, ST96-VC, ST96-HC, QP119, ST97-VC, ST97-HC, BPM73, QP120, ST98-VC, ST98-HC, QP121, ST99-VC, ST99-HC, BPM74, QP122, ST100-VC, ST100-HC, QP123, ST101-VC, ST101-HC, BPM75, QP124, ST102-VC, ST102-HC, QP125, ST103-VC, ST103-HC, BPM76, QP126, ST104-VC, ST104-HC, QP127, ST105-VC, ST105-HC, BPM77, QP128, ST106-VC, ST106-HC, QP129, ST107-VC, ST107-HC, BPM78, QP130, ST108-VC, ST108-HC, QP131, ST109-VC, ST109-HC, BPM79, QP132, ST110-VC, ST110-HC, QP133, ST111-VC, ST111-HC, BPM80, QP134, ST112-VC, ST112-HC, QP135, ST113-VC, ST113-HC, BPM81, QP136, ST114-VC, ST114-HC, QP137, ST115-VC, ST115-HC, BPM82, QP138, ST116-VC, ST116-HC, QP139, ST117-VC, ST117-HC, BPM83, QP140, ST118-VC, ST118-HC, BPM84, BEND1, QP141, ST119-VC, ST119-HC, BPM85, QP142, ST120-VC, ST120-HC, QP143, ST121-VC, ST121-HC, BPM86, QP144, ST122-VC, ST122-HC, QP145, ST123-VC, ST123-HC, BPM87, QP146, ST124-VC, ST124-HC, QP147, ST125-VC, ST125-HC, BPM88, QP148, ST126-VC, ST126-HC, QP149, ST127-VC, ST127-HC, BPM89, QP150, ST128-VC, ST128-HC, QP151, ST129-VC, ST129-HC, BPM90, QP152, ST130-VC, ST130-HC, BPM91, BEND2, TS41-VC, TS41-HC, QP153, QP154, TS42-VC, TS42-HC, BPM92, BPM93, QP155, BPM94, BPM95, QP156, TS43-VC, TS43-HC, TS44-VC, TS44-HC, TS45-VC, TS45-HC, TS46-VC, TS46-HC, TS47-VC, TS47-HC, TS48-VC, TS48-HC, TS49-VC, TS49-HC, TS50-VC, TS50-HC, TS51-VC, TS51-HC, TS52-VC, TS52-HC, QP157, QP158, BPM96, BPM97, BPM98, BPM99, BPM100, BPM101, QP159]

In [12]:
print Sequence.getAllNodesOfType('Quad')
[QP1, QP2, QP3, QP4, QP5, QP6, QP7, QP8, QP9, QP10, QP11, QP12, QP13, QP14, QP15, QP16, QP17, QP18, QP19, QP20, QP21, QP22, DTL1:Q1, DTL1:Q2, DTL2:Q1, DTL2:Q2, DTL3:Q1, DTL3:Q2, DTL4:Q1, DTL4:Q2, DTL5:Q1, DTL5:Q2, DTL6:Q1, DTL6:Q2, DTL7:Q1, DTL7:Q2, DTL8:Q1, DTL8:Q2, DTL9:Q1, DTL9:Q2, DTL10:Q1, DTL10:Q2, DTL11:Q1, DTL11:Q2, DTL12:Q1, DTL12:Q2, DTL13:Q1, DTL13:Q2, DTL14:Q1, DTL14:Q2, DTL15:Q1, DTL15:Q2, DTL16:Q1, DTL16:Q2, DTL17:Q1, DTL17:Q2, DTL18:Q1, DTL18:Q2, DTL19:Q1, DTL19:Q2, DTL20:Q1, DTL20:Q2, DTL21:Q1, DTL21:Q2, DTL22:Q1, DTL22:Q2, DTL23:Q1, DTL23:Q2, DTL24:Q1, DTL24:Q2, DTL25:Q1, DTL25:Q2, DTL26:Q1, DTL26:Q2, DTL27:Q1, DTL27:Q2, DTL28:Q1, DTL28:Q2, DTL29:Q1, DTL29:Q2, DTL30:Q1, DTL30:Q2, DTL31:Q1, DTL31:Q2, DTL32:Q1, DTL32:Q2, DTL33:Q1, DTL33:Q2, DTL34:Q1, DTL34:Q2, DTL35:Q1, DTL35:Q2, DTL36:Q1, DTL36:Q2, DTL37:Q1, DTL37:Q2, DTL38:Q1, DTL38:Q2, DTL39:Q1, DTL39:Q2, DTL40:Q1, DTL40:Q2, DTL41:Q1, DTL41:Q2, DTL42:Q1, DTL42:Q2, DTL43:Q1, DTL43:Q2, DTL44:Q1, DTL44:Q2, DTL45:Q1, DTL45:Q2, DTL46:Q1, DTL46:Q2, DTL47:Q1, DTL47:Q2, DTL48:Q1, DTL48:Q2, DTL49:Q1, DTL49:Q2, DTL50:Q1, DTL50:Q2, DTL51:Q1, DTL51:Q2, DTL52:Q1, DTL52:Q2, DTL53:Q1, DTL53:Q2, DTL54:Q1, DTL54:Q2, DTL55:Q1, DTL55:Q2, DTL56:Q1, DTL56:Q2, DTL57:Q1, DTL57:Q2, DTL58:Q1, DTL58:Q2, DTL59:Q1, DTL59:Q2, DTL60:Q1, DTL60:Q2, DTL61:Q1, DTL61:Q2, DTL62:Q1, DTL62:Q2, DTL63:Q1, DTL63:Q2, DTL64:Q1, DTL64:Q2, DTL65:Q1, DTL65:Q2, DTL66:Q1, DTL66:Q2, DTL67:Q1, DTL67:Q2, DTL68:Q1, DTL68:Q2, DTL69:Q1, DTL69:Q2, DTL70:Q1, DTL70:Q2, DTL71:Q1, DTL71:Q2, DTL72:Q1, DTL72:Q2, DTL73:Q1, DTL73:Q2, DTL74:Q1, DTL74:Q2, DTL75:Q1, DTL75:Q2, DTL76:Q1, DTL76:Q2, DTL77:Q1, DTL77:Q2, DTL78:Q1, DTL78:Q2, DTL79:Q1, DTL79:Q2, DTL80:Q1, DTL80:Q2, DTL81:Q1, DTL81:Q2, DTL82:Q1, DTL82:Q2, DTL83:Q1, DTL83:Q2, DTL84:Q1, DTL84:Q2, DTL85:Q1, DTL85:Q2, DTL86:Q1, DTL86:Q2, DTL87:Q1, DTL87:Q2, DTL88:Q1, DTL88:Q2, DTL89:Q1, DTL89:Q2, DTL90:Q1, DTL90:Q2, DTL91:Q1, DTL91:Q2, DTL92:Q1, DTL92:Q2, DTL93:Q1, DTL93:Q2, DTL94:Q1, DTL94:Q2, DTL95:Q1, DTL95:Q2, DTL96:Q1, DTL96:Q2, DTL97:Q1, DTL97:Q2, DTL98:Q1, DTL98:Q2, DTL99:Q1, DTL99:Q2, DTL100:Q1, DTL100:Q2, DTL101:Q1, DTL101:Q2, DTL102:Q1, DTL102:Q2, DTL103:Q1, DTL103:Q2, DTL104:Q1, DTL104:Q2, DTL105:Q1, DTL105:Q2, DTL106:Q1, DTL106:Q2, DTL107:Q1, DTL107:Q2, DTL108:Q1, DTL108:Q2, DTL109:Q1, DTL109:Q2, DTL110:Q1, DTL110:Q2, DTL111:Q1, DTL111:Q2, DTL112:Q1, DTL112:Q2, DTL113:Q1, DTL113:Q2, DTL114:Q1, DTL114:Q2, DTL115:Q1, DTL115:Q2, DTL116:Q1, DTL116:Q2, DTL117:Q1, DTL117:Q2, DTL118:Q1, DTL118:Q2, DTL119:Q1, DTL119:Q2, DTL120:Q1, DTL120:Q2, DTL121:Q1, DTL121:Q2, DTL122:Q1, DTL122:Q2, DTL123:Q1, DTL123:Q2, DTL124:Q1, DTL124:Q2, DTL125:Q1, DTL125:Q2, DTL126:Q1, DTL126:Q2, DTL127:Q1, DTL127:Q2, DTL128:Q1, DTL128:Q2, DTL129:Q1, DTL129:Q2, DTL130:Q1, DTL130:Q2, DTL131:Q1, DTL131:Q2, DTL132:Q1, DTL132:Q2, DTL133:Q1, DTL133:Q2, DTL134:Q1, DTL134:Q2, DTL135:Q1, DTL135:Q2, DTL136:Q1, DTL136:Q2, DTL137:Q1, DTL137:Q2, DTL138:Q1, DTL138:Q2, DTL139:Q1, DTL139:Q2, DTL140:Q1, DTL140:Q2, DTL141:Q1, DTL141:Q2, DTL142:Q1, DTL142:Q2, DTL143:Q1, DTL143:Q2, DTL144:Q1, DTL144:Q2, DTL145:Q1, DTL145:Q2, DTL146:Q1, DTL146:Q2, DTL147:Q1, DTL147:Q2, DTL148:Q1, DTL148:Q2, DTL149:Q1, DTL149:Q2, DTL150:Q1, DTL150:Q2, DTL151:Q1, DTL151:Q2, DTL152:Q1, DTL152:Q2, DTL153:Q1, DTL153:Q2, DTL154:Q1, DTL154:Q2, DTL155:Q1, DTL155:Q2, DTL156:Q1, DTL156:Q2, DTL157:Q1, DTL157:Q2, DTL158:Q1, DTL158:Q2, DTL159:Q1, DTL159:Q2, DTL160:Q1, DTL160:Q2, DTL161:Q1, DTL161:Q2, DTL162:Q1, DTL162:Q2, DTL163:Q1, DTL163:Q2, DTL164:Q1, DTL164:Q2, DTL165:Q1, DTL165:Q2, DTL166:Q1, DTL166:Q2, DTL167:Q1, DTL167:Q2, DTL168:Q1, DTL168:Q2, DTL169:Q1, DTL169:Q2, DTL170:Q1, DTL170:Q2, DTL171:Q1, DTL171:Q2, DTL172:Q1, DTL172:Q2, DTL173:Q1, DTL173:Q2, DTL174:Q1, DTL174:Q2, DTL175:Q1, DTL175:Q2, DTL176:Q1, DTL176:Q2, DTL177:Q1, DTL177:Q2, QP23, QP24, QP25, QP26, QP27, QP28, QP29, QP30, QP31, QP32, QP33, QP34, QP35, QP36, QP37, QP38, QP39, QP40, QP41, QP42, QP43, QP44, QP45, QP46, QP47, QP48, QP49, QP50, QP51, QP52, QP53, QP54, QP55, QP56, QP57, QP58, QP59, QP60, QP61, QP62, QP63, QP64, QP65, QP66, QP67, QP68, QP69, QP70, QP71, QP72, QP73, QP74, QP75, QP76, QP77, QP78, QP79, QP80, QP81, QP82, QP83, QP84, QP85, QP86, QP87, QP88, QP89, QP90, QP91, QP92, QP93, QP94, QP95, QP96, QP97, QP98, QP99, QP100, QP101, QP102, QP103, QP104, QP105, QP106, QP107, QP108, QP109, QP110, QP111, QP112, QP113, QP114, QP115, QP116, QP117, QP118, QP119, QP120, QP121, QP122, QP123, QP124, QP125, QP126, QP127, QP128, QP129, QP130, QP131, QP132, QP133, QP134, QP135, QP136, QP137, QP138, QP139, QP140, QP141, QP142, QP143, QP144, QP145, QP146, QP147, QP148, QP149, QP150, QP151, QP152, QP153, QP154, QP155, QP156, QP157, QP158, QP159]

In [13]:
print Sequence.getAllNodesOfType('BPM')
[BPM1, BPM2, BPM3, BPM4, BPM5, BPM6, BPM7, BPM8, BPM9, BPM10, BPM11, BPM12, BPM13, BPM14, BPM15, BPM16, BPM17, BPM18, BPM19, BPM20, BPM21, BPM22, BPM23, BPM24, BPM25, BPM26, BPM27, BPM28, BPM29, BPM30, BPM31, BPM32, BPM33, BPM34, BPM35, BPM36, BPM37, BPM38, BPM39, BPM40, BPM41, BPM42, BPM43, BPM44, BPM45, BPM46, BPM47, BPM48, BPM49, BPM50, BPM51, BPM52, BPM53, BPM54, BPM55, BPM56, BPM57, BPM58, BPM59, BPM60, BPM61, BPM62, BPM63, BPM64, BPM65, BPM66, BPM67, BPM68, BPM69, BPM70, BPM71, BPM72, BPM73, BPM74, BPM75, BPM76, BPM77, BPM78, BPM79, BPM80, BPM81, BPM82, BPM83, BPM84, BPM85, BPM86, BPM87, BPM88, BPM89, BPM90, BPM91, BPM92, BPM93, BPM94, BPM95, BPM96, BPM97, BPM98, BPM99, BPM100, BPM101]

In [14]:
Sequence.getLength()
Out[14]:
596.6914855007044

Node Methods:

http://xaldev.sourceforge.net/javadoc/xal/smf/AcceleratorNode.html

In [15]:
MyQuad = Sequence.getNodeWithId('QP1')
In [16]:
MyQuad.getField()
---------------------------------------------------------------------------
xal.ca.ConnectionExceptionPyRaisable      Traceback (most recent call last)
<ipython-input-16-475ba91929e7> in <module>()
----> 1 MyQuad.getField()

xal.ca.ConnectionExceptionPyRaisable: xal.ca.ConnectionException: Channel::nativeType() - The channel "QP1:B" must be connected at least once in the past to use this feature.
In []:
MyQuad.field
In []:
MyQuad.isMagnet()
In []:
Sequence.getNodeWithId('BPM1').isMagnet()
In []:
print MyQuad.handles
In []:
MyQuad.handles.toString()
In []:
MyQuad.getChannel('fieldSet').getId()
In []:
MyQuad.getChannel('fieldRB').getId()

It is time to run a simulation

Setup generic parameters for an algorithm of simulation

http://xaldev.sourceforge.net/javadoc/xal/model/alg/EnvTrackerAdapt.html

In [17]:
_AlgorithFactory = JClass("xal.sim.scenario.AlgorithmFactory")
In [18]:
EnvelopeTracker = _AlgorithFactory.createEnvTrackerAdapt(Sequence)
In [19]:
EnvelopeTracker.setMaxIterations(1000)
EnvelopeTracker.setAccuracyOrder(1)
EnvelopeTracker.setErrorTolerance(0.001)

Setup a probe for the simulation (Beam)

http://xaldev.sourceforge.net/javadoc/xal/model/alg/EnvTrackerAdapt.html

In [20]:
_ProbeFactory = JClass("xal.sim.scenario.ProbeFactory")
In [21]:
Probe = _ProbeFactory.getEnvelopeProbe(Sequence, EnvelopeTracker)

Setup a model (Scenario) for the simulation

http://xaldev.sourceforge.net/javadoc/xal/sim/scenario/Scenario.html

In [22]:
_Scenario = JClass("xal.sim.scenario.Scenario")
In [23]:
Model = _Scenario.newScenarioFor(Sequence)
In [24]:
Model.setProbe(Probe)
In [25]:
Model.setSynchronizationMode('LIVE')
#Model.setSynchronizationMode('DESIGN')
In [26]:
Model.resync()
---------------------------------------------------------------------------
java.lang.NullPointerExceptionPyRaisable  Traceback (most recent call last)
<ipython-input-26-947ed1cf0f63> in <module>()
----> 1 Model.resync()

java.lang.NullPointerExceptionPyRaisable: java.lang.NullPointerException

Run the simulation

In [27]:
Model.run()

Get back the probe (Beam)

In [28]:
Probe = Model.getProbe()

Get the trajectory

http://xaldev.sourceforge.net/javadoc/xal/model/probe/traj/Trajectory.html

In [29]:
Trajectory = Probe.getTrajectory()
In [30]:
Positions=[]
for State in Trajectory.stateIterator():
    Positions.append(State.getPosition())
In [31]:
CovarianceMatrices=[]
for State in Trajectory.stateIterator():
    CovarianceMatrices.append(State.getCovarianceMatrix())
In [32]:
SigmaX=[]
SigmaY=[]
SigmaZ=[]
for CovarianceMatrix in CovarianceMatrices:
    SigmaX.append(CovarianceMatrix.getSigmaX())
    SigmaY.append(CovarianceMatrix.getSigmaY())
    SigmaZ.append(CovarianceMatrix.getSigmaZ())
In [33]:
fig, (ax1, ax2, ax3) = subplots(ncols=3, figsize=(18,8))
ax1.set_xlabel('Position [m]')
ax1.set_ylabel('$\sigma_x$ [m]')
ax1.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
ax1.plot(Positions, SigmaX, color='r')

ax2.plot(Positions, SigmaY, color='g')
ax2.set_xlabel('Position [m]')
ax2.set_ylabel('$\sigma_y$ [m]')
ax2.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

ax3.plot(Positions, SigmaZ, color='b')
ax3.set_xlabel('Position [m]')
ax3.set_ylabel('$\sigma_z$ [m]')
ax3.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

show()

A little break

What if we want to modify one variable?
We can use EPICS

In []:
from epics import caget, caput
In []:
caget('QP1:B')
In []:
caput('QP1:FldSet', 20)
In []:
caget('QP1:B')

So why not to do it interactively?

In []:
from IPython.html.widgets import interact, interactive
In []:
def PlayWithQuad(QP1Field=-16.1578):
    caput('QP1:FldSet', QP1Field) # This is not part of OpenXAL, with this command we are changing the "Hardware".
#    MyQuad.setDfltField(QP1Field) # This modifies a variable in OpenXAL.
    Probe = _ProbeFactory.getEnvelopeProbe(Sequence, EnvelopeTracker)
    Model.setProbe(Probe)
    Model.resync()
    Model.run()
    Probe = Model.getProbe()
    Trajectory = Probe.getTrajectory()
    Positions=[]
    CovarianceMatrices=[]
    for State in Trajectory.stateIterator():
        Positions.append(State.getPosition())
        CovarianceMatrices.append(State.getCovarianceMatrix())
    SigmaX=[]
    SigmaY=[]
    SigmaZ=[]
    for CovarianceMatrix in CovarianceMatrices:
        SigmaX.append(CovarianceMatrix.getSigmaX())
        SigmaY.append(CovarianceMatrix.getSigmaY())
        SigmaZ.append(CovarianceMatrix.getSigmaZ())

    fig, (ax1, ax2, ax3) = subplots(ncols=3, figsize=(18,8))
    ax1.set_xlabel('Position [m]')
    ax1.set_ylabel('$\sigma_x$ [m]')
    ax1.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
    ax1.plot(Positions, SigmaX, color='r')

    ax2.plot(Positions, SigmaY, color='g')
    ax2.set_xlabel('Position [m]')
    ax2.set_ylabel('$\sigma_y$ [m]')
    ax2.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

    ax3.plot(Positions, SigmaZ, color='b')
    ax3.set_xlabel('Position [m]')
    ax3.set_ylabel('$\sigma_z$ [m]')
    ax3.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
    
    show()
In []:
interactive(PlayWithQuad, QP1Field=(-20.0, 20.0))
In []:
def PlayWithCav(CAV1Amp=0.125):
    caput('GAP1:AmpCtl', CAV1Amp)
    Probe = _ProbeFactory.getEnvelopeProbe(Sequence, EnvelopeTracker)
    Model.setProbe(Probe)
    Model.resync()
    Model.run()
    Probe = Model.getProbe()
    Trajectory = Probe.getTrajectory()
    Positions=[]
    CovarianceMatrices=[]
    for State in Trajectory.stateIterator():
        Positions.append(State.getPosition())
        CovarianceMatrices.append(State.getCovarianceMatrix())
    SigmaX=[]
    SigmaY=[]
    SigmaZ=[]
    for CovarianceMatrix in CovarianceMatrices:
        SigmaX.append(CovarianceMatrix.getSigmaX())
        SigmaY.append(CovarianceMatrix.getSigmaY())
        SigmaZ.append(CovarianceMatrix.getSigmaZ())

    fig, (ax1, ax2, ax3) = subplots(ncols=3, figsize=(18,8))
    ax1.set_xlabel('Position [m]')
    ax1.set_ylabel('$\sigma_x$ [m]')
    ax1.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
    ax1.plot(Positions, SigmaX, color='r')

    ax2.plot(Positions, SigmaY, color='g')
    ax2.set_xlabel('Position [m]')
    ax2.set_ylabel('$\sigma_y$ [m]')
    ax2.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

    ax3.plot(Positions, SigmaZ, color='b')
    ax3.set_xlabel('Position [m]')
    ax3.set_ylabel('$\sigma_z$ [m]')
    ax3.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
    
    show()
In []:
interactive(PlayWithCav, CAV1Amp=(0, 10.0))
In []:
#shutdownJVM()