From a76df6f9211e6e651c83442855c37efcd872a018 Mon Sep 17 00:00:00 2001
From: nadolski <nadolski@9a6e40ed-f3a0-4838-9b4a-bf418f78e88d>
Date: Mon, 11 Oct 2010 11:04:07 +0000
Subject: [PATCH] =?UTF-8?q?=C3=82=C3=8D=C3=85=C2=80=C3=84=3F=C3=8A=C3=8A?=
 =?UTF-8?q?=C3=91=C3=85=C3=BE=C2=80=C2=80=C3=91>=C2=80=C3=AA=C3=91>=C3=85?=
 =?UTF-8?q?=C2=AC=C3=A5=C3=81=C3=88=C3=84=C3=87=C3=8A=3F=5F=C2=80=C3=B8=3F?=
 =?UTF-8?q?=C3=8D=C3=8A=C2=80=C3=8C=C3=91=C2=80=15=C2=80=C2=90=C2=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 tracy/tracy/src/t2ring.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tracy/tracy/src/t2ring.cc b/tracy/tracy/src/t2ring.cc
index b88a96d..9d038ef 100644
--- a/tracy/tracy/src/t2ring.cc
+++ b/tracy/tracy/src/t2ring.cc
@@ -477,10 +477,12 @@ void Cell_Twiss(long i0, long i1, ss_vect<tps> &Ascr, bool chroma, bool ring,
        16/10/03 Modified convergence test: now done for both planes
        01/09/10 Modify the convergence criteria on relative diff of the chroma value
                 The previous test does not work well for non zero chromaticities
+                Test convergence changed if chroma closed to zero
 ****************************************************************************/
 #define n               4
 #define chromeps        1e-6 /* convergence condition for chromaticity computation */
 #define LOG10 log(10.0)
+#define ZEROCHRO 0.1
 
 void Ring_Getchrom(double dP) {
 	long int lastpos = 0;
@@ -546,6 +548,10 @@ void Ring_Getchrom(double dP) {
 		Norm_TEMP = sqrt(TEMP[0] * TEMP[0] + TEMP[1] * TEMP[1]);
 		NORMchro = sqrt(globval.Chrom[0] * globval.Chrom[0] + globval.Chrom[1]
 				* globval.Chrom[1]);
+		// if chroma closed to zero, norm is one for avoiding divergence of convergence test
+		if (NORMchro < ZEROCHRO){
+			NORMchro = 1.0;
+		}
 
 		// TEST CHROMA convergence
 		if (trace) {
@@ -572,6 +578,7 @@ void Ring_Getchrom(double dP) {
 #undef n
 #undef chromeps
 #undef LOG10
+#undef ZEROCHRO
 
 
 /****************************************************************************/
-- 
GitLab