Example #1
0
 def _run_simulation(self):
     """Generate the input files and start the Elegant process."""
     momentum = self.validate_momentum()
     if not momentum:
         return
     if not os.getenv('RPN_DEFNS', None):
         os.environ['RPN_DEFNS'] = resource.filename('defns.rpn')
     self.error_file = open(
         self.session_file(file_name=self.ERROR_FILE_NAME), 'w')
     self.output_file = open(
         self.session_file(file_name=self.OUTPUT_FILE_NAME), 'w')
     self._enable_status_and_results()
     # The replace() command escapes backslashes
     # since Elegant interprets \x as a special character.
     elegant_input_file = self._write_simulation_input_files(momentum).replace('\\', '\\\\')
     self.append_status('Running simulation ...\n')
     self.process.start('elegant', [elegant_input_file])
Example #2
0
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_newsrw()
        self.ui.setupUi(self)
        self.up = UP()
        self.beam = SRWLPartBeam()
        #self.precis = Precis()
        self.arPrecF = [0]*5
        self.arPrecP = [0]*5
        #load initial values from excel
        self.workbook = open_workbook(resource.filename('SRWinitialvalues.xls'))
        self.thick(self.ui.deparg.currentIndex())
        #disable/remove broken simulation argument
        self.ui.deparg.removeItem(6)
        self.ui.deparg.removeItem(5)
        self.ui.deparg.removeItem(4)
        self.ui.intensity.hide()
        self.ui.formLayout_4.labelForField(self.ui.intensity).hide()
        self.ui.polar.hide()
        self.ui.formLayout_4.labelForField(self.ui.polar).hide()

        #set srw initial values
        column = self.workbook.sheet_by_name('thick undulator').col(0)
        units = self.workbook.sheet_by_name('thick undulator').col(1)
        units = self.unitstr(units)
        self.GetUndParams(DialogU(self,units,column))
        column = self.workbook.sheet_by_name('thick beam').col(0)
        units = self.workbook.sheet_by_name('thick beam').col(1)
        units = self.unitstr(units)
        self.GetBeamParams(DialogB(self,units,column))
        column = self.workbook.sheet_by_name('thick precision').col(0)
        units = self.workbook.sheet_by_name('thick precision').col(1)
        print column
        units = self.unitstr(units)
        self.GetPrecision(DialogP(self,units,column))

        #connections
        self.ui.undulator.clicked.connect(self.makeund)
        self.ui.beam.clicked.connect(self.makebeam)
        self.ui.precision.clicked.connect(self.setprec)
        self.ui.deparg.currentIndexChanged.connect(self.thick)
        self.ui.sim.clicked.connect(self.srwbuttonThick)
        self.ui.analyze.clicked.connect(self.AnalyticA)
        #indicators
        self.ui.status.setText('Initiated')
        self.ui.analytic.setText('No calculations performed...As of Yet')
Example #3
0
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_newsrw()
        self.ui.setupUi(self)
        self.up = UP()
        self.beam = SRWLPartBeam()
        self.precis = Precis()
        #load initial values from excel
        self.workbook = open_workbook(resource.filename('SRWinitialvalues.xls'))
        self.thin(self.ui.deparg.currentIndex())
        #set srw initial values
        column = self.workbook.sheet_by_name('thin undulator').col(0)
        units = self.workbook.sheet_by_name('thin undulator').col(1)
        units =self.unitstr(units)
        self.GetUndParams(DialogU(self,units,column))
        column = self.workbook.sheet_by_name('thin beam').col(0)
        units = self.workbook.sheet_by_name('thin beam').col(1)
        units =self.unitstr(units)
        self.GetBeamParams(DialogB(self,units,column))
        column = self.workbook.sheet_by_name('thin precision').col(0)
        units = self.workbook.sheet_by_name('thin precision').col(1)
        units =self.unitstr(units)
        self.GetPrecision(DialogP(self,units,column))
        #removed exy option
        self.ui.deparg.removeItem(6)

        #connections
        self.ui.undulator.clicked.connect(self.makeund)
        self.ui.beam.clicked.connect(self.makebeam)
        self.ui.precision.clicked.connect(self.setprec)
        self.ui.deparg.currentIndexChanged.connect(self.thin)
        self.ui.sim.clicked.connect(self.srwbuttonThin)
        self.ui.analyze.clicked.connect(self.AnalyticA)
        #indicators
        self.ui.status.setText('Initiated')
        self.ui.analytic.setText('No calculations performed...As of Yet')
Example #4
0
import os, glob, subprocess, string
import radtrack.beamlines.RbElegantElements as ele
import radtrack.beamlines.RbOpticalElements as opt
from radtrack.RbUtility import insideQuote

import radtrack.util.resource as resource
if not os.getenv('RPN_DEFNS', None):
    os.environ['RPN_DEFNS'] = resource.filename('defns.rpn')

exportEnd = '_export.lte'

elegantFilesLocation = os.path.join(os.getcwd(), 'deprecated', 'elegant')
elegantTestFile = os.path.join(elegantFilesLocation, 'elegantTest.ele')
particleFileList = glob.glob(os.path.join(elegantFilesLocation, 'beamlines', '*.lte'))
excludedList = ['dtSweep.lte',
                'fourDipoleCSR.lte',
                'lattice.lte',
                'multiple.lte',
                'mv15-c5-v2-ring.lte']

opticalFileList = glob.glob(os.path.join(os.getcwd(), 'deprecated', 'laser_transport', '*.rad'))

fileLists = [particleFileList, opticalFileList]
fileHandlers = [ele, opt]

elegantSimTemplate = '''&run_setup
    lattice = "%s",
    use_beamline = %s,
    default_order = 2,
    p_central_mev = 200.0,
    output = %%s.out,
Example #5
0
def test_conformance():
    """Find resource we know about. Make sure it exists"""
    assert os.path.isfile(resource.filename('defns.rpn')), 'defns.rpn not found'
Example #6
0
def test_deviance():
    """Make sure we can't find a resource that doesn't exist"""
    with pytest.raises(IOError):
        resource.filename('not_found_resource')