Skip to content
Snippets Groups Projects
Commit 34cdf30a authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Small change for CavityResonator

Add form factor option to set_optimal_detune.
Fix priniting in BeamLoadingEquilibrium.
parent dcb29270
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,4 @@
*.ipynb_checkpoints*
test_*.py
*.hdf5
*.pyc
......@@ -803,7 +803,7 @@ class CavityResonator():
"""Cavity impedance in [Ohm] for a given frequency f in [Hz]"""
return self.RL / (1 + 1j * self.QL * (self.fr / f - f / self.fr))
def set_optimal_detune(self, I0):
def set_optimal_detune(self, I0, F=1):
"""
Set detuning to optimal conditions - second Eq. (4.2.1) in [1].
......@@ -813,7 +813,7 @@ class CavityResonator():
Beam current in [A].
"""
self.psi = np.arctan(-self.Vbr(I0) / self.Vc * np.sin(self.theta))
self.psi = np.arctan(-self.Vbr(I0) * F / self.Vc * np.sin(self.theta))
def set_optimal_coupling(self, I0):
"""
......
......@@ -270,7 +270,8 @@ class BeamLoadingEquilibrium():
method='hybr',
options=None,
plot=False,
CM=True):
CM=True,
verbiose=False):
"""Solve system of non-linear equation to find the form factors F
and PHI at equilibrum. Can be used to compute the equilibrium bunch
profile.
......@@ -284,6 +285,7 @@ class BeamLoadingEquilibrium():
plot : if True, plot the equilibrium bunch profile
CM : if True, the system imposes zero center of mass offset,
if False, the system imposes energy balance.
verbiose : if True, print out informations about convergence.
Returns
-------
......@@ -294,12 +296,13 @@ class BeamLoadingEquilibrium():
if self.auto_set_MC_theta:
x0 = x0 + [self.cavity_list[0].theta]
if CM:
print("The initial center of mass offset is " +
str(self.center_of_mass() * 1e12) + " ps")
else:
print("The initial energy balance is " +
str(self.energy_balance()) + " eV")
if verbiose:
if CM:
print("The initial center of mass offset is " +
str(self.center_of_mass() * 1e12) + " ps")
else:
print("The initial energy balance is " +
str(self.energy_balance()) + " eV")
sol = root(lambda x: self.to_solve(x, CM),
x0,
......@@ -318,13 +321,15 @@ class BeamLoadingEquilibrium():
self.F = sol.x[::2]
self.PHI = sol.x[1::2]
if CM:
print("The final center of mass offset is " +
str(self.center_of_mass() * 1e12) + " ps")
else:
print("The final energy balance is " + str(self.energy_balance()) +
" eV")
print("The algorithm has converged: " + str(sol.success))
if verbiose:
if CM:
print("The final center of mass offset is " +
str(self.center_of_mass() * 1e12) + " ps")
else:
print("The final energy balance is " + str(self.energy_balance()) +
" eV")
if not sol.success:
print("The algorithm has converged: " + str(sol.success))
if plot:
self.plot_rho(self.B1 / 4, self.B2 / 4)
......@@ -351,7 +356,7 @@ class BeamLoadingEquilibrium():
The default is None. If None, uniform filling is assumed.
MC_index : int, optional
Index of the main cavity in cavity_list. The default is 0.
HC_index : TYPE, optional
HC_index : int, optional
Index of the harmonic cavity in cavity_list. The default is 1.
Returns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment