浏览代码

Relaxed condition for convergence of expansion coefficients

Ovidio Peña Rodríguez 10 年之前
父节点
当前提交
efd960677e
共有 2 个文件被更改,包括 11 次插入3 次删除
  1. 10 2
      nmie.cc
  2. 1 1
      tests/python/test04_field.py

+ 10 - 2
nmie.cc

@@ -1073,9 +1073,17 @@ namespace nmie {
     // Check the result and change  aln_[0][n] and aln_[0][n] for exact zero
     for (int n = 0; n < nmax_; ++n) {
       if (std::abs(aln_[0][n]) < 1e-10) aln_[0][n] = 0.0;
-      else throw std::invalid_argument("Unstable calculation of aln_[0][n]!");
+      else {
+        //throw std::invalid_argument("Unstable calculation of aln_[0][n]!");
+        printf("Warning: Potentially unstable calculation of aln (aln[0][%i] = %g, %gi)\n", n, aln_[0][n].real(), aln_[0][n].imag());
+        aln_[0][n] = 0.0;
+      }
       if (std::abs(bln_[0][n]) < 1e-10) bln_[0][n] = 0.0;
-      else throw std::invalid_argument("Unstable calculation of bln_[0][n]!");
+      else {
+        //throw std::invalid_argument("Unstable calculation of bln_[0][n]!");
+        printf("Warning: Potentially unstable calculation of bln (bln[0][%i] = %g, %gi)\n", n, bln_[0][n].real(), bln_[0][n].imag());
+        bln_[0][n] = 0.0;
+      }
     }
 
     isExpCoeffsCalc_ = true;

+ 1 - 1
tests/python/test04_field.py

@@ -97,7 +97,7 @@ try:
     scale_ticks = np.power(10.0, np.linspace(np.log10(min_tick), np.log10(max_tick), 6))
 
     # Interpolation can be 'nearest', 'bilinear' or 'bicubic'
-    cax = ax.imshow(edata, interpolation = 'nearest', cmap = cm.afmhot,
+    cax = ax.imshow(edata, interpolation = 'nearest', cmap = cm.jet,
                     origin = 'lower', vmin = min_tick, vmax = max_tick,
                     extent = (min(scale_x), max(scale_x), min(scale_y), max(scale_y)),
                     norm = LogNorm())