예제 #1
0
def _generate_parameters_file(data, run_dir=None, is_parallel=False):
    _validate_data(data, simulation_db.get_schema(SIM_TYPE))
    _convert_meters_to_centimeters(data['models'])
    _convert_meters_to_centimeters(data['models']['beamline'])
    v = template_common.flatten_data(data['models'], {})
    r = data['report']
    report_model = data['models'][r]
    beamline = data['models']['beamline']
    v['shadowOutputFile'] = _SHADOW_OUTPUT_FILE

    if r == 'initialIntensityReport':
        v['distanceFromSource'] = beamline[0]['position'] if len(
            beamline) else template_common.DEFAULT_INTENSITY_DISTANCE
    elif template_common.is_watchpoint(r):
        v['beamlineOptics'] = _generate_beamline_optics(
            data['models'], template_common.watchpoint_id(r))
    else:
        v['distanceFromSource'] = report_model['distanceFromSource']

    if v['simulation_sourceType'] == 'bendingMagnet':
        v['bendingMagnetSettings'] = _generate_bending_magnet(data)
    elif v['simulation_sourceType'] == 'geometricSource':
        v['geometricSourceSettings'] = _generate_geometric_source(data)
    elif v['simulation_sourceType'] == 'wiggler':
        v['wigglerSettings'] = _generate_wiggler(data)
        v['wigglerTrajectoryFilename'] = _WIGGLER_TRAJECTOR_FILENAME
        v['wigglerTrajectoryInput'] = ''
        if data['models']['wiggler']['b_from'] in ('1', '2'):
            v['wigglerTrajectoryInput'] = _wiggler_file(
                data['models']['wiggler']['trajFile'])
    return template_common.render_jinja(SIM_TYPE, v)
예제 #2
0
파일: shadow.py 프로젝트: e-carlin/sirepo
def _generate_parameters_file(data, run_dir=None, is_parallel=False):
    _validate_data(data, simulation_db.get_schema(SIM_TYPE))
    _convert_meters_to_centimeters(data['models'])
    _convert_meters_to_centimeters(data['models']['beamline'])
    v = template_common.flatten_data(data['models'], {})
    r = data['report']
    report_model = data['models'][r]
    beamline = data['models']['beamline']
    v['shadowOutputFile'] = _SHADOW_OUTPUT_FILE

    if r == 'initialIntensityReport':
        v['distanceFromSource'] = beamline[0]['position'] if len(beamline) else template_common.DEFAULT_INTENSITY_DISTANCE
    elif template_common.is_watchpoint(r):
        v['beamlineOptics'] = _generate_beamline_optics(data['models'], template_common.watchpoint_id(r))
    else:
        v['distanceFromSource'] = report_model['distanceFromSource']

    if v['simulation_sourceType'] == 'bendingMagnet':
        v['bendingMagnetSettings'] = _generate_bending_magnet(data)
    elif v['simulation_sourceType'] == 'geometricSource':
        v['geometricSourceSettings'] = _generate_geometric_source(data)
    elif v['simulation_sourceType'] == 'wiggler':
        v['wigglerSettings'] = _generate_wiggler(data)
        v['wigglerTrajectoryFilename'] = _WIGGLER_TRAJECTOR_FILENAME
        v['wigglerTrajectoryInput'] = ''
        if data['models']['wiggler']['b_from'] in ('1', '2'):
            v['wigglerTrajectoryInput'] = _wiggler_file(data['models']['wiggler']['trajFile'])
    return template_common.render_jinja(SIM_TYPE, v)
예제 #3
0
def models_related_to_report(data):
    """What models are required for this data['report']

    Args:
        data (dict): simulation
    Returns:
        list: Named models, model fields or values (dict, list) that affect report
    """
    r = data['report']
    res = template_common.report_fields(data, r, _REPORT_STYLE_FIELDS) + [
        'bendingMagnet',
        'electronBeam',
        'geometricSource',
        'rayFilter',
        'simulation.istar1',
        'simulation.npoint',
        'simulation.sourceType',
        'sourceDivergence',
        'wiggler',
    ]
    if r == 'initialIntensityReport' and len(data['models']['beamline']):
        res.append([data['models']['beamline'][0]['position']])
    #TODO(pjm): only include items up to the current watchpoint
    if template_common.is_watchpoint(r):
        res.append('beamline')
    for f in template_common.lib_files(data):
        res.append(f.mtime())
    return res
예제 #4
0
파일: shadow.py 프로젝트: e-carlin/sirepo
def models_related_to_report(data):
    """What models are required for this data['report']

    Args:
        data (dict): simulation
    Returns:
        list: Named models, model fields or values (dict, list) that affect report
    """
    r = data['report']
    res = template_common.report_fields(data, r, _REPORT_STYLE_FIELDS) + [
        'bendingMagnet',
        'electronBeam',
        'geometricSource',
        'rayFilter',
        'simulation.istar1',
        'simulation.npoint',
        'simulation.sourceType',
        'sourceDivergence',
        'wiggler',
    ]
    if r == 'initialIntensityReport' and len(data['models']['beamline']):
        res.append([data['models']['beamline'][0]['position']])
    #TODO(pjm): only include items up to the current watchpoint
    if template_common.is_watchpoint(r):
        res.append('beamline')
    for f in template_common.lib_files(data):
        res.append(f.mtime())
    return res
예제 #5
0
파일: shadow.py 프로젝트: njsmith/sirepo
def fixup_old_data(data):
    if (float(data.fixup_old_version) < 20170703.000001
            and 'geometricSource' in data.models):
        g = data.models.geometricSource
        x = g.cone_max
        g.cone_max = g.cone_min
        g.cone_min = x
    if 'verticalOffset' not in data.models.initialIntensityReport:
        for name in data['models']:
            if name == 'initialIntensityReport' or name == 'plotXYReport' or template_common.is_watchpoint(
                    name):
                m = data.models[name]
                m.overrideSize = '0'
                m.horizontalSize = m.verticalSize = 10
                m.horizontalOffset = m.verticalOffset = 0
예제 #6
0
파일: shadow.py 프로젝트: e-carlin/sirepo
def fixup_old_data(data):
    if (
        float(data.fixup_old_version) < 20170703.000001
        and 'geometricSource' in data.models
    ):
        g = data.models.geometricSource
        x = g.cone_max
        g.cone_max = g.cone_min
        g.cone_min = x
    if 'verticalOffset' not in data.models.initialIntensityReport:
        for name in data['models']:
            if name == 'initialIntensityReport' or name == 'plotXYReport' or template_common.is_watchpoint(name):
                m = data.models[name]
                m.overrideSize = '0'
                m.horizontalSize = m.verticalSize = 10
                m.horizontalOffset = m.verticalOffset = 0
예제 #7
0
def _generate_parameters_file(data, run_dir=None, is_parallel=False):
    _validate_data(data, simulation_db.get_schema(SIM_TYPE))
    _convert_meters_to_centimeters(data['models'])
    _convert_meters_to_centimeters(data['models']['beamline'])
    v = template_common.flatten_data(data['models'], {})
    r = data['report']
    report_model = data['models'][r]
    beamline = data['models']['beamline']

    if r == 'initialIntensityReport':
        v['distanceFromSource'] = beamline[0]['position'] if len(
            beamline) else template_common.DEFAULT_INTENSITY_DISTANCE
    elif template_common.is_watchpoint(r):
        v['beamlineOptics'] = _generate_beamline_optics(
            data['models'], template_common.watchpoint_id(r))
    else:
        v['distanceFromSource'] = report_model['distanceFromSource']
    return pkjinja.render_resource('shadow.py', v)
예제 #8
0
def fixup_old_data(data):
    if (float(data.fixup_old_version) < 20170703.000001
            and 'geometricSource' in data.models):
        g = data.models.geometricSource
        x = g.cone_max
        g.cone_max = g.cone_min
        g.cone_min = x
    for m in [
            'initialIntensityReport',
            'plotXYReport',
    ]:
        if m not in data.models:
            data.models[m] = pkcollections.Dict({})
        template_common.update_model_defaults(data.models[m], m, _SCHEMA)
    for m in data.models:
        if template_common.is_watchpoint(m):
            template_common.update_model_defaults(data.models[m],
                                                  'watchpointReport', _SCHEMA)
    template_common.organize_example(data)
예제 #9
0
def models_related_to_report(data):
    """What models are required for this data['report']

    Args:
        data (dict): simulation
    Returns:
        list: Named models, model fields or values (dict, list) that affect report
    """
    r = data['report']
    res = [
        r,
        'bendingMagnet',
        'rayFilter',
    ]
    if r == 'initialIntensityReport' and len(data['models']['beamline']):
        res.append([data['models']['beamline'][0]['position']])
    #TODO(pjm): only include items up to the current watchpoint
    if template_common.is_watchpoint(r):
        res.append('beamline')
    return res