From bde19da4fc4705a86320d932d62adc8a44279506 Mon Sep 17 00:00:00 2001 From: Ryoichi Miyamoto <ryoichi.miyamoto@esss.se> Date: Thu, 18 Aug 2016 20:58:46 +0200 Subject: [PATCH] A way around for 0 emittance (which could happen, for example, in LEBT or when all the particles are lost when the MEBT chopper is on) was extended to x and y plane for the PARTRAN class. --- ess/lib_tw.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ess/lib_tw.py b/ess/lib_tw.py index e70da71..63a8c8a 100644 --- a/ess/lib_tw.py +++ b/ess/lib_tw.py @@ -413,8 +413,10 @@ class PARTRAN: self.halx =data[idx_halx ]; self.haly=data[idx_haly]; self.halz=data[idx_halp]; self.halp=data[idx_halp] self.Nptcl=data[idx_Nptcl]; self.loss=data[idx_loss] - # To avoid #/0 for LEBT + # Way around for 0 emitt for i in range(len(self.s)): + if self.epsx[i]==0.0: self.epsx[i]=inf + if self.epsy[i]==0.0: self.epsy[i]=inf if self.epsz[i]==0.0: self.epsz[i]=inf if self.epsp[i]==0.0: self.epsp[i]=inf @@ -431,8 +433,10 @@ class PARTRAN: self.alfz =-data[idx_alfz]/self.epsz*self.beta*self.gamma**3 self.alfp =-self.alfz - # Set epsz/epsp back to 0 + # Set inf emitt back to 0 for i in range(len(self.s)): + if self.epsx[i]==inf: self.epsx[i]=0.0 + if self.epsy[i]==inf: self.epsy[i]=0.0 if self.epsz[i]==inf: self.epsz[i]=0.0 if self.epsp[i]==inf: self.epsp[i]=0.0 -- GitLab