コード例 #1
0
ファイル: jspec.py プロジェクト: pir8aye/sirepo
def _elegant_to_madx(ring):
    # if the lattice source is an elegant twiss file, convert it to MAD-X format
    if ring['latticeSource'] == 'madx':
        return
    if ring['latticeSource'] == 'elegant':
        elegant_twiss_file = template_common.lib_file_name('ring', 'elegantTwiss', ring['elegantTwiss'])
    else: # elegant-sirepo
        if 'elegantSirepo' not in ring or not ring['elegantSirepo']:
            raise RuntimeError('elegant simulation not selected')
        elegant_twiss_file = template.ELEGANT_TWISS_FILENAME
        if not os.path.exists(elegant_twiss_file):
            raise RuntimeError('elegant twiss output unavailable. Run elegant simulation.')
    sdds_util.twiss_to_madx(elegant_twiss_file, template.JSPEC_TWISS_FILENAME)
コード例 #2
0
ファイル: jspec.py プロジェクト: e-carlin/sirepo
def _elegant_to_madx(ring):
    # if the lattice source is an elegant twiss file, convert it to MAD-X format
    if ring['latticeSource'] == 'madx':
        return template_common.lib_file_name('ring', 'lattice', ring['lattice'])
    if ring['latticeSource'] == 'elegant':
        elegant_twiss_file = template_common.lib_file_name('ring', 'elegantTwiss', ring['elegantTwiss'])
    else: # elegant-sirepo
        if 'elegantSirepo' not in ring or not ring['elegantSirepo']:
            raise RuntimeError('elegant simulation not selected')
        elegant_twiss_file = template.ELEGANT_TWISS_FILENAME
        if not os.path.exists(elegant_twiss_file):
            raise RuntimeError('elegant twiss output unavailable. Run elegant simulation.')
    sdds_util.twiss_to_madx(elegant_twiss_file, template.JSPEC_TWISS_FILENAME)
    return template.JSPEC_TWISS_FILENAME
コード例 #3
0
ファイル: jspec.py プロジェクト: ahebnl/Sirepo
def _elegant_to_madx(ring):
    # if the lattice source is an elegant twiss file, convert it to MAD-X format
    if ring['latticeSource'] == 'madx':
        return _SIM_DATA.lib_file_name_with_model_field(
            'ring', 'lattice', ring['lattice'])
    if ring['latticeSource'] == 'elegant':
        elegant_twiss_file = _SIM_DATA.lib_file_name_with_model_field(
            'ring', 'elegantTwiss', ring['elegantTwiss'])
    else:  # elegant-sirepo
        if 'elegantSirepo' not in ring or not ring['elegantSirepo']:
            raise RuntimeError('elegant simulation not selected')
        tf = _SIM_DATA.jspec_elegant_dir().join(
            ring.elegantSirepo, _SIM_DATA.jspec_elegant_twiss_path())
        if not tf.exists():
            raise RuntimeError(
                'elegant twiss output unavailable. Run elegant simulation.')
        shutil.copyfile(str(tf), _SIM_DATA.JSPEC_ELEGANT_TWISS_FILENAME)
        elegant_twiss_file = _SIM_DATA.JSPEC_ELEGANT_TWISS_FILENAME
    sdds_util.twiss_to_madx(elegant_twiss_file, template.JSPEC_TWISS_FILENAME)
    return template.JSPEC_TWISS_FILENAME