def _generate_parameters_file(data): v = None template_common.validate_models(data, _SCHEMA) v = template_common.flatten_data(data['models'], {}) v['particlePeriod'] = _PARTICLE_PERIOD v['particleFile'] = _PARTICLE_FILE v['densityFile'] = _DENSITY_FILE v['egunCurrentFile'] = _EGUN_CURRENT_FILE v['conductors'] = _prepare_conductors(data) v['maxConductorVoltage'] = _max_conductor_voltage(data) v['is3D'] = _is_3D(data) if not v['is3D']: v['simulationGrid_num_y'] = v['simulationGrid_num_x'] v['simulationGrid_channel_height'] = v['simulationGrid_channel_width'] if 'report' not in data: data['report'] = 'animation' v['isOptimize'] = data['report'] == 'optimizerAnimation' if v['isOptimize']: _replace_optimize_variables(data, v) res = _render_jinja('base', v) if data['report'] == 'animation': if data['models']['simulation']['egun_mode'] == '1': v['egunStatusFile'] = _EGUN_STATUS_FILE res += _render_jinja('egun', v) else: res += _render_jinja('visualization', v) res += _render_jinja('impact-density', v) elif data['report'] == 'optimizerAnimation': res += _render_jinja('parameters-optimize', v) else: res += _render_jinja('source-field', v) return res, v
def _generate_parameters_file(data, run_dir=None, is_parallel=False): v = None template_common.validate_models(data, _SCHEMA) v = template_common.flatten_data(data['models'], {}) v['outputDir'] = '"{}"'.format(run_dir) if run_dir else None v['particlePeriod'] = _PARTICLE_PERIOD v['particleFile'] = _PARTICLE_FILE v['impactDensityCalculation'] = _generate_impact_density() v['egunCurrentFile'] = _EGUN_CURRENT_FILE v['conductorLatticeAndParticleScraper'] = _generate_lattice(data) v['maxConductorVoltage'] = _max_conductor_voltage(data) v['is3D'] = data.models.simulationGrid.simulation_mode == '3d' if not v['is3D']: v['simulationGrid_num_y'] = v['simulationGrid_num_x'] v['simulationGrid_channel_height'] = v['simulationGrid_channel_width'] template_name = '' if 'report' not in data: template_name = 'visualization' elif data['report'] == 'animation': if data['models']['simulation']['egun_mode'] == '1': v['egunStatusFile'] = _EGUN_STATUS_FILE template_name = 'egun' else: template_name = 'visualization' else: template_name = 'source-field' return template_common.render_jinja(SIM_TYPE, v, 'base.py') \ + template_common.render_jinja(SIM_TYPE, v, '{}.py'.format(template_name))
def _validate_data(data, schema): template_common.validate_models(data, schema) if data.models.simulation.sourceType == 'undulator': und = data.models.undulator if und.select_energy == 'single': und.emin = und.photon_energy und.emax = und.photon_energy if und.emin == und.emax: und.ng_e = 1
def _generate_parameters_file(data, run_dir=None, is_parallel=False): template_common.validate_models(data, _SCHEMA) v = template_common.flatten_data(data['models'], {}) v['optionsCommand'] = _generate_options(data['models']) v['solenoidCommand'] = _generate_solenoid(data['models']) v['beamCommand'] = _generate_beam(data['models']) v['currentCommand'] = _generate_current(data['models']) v['chargeCommand'] = _generate_charge(data['models']) if is_parallel: v['latticeCommands'] = _generate_lattice(data['models']) else: v['latticeCommands'] = _DEFAULT_DRIFT_ELEMENT return template_common.render_jinja(SIM_TYPE, v)
def generate_parameters_file(data, is_parallel=False): template_common.validate_models(data, _SCHEMA) res, v = template_common.generate_parameters_file(data) v['isAnimationView'] = is_parallel v['incSteps'] = 50 v['diagnosticPeriod'] = 50 if data['models']['simulation']['sourceType'] == 'electronBeam': v['useBeam'] = 1 v['useLaser'] = 0 else: v['useBeam'] = 0 v['useLaser'] = 1 if data['models']['electronBeam']['beamRadiusMethod'] == 'a': v['electronBeam_transverseEmittance'] = 0 return res + template_common.render_jinja(SIM_TYPE, v)
def _generate_parameters_file(data): report = data['report'] if 'report' in data else None template_common.validate_models(data, simulation_db.get_schema(SIM_TYPE)) v = template_common.flatten_data(data['models'], {}) v['beamEvolutionOutputFilename'] = _BEAM_EVOLUTION_OUTPUT_FILENAME v['runSimulation'] = report is None or report == 'animation' v['runRateCalculation'] = report is None or report == 'rateCalculationReport' if data['models']['ring']['latticeSource'] == 'madx': v['latticeFilename'] = template_common.lib_file_name('ring', 'lattice', v['ring_lattice']) else: v['latticeFilename'] = JSPEC_TWISS_FILENAME if v['ionBeam_beam_type'] == 'continuous': v['ionBeam_rms_bunch_length'] = 0 v['simulationSettings_ibs'] = 'on' if v['simulationSettings_ibs'] == '1' else 'off' v['simulationSettings_e_cool'] = 'on' if v['simulationSettings_e_cool'] == '1' else 'off' return template_common.render_jinja(SIM_TYPE, v)
def generate_parameters_file(data, run_dir=None, is_parallel=False): template_common.validate_models(data, _SCHEMA) v = template_common.flatten_data(data['models'], {}) v['outputDir'] = '"{}"'.format(run_dir) if run_dir else None v['isAnimationView'] = is_parallel v['incSteps'] = 50 v['diagnosticPeriod'] = 50 if data['models']['simulation']['sourceType'] == 'electronBeam': v['useBeam'] = 1 v['useLaser'] = 0 else: v['useBeam'] = 0 v['useLaser'] = 1 if data['models']['electronBeam']['beamRadiusMethod'] == 'a': v['electronBeam_transverseEmittance'] = 0 return template_common.render_jinja(SIM_TYPE, v)
def _generate_parameters_file(data): v = None template_common.validate_models(data, _SCHEMA) res, v = template_common.generate_parameters_file(data) v['particlePeriod'] = _PARTICLE_PERIOD v['particleFile'] = _PARTICLE_FILE v['potentialFile'] = _POTENTIAL_FILE v['stepSize'] = COMPARISON_STEP_SIZE v['densityFile'] = _DENSITY_FILE v['egunCurrentFile'] = _EGUN_CURRENT_FILE v['estimateFile'] = _FIELD_ESTIMATE_FILE v['conductors'] = _prepare_conductors(data) v['maxConductorVoltage'] = _max_conductor_voltage(data) v['is3D'] = _SIM_DATA.warpvnd_is_3d(data) v['anode'] = _prepare_anode(data) v['saveIntercept'] = v['anode']['isReflector'] for c in data.models.conductors: if c.conductor_type.type == 'stl': # if any conductor is STL then don't save the intercept v['saveIntercept'] = False v['polyFile'] = _SIM_DATA.lib_file_abspath( _stl_polygon_file(c.conductor_type.name), ) break if c.conductor_type.isReflector: v['saveIntercept'] = True if not v['is3D']: v['simulationGrid_num_y'] = v['simulationGrid_num_x'] v['simulationGrid_channel_height'] = v['simulationGrid_channel_width'] if 'report' not in data: data['report'] = 'animation' v['isOptimize'] = data['report'] == 'optimizerAnimation' if v['isOptimize']: _replace_optimize_variables(data, v) res = _render_jinja('base', v) if data['report'] == 'animation': if data['models']['simulation']['egun_mode'] == '1': v['egunStatusFile'] = _EGUN_STATUS_FILE res += _render_jinja('egun', v) else: res += _render_jinja('visualization', v) res += _render_jinja('impact-density', v) elif data['report'] == 'optimizerAnimation': res += _render_jinja('parameters-optimize', v) else: res += _render_jinja('source-field', v) return res, v
def _validate_data(data, schema): # ensure enums match, convert ints/floats, apply scaling enum_info = template_common.validate_models(data, schema) _correct_halo_gaussian_distribution_type(data['models']['bunch']) for model_type in ['elements', 'commands']: for m in data['models'][model_type]: template_common.validate_model(m, schema['model'][_model_name_for_data(m)], enum_info) _correct_halo_gaussian_distribution_type(m)
def _validate_data(data, schema): # ensure enums match, convert ints/floats, apply scaling enum_info = template_common.validate_models(data, schema) for m in data.models.elements: template_common.validate_model( m, schema.model[LatticeUtil.model_name_for_data(m)], enum_info)
def _validate_data(data, schema): # ensure enums match, convert ints/floats, apply scaling enum_info = template_common.validate_models(data, schema) _correct_halo_gaussian_distribution_type(data['models']['bunch']) for model_type in ['elements', 'commands']: for m in data['models'][model_type]: template_common.validate_model( m, schema['model'][_model_name_for_data(m)], enum_info) _correct_halo_gaussian_distribution_type(m)
def _generate_parameters_file(data): report = data.report if 'report' in data else None _set_mass_and_charge(data.models.ionBeam) template_common.validate_models(data, simulation_db.get_schema(SIM_TYPE)) v = template_common.flatten_data(data.models, PKDict()) v.beamEvolutionOutputFilename = _BEAM_EVOLUTION_OUTPUT_FILENAME v.runSimulation = report is None or report == 'animation' v.runRateCalculation = report is None or report == 'rateCalculationReport' if data.models.ring.latticeSource == 'madx': v.latticeFilename = _SIM_DATA.lib_file_name_with_model_field( 'ring', 'lattice', v.ring_lattice) else: v.latticeFilename = JSPEC_TWISS_FILENAME if v.ionBeam_beam_type == 'continuous': v.ionBeam_rms_bunch_length = 0 v.simulationSettings_ibs = 'on' if v.simulationSettings_ibs == '1' else 'off' v.simulationSettings_e_cool = 'on' if v.simulationSettings_e_cool == '1' else 'off' return template_common.render_jinja(SIM_TYPE, v)
def _generate_parameters_file(data, run_dir=None, is_parallel=False): v = None template_common.validate_models(data, simulation_db.get_schema(SIM_TYPE)) v = template_common.flatten_data(data['models'], {}) v['outputDir'] = '"{}"'.format(run_dir) if run_dir else None v['particlePeriod'] = _PARTICLE_PERIOD v['particleFile'] = _PARTICLE_FILE v['impactDensityCalculation'] = _generate_impact_density() v['egunCurrentFile'] = _EGUN_CURRENT_FILE v['conductorLatticeAndParticleScraper'] = _generate_lattice(data) template_name = '' if 'report' not in data: template_name = 'visualization' elif data['report'] == 'animation': if data['models']['simulation']['egun_mode'] == '1': v['egunStatusFile'] = _EGUN_STATUS_FILE template_name = 'egun' else: template_name = 'visualization' else: template_name = 'source-field' return template_common.render_jinja(SIM_TYPE, v, 'base.py') \ + template_common.render_jinja(SIM_TYPE, v, '{}.py'.format(template_name))
def _validate_data(self): def _fix(m): """the halo(gaussian) value will get validated/escaped to halogaussian, change it back""" if 'distribution_type' in m and 'halogaussian' in m.distribution_type: m.distribution_type = m.distribution_type.replace( 'halogaussian', 'halo(gaussian)') enum_info = template_common.validate_models(self.data, _SCHEMA) _fix(self.data.models.bunch) for t in ['elements', 'commands']: for m in self.data.models[t]: template_common.validate_model( m, _SCHEMA.model[LatticeUtil.model_name_for_data(m)], enum_info, ) _fix(m)
def _validate_data(data, schema): # ensure enums match, convert ints/floats, apply scaling enum_info = template_common.validate_models(data, schema) for m in data['models']['elements']: template_common.validate_model( m, schema['model'][_model_name_for_data(m)], enum_info)
def _validate_data(data, schema): template_common.validate_models(data, schema)
def _validate_data(data, schema): # ensure enums match, convert ints/floats, apply scaling enum_info = template_common.validate_models(data, schema) for m in data['models']['elements']: template_common.validate_model(m, schema['model'][_model_name_for_data(m)], enum_info)