Você está na página 1de 4

ComplexAmplitude ca = (ComplexAmplitude)InputField[0].

Clone();
Globals.DataDisplay.LogMessage("ca_centraldirection:" + ca.CentralDirection.ToString());
//ComplexAmplitude ca = ExtractLinearPhaseInSpatialDomain_LT(ca_0);
//Globals.DataDisplay.ShowDocument(ca_0, "ca_0");
//Globals.DataDisplay.ShowDocument(ca, "ca");
double lambda = ca.Wavelength;
double k_0 = MathFunctions.TwoPi / lambda;
//Define a new DataArray2D to record the ux, uy, uz
SamplingParameters SP = new SamplingParameters(new Vector((int)Sx, (int)Sy), new
VectorD(Thickness / Sx, Width / Sy));
PhysicalProperty[] unit = new PhysicalProperty[] { PhysicalProperty.NoUnit,
PhysicalProperty.NoUnit, PhysicalProperty.NoUnit };
string[] label = new string[] { "Ex", "Ey", "Ez" };
ComplexField ux = new ComplexField(SP.SamplingPoints);
ComplexField uy = new ComplexField(SP.SamplingPoints);
ComplexField uz = new ComplexField(SP.SamplingPoints);
ComplexField Ex = new ComplexField(SP.SamplingPoints);
ComplexField Ey = new ComplexField(SP.SamplingPoints);
ComplexField Ez = new ComplexField(SP.SamplingPoints);

Vector RayNumber = new Vector(ca.SamplingPoints);


for (int InY = 0; InY < RayNumber.Y; InY++)
{
for (int InX = 0; InX < RayNumber.X; InX++)
{
VectorD StartingPoint =
CoordinateTransformations.PointFromPixelToPhysicalCoordinates(new Vector(InX, InY),
ca.SamplingParameters);
//Globals.DataDisplay.LogMessage("position:"+StartingPoint.ToString());
// initialize the (r,s,OPL,u,T,E,|E|)
//u_0?????????????????????????????
//Vector3C u = u_generator(ca, StartingPoint);
Vector3C E_0 = new Vector3C();
E_0.X = ca[InX, InY, false];
if (ca.IsLocallyPolarized == true)
{
E_0.Y = ca[InX, InY, true];
}
else
{
E_0.X = ca.JonesVector.X * ca[InX, InY, false];
E_0.Y = ca.JonesVector.Y * ca[InX, InY, false];
}
Complex n_before = SurroundingMaterial.GetComplexRefractiveIndex(lambda);
//r_0
Vector3D r = new Vector3D(StartingPoint.X, StartingPoint.Y, 0);
List<Vector3D> intermediatePoints = new List<Vector3D>();
Complex n_GRIN = GRIN.GetComplexRefractiveIndex(r, lambda);
Vector3D s = new Vector3D();
Vector3D s_0 = StartDirection(ca, new Vector(InX, InY), StartingPoint);

s.X = s_0.X * n_before.Re / n_GRIN.Re;


s.Y = s_0.Y * n_before.Re / n_GRIN.Re;
s.Z = Math.Sqrt(1 - s.X * s.X - s.Y * s.Y);

//
List<Complex> TransferMatrix = TransferMatrix_WithCoating(plane, n_before,
n_GRIN, lambda, s_0, true);
Vector3C E = new Vector3C();
E.X = TransferMatrix[4] * E_0.X + TransferMatrix[5] * E_0.Y;
E.Y = TransferMatrix[6] * E_0.X + TransferMatrix[7] * E_0.Y;
E.Z = -(s.X * E.X + s.Y * E.Y) / s.Z;
Vector3C u = new Vector3C(E);
u.Normalize();
double I = E.Norm() * s.Z;
//T_0
Vector3C T = GRIN.GetComplexRefractiveIndex(r, lambda) * (Vector3C)s;
//OPL_0
Complex OPL = (s.X * StartingPoint.X + s.Y * StartingPoint.Y) * n_GRIN;
if (ca.HasSphericalPhaseRadius == true)
{ OPL += k_0 * n_GRIN * Math.Sqrt(StartingPoint.Norm() + ca.SphericalPhaseRadius
* ca.SphericalPhaseRadius); }
Vector3C k_1, k_2, k_3, k_4;
Vector3D r_prime, s_prime;
Vector3C T_prime;
Complex OPL_prime;
Complex n_1, n_2, n_3;
for (int ti = 1; r.Z < Thickness; ti++)
{
//Globals.DataDisplay.LogMessage(r.ToString());
intermediatePoints.Add(r);
n_1 = GRIN.GetComplexRefractiveIndex(r, lambda);
k_1 = -(u | D(r, GRIN, lambda)) / n_1 * T / n_1;
RK4_RayEquation(r, T, OPL, dt / 2, GRIN, lambda, out r_prime, out T_prime, out
s_prime, out OPL_prime);
n_2 = GRIN.GetComplexRefractiveIndex(r_prime, lambda);
k_2 = -((u + dt / 2 * k_1) | D(r_prime, GRIN, lambda)) / n_2 * T_prime / n_2;
k_3 = -((u + dt / 2 * k_2) | D(r_prime, GRIN, lambda)) / n_2 * T_prime / n_2;
RK4_RayEquation(r_prime, T_prime, OPL_prime, dt / 2, GRIN, lambda, out r, out T,
out s, out OPL);
n_3 = GRIN.GetComplexRefractiveIndex(r, lambda);
k_4 = -((u + dt * k_3) | D(r, GRIN, lambda)) / n_3 * T / n_3;
u += dt / 6 * (k_1 + 2 * k_2 + 2 * k_3 + k_4);
u.Normalize();
//output
if (r.Y == 0)
{
Vector SampIndex =
CoordinateTransformations.PointFromPhysicalToPixelCoordinates(new VectorD(r.X, r.Y), new
SamplingParameters(new Vector(SP.SamplingPointsY, SP.SamplingPointsY), new
VectorD(SP.SamplingDistance.Y, SP.SamplingDistanceY)));

int SampIndexZ = (int)(r.Z / SP.SamplingDistanceX);


ux[SampIndexZ, SampIndex.X] = u.X;
uy[SampIndexZ, SampIndex.X] = u.Y;
uz[SampIndexZ, SampIndex.X] = u.Z;
Ex[SampIndexZ, SampIndex.X] += Math.Sqrt(I / s.Z) * u.X *
Complex.Exp(Complex.i * k_0 * OPL);
Ey[SampIndexZ, SampIndex.X] += Math.Sqrt(I / s.Z) * u.Y *
Complex.Exp(Complex.i * k_0 * OPL);
Ez[SampIndexZ, SampIndex.X] += Math.Sqrt(I / s.Z) * u.Z *
Complex.Exp(Complex.i * k_0 * OPL);
//Globals.DataDisplay.LogMessage(u.ToString());
}
// Globals.DataDisplay.LogMessage(u.ToString());
}

ComplexFieldArray a = new ComplexFieldArray(3);


a[0] = ux;
a[1] = uy;
a[2] = uz;
DataArray2D u_xz = new DataArray2D(a, unit, label, SP.SamplingDistanceX, 0,
PhysicalProperty.Length, "z", SP.SamplingDistanceY, -Width / 2, PhysicalProperty.Length, "x");
a[0] = Ex;
a[1] = Ey;
a[2] = Ez;
DataArray2D E_xz = new DataArray2D(a, unit, label, SP.SamplingDistanceX, 0,
PhysicalProperty.Length, "z", SP.SamplingDistanceY, -Width / 2, PhysicalProperty.Length, "x");
//Globals.DataDisplay.LogMessage("no problem");
// DataArray2D u_xz = new DataArray2D(new ComplexFieldArray(ux, uy, uz), unit, label,
SP.SamplingDistanceX, 0, PhysicalProperty.Length, "z", SP.SamplingDistanceY, -Width / 2,
PhysicalProperty.Length, "x");
// Globals.DataDisplay.ShowDocument(u_xz, "u_xz");
Globals.DataDisplay.ShowDocument(E_xz, "E_xz");
//Define the back plane of bounding box for inversely propagation
//Globals.DataDisplay.LogMessage("u is:" + u.ToString() + ";r is:" + r.ToString() + ";s is:" +
s.ToString() + ";AbsolutePhase:" + OPL.ToString());
ComplexAmplitude uxy = new ComplexAmplitude(Ex, Ey);
// ComplexAmplitude uxz = new ComplexAmplitude(ux, uz);
uxy.SamplingParameters = SP;
// uxz.SamplingParameters = SP;
//Globals.DataDisplay.ShowDocument(uxy, "uxy");
// Globals.DataDisplay.ShowDocument(uxz, "uxz");
//Globals.DataDisplay.LogMessage("After OPL is:"+OPL.ToString());
#endregion
ca.LFO_CoordinateSystem.Origin.Coordinates = new Vector3D(0, 0, Thickness);
hfsReturn.Add(ca);
return ca;

Você também pode gostar