From c713b995d2d95736e8c5eafe148e06e4d9c809d1 Mon Sep 17 00:00:00 2001
From: Gamelin Alexis <alexis.gamelin@synchrotron-soleil.fr>
Date: Wed, 23 Nov 2022 12:23:52 +0100
Subject: [PATCH] [Fix] Coating impedance convention

Change sign of the imaginary part of the impedance in the Coating class to agree with mbtrack2 convention.
---
 mbtrack2/impedance/resistive_wall.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mbtrack2/impedance/resistive_wall.py b/mbtrack2/impedance/resistive_wall.py
index 8434db6..13a736b 100644
--- a/mbtrack2/impedance/resistive_wall.py
+++ b/mbtrack2/impedance/resistive_wall.py
@@ -322,14 +322,14 @@ class Coating(WakeField):
         
         if approx == False:
             alpha = skin1/skin2
-            tanh = np.tanh( (1 - 1j*np.sign(f)) * self.thickness / skin1 )
-            bracket = ( (np.sign(f) - 1j) * skin1 * 
+            tanh = np.tanh( (1 + 1j*np.sign(f)) * self.thickness / skin1 )
+            bracket = ( (np.sign(f) + 1j) * skin1 * 
                        (alpha * tanh + 1) / (alpha + tanh) )
         else:
             valid_approx = self.thickness / np.min(skin1)
             if valid_approx < 0.01:
                 print("Approximation is not valid. Returning impedance anyway.")
-            bracket = ( (np.sign(f) - 1j) * skin2 - 2 * 1j * self.thickness * 
+            bracket = ( (np.sign(f) + 1j) * skin2 + 2 * 1j * self.thickness * 
                        (1 - self.rho2/self.rho1) )
         
         Zl = factor * bracket
@@ -370,14 +370,14 @@ class Coating(WakeField):
         
         if approx == False:
             alpha = skin1/skin2
-            tanh = np.tanh( (1 - 1j*np.sign(f)) * self.thickness / skin1 )
-            bracket = ( (1 - 1j*np.sign(f)) * skin1 * 
+            tanh = np.tanh( (1 + 1j*np.sign(f)) * self.thickness / skin1 )
+            bracket = ( (1 + 1j*np.sign(f)) * skin1 * 
                        (alpha * tanh + 1) / (alpha + tanh) )
         else:
             valid_approx = self.thickness / np.min(skin1)
             if valid_approx < 0.01:
                 print("Approximation is not valid. Returning impedance anyway.")
-            bracket = ( (1 - 1j*np.sign(f)) * skin2 - 2 * 1j * self.thickness 
+            bracket = ( (1 + 1j*np.sign(f)) * skin2 + 2 * 1j * self.thickness 
                        * np.sign(f) * (1 - self.rho2/self.rho1) )
         
         Zt = factor * bracket
-- 
GitLab