# for help about s-matrix method

Status
Not open for further replies.

#### shenhongj2004

##### Member level 1
rumpf thesis rcwa fdfd

recently , i wrote a code computing reflectivity of PC slab,BUT i could not get a good result ,so maybe somebody can help me with it , if you can ,go ahead . i need your help badly.

#### rrumpf

##### Full Member level 5
s-matrix rcwa

What method are you using, i.e. method of lines, rigorous coupled-wave analysis, etc.?

-Tip

#### shenhongj2004

##### Member level 1
rcwa s-matrix

the reference which i used for the code is the article titled:" Scattering-matrix treatment of patterned multiplayer photonic structure" PRB 60 2610 (1999)

#### rrumpf

##### Full Member level 5
enhanced transmittance matrix

The s-matrix method is great if you need to stack many unit cells in the longitudinal direction. Otherwise, the enhanced transmittance matrix method is faster and it may be easier to implement. I uploaded my dissertation to a discussion on 3D UPML for FDTD. Chapter 6 describes my formulation of RCWA using the enhanced transmittance matrix method and I provide a detailed block diagram at the end of how to implement the equations. I think you will find RCWA is essentially the same as what is described in the PRB paper you referenced.

Let me know if this is of help.

-Tip

#### shenhongj2004

##### Member level 1
rcwa cos sin method

where can I find your dissertation? I am sure that it will be helpful

-Tip

#### lostinsocorro

##### Member level 2
Rumpf,

I tried to recreate your RCWA code, but I am having an error. I can't get the diffraction efficiency to output values that make very much sense. My code is very organized and commented. If you can please look over it, I'm sure you can quickly find my error.

From one student to another,
lostinsocorro

#### rrumpf

##### Full Member level 5
I took a quick look at your code. The logical flow certainly seems correct so you have the concept of RCWA down pretty well. Congrats! My schedule is pretty hectic right now so I will have to look at your code in pieces as I have time.

One thing that is incorrect is your input polarization. The magnitude of this vector should be 1 if you do not account for it in the calculation of reflection and transmission, which you don't. In your code right now, the magnitude is sqrt(2). Using your notation, for example, your input polarization should be ux0=1/sqrt(2) and uy0=1/sqrt(2) for a linear polarization at 45 degrees with magnitude 1. Since you do not normalize your reflection and transmission coefficient relative to the input field magnitude, this will give you an error. I don't think this will be the complete fix and I will try to look at your code some more over the weekend.

Keep at it!!

-Tip

#### lostinsocorro

##### Member level 2
Thank you so much for your help. It means a lot to me considering I've been pulling my hair out over this problem for the last month.

I redefined the incident wave vector to the following.

ux0=cos(psi)*cos(theta0)*cos(phi0)-sin(psi)*sin(phi0);
uy0=cos(psi)*cos(theta0)*sin(phi0)+sin(psi)*cos(phi0);
uz0=-cos(psi)*sin(theta0);

For the case when psi=45, theta0=0, and phi0=0, I get ux0=1/sqrt(2), uy0=1/sqrt(2), and uz0=0, so that the magnitude is 1. Thanks for the tip on that one.

I also noticed that I didn't multiply 2*pi when I defined my irreducible lattice vector in the file titled input_var.m

And I have an extra 2*pi when I defined x in the file called eps_convo.m. I have x=2*pi*GG when it should be x=GG.

And finally, when I defined the transmission diffraction efficiency, I placed a kz_c (cover wavenumber) value when it should be a kz_s (substrate wavenumber) value.

I now get a list of diffraction efficiencies that look symmetric, but I can't get them to sum up to 100%.

Have you had any luck getting this thing to work? Again, thank you so much for your time.

From one student to another,
lostinsocorro

P.S. When I define the k+G vector in the file titled kvect.m, should I normalize?

Added after 4 hours 42 minutes:

Rumpf,

In your thesis, you define Pi (Eq. 6.52) and Qi (Eq. 6.53). Within those equations, you define inv( epsilon_iz ) , epsilon_ix, and epsilon_iy. What is the difference between these three equations? Can I define them the way I did in my code??

Thanks.

#### rrumpf

##### Full Member level 5
Can you send me your updated code so I don't have to fix problems you already corrected?

In my equations 6.52 and 6.53, the different convolution matrices (eps_ix, eps_iy, and eps_iz) will be the same unless you have an anisotropic material or you are incorporating a Perfectly Matched Layer (PML) boundary condition.

For the term (k+G), you will have to normalize. Think of this expression this way (k + G)/k0. Keep in mind, when you deviate from rectangular symmetry, your convolution matrices need to be calculated differently (can't use FFT). I haven't looked at your convolution code yet to verify this.

-Tip

#### lostinsocorro

##### Member level 2
Oh, I see. So you wrote up a very general RCWA formulation in your thesis. Thanks! A more generalized form (for anisotropic materials) will serve to be very useful for me later on once I get my head screwed on tight.

Ok, so here is the updated version. My diffraction efficiencies look symmetric but don't add up to 1. I'm still a bit confused. I'm still not sure if my overall formulation is correct or if my k-vectors might be the problem.

Thank you so much. Perhaps my advisor will think I'm cool again...

#### rrumpf

##### Full Member level 5
Good. The thing we need to do from here is to check your matrices one step at a time. First, we'll verify that your convolution matrix is the same as mine. Then we'll verify that your K matrices are the same as mine. Then we'll verify that the eigenmodes are the same. And etc.

If your matrices are different, that doesn't necessarily mean they are wrong or that you did anything incorrectly. We may just be ordering terms differently, normalizing differently, etc. It will, however, make troubleshooting more difficult. For this reason, we may want to modify your codes to produce the same matrices as mine. Once you get something working, then you can do whatever you wish.

Just to let you know, this discussion is titled "s-matrix method." I have RCWA codes based on s-matrices and the enhanced transmittance matrix approach. The ETM is 10 times faster than s-matrices, so unless there is a specific reason to use s-matrices, I would not recommend using them. It looks like your code is just a single layer so neither method really applies to you yet.

-Tip

#### lostinsocorro

##### Member level 2
Thank you, Rumpf. My email address is lostinsocorro at gmail dot com in case you might have any questions that need to be answered right away.

#### lostinsocorro

##### Member level 2
I've got a really quick question. How to define Epsilon_ix and Epsilon_iy seems to make a lot of sense to me, but I'm confused about how to define Epsilon_iz inside a photonic crystal slab. Is Epsilon_iz the permittivity of the bulk material, or is there an equation out there that defines some sort of average permittivity in the z-direction. I believe this might be my error in my code! Thanks.

Sincerely,
lostinsocorro

#### lostinsocorro

##### Member level 2
Problem solved. For those interested in fixing my code, be careful with how you define your matrices. Many of the matrices used in the code are not diagonal when they should be. For example, the exponential equation that contains the eigenvalues is not correct. First, undiagonalize the eigenvalues, perform your exp(-k0*eigenvalues*depth) multiplication, then diagonalize diag(exp(stuff)). Also, be sure to use a diagonal matrix such as the eye function for constants... This will make more sense if you choose to tackle this problem. I believe the epsilon convolution matrix is correct, and how I defined the k vectors. Oh, be especially careful with those k vectors when using them. Ask yourself constantly, is the matrix form of this correct?

As I've learned myself, this would not be a learning experience if the answers were handed to you, but a good start is always beneficial. If you analyze my code, you should be able to get S-Matrix RCWA working for you.

#### Krzysztow

##### Newbie level 5
Good day everyone,

the Dissertation by Rrumpf is very helpful. I think, at last I'll understand that. But there are still some uncertanities hidden, I'd like You to explain.

When there are defined reciprocal unit vectors G1 and G2 in (6.14) these are Gi=2*pi/(LAMBDA)? LAMBDA is the grating vector. Or maybe it has to be divided by refractive index. I think rather the second option is fine, but then what refractive index? of the grating material or the preciding material, or maybe some effective on, that is a weighted value.

Please, help me with that question. I'd be really thankfull.

Status
Not open for further replies.