-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errata and bug: about signs for imaginary parts of complex refractive index and refracted angles #1113
Comments
@tizian this might interest you. |
Thanks for letting me know. I'm away for the next 2.5 weeks or so but I'll try to take a closer look once I'm back. The sign flip given in the example with a small complex component is indeed very suspicious. I think a first step would be to reproduce the plots from this section in the documentation. I do recall running similar experiments where I basically reproduced the dielectric behaviour with the complex case (and kappa ~= 0). But I don't see them in the document so probably didn't include them at the time. |
It also has been a while since I've been thinking intensely about the various signs of the polarization code. It might take me a bit to refamiliarize myself with it 🙂 |
Thank you for the response.
In my understanding, plots in Figures 12 and 14 in the Mitsuba documentation are based on considering phase as |
I finally found some time to play with this a bit, and indeed something seems to be wrong about the conductor case. Given that you raise two issues at once, let's start with the first one regarding the documentation text. I'm not sure I completely follow this. Do you have a concrete suggestion of how to rephrase the description? And maybe a good source to cite in addition? My understanding here was the following: A wave can be described by For real IOR An imaginary component of So which amounts to a decaying wave when |
The problem what I want to point out comes from that the current Mitsuba 3 document explains formulae for waves only with time-dependency term, without spatial dependency. with the relation Here Note that Eq. (2-2) does not contain The first part I want to point out is that the I also want to write a concrete suggestion for rephrasing the Mitsuba documentation, but I apologize I would be able to write that suggestion and more discussions at least next week due to my personal schedule. |
I think I see where you're getting at. I found a slightly more gentle explanation in "Optics" by Hecht (5th Edition) Section 4.8 "Optical Properties of Metals" ... Harmonic wave propagating along spatial dimension with when parameterizing with temporal and spatial periods Spatial and temporal propagation are actually related by considering the propagation speed Now, choosing the convention to represent conductor IORs with a negative complex component This is actually where we started, just with All that being said, I'm not convinced the discussion of both spatial and temporal dimension here adds a lot to the high-level insight behind the complex IOR. We can always be more precise and more correct but need to draw the line somewhere. In particular, the temporal aspect actually doesn't play any role in these equations. So a compromise could be to change the documentation text referencing "increase in time" to "increase in distance into the medium" and replace the reasoning with the equations above---but just illustrating the spatial dimension. (I.e. remove " A reference to Hecht should then be enough for the more interested reader to dig deeper into the topic. |
Sorry for late response About your latest commentYour understanding through [Hecht] looks right. (while denoting temporal and spatial periods by
I totally agree with you. One of the reasons I wrote such a long derivation is just clarification for verification. Since it is so confusing, I was concerned that I might be wrong, and wanted to clarify the details to avoid another error. While obliquely incident rays with vector spatial frequency rather than the scalar one will be more complicated, (unfortunately the direction of exponential decay and the direction of transmitted plane wave will be different in general), it will not be need to be explained in the documentation.
I understand what you want say, and actually the temporal term itself seems not be matter to determine the sign of complex numbers. It will be confusing. Note that for a general wave function formed In summary, using Concrete suggestion for the documentation textIn conclusion, my suggestion is changing the following current phrases:
into the following new phrases:
Remained issue: the imaginary sign for "cosine refracted angle"One of the reasons I wrote the long derivation is that the confusing imaginary signs appear in both complex refractive index and complex refracted angle. For complex refractive index, it is just fine to change the documentation text (mainly "comes from the expression Our discussion during this several weeks has mainly focused on the complex refractive index issue. However, for complex refracted angle for total internal reflection and reflection on conductors, what I found is that the values produced by the source code appear to be incorrect, and the code should be revised. If you (or one of the people who manage Mitsuba 3) agree the problem in computing complex refracted angles in mitsuba3/include/mitsuba/render/fresnel.h Line 227 in 3013adb
|
Good catch! And thanks for the additional explanations. So technically the time component is not needed, but it implicitly defines the sign of the spatial component. I think given all this discussion it's safe to say this maybe requires a bit more explanation in the documentation after all. I suggest the following text: The same expressions also hold in the conductor case where the indices of refraction are complex valued, i.e. There also exist alternate conventions of the above behaviour where the direction of time dependence is reversed, i.e. Yes, please open a separate issue or PR for the actual code issue. Aplogogies for delaying that (arguably more important) discussion a bit. I just wanted to first clarify the confusion around the documentation. |
Your suggestion for the text is good and I cannot find any problem, except a minor suggestion.
This sentence is not wrong, it's fine. But I'm a little concerned that the above phrase might be misread as some physical meaning in time. My suggestion is
I think this is slightly better to clarify that the difference between those two formulae is nothing but a convention, without any change in physical meaning and behaviour. This discussion has been too long so that it seems difficult to read the two issues (complex IOR, complex refracted angle) separately. |
Sounds good. I'll prepare a PR for the documentation changes tomorrow. |
FYI: #1150 |
I have created PR #1161 . The bug of the previous implementation of |
Sorry that this hasn't been getting too much attention. |
No problem. Thanks for taking care of this issue. |
Hi,
I found that some detailed description in the document
https://mitsuba.readthedocs.io/en/latest/src/key_topics/polarization.html#theory
seems to contain errata, and the current implementation has a bug in terms of sign flipping in imaginary parts.
I'm not sure where this issue should be posted, but I want to discuss it for completeness of Mitsuba 3 documentation and code.
Errata in documentation
What I want to discuss is about the following paragraphs in https://mitsuba.readthedocs.io/en/latest/src/key_topics/polarization.html.
Here,
$\eta = n-ki$ comes from $\exp\left(+i\omega t\right)$ rather than $\exp\left(-i \alpha \eta t\right)$ (while difference between my notation $\omega$ and $\alpha\eta$ in Mitsuba documentation is not importance, their signs are very important). Similarly, $\eta = n+ki$ comes from $\exp\left(-i\omega t\right)$ contrast to what rewritten in the last paragraph. The current document has flipped signs, and description of the reasoning of these signs is wrong. In a wave formulation $\exp\left(\pm i \left(\omega t - \boldsymbol\kappa \cdot \mathbf r\right)\right)$ , the coefficient $\omega$ of time $t$ should be a positive real number, and the complex coefficient is $\boldsymbol\kappa$ .
Issue in code:$\cos\theta_t$ on conducting media
fresnel_polarized
infresnel.h
computes complex refracted angles for total reflection between dielectric media and incidence on a conducting medium. While the former is implemented correctly (i.e., consistent to the convention ofAs one effect of inconsistent implementation, here we can see a discontinuous behavior for the first and second entries (
a_s
anda_p
) for the output tuples for very little change of imaginary parts of the refractive index.The actual derivation for complex angles is written in the next section.
Detailed description
Since this sign convention problem is very very, so much confusing, I want to start from the most fundamental facts and derive results step-by-step to argue the errata.
Plane waves
From Maxwell's equations in a medium with permittivity$\epsilon$ , permeability $\mu$ , and conductivity $g$ , assuming no free charge and $\mathbf j_{\mathrm{free}} = g \mathbf {E}$ yields the following equations:
It holds independent of choice of conventions yet.
Assume a plane wave solution$\mathbf E\left(\mathbf r,t \right) = \mathbf E e^{\pm i\left(\omega t- \boldsymbol{\kappa} \cdot \mathbf r\right)}$ . Note that taking the sign $\pm$ yields each of different conventions. To make clear which part depends the conventions and which are not, we keep to write $\pm$ symbols rather than choosing one convention. (Then $\mp$ indicates the opposite sign to the convention symbol $\pm$ )
Substituting the plane wave form into the first equation, we obtain that it becomes a solution whenever the following relation between$\omega$ and $\boldsymbol\kappa$ holds.
Defining a complex permittivity as$\tilde \epsilon \coloneqq \epsilon\mp \frac{g}{\omega}i $ , the above equation can be rewritten as,
Two semi-infinite media
Now considering a scenario that a plane wave at Medium 1 with$\epsilon_1\in\mathbb R$ Incidents to Medium 2 with $\tilde \epsilon_2\in \mathbb C$ , and a common permeability $\mu$ .
Here, I am writing the three waves with the same temporal frequency$\omega$ , which is explained the next next paragraph. While $\boldsymbol\kappa_0$ for the incident wave is a real vector, we do not know ${\boldsymbol\kappa}_1$ and $\tilde{\boldsymbol\kappa}_2$ are real or complex yet, but I will prove that ${\boldsymbol\kappa}_1$ is always real but $\tilde{\boldsymbol\kappa}_2$ may be complex.
Boundary conditions of Maxwell's equations for these three wave functions consist of four equations of linear combinations of them such as$\epsilon_1\mathbf E_{0}\left(\mathbf r,t\right)\cdot \mathbf n + \epsilon_1\mathbf E_{1}\left(\mathbf r,t\right)\cdot \mathbf n = \epsilon_2\mathbf E_{2}\left(\mathbf r,t\right)\cdot \mathbf n $ . This can be splitted into two conditions (where both should be satisfied): (1) constraints for $e^{\pm i\left(\omega t- \boldsymbol\kappa\cdot \mathbf r\right)}$ , and (2) constraints for amplitudes (including phases) $\hat{\mathbf E}_0$ , $\hat{\mathbf E}_1$ , and $\hat{\mathbf E}_2$ , which yield well known Fresnel equations.
(1) Constraints for$e^{\pm i\left(\omega t-\boldsymbol\kappa\cdot \mathbf r\right)}$
Claim: incident, reflected, and transmitted waves have the same real temporal frequency$\omega$ and may have complex values in waves numbers $\boldsymbol\kappa$ .
Note that the boundary conditions should hold for any time and any position on the interface,$z=0$ . It first yields the three waves have the identical coefficient of the time dependency at their exponents, so that the temporal frequency $\omega$ for the refracted wave should be real, contrast to what is written in the current Mitsuba 3 documentation. Note that the equations above have already been written using the same $\omega$ based on this fact.
Next,$e^{\mp i \boldsymbol\kappa\cdot \mathbf r}$ for the three waves should be identical at any position at $z=0$ . It can be rewritten as follows:
From Equation (3), we observe that all wave vectors$\boldsymbol\kappa_0$ , $\boldsymbol\kappa_1$ , and $\tilde{\boldsymbol\kappa}_2$ lie on a single plane. Assigning a coordinate system as follows, $\boldsymbol\kappa_0$ , $\boldsymbol\kappa_1$ , and $\tilde{\boldsymbol\kappa}_2$ only have $x$ and $y$ coordinates. Then they are rewritten using angles $\theta_i$ , $\theta_r$ , and $\tilde \theta_t$ as follows:
where$\kappa_0 = \sqrt{\boldsymbol\kappa_0 \cdot\boldsymbol\kappa_0} = \sqrt{\epsilon_1\mu}\omega\ge 0$ .
From Equations (1) and (3), we easily get$\kappa_1 =\kappa_0$ and $\theta_r = \theta_i$ . For $\tilde{\boldsymbol\kappa}_2$ , Equation (1) is rewritten as follows.
Define the relative refractive index$\eta$ as one of square root of $\tilde \epsilon_2 / \epsilon_1$ , $\tilde \kappa_2 = \eta \kappa_0$
Claim:$\exp\left(\pm i\omega t\right)$ convention for plane waves yields complex refractive indices of signs $\eta = n \mp k i$ , respectively.
I believe the real part of$\tilde \kappa_2$ should be taken as positive since it represents the actual wavelength of the wave. For example, if we consider two media with the same permittivity and zero conductivity for one and infinitesimally small conductivity for the other, as the example code above, it will be natural that two media yield very similar values of wave numbers $\kappa$ . Even though I could not found a concrete reference for this reasoning, I provide several examples of references consistent of this claim.
Note that taking the sign of$\eta = \left(\tilde \epsilon \mu\right)^{\frac12}$ in this way, the argument (the angle between given complex number and the positive real axis in the complex plane) of $\eta$ belongs to the following range.
Note that$\tilde \kappa_2 = \eta \kappa_0$ has the argument in the same range as $\eta$ .
Now we can get$\tilde \theta_t$ . From Equation (3) and (4), we get $\kappa_0\sin\theta_i = \tilde\kappa_2 \sin\tilde \theta_t$ . Substituting $\tilde \kappa_2=\eta\kappa_0$ to here, $\sin\tilde\theta_t = \frac1{\eta}\sin\theta_i$ . Then $\cos\tilde\theta_t$ becomes one of square roots of $\cos^2\tilde\theta_t=1-\sin^2\tilde\theta_t = 1-\frac1{\eta^2}\sin^2\theta_i$ . From Equation (5), we get:
To determine the sign of$\cos\tilde\theta_t$ , we should select the sign which makes the refracted wave decays rather than diverge. Substituting Equation (4) into Equation (2) for the refracted wave,
In our coordinate system, the wave decays to zero at$y=-\infty$ . It can be written as $\mp \Im\left(\tilde\kappa_2\cos\tilde\theta_t\right)\cdot \left(-\infty\right)\le 0$ , furthermore,
for$e^{\pm i\omega t}$ convention, respectively. According ranges of arguments of $\tilde \kappa_2$ and $\cos^2\tilde\theta_t$ , which are already obtained, we should take $\cos\tilde\theta_t$ with the argument in the following range.
In summary,
Claim: For both total internal reflection between dielectric media and reflection on a conductor,$\Im \cos\tilde\theta_t$ should have $\mp$ sign for $e^{\pm i\omega t}$ convention, respectively.
I found that in Mitsuba 3 ($e^{+i\omega t}$ convention) while $\cos\tilde\theta_t$ for total internal reflection is implemented correctly,
mitsuba3/include/mitsuba/render/fresnel.h
Line 150 in 3013adb
however,$\cos\tilde\theta_t$ for conductors is implemented wrong, as best of my knowledge.
mitsuba3/include/mitsuba/render/fresnel.h
Line 227 in 3013adb
The discontinuous complex reflectance change in the code example above is yielded by this implementation issue for conductors.
(2) Constraints for$\hat {\mathbf E}_0$ , $\hat {\mathbf E}_1$ , and $\hat {\mathbf E}_2$ : Fresnel equations
Constraints (boundary conditions) for amplitudes yields the well known Fresnel equation. I have not found any error in the Fresnel equation in Mitsuba 3 itself, I omit detailed description for this part.
References
The text was updated successfully, but these errors were encountered: