\documentclass[a4paper]{article}

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}

\begin{center}
  Response Letter
\end{center}
Dear Editor,
\vspace{10pt}

Many thanks for sending us referees’ reports on our manuscript
entitled ``Mie calculation of electromagnetic near-field for a multilayered sphere'' by K. Ladutenko, U. Pal, A. Rivera and O. Pe\~na (CPC manuscript CPC-D-15-00354). We are pleased with
overall very positive tone of these reports, as well as with referees’
constructive comments.

We have addressed all the comments of the referees, and we present our
response and the summary of the changes made to the manuscript below.
\vspace{10pt}
\\
Sincerely Yours,\\
On behalf of the authors,\\
%TODO add name

\vspace{10pt}

\newpage
\textbf{Reviewer \#1 comments}

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & There are several alternatives currently available, Mathematica GLMT Scripts, for example. It provides both near- and far-field results for multilayered sphere. Moreover, Mathematica can handle Bessel functions up to arbitrary precision without any difficulties, and the code is very transparent and compact. 
\end{tabular}
\vspace{0.5em}

We are actually not very familiar with Mathematica GLMT Scripts, however, fast review of this code revealed a number of significant differences:
\begin{itemize}
\item As it is published at \verb+http://photonicsdesign.jimdo.com/software/+ it does not provide any appropriate license condition, particularly it is not clear, is it valid to distribute this code, to modify it (e.g. to put your own model parameters), to use it for academic or corporate research, etc. Our code Scattnlay is distributed under GPL (version 3) --- a well-known permissive license for open source software. 
\item You need to buy Mathematica license first to use this script.
\item This script do not provide near-field evaluation inside the particle, at least all provided examples do not have it.
\item It does not use Mathematica ability to do arbitrary precision for calculation of Mie coefficients for multilayer sphere. Actually GLMT Script itself references our previous paper in CPC, and uses the same evaluation of spherical functions via series with the same error due to $N_{\mathrm{stop}}$ selection. Equations needed to do the evaluation of the near-field distribution inside the multilayered spherical particle are provided in our present manuscript.
\end{itemize}

Finally, we should point out that the authors of Mathematica GLMT started using Scattnlay and, at least the initial versions of their scripts, were heavily based on our code. Indeed, even now most of their varibles use exactly the same names than Scattnlay. Hence, it is safe to say that Mathematica GLMT is a derivative work of our code, even if both projects have diverged over time. To the best of our knowledge the only code available which provide similar posibilities is MSTM by Mackowski and Mishchenko. However, it uses T-matrix approach (which is considerably less efficient for the case of concentric spheres) to do the evaluation and has no usage license defined. We  had actually verified our code against MSTM results too, however, we do not include them to the manuscript due to abovementioned license restrictions of MSTM.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & The only advantage I see of the algorithm presented here is the speed, since it is implemented in the newest C++ language. But, to prove it benchmarking should be performed.
\end{tabular}
\vspace{0.5em}

We do concern the speed of our implementation, we have done an optimization of the previous code, which lead to more than a two fold speed-up. However, this is not the main point of the manuscript.  We would like to thank the reviewer for a useful comment, as it seems that our initial version of the manuscript do not stress the novelty enough. To do this we provide a number of changes in the manuscript:
TODO - stress novelty in the abstract, manuscript, and in the conclusion: 
1) We provide explicit expressions for Mie coefficients inside the sphere.
2) We suggest to use Ricatti-Bessel functions for vector spherical harmonics evaluations and prove the correctness of this approach.
3) We verify the provided approach comparing to other codes and full-wave 3D simulation.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & For currently presented test runs only core-shell structures are selected. The last example is, actually, from the same authors, which looks really confusing, since, I guess, they've  used exactly this code. So, they are test themselves with the same code - kind of weird. 
\end{tabular}
\vspace{0.5em}

We would like to thank the reviewer for finding, that just referencing our previous paper can lead to misunderstanding. In our last example we used near-field results obtained with full-wave commercial 3D electromagnetic simulation software CST MWS. Actually the lack of our code to provide near-field data for that project initiated development of the current version of Scattnlay.

We add to the manuscript after the corresponding reference ``reported recently [10]'' the following sentence ``, where we obtained near-field distribution using full-wave commercial 3D electromagnetic simulation software CST MWS[TODO add link to cst.com in references ]'' 

We had to restrict ourselves mostly to compare against core-shell cases due to the lack of analytic software, which allows (including usage statements in the software license) to do the simulation of multilayered sphere. We had to verify the multilayered case against full-wave simulation done with finite-element method using CST MWS and finite-difference time-domain method using Lumerical FDTD. After doing this we are pretty sure that our code provides correct results (at least for the tested range of input parameters). As it was stated in ``Restrictions'' line of ``Program description'' section large complex part of layers refractive index leads to convergence problems.  Note that usage of full-wave 3D simulation required 4-5 orders of magnitude more computational resources (time) to get e.g. total scattering cross-section with a comparable accuracy. 

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & Also, in Fig. 2 they compare published and their results. But in all other figures they show only their results and refer to the literature for comparison. They should present all test and original results in the current manuscript.
\end{tabular}
\vspace{0.5em}

We do not compare with published result in Fig.2, we have downloaded and run the referenced software. All the results presented in Fig.2 were obtained by ourself. To compare the result obtained from our code (presented in Fig.2b) we used the BHFIELD code developed by Suzuki and Lee to get the field distribution presented in Fig. 2a. To make it more clear we provide the following change to the manuscript: instead of ``For this, we calculated electric and magnetic fields for the example provided with their computer code'' we write ``For this, we calculated electric and magnetic fields using the example provided with their computer code''  

As for other figures, we do not have a permission to reprint figures from several other journals (see the corresponding references) , this way we can only provide the text description and to reference them.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & On another note, since there are plenty of Mie based simulators which can be found at scattport.org I would encourage the authors to add GUI to their code to provide more flexibility and user-friendly environment. Otherwise, it's easier to code generalised Mie solution in Mathematica, which is perfectly suitable for it, and I don't see any advantage of the current program compare to others. Near field can now also be accessed in other programs I've mentioned and found at scattport.org
\end{tabular}
\vspace{0.5em}

We have checked each and every program listed at ``Mie type codes'' section (\href{http://www.scattport.org/index.php/light-scattering-software/mie-type-codes}{link}\footnote{http://www.scattport.org/index.php/light-scattering-software/mie-type-codes}) of Scattport before starting the development of our code (fall of 2014). While really the software list is very large, most of the listed codes re-implement Mie solution as it was published in classical book of Bohren and Huffman ``Absorption and Scattering of Light by Small Particles'' (usually referenced as BHMIE) or re-implement MIEV0 code by Wiscombe.  Few original approaches that we were able to find were referenced in the manuscript as [11-18,22,23]. Note, that most of this solutions to not provide the ability to evaluate field distribution inside the particle and do only cover the case of one (bulk sphere) or two (core-shell) layers in the particle.

We are totally agree with the reviewer, that it is a good idea to provide a GUI. However, adding a GUI is a very time consuming task and we do not have any funding for this.  Actually, the code described in our previous publication has no GUI either, still that paper has more than 50 citations at the moment as it is listed in Scopus database. So we should expect that this code and the manuscript are valuable and important even without GUI. In our first comment in this reply we have tried to cover the cases, when Mathematica usage is not beneficial. As an intermediate solution we provide bindings to Python language, which are the part of the released code. It can provide good enough plotting (see figures 2,3, and 4 in the manuscript) via MatPlotLib module, Python syntax is about the same complexity as used by Mathematica or Matlab. However, Python can be used free of charge.

\newpage
\section{Reviewer \#2}

First of all we would like to thank this reviewer for his work. We were really impressed with his detailed review and would like to add to the ``Acknowledgements'' section the following text ``All authors would like to thank two anonymous reviewers for their valuable comments.''


\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
The paper does not make any claim to originality as far as the algorithm is
concerned.
\end{tabular} 
\vspace{0.5em}

COPY-PASTE from reviewer 1 answer: We would like to thank the reviewer for a useful comment, as it seems that our initial version of the manuscript do not stress the novelty enough. To do this we provide a number of changes in the manuscript:
TODO - stress novelty in the abstract, manuscript, and in the conclusion: 
1) We provide explicit expressions for Mie coefficients inside the sphere.
2) We suggest to use Ricatti-Bessel functions for vector spherical harmonics evaluations and prove the correctness of this approach.
3) We verify the provided approach comparing to other codes and full-wave 3D simulation.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & The authors’ citation list does acknowledge some of this earlier work.
The first recursive algorithm for the multi-layered sphere known to this
reviewer was published by Wait [2] in 1963, although this work does not
address the numerical issues tackled by the approach of Yang. The algorithm
is described in a 1970 textbook [3].
\end{tabular}
\vspace{0.5em}

We already provided Ref. 13 in the manuscript to the Wait paper. However, we found a  small typo (both in our list and in the reviewer comment). According to journal`s web-site the  Wait paper was published in 1962 \href{http://link.springer.com/article/10.1007/BF02923455}{http://link.springer.com/article/10.1007/BF02923455} )  
TODO fix reference 12 Wait, J.R. Appl. sci. Res. (1962) 10: 441. doi:10.1007/BF02923455 

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
The introductory section of the write-up includes an incidental citation of the
authors’ reference [18], which is a paper on the T-matrix method. This re-
viewer understands the T-matrix method as being applicable to a collection
of spheres side-by-side, not to a multi-layered sphere defined by concentric
spherical shells. If the authors agree, reference [18] should be omitted.
\end{tabular}
\vspace{0.5em}

No, the only restriction of T-matrix formulation as stated in Red. 18 is that spheres surfaces should not intersect. This way it is quite legal to use several spheres embedded into each other to simulate a stratified sphere, which is an object of interest in the presented manuscript and this way is highly relevant to the subject of our work. However, it is considerably less efficient for the case of concentric spheres. Moreover, it does not provide any appropriate license condition, particularly it is not clear, is it valid to distribute this code, to modify it (e.g. to put your own model parameters), to use it for academic or corporate research, etc. Our code Scattnlay is distributed under GPL (version 3) --- a well-known permissive license for open source software.   See the details at the MSTM web-page \href{http://www.eng.auburn.edu/~dmckwski/scatcodes/}{http://www.eng.auburn.edu/~dmckwski/scatcodes/} 

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 

This reviewer approves of the level of detail provided by the authors in
their derivation of the background theory and their algorithm. However, he
makes the following suggestion to improve the logical progression of the de-
velopment and to avoid the near-repetition of the definition of the spherical
waves occurring in equations (2.1)–(2.4) and (9.1)–(9.4).
First, the reader could be given more guidance to the source of the
definitions by including the section in the citation of Bohren and Huffman
and the continue as follows: “Vector spherical harmonics can be calculated
using the expressions [12, Section 4.3], re-stated in terms of Ricatti-Bessel
functions for numerical reasons [17] as. . . ” followed by equations (9.1)–(9.4).
(1)
(3)
% The definitions of r n , ψ n , ζ n , D n and D n should be given at this early
%point in the presentation so that they are ready to be used in equations
%(5.1)–(5.4), (6.1)–(6.4) and (7.1)–(7.4), rather than being left until later.
%If the authors choose to leave equations (2.1)–(2.4) as they occur in the
%submitted version of the paper, they should correct the inconsistency in
%notation: superscript (j) is used in (2.1) but (i) is used in (2.2)–(2.4).
\end{tabular}
\vspace{0.5em}

TODO Ovidio, this looks resonable. Could you please reorganize the manuscrpit? Could you  additionally stress, that the restatement of vector spherical harmonics in terms of Ricatti-Bessel functions is new? Please, re-check the literature available to be sure that it is correct.
After we omit 2.1-2.4 (reference them to Bohren) we can rewrite functions T1-T4 (eq. 7.1 - 7.2) using complex argument $z=m_{l+1}x_l$. This will make record much shorter.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & This reviewer failed to reproduce the derivation of equations (6.1)–(6.4)
until he realised that there is a typographical error in equation (7.4), which
should read
\begin{equation*}
  T_4(m_{l+1}x_l) =  c^{(l+1)}_{n}  D^{(1)}_{n}(m_{l+1}x_l)  \psi_{n}(m_{l+1}x_l) 
          - b^{(l+1)}_{n}  D^{(3)}_{n}(m_{l+1}x_l)  \zeta_{n} (m_{l+1}x_l)\:,
\end{equation*}

The authors must correct this error and confirm that the correct T 4 has been
used in the code.
\end{tabular}
\vspace{0.5em}

Thank you for pointing this out, for sure this is a typo which we correct in the updated manuscript. The code has the correct equation from the beginning ( \href{https://github.com/ovidiopr/scattnlay/blob/c72d4e94dee437cb6a4f170580dc13a4a4638f05/src/nmie-impl.hpp#L960}{link} \footnote{https://github.com/ovidiopr/scattnlay/blob/c72d4e94dee437cb6a4f170580dc13a4a4638f05/src/nmie-impl.hpp\#L960 } goes to the exact position in the code). Our derivation with the correct equation is also available \href{https://github.com/ovidiopr/scattnlay/blob/c72d4e94dee437cb6a4f170580dc13a4a4638f05/doc/EvalField.ipynb}{online}\footnote{https://github.com/ovidiopr/scattnlay/blob/c72d4e94dee437cb6a4f170580dc13a4a4638f05/doc/EvalField.ipynb}, see the output of the cell at the end of the file just after the word ``Finally''.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
The authors have repeated the misunderstanding of Yang [1] regarding
the justification of the boundary conditions at the centre of the sphere:
$a_n^{(1)} = 0$ and $b_n^{(1)} = 0$. The correct reason is given by Bohren and Huffman [4]
in their Sections 4.3 and 8.1. The point is that only the $j_n (kr)$ dependence
gives a finite, non-singular behaviour at the origin, and so can be the only
radial dependence occurring in the spherical wave expansion of the fields
in the core, region 1. A radial dependence of $j_n (kr)$ represents a standing
wave, that is, a superposition of both incoming and outgoing waves.
\end{tabular}
\vspace{0.5em}

We would like to thank the reviewer for provided explanation and we will add the discussion about the singularity of Bessel functions to the manuscript. However, we would argue that this purely  mathematical representation of the problem  on the boundary conditions contradicts the explanation in terms of outgoing wave. Moreover, to our opinion, they nicely complement each other. Due to superposition principle we can always extract the outgoing wave from the total field. From the reciprocity non-zero outgoing wave is equivalent to some non-zero incoming wave, that will focus into a single point which will obviously lead to singularity.

TODO We should add this description to the manuscript too.

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
The authors mention that the code can accommodate a perfectly-conduct-
ing shell. Perfect conductor (PEC) is an idealisation that must be distin-
guished from real conductors. The only place a PEC layer should appear in
the model is at the core. It is futile to enclose other materials inside a PEC
shell since such a shell would exclude all fields from its interior.
There are several omissions from the reference list. No DOIs are given for
[8], [9] and [22] and no ISBN is given for [12]. Several authors have second
initials which have been omitted: J.R. Wait for [13] and M.V. Bashevoy,
V.A. Fedotov and N.I. Zheludev for [20]. The final page number for [19]
should be given; this reviewer cannot ascertain whether it is 4735 or 4736
since he does not have ready access to the full paper. The full citation
for [21] is Nat. Commun. 5:3402(2014). [26] appears to be an unpublished
report, so readers should be told how to access it; a URL should be given.
\end{tabular}
\vspace{0.5em}

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
The Code Package
This reviewer has successfully compiled the standalone programs and run
the supplied tests. However, he has failed to compile the python and cython
extensions.
The authors should put much more effort into providing a greatly ex-
panded README file, the first place any new user would look. Step-by-step
instructions should be provided in detail for the compilation of the various
programs in the package including any unusual dependencies on external li-
braries and commands. Step-by-step instructions for running the programs
should also be given, with an explanation of the command-line arguments
and expected outputs.
\end{tabular}
\vspace{0.5em}

\vspace{0.5em}
\begin{tabular}[!H]{l|p{0.9\textwidth}}
\quad & 
Recommendations
This paper and code should not be published in their present form.
They may be suitable for publication if the authors accept the sugges-
tions and undertake the extensions and revisions described above.
The editors should refer any revisions to this reviewer to confirm that
the authors have acted on his suggestions and taken his recommendations
seriously.
The authors have chosen to use make their code publicly available on
the Web as well as submitting it to the CPC Library. The editors must
confirm that this action does not prevent the addition of the code to the
CPC Library.
\end{tabular}
\vspace{0.5em}


%\bibliographystyle{alpha}
%\bibliography{sample}

\end{document}