Skip to content

Commit

Permalink
fixed twiss calculation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan committed Feb 23, 2023
1 parent 5c010fa commit a0d1ccc
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ParticlePhaseSpace/_ParticlePhaseSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def print_twiss_parameters(self, file_name=None, beam_direction: str = 'z'): #
:type beam_direction: str, optional
"""
for particle in self._unique_particles:
if not self.twiss_parameters[particle_cfg.particle_properties[particle]['name']]:
if not self.twiss_parameters:
self.calculate_twiss_parameters(beam_direction=beam_direction)
if file_name:
file_name = Path(file_name)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@
{
"data": {
"text/plain": [
"<ParticlePhaseSpace.DataExporters.CSV_Exporter at 0x7f2db2c6e760>"
"<ParticlePhaseSpace.DataExporters.CSV_Exporter at 0x7f22ff8d5ee0>"
]
},
"execution_count": 19,
Expand Down
119 changes: 104 additions & 15 deletions examples/grid_merge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
"cell_type": "code",
"execution_count": 1,
"id": "417ba109",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:13:02.509711Z",
"iopub.status.busy": "2023-02-23T05:13:02.509279Z",
"iopub.status.idle": "2023-02-23T05:13:03.399053Z",
"shell.execute_reply": "2023-02-23T05:13:03.398298Z"
}
},
"outputs": [],
"source": [
"from pathlib import Path\n",
Expand Down Expand Up @@ -44,7 +51,14 @@
"cell_type": "code",
"execution_count": 2,
"id": "68664df6",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:13:03.402680Z",
"iopub.status.busy": "2023-02-23T05:13:03.402341Z",
"iopub.status.idle": "2023-02-23T05:13:03.462419Z",
"shell.execute_reply": "2023-02-23T05:13:03.461519Z"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -74,14 +88,21 @@
"cell_type": "code",
"execution_count": 3,
"id": "0f9e9e14",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:13:03.465841Z",
"iopub.status.busy": "2023-02-23T05:13:03.465565Z",
"iopub.status.idle": "2023-02-23T05:16:10.011814Z",
"shell.execute_reply": "2023-02-23T05:16:10.011065Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"merge operation removed 0 particles. Original data had 279094\n",
"merge operation took 179.8 s\n"
"merge operation took 186.5 s\n"
]
}
],
Expand All @@ -103,13 +124,26 @@
"cell_type": "code",
"execution_count": 4,
"id": "86556438",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:16:10.014939Z",
"iopub.status.busy": "2023-02-23T05:16:10.014673Z",
"iopub.status.idle": "2023-02-23T05:16:16.431408Z",
"shell.execute_reply": "2023-02-23T05:16:16.430878Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"not regriding z as it is already single valued\n",
"not regriding z as it is already single valued\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"not regriding time as it is already single valued\n"
]
}
Expand All @@ -122,14 +156,21 @@
"cell_type": "code",
"execution_count": 5,
"id": "df7c2811",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:16:16.433993Z",
"iopub.status.busy": "2023-02-23T05:16:16.433783Z",
"iopub.status.idle": "2023-02-23T05:17:26.942950Z",
"shell.execute_reply": "2023-02-23T05:17:26.942027Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"merge operation removed 157174 particles. Original data had 279094\n",
"merge operation took 66.9 s\n"
"merge operation took 70.5 s\n"
]
}
],
Expand All @@ -149,7 +190,14 @@
"cell_type": "code",
"execution_count": 6,
"id": "992ea017",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:26.946069Z",
"iopub.status.busy": "2023-02-23T05:17:26.945769Z",
"iopub.status.idle": "2023-02-23T05:17:27.029818Z",
"shell.execute_reply": "2023-02-23T05:17:27.029211Z"
}
},
"outputs": [],
"source": [
"new_PS = new_PS + PS_discard\n",
Expand All @@ -170,7 +218,14 @@
"cell_type": "code",
"execution_count": 7,
"id": "8629285e",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:27.033196Z",
"iopub.status.busy": "2023-02-23T05:17:27.033039Z",
"iopub.status.idle": "2023-02-23T05:17:28.212578Z",
"shell.execute_reply": "2023-02-23T05:17:28.211923Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -202,7 +257,14 @@
"cell_type": "code",
"execution_count": 8,
"id": "21853935",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:28.216462Z",
"iopub.status.busy": "2023-02-23T05:17:28.216093Z",
"iopub.status.idle": "2023-02-23T05:17:30.956859Z",
"shell.execute_reply": "2023-02-23T05:17:30.956242Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -242,7 +304,14 @@
"cell_type": "code",
"execution_count": 9,
"id": "28556d7b",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:30.960023Z",
"iopub.status.busy": "2023-02-23T05:17:30.959781Z",
"iopub.status.idle": "2023-02-23T05:17:32.000397Z",
"shell.execute_reply": "2023-02-23T05:17:31.999733Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -274,7 +343,14 @@
"cell_type": "code",
"execution_count": 10,
"id": "743d2a2c",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:32.004164Z",
"iopub.status.busy": "2023-02-23T05:17:32.003961Z",
"iopub.status.idle": "2023-02-23T05:17:33.529451Z",
"shell.execute_reply": "2023-02-23T05:17:33.528656Z"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -302,7 +378,13 @@
" median energy: 2.39 MeV\n",
" Energy spread IQR: 2.39 MeV\n",
" min energy 0.08 MeV\n",
" max energy 8.46 MeV\n",
" max energy 8.46 MeV\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"===================================================\n",
" ENERGY STATS \n",
"===================================================\n",
Expand Down Expand Up @@ -346,7 +428,14 @@
"cell_type": "code",
"execution_count": 11,
"id": "22fe8d6b",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-23T05:17:33.531960Z",
"iopub.status.busy": "2023-02-23T05:17:33.531728Z",
"iopub.status.idle": "2023-02-23T05:17:36.543696Z",
"shell.execute_reply": "2023-02-23T05:17:36.543098Z"
}
},
"outputs": [
{
"data": {
Expand Down

0 comments on commit a0d1ccc

Please sign in to comment.