Skip to content
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

0 degree incidence angle results in singular matrix error #69

Open
hag174 opened this issue May 21, 2024 · 2 comments
Open

0 degree incidence angle results in singular matrix error #69

hag174 opened this issue May 21, 2024 · 2 comments

Comments

@hag174
Copy link

hag174 commented May 21, 2024

Plane wave illumination with theta = 0 and phi = 0 degrees angle incidence angle results in singular matrix error. The work arround is to enter for theta a very small angle.

@hag174
Copy link
Author

hag174 commented May 24, 2024

I think this problem can be solved by using np.linalg.pinv() instead of np.linalg.inv().

@yufu-liu
Copy link

yufu-liu commented Jan 24, 2025

[Solved]

Hi there,

I am also trying to use theta = 0 and phi = 0 degree for 1D grating diffraction, but the results are weird. (larger than 1)
Maybe my task is a little bit different to yours, but could you help me to find the root cause or give me some suggestion?

Image

Here is my code which I modified from the example in the repository.
I am thinking about the large imaginary part of n and small N_harmonics.

from rcwa.shorthand import complexArray
import numpy as np

def solve_system():
    wavelength = 0.365
    deg = np.pi / 180
    theta = 0 * deg
    phi = 0 * deg
    pTEM = 1/np.sqrt(1)*complexArray([0,1j])
    source = Source(wavelength=wavelength, theta=theta, phi=phi, pTEM=pTEM)
    N_harmonics = 5

    grating_layer = RectangularGrating(period=2, thickness=1.6, er = 10.85241249, ur = 1, n=1.52+3.2943j,
                                        n_void=1, groove_width=0.5, nx=512)
    layer_stack = LayerStack(grating_layer)

    solver_1d = Solver(layer_stack, source, N_harmonics)
    results = solver_1d.solve()

    return results

if __name__ == '__main__':
    results = solve_system()

    # Get the amplitude reflection and transmission coefficients
    (rxCalculated, ryCalculated, rzCalculated) = (results['rx'], results['ry'], results['rz'])
    (txCalculated, tyCalculated, tzCalculated) = (results['tx'], results['ty'], results['tz'])

    # Get the diffraction efficiencies R and T and overall reflection and transmission coefficients R and T
    (R, T, RTot, TTot) = (results['R'], results['T'], results['RTot'], results['TTot'])
    print(RTot, TTot, RTot+TTot)

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants