From 5939fe4aa4a4ee1585c153f17aa482398703d739 Mon Sep 17 00:00:00 2001 From: git-user Date: Fri, 21 Jul 2023 17:49:42 +0000 Subject: [PATCH] Fix #6143: chirp --- sirepo/package_data/static/js/silas.js | 16 ++++++++++------ sirepo/template/silas.py | 6 +++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sirepo/package_data/static/js/silas.js b/sirepo/package_data/static/js/silas.js index 155107038f..30f4266aa9 100644 --- a/sirepo/package_data/static/js/silas.js +++ b/sirepo/package_data/static/js/silas.js @@ -427,10 +427,13 @@ SIREPO.viewLogic('laserPulseView', function(appState, panelState, requestSender, requestSender.sendStatelessCompute( appState, data => { + srdbg(data); if (data.error) { + $scope.model.chirp = "n/a"; throw new Error(data.error); } - $scope.model.chirp = data.chirp; + // $scope.model.chirp = data.chirp; + appState.models.laserPulse.chirp = data.chirp; srdbg('chirp from server:', data.chirp); srdbg('$scope.model.chirp:', $scope.model.chirp); }, @@ -459,13 +462,14 @@ SIREPO.viewLogic('laserPulseView', function(appState, panelState, requestSender, 'laserPulse.distribution', ], updateEditor, ['laserPulse.nx_slice'], updateMeshPoints, + ['laserPulse.tau_0', 'laserPulse.tau_fwhm'], computeChirp ]; - $scope.$on(['laserPulse.changed'], (e, name) => { - srdbg('name:', name); - srdbg('event:', e); - computeChirp(); - }); + // $scope.$on(['laserPulse.changed'], (e, name) => { + // srdbg('name:', name); + // srdbg('event:', e); + // computeChirp(); + // }); }); SIREPO.viewLogic('crystalCylinderView', function(appState, panelState, silasService, $scope) { diff --git a/sirepo/template/silas.py b/sirepo/template/silas.py index 940ead374e..ca5588cf34 100644 --- a/sirepo/template/silas.py +++ b/sirepo/template/silas.py @@ -129,8 +129,12 @@ def stateful_compute_mesh_dimensions(data, **kwargs): def stateless_compute_calc_chirp(data, **kwargs): from rslaser.pulse import pulse + try: + res = round(pulse.LaserPulse(params=data.model).initial_chirp, 7) + except Exception as e: + return PKDict(error=str(e)) return PKDict( - chirp=round(pulse.LaserPulse(params=data.model).initial_chirp, 7) + chirp=res )