Example #1
0
void reflTrans(const mlgeo &g, double k0, double theta, int pol, 
				cdouble *r, double *R, cdouble *t, double *T) {
	SMatrix S = new SMatrix(g, k0, k0 * sin(theta));
	*r = S->S21(0, g.N, pol);
	*t = S->S11(0, g.N, pol);
	*R = (*r) * conj(*r); 
	*T = real(sqrt(g.eps(N))) / real(sqrt(g.eps(0))) * (*t) * conj(*t); 
}
Example #2
0
// compute just the partial waves in layer l
//   Splus and Sminus taken out, inserted in flux eqn. (as in Francoeur)
void pWavesL(const SMatrix &S, int l, int s, int pol, pwaves *p) {
	int N = S.N;
	if (s==0) { // emitting half-space
		p->Cl = 0; // no waves emitted in the backward direction
		p->Dl = 0;
		if (l==0) {
			p->Al = 0;
			p->Bl = S.S21(l,N,pol);
		} else {
			p->Al = S.S11(0,N,pol) / S.S11(l,N,pol);
			p->Bl = S.S21(l,N,pol) * p->Al;
		}
	} else if (s==N) {
		p->Al = 0; // no waves in forward dir
		p->Bl = 0;
		if (l==N) {
			p->Dl = 0;
			p->Cl = S.S12(0,l,pol);
		} else {
			p->Dl = S.S22(0,N,pol) / S.S22(0,l,pol);
			p->Cl = S.S12(0,l,pol) * p->Dl;
		}
	} else {
		// partial waves in s,0,N layers (A0=BN=C0=DN=0)
		cdouble Bs = S.S21(s,N,pol) / (1. - S.S12(0,s,pol)*S.S21(s,N,pol)) ; 
		cdouble As = S.S12(0,s,pol) * Bs;
		cdouble B0 = S.S22(0,s,pol) * Bs;
		cdouble AN = S.S11(s,N,pol) * (As + 1.);
		cdouble Cs = S.S12(0,s,pol) / (1. - S.S12(0,s,pol)*S.S21(s,N,pol));
		cdouble Ds = S.S21(s,N,pol) * Cs;
		cdouble CN = S.S11(s,N,pol) * Cs;
		cdouble D0 = S.S22(0,s,pol) * (Ds + 1.);
		if (l==s) { // flux, emitter in same layer
			p->Al = As;
			p->Bl = Bs;
			p->Cl = Cs;
			p->Dl = Ds;
		} else if (l<s) { // flux to the left of emitter
			p->Bl = B0 / S.S22(0,l,pol);
			p->Al = S.S12(0,l,pol) * p->Bl;
			p->Dl = D0 / S.S22(0,l,pol);
			p->Cl = S.S12(0,l,pol) * p->Dl;
		} else { // flux to the right of emitter
			p->Al = AN / S.S11(l,N,pol);
			p->Bl = S.S21(l,N,pol) * p->Al;
			p->Cl = CN / S.S11(l,N,pol);
			p->Dl = S.S21(l,N,pol) * p->Cl;
		}
	}
}