Пример #1
0
def _generate_twiss_simulation(data, v):
    max_id = elegant_lattice_importer.max_id(data)
    sim = data['models']['simulation']
    sim['simulationMode'] = 'serial'
    run_setup = _find_first_command(data, 'run_setup') or {
        '_id': max_id + 1,
        '_type': 'run_setup',
        'lattice': 'Lattice',
        'p_central_mev': data['models']['bunch']['p_central_mev'],
    }
    run_setup['use_beamline'] = sim['activeBeamlineId']
    twiss_output = _find_first_command(data, 'twiss_output') or {
        '_id': max_id + 2,
        '_type': 'twiss_output',
        'filename': '1',
    }
    twiss_output['output_at_each_step'] = "0"
    data['models']['commands'] = [
        run_setup,
        twiss_output,
    ]
    filename_map = _build_filename_map(data)
    beamline_map = _build_beamline_map(data)
    v['lattice'] = generate_lattice(data, filename_map, beamline_map, v)
    v['commands'] = _generate_commands(data, filename_map, beamline_map, v)
    return template_common.render_jinja(SIM_TYPE, v)
Пример #2
0
def _generate_twiss_simulation(data, v):
    max_id = elegant_lattice_importer.max_id(data)
    sim = data['models']['simulation']
    sim['simulationMode'] = 'serial'
    run_setup = _find_first_command(data, 'run_setup') or {
        '_id': max_id + 1,
        '_type': 'run_setup',
        'lattice': 'Lattice',
        'p_central_mev': data['models']['bunch']['p_central_mev'],
    }
    run_setup['use_beamline'] = sim['activeBeamlineId']
    twiss_output = _find_first_command(data, 'twiss_output') or {
        '_id': max_id + 2,
        '_type': 'twiss_output',
        'filename': '1',
    }
    twiss_output['final_values_only'] = '0'
    twiss_output['output_at_each_step'] = '0'
    data['models']['commands'] = [
        run_setup,
        twiss_output,
    ]
    filename_map = _build_filename_map(data)
    beamline_map = _build_beamline_map(data)
    v['lattice'] = generate_lattice(data, filename_map, beamline_map, v)
    v['commands'] = _generate_commands(data, filename_map, beamline_map, v)
    return template_common.render_jinja(SIM_TYPE, v)
Пример #3
0
def _create_default_commands(data):
    max_id = elegant_lattice_importer.max_id(data)
    simulation = data['models']['simulation']
    bunch = data['models']['bunch']
    return [
        _create_command('command_run_setup', {
            "_id": max_id + 1,
            "_type": "run_setup",
            "centroid": "1",
            "concat_order": 2,
            "lattice": "Lattice",
            "output": "1",
            "p_central_mev": bunch['p_central_mev'],
            "parameters": "1",
            "print_statistics": 1,
            "sigma": "1",
            "use_beamline": simulation['visualizationBeamlineId'] if 'visualizationBeamlineId' in simulation else '',
        }),
        _create_command('command_run_control', {
            "_id": max_id + 2,
            "_type": "run_control",
        }),
        _create_command('command_twiss_output', {
            "_id": max_id + 3,
            "_type": "twiss_output",
            "alpha_x": bunch['alpha_x'],
            "alpha_y": bunch['alpha_y'],
            "beta_x": bunch['beta_x'],
            "beta_y": bunch['beta_y'],
            "filename": "1",
            "matched": "0",
            "output_at_each_step": "1",
            "statistics": 1
        }),
        _create_command('command_bunched_beam', {
            "_id": max_id + 4,
            "_type": "bunched_beam",
            "alpha_x": bunch['alpha_x'],
            "alpha_y": bunch['alpha_y'],
            "alpha_z": bunch['alpha_z'],
            "beta_x": bunch['beta_x'],
            "beta_y": bunch['beta_y'],
            "beta_z": bunch['beta_z'],
            "distribution_cutoff": '3, 3, 3',
            "enforce_rms_values": '1, 1, 1',
            "emit_x": bunch['emit_x'] / 1e09,
            "emit_y": bunch['emit_y'] / 1e09,
            "emit_z": bunch['emit_z'],
            "n_particles_per_bunch": bunch['n_particles_per_bunch'],
            "one_random_bunch": '0',
            "sigma_dp": bunch['sigma_dp'],
            "sigma_s": bunch['sigma_s'] / 1e06,
            "symmetrize": 1,
        }),
        _create_command('command_track', {
            "_id": max_id + 5,
            "_type": "track",
        }),
    ]
Пример #4
0
def _create_default_commands(data):
    max_id = elegant_lattice_importer.max_id(data)
    simulation = data['models']['simulation']
    bunch = data['models']['bunch']
    return [
        _create_command('command_run_setup', {
            "_id": max_id + 1,
            "_type": "run_setup",
            "centroid": "1",
            "concat_order": 2,
            "lattice": "Lattice",
            "output": "1",
            "p_central_mev": bunch['p_central_mev'],
            "parameters": "1",
            "print_statistics": "1",
            "sigma": "1",
            "use_beamline": simulation['visualizationBeamlineId'] if 'visualizationBeamlineId' in simulation else '',
        }),
        _create_command('command_run_control', {
            "_id": max_id + 2,
            "_type": "run_control",
        }),
        _create_command('command_twiss_output', {
            "_id": max_id + 3,
            "_type": "twiss_output",
            "filename": "1",
        }),
        _create_command('command_bunched_beam', {
            "_id": max_id + 4,
            "_type": "bunched_beam",
            "alpha_x": bunch['alpha_x'],
            "alpha_y": bunch['alpha_y'],
            "alpha_z": bunch['alpha_z'],
            "beta_x": bunch['beta_x'],
            "beta_y": bunch['beta_y'],
            "beta_z": bunch['beta_z'],
            "distribution_cutoff": '3, 3, 3',
            "enforce_rms_values": '1, 1, 1',
            "emit_x": bunch['emit_x'] / 1e09,
            "emit_y": bunch['emit_y'] / 1e09,
            "emit_z": bunch['emit_z'],
            "n_particles_per_bunch": bunch['n_particles_per_bunch'],
            "one_random_bunch": '0',
            "sigma_dp": bunch['sigma_dp'],
            "sigma_s": bunch['sigma_s'] / 1e06,
            "symmetrize": '1',
            "Po": 0.0,
        }),
        _create_command('command_track', {
            "_id": max_id + 5,
            "_type": "track",
        }),
    ]
Пример #5
0
def _create_default_commands(data):
    max_id = elegant_lattice_importer.max_id(data)
    simulation = data["models"]["simulation"]
    bunch = data["models"]["bunch"]
    return [
        _create_command(
            "command_run_setup",
            {
                "_id": max_id + 1,
                "_type": "run_setup",
                "centroid": "1",
                "concat_order": 2,
                "lattice": "Lattice",
                "output": "1",
                "p_central_mev": bunch["p_central_mev"],
                "parameters": "1",
                "print_statistics": 1,
                "sigma": "1",
                "use_beamline": simulation["visualizationBeamlineId"]
                if "visualizationBeamlineId" in simulation
                else "",
            },
        ),
        _create_command("command_run_control", {"_id": max_id + 2, "_type": "run_control"}),
        _create_command(
            "command_twiss_output",
            {
                "_id": max_id + 3,
                "_type": "twiss_output",
                "alpha_x": bunch["alpha_x"],
                "alpha_y": bunch["alpha_y"],
                "beta_x": bunch["beta_x"],
                "beta_y": bunch["beta_y"],
                "filename": "1",
                "matched": "0",
                "output_at_each_step": "1",
                "statistics": 1,
            },
        ),
        _create_command(
            "command_bunched_beam",
            {
                "_id": max_id + 4,
                "_type": "bunched_beam",
                "alpha_x": bunch["alpha_x"],
                "alpha_y": bunch["alpha_y"],
                "alpha_z": bunch["alpha_z"],
                "beta_x": bunch["beta_x"],
                "beta_y": bunch["beta_y"],
                "beta_z": bunch["beta_z"],
                "distribution_cutoff": "3, 3, 3",
                "enforce_rms_values": "1, 1, 1",
                "emit_x": bunch["emit_x"] / 1e09,
                "emit_y": bunch["emit_y"] / 1e09,
                "emit_z": bunch["emit_z"],
                "n_particles_per_bunch": bunch["n_particles_per_bunch"],
                "one_random_bunch": "0",
                "sigma_dp": bunch["sigma_dp"],
                "sigma_s": bunch["sigma_s"] / 1e06,
                "symmetrize": 1,
            },
        ),
        _create_command("command_track", {"_id": max_id + 5, "_type": "track"}),
    ]