ovidiopr/scattnlay

Jump of field value at z=0

Closed this issue · 2 comments

Consider the following command:

$ ./fieldnlay-mp -l 1 113 1.3346 0 -p 242.1 242.1 1 -187.1 -187.1 1 -0.001 0.001 9

EM field in the range of z∈[-0.001,0.001] should be very smooth, but the calculated values exhibit a jump at z=0:

Econv:5.62569 Hconv:1.77823
Econv:0.00969625 Hconv:0.0109756
Econv:0.00457643 Hconv:0.00520441
Field evaluation failed to converge an nmax = 189
Near-field convergence threshold: 1e-14
         X,          Y,          Z,         Ex.r,         Ex.i,         Ey.r,         Ey.i,         Ez.r,         Ez.i,         Hx.r,         Hx.i,         Hy.r,         Hy.i,         Hz.r,         Hz.i
242.1000000, -187.1000000, -0.0010000, +nan, +nan, +nan, +nan, +nan, +nan, +nan, +nan, +nan, +nan, +nan, +nan
242.1000000, -187.1000000, -0.0007500, +2.40842e-02, -1.73683e-02, -7.43300e-03, -2.51150e-02, -6.98682e-03, -2.42827e-02, +2.85789e-05, +2.27491e-05, +9.94119e-05, -1.28891e-05, -3.36413e-05, -3.00095e-05
242.1000000, -187.1000000, -0.0005000, +2.40856e-02, -1.73637e-02, -7.43103e-03, -2.51140e-02, -6.98698e-03, -2.42823e-02, +2.85769e-05, +2.27549e-05, +9.94121e-05, -1.28738e-05, -3.36341e-05, -3.00127e-05
242.1000000, -187.1000000, -0.0002500, +2.40870e-02, -1.73591e-02, -7.42906e-03, -2.51130e-02, -6.98714e-03, -2.42819e-02, +2.85749e-05, +2.27608e-05, +9.94124e-05, -1.28585e-05, -3.36269e-05, -3.00160e-05
242.1000000, -187.1000000,  0.0000000, +5.41821e-03, -1.86391e-02, +7.00168e-03, -2.41193e-02, -6.98730e-03, -2.42815e-02, +5.87756e-05, +2.29790e-06, +7.60713e-05, +2.97548e-06, -3.36197e-05, -3.00193e-05
242.1000000, -187.1000000,  0.0002500, +2.40899e-02, -1.73500e-02, -7.42513e-03, -2.51110e-02, -6.98746e-03, -2.42811e-02, +2.85708e-05, +2.27725e-05, +9.94129e-05, -1.28279e-05, -3.36124e-05, -3.00226e-05
242.1000000, -187.1000000,  0.0005000, +2.40913e-02, -1.73454e-02, -7.42316e-03, -2.51100e-02, -6.98762e-03, -2.42808e-02, +2.85688e-05, +2.27783e-05, +9.94131e-05, -1.28126e-05, -3.36052e-05, -3.00258e-05
242.1000000, -187.1000000,  0.0007500, +2.40928e-02, -1.73408e-02, -7.42120e-03, -2.51090e-02, -6.98777e-03, -2.42804e-02, +2.85667e-05, +2.27842e-05, +9.94134e-05, -1.27973e-05, -3.35980e-05, -3.00291e-05
242.1000000, -187.1000000,  0.0010000, +2.40942e-02, -1.73363e-02, -7.41923e-03, -2.51080e-02, -6.98793e-03, -2.42800e-02, +2.85647e-05, +2.27900e-05, +9.94136e-05, -1.27819e-05, -3.35908e-05, -3.00324e-05

Here's a plot of these values (51 points instead of the 9 above) to make the jump more obvious:

Screenshot_20211119_182056

Thank you for reporting! We will try to manage this by the next release. Unfortunately, Mie theory for near-field is not developed to the same state of the art as far-field computations...

It seems that changes from #42 also fixed this.

$ ./fieldnlay-dp -l 1 113 1.3346 0 -p 242.1 242.1 1 -187.1 -187.1 1 -0.001 0.001 9
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Near-field early convergence at nmax = 148
Number of multipoles used in Mie series nmax=183
         X,          Y,          Z,         Ex.r,         Ex.i,         Ey.r,         Ey.i,         Ez.r,         Ez.i,         Hx.r,         Hx.i,         Hy.r,         Hy.i,         Hz.r,         Hz.i
242.1000000, -187.1000000, -0.0010000, +9.90348e-01, -1.83520e-02, -9.49330e-03, -2.51073e-02, -6.98874e-03, -1.24879e-03, +2.31173e-05, +2.27662e-05, +2.66144e-03, -1.54915e-05, -3.36443e-05, -7.72585e-05
242.1000000, -187.1000000, -0.0007500, +9.90350e-01, -1.81027e-02, -9.49134e-03, -2.51085e-02, -6.98838e-03, -1.24841e-03, +2.31152e-05, +2.27663e-05, +2.66144e-03, -1.48295e-05, -3.36381e-05, -7.72618e-05
242.1000000, -187.1000000, -0.0005000, +9.90352e-01, -1.78533e-02, -9.48937e-03, -2.51096e-02, -6.98802e-03, -1.24802e-03, +2.31132e-05, +2.27664e-05, +2.66144e-03, -1.41674e-05, -3.36320e-05, -7.72650e-05
242.1000000, -187.1000000, -0.0002500, +9.90353e-01, -1.76039e-02, -9.48740e-03, -2.51108e-02, -6.98766e-03, -1.24764e-03, +2.31112e-05, +2.27665e-05, +2.66144e-03, -1.35053e-05, -3.36258e-05, -7.72683e-05
242.1000000, -187.1000000,  0.0000000, +9.90355e-01, -1.73546e-02, -9.48544e-03, -2.51120e-02, -6.98730e-03, -1.24725e-03, +2.31091e-05, +2.27666e-05, +2.66144e-03, -1.28432e-05, -3.36197e-05, -7.72716e-05
242.1000000, -187.1000000,  0.0002500, +9.90356e-01, -1.71052e-02, -9.48347e-03, -2.51132e-02, -6.98694e-03, -1.24687e-03, +2.31071e-05, +2.27667e-05, +2.66144e-03, -1.21811e-05, -3.36135e-05, -7.72749e-05
242.1000000, -187.1000000,  0.0005000, +9.90357e-01, -1.68558e-02, -9.48150e-03, -2.51143e-02, -6.98658e-03, -1.24649e-03, +2.31051e-05, +2.27669e-05, +2.66144e-03, -1.15190e-05, -3.36074e-05, -7.72781e-05
242.1000000, -187.1000000,  0.0007500, +9.90359e-01, -1.66065e-02, -9.47953e-03, -2.51155e-02, -6.98621e-03, -1.24610e-03, +2.31031e-05, +2.27670e-05, +2.66144e-03, -1.08569e-05, -3.36012e-05, -7.72814e-05
242.1000000, -187.1000000,  0.0010000, +9.90360e-01, -1.63571e-02, -9.47757e-03, -2.51167e-02, -6.98585e-03, -1.24572e-03, +2.31010e-05, +2.27671e-05, +2.66144e-03, -1.01948e-05, -3.35951e-05, -7.72847e-05

Add a related test here https://github.com/ovidiopr/scattnlay/blob/quasar/tests/test_near_field.cc#L7-L42 , it passes OK now in quasar branch