Skip to content

Commit 7cf565e

Browse files
author
Lee Carver
committed
Fix a very specific with initial beam loading parameters
1 parent 94af515 commit 7cf565e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pyat/at/collective/beam_loading.py

+7
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,15 @@ def _init_bl_params(self, current):
231231
a = self.Voltage*numpy.cos(theta-self._phis)
232232
b = self.Voltage*numpy.sin(theta-self._phis)-vb*numpy.cos(theta)
233233
psi = numpy.arcsin(b/numpy.sqrt(a**2+b**2))
234+
if numpy.isnan(psi):
235+
psi = 0.0
236+
warning_string = 'Unusual cavity configuration found.' + \
237+
'Setting initial psi to 0 to avoid NaNs'
238+
warnings.warn(AtWarning(warning_string))
239+
234240
vgen = self.Voltage*numpy.cos(psi) + \
235241
vb*numpy.cos(psi)*numpy.sin(self._phis)
242+
print(a,b,psi,vgen)
236243
elif self._cavitymode == 2:
237244
vgen = 0
238245
psi = 0

0 commit comments

Comments
 (0)