Skip to content

Commit

Permalink
Fix #6004: change laser pulse units (#6016)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurhar1133 authored Jun 28, 2023
1 parent 13dd90e commit f45e00d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
16 changes: 7 additions & 9 deletions sirepo/package_data/static/json/silas-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@
"ccd": ["Intensity", "InputFile", ""],
"meta": ["WFS Space Data", "InputFile", "", "A file describing the pixel dimensions of your wavefront sensor. Pixel dimensions are assumed to be in microns."],
"wfs": ["Phase", "InputFile", ""],
"num_sig_long": ["Number of Gaussian Sigmas", "Integer", 3],
"num_sig_trans": ["Number of Gaussian Sigmas", "Integer", 6],
"num_sig_long": ["Longitudinal RMS (in terms of beam size)", "Integer", 6],
"num_sig_trans": ["Transverse RMS (in terms of beam size)", "Integer", 12],
"nx_slice": ["Horizontal Number of Mesh Points in Slice", "Integer", 64, "", 1],
"ny_slice": ["Vertical Number of Mesh Points in Slice", "Integer", 64, "", 1],
"nslice": ["Number of Slices", "Integer", 3, "", 1],
"nslice": ["Number of Slices", "Integer", 5, "", 1],
"photon_e_ev": ["Photon energy [eV]", "Float", 1.5],
"poltype": ["Polarization", "GaussianBeamPolarization", "1"],
"tau_fwhm": ["FWHM Length [s]", "Float", 2.35865e-11],
"tau_0": ["Fourier-limited pulse length of a given spectral bandwidth", "Float", 2.35865e-11],
"tau_fwhm": ["FWHM Length [ps]", "Float", 23.5865],
"tau_0": ["Fourier-limited pulse length of a given spectral bandwidth [ps]", "Float", 23.5865],
"pulseE": ["Total Laser Pulse Energy [J]", "Float", 0.001],
"distribution": ["Distribution Type", "DistributionType", "gaussian"],
"sigx_waist": ["Horizontal RMS Waist Size [m]", "Float", 0.001],
"sigy_waist": ["Vertical RMS Waist Size [m]", "Float", 0.001],
"sigx_waist": ["Horizontal Beam Size [m]", "Float", 0.001],
"sigy_waist": ["Vertical Beam Size [m]", "Float", 0.001],
"phase_flatten_cutoff": ["Phase Flatten Cutoff", "Float", 0.85]
},
"laserPulseAnimation": {
Expand Down Expand Up @@ -298,8 +298,6 @@
]],
["Transverse", [
"num_sig_trans",
"distribution",
"poltype",
"ccd",
"wfs",
"meta",
Expand Down
11 changes: 11 additions & 0 deletions sirepo/sim_data/silas.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def fixup_old_data(cls, data, qcall, **kwargs):
if "n2" in m:
del m["n2"]
cls.update_model_defaults(m, m.type)
cls.__fixup_laser_pulse(dm.laserPulse)

@classmethod
def _compute_model(cls, analysis_model, *args, **kwargs):
Expand All @@ -69,6 +70,16 @@ def _compute_model(cls, analysis_model, *args, **kwargs):
def _compute_job_fields(cls, data, r, compute_model):
return []

@classmethod
def __fixup_laser_pulse(cls, laser_pulse):
# adjust laser pulse to new units
if laser_pulse.tau_fwhm < 1e-6 or laser_pulse.tau_0 < 1e-6:
laser_pulse.num_sig_long *= 2
laser_pulse.num_sig_trans *= 2
for f in ("tau_fwhm", "tau_0"):
if laser_pulse[f] < 1e-6:
laser_pulse[f] = round(laser_pulse[f] * 1e12, 6)

@classmethod
def _lib_file_basenames(cls, data):
res = []
Expand Down
10 changes: 9 additions & 1 deletion sirepo/template/silas.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _generate_parameters_file(data):
return res + template_common.render_jinja(SIM_TYPE, v, "crystal.py")
if data.report in _SIM_DATA.SOURCE_REPORTS:
data.models.beamline = []
v.laserPulse = data.models.laserPulse
v.laserPulse = _convert_laser_pulse_units(data.models.laserPulse)
if data.models.laserPulse.distribution == "file":
for f in ("ccd", "meta", "wfs"):
v[f"{f}File"] = _SIM_DATA.lib_file_name_with_model_field(
Expand Down Expand Up @@ -518,6 +518,14 @@ def _parse_silas_log(run_dir):
return "An unknown error occurred"


def _convert_laser_pulse_units(laserPulse):
laserPulse.tau_0 = laserPulse.tau_0 / 1e12
laserPulse.tau_fwhm = laserPulse.tau_fwhm / 1e12
laserPulse.num_sig_long = laserPulse.num_sig_long / 2
laserPulse.num_sig_trans = laserPulse.num_sig_trans / 2
return laserPulse


def _report_to_file_index(sim_in, report):
if report in _SIM_DATA.SOURCE_REPORTS:
return 0, None
Expand Down

0 comments on commit f45e00d

Please sign in to comment.