Skip to content

Commit

Permalink
fix #7281 add support for aperture and rfcavity elements (#7357)
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep authored Nov 12, 2024
1 parent 1c9aa3d commit 860fbf5
Show file tree
Hide file tree
Showing 15 changed files with 1,722 additions and 240 deletions.
27 changes: 13 additions & 14 deletions sirepo/package_data/static/js/elegant.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,34 +155,33 @@ SIREPO.app.factory('elegantService', function(appState, commandService, requestS
}

function commandsChanged() {
let cmd = self.findFirstCommand('run_setup');
if (cmd && cmd.use_beamline) {
appState.models.simulation.visualizationBeamlineId = cmd.use_beamline;
const rscmd = self.findFirstCommand('run_setup');
if (rscmd && rscmd.use_beamline) {
appState.models.simulation.visualizationBeamlineId = rscmd.use_beamline;
appState.saveQuietly('simulation');
}

// update bunchSource, bunchFile, bunch models
cmd = self.findFirstCommand(['bunched_beam', 'sdds_beam']);
if (! cmd) {
const bcmd = self.findFirstCommand(['bunched_beam', 'sdds_beam']);
if (! bcmd) {
return;
}
appState.models.bunchSource.inputSource = cmd._type;
appState.models.bunchSource.inputSource = bcmd._type;
appState.saveQuietly('bunchSource');
cmd = self.findFirstCommand('run_setup');
const bunch = appState.models.bunch;
if (cmd) {
if (rpnService.getRpnValue(cmd.p_central_mev) !== 0) {
bunch.p_central_mev = cmd.p_central_mev;
if (rscmd) {
if (rpnService.getRpnValue(rscmd.p_central_mev) !== 0) {
bunch.p_central_mev = rscmd.p_central_mev;
}
else {
bunch.p_central_mev = rpnService.getRpnValue(cmd.p_central) * SIREPO.APP_SCHEMA.constants.ELEGANT_ME_EV;
bunch.p_central_mev = rpnService.getRpnValue(rscmd.p_central) * SIREPO.APP_SCHEMA.constants.ELEGANT_ME_EV;
}
}
if (cmd._type == 'bunched_beam') {
updateBunchFromCommand(bunch, cmd);
if (bcmd._type == 'bunched_beam') {
updateBunchFromCommand(bunch, bcmd);
}
else {
appState.models.bunchFile.sourceFile = cmd.input;
appState.models.bunchFile.sourceFile = bcmd.input;
appState.saveQuietly('bunchFile');
}
// need to update source reports.
Expand Down
2 changes: 1 addition & 1 deletion sirepo/package_data/static/js/sirepo-lattice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ SIREPO.app.directive('lattice', function(appState, latticeService, panelState, p
currentLength = x;
}
var picType = getPicType(item.type);
var length = rpnValue(item.l || item.xmax || 0);
var length = rpnValue(item.l || (item.type == "ALPH" && item.xmax) || 0);
if (picType == 'zeroLength') {
length = 0;
}
Expand Down
46 changes: 3 additions & 43 deletions sirepo/package_data/static/js/sirepo-plotting.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,6 @@ class AbstractPlotShape2D extends AbstractPlotShape {
}
}

class PlotLine extends AbstractPlotShape {
constructor(
id,
name,
line
) {
super(
id,
name,
'line'
);
this.line = line;
}
}

class PlotPolygon extends AbstractPlotShape2D {
constructor(
id,
Expand Down Expand Up @@ -253,32 +238,6 @@ class PlotPolygon extends AbstractPlotShape2D {
}
}

class PlotRect extends AbstractPlotShape2D {
constructor(
id,
name,
center,
size=[1, 1]
) {
super(id, name, 'rect', center);
this.size = {
x: size[0],
y: size[1],
};
this.x = this.center.x + this.size.x / 2;
this.y = this.center.y - this.size.y / 2;
}

getSizeCoords() {
return this.getCoords(this.size);
}

setSize(coords) {
this.setCoords(this.size, coords);
}
}


SIREPO.app.factory('plotting', function(appState, frameCache, panelState, utilities, requestQueue, simulationQueue, $interval, $rootScope, $window) {

var INITIAL_HEIGHT = 400;
Expand Down Expand Up @@ -2657,6 +2616,9 @@ SIREPO.app.directive('plot3d', function(appState, focusPointService, layoutServi
function adjustZoomToCenter(scale) {
// if the domain is almost centered on 0.0 (within 10%) adjust zoom and offset to center
var domain = scale.domain();
if (SIREPO.PLOTTING_SUMMED_LINEOUTS) {
return;
}
if (domain[0] < 0 && domain[1] > 0) {
var width = domain[1] - domain[0];
var diff = (domain[0] + domain[1]) / width;
Expand Down Expand Up @@ -4144,8 +4106,6 @@ SIREPO.app.directive('particle', function(plotting, plot2dService) {

SIREPO.PLOTTING = {
HeatmapSelectCellEvent: 'heatmapSelectCell',
PlotLine: PlotLine,
PlotPolygon: PlotPolygon,
PlotRect: PlotRect,
Utils: PlottingUtils,
};
10 changes: 5 additions & 5 deletions sirepo/package_data/static/json/canvas-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"bunchAnimation": {
"x": ["Horizontal Value to Plot", "PhaseSpaceCoordinate", "x"],
"y": ["Vertical Value to Plot", "PhaseSpaceCoordinate", "px"],
"plotType": ["Plot Type", "PlotType", "heatmap"],
"plotType": ["Plot Type", "PlotType", "3d"],
"histogramBins": ["Histogram Bins", "Integer", 60],
"colorMap": ["Color Map", "ColorMap", "viridis"],
"selectedFrame": ["", "FrameSlider", 0],
Expand All @@ -134,7 +134,7 @@
"simCode": ["", "String", "elegant"],
"x": ["Horizontal Value to Plot", "PhaseSpaceCoordinate", "x"],
"y": ["Vertical Value to Plot", "PhaseSpaceCoordinate", "px"],
"plotType": ["Plot Type", "PlotType", "heatmap"],
"plotType": ["Plot Type", "PlotType", "3d"],
"histogramBins": ["Histogram Bins", "Integer", 60],
"colorMap": ["Color Map", "ColorMap", "viridis"],
"notes": ["Notes", "Text", ""]
Expand All @@ -143,7 +143,7 @@
"simCode": ["", "String", "madx"],
"x": ["Horizontal Value to Plot", "PhaseSpaceCoordinate", "x"],
"y": ["Vertical Value to Plot", "PhaseSpaceCoordinate", "px"],
"plotType": ["Plot Type", "PlotType", "heatmap"],
"plotType": ["Plot Type", "PlotType", "3d"],
"histogramBins": ["Histogram Bins", "Integer", 60],
"colorMap": ["Color Map", "ColorMap", "viridis"],
"notes": ["Notes", "Text", ""]
Expand All @@ -152,7 +152,7 @@
"simCode": ["", "String", "impactx"],
"x": ["Horizontal Value to Plot", "PhaseSpaceCoordinate", "x"],
"y": ["Vertical Value to Plot", "PhaseSpaceCoordinate", "px"],
"plotType": ["Plot Type", "PlotType", "heatmap"],
"plotType": ["Plot Type", "PlotType", "3d"],
"histogramBins": ["Histogram Bins", "Integer", 60],
"colorMap": ["Color Map", "ColorMap", "viridis"],
"notes": ["Notes", "Text", ""]
Expand Down Expand Up @@ -245,7 +245,7 @@
"_super": ["", "model", "_ELEMENT"],
"volt": ["Voltage [V]", "RPNValue", 0],
"freq": ["Frequency [Hz]", "RPNValue", 0],
"phase": ["Phase [rad]", "RPNValue", 0]
"phase": ["Phase [deg]", "RPNValue", 0, "RF synchronous phase (phase = 0 corresponds to maximum energy gain, phase = -90 corresponds to zero energy gain for bunching)"]
},
"SBEND": {
"_super": ["", "model", "_ELEMENT"],
Expand Down
2 changes: 1 addition & 1 deletion sirepo/package_data/static/json/impactx-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
"_super": ["_", "model", "_ELEMENT_WITH_ERROR"],
"V": ["V","RPNValue",null,"Normalized RF voltage V = maximum energy gain/(m*c²)"],
"freq": ["FREQ","RPNValue",null,"RF frequency in Hz"],
"phase": ["PHASE [deg]","RPNValue",-90.0,"RF synchronous phase (phase = 0 corresponds to maximum energy gain, phase = -90 corresponds go zero energy gain for bunching)"]
"phase": ["PHASE [deg]","RPNValue",-90.0,"RF synchronous phase (phase = 0 corresponds to maximum energy gain, phase = -90 corresponds to zero energy gain for bunching)"]
},
"SOFTQUADRUPOLE": {
"_super": ["_", "model", "_ELEMENT_WITH_LENGTH_AND_ERROR"],
Expand Down
64 changes: 20 additions & 44 deletions sirepo/package_data/template/canvas/examples/bessy-ii.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"angle": 6.283185307179586,
"count": 49,
"count": 56,
"distance": 7.385346623550245e-15,
"id": 111,
"items": [
Expand All @@ -45,10 +45,11 @@
},
{
"angle": 0.7853981633974483,
"count": 6,
"count": 7,
"distance": 11.642938286447297,
"id": 109,
"items": [
112,
103,
103,
105,
Expand All @@ -69,18 +70,12 @@
}
],
"bunchAnimation1": {
"histogramBins": 80,
"notes": "",
"simCode": "elegant"
},
"bunchAnimation2": {
"histogramBins": 80,
"notes": "",
"simCode": "madx"
},
"bunchAnimation3": {
"histogramBins": 80,
"notes": "",
"simCode": "impactx"
},
"bunchReport1": {
Expand Down Expand Up @@ -132,7 +127,7 @@
"muypy": -0.6715875410129232,
"normalize": 0,
"normalize_halo": 0,
"particleCount": 10000,
"particleCount": 5000,
"species": "electron"
},
"elements": [
Expand Down Expand Up @@ -176,6 +171,16 @@
"psi": 0,
"type": "DRIFT"
},
{
"_id": 112,
"_super": "_ELEMENT",
"dx": 0,
"dy": 0,
"l": 0,
"name": "M1",
"psi": 0,
"type": "MONITOR"
},
{
"_id": 105,
"_super": "_ELEMENT",
Expand Down Expand Up @@ -231,22 +236,10 @@
}
],
"rpnVariables": [
{
"name": "pi",
"value": 3.141592653589793
},
{
"name": "ncell",
"value": 8
},
{
"name": "bendangle",
"value": "pi/ncell"
},
{
"name": "lbend",
"value": 2.6193
},
{
"name": "bendradius",
"value": "ncell*lbend/pi"
Expand All @@ -268,40 +261,23 @@
"value": 2.1082
},
{
"name": "lquad",
"value": 0.3
},
{
"name": "twopi",
"value": "pi * 2"
"name": "lbend",
"value": 2.6193
},
{
"name": "raddeg",
"value": "pi / 180"
"name": "lquad",
"value": 0.3
},
{
"name": "degrad",
"value": "180 / pi"
"name": "ncell",
"value": 8
}
],
"sigmaAnimation": {
"includeLattice": "1",
"notes": ""
},
"simulation": {
"activeBeamlineId": 111,
"folder": "/Examples",
"name": "BESSY-II-Booster",
"visualizationBeamlineId": 111
},
"simulationSettings": {
"useElegant": "1",
"useImpactX": "1",
"useMadx": "1"
},
"twissAnimation": {
"includeLattice": "1",
"notes": ""
}
},
"simulationType": "canvas"
Expand Down
22 changes: 0 additions & 22 deletions sirepo/package_data/template/canvas/examples/fodo-cell.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@
}
],
"bunchAnimation1": {
"histogramBins": 80,
"notes": "",
"simCode": "elegant"
},
"bunchAnimation2": {
"histogramBins": 80,
"notes": "",
"simCode": "madx"
},
"bunchAnimation3": {
"histogramBins": 80,
"notes": "",
"simCode": "impactx"
},
"bunchReport1": {
Expand Down Expand Up @@ -123,28 +117,12 @@
"type": "QUADRUPOLE"
}
],
"panelState": {
"hidden": []
},
"rpnVariables": [],
"sigmaAnimation": {
"includeLattice": "1",
"notes": ""
},
"simulation": {
"activeBeamlineId": 2,
"folder": "/Examples",
"name": "FODO Cell",
"visualizationBeamlineId": 2
},
"simulationSettings": {
"useElegant": "1",
"useImpactX": "1",
"useMadx": "1"
},
"twissAnimation": {
"includeLattice": "1",
"notes": ""
}
},
"simulationType": "canvas"
Expand Down
Loading

0 comments on commit 860fbf5

Please sign in to comment.