-
-
May 31, 2024 at 11:16 amph23resch01002Subscriber
I am working on Chiral Metasurface. In the metalens example, if we change the parameter, radius, we get a phase shift ranging from 0 to 2*pi. In my problem, I have to vary parameters namely w1, w2 along with the orientation angle of the meta atom (theta) to get a 0 to 2*pi phase shift for circularly polarised light incidence and to maintain a constant transmission coefficient. I use Geometric phase phenomena to get the 0 to 2*pi phase shifts. I have written this code, to find a suitable w1, w2, value for each theta to get a nearly constant transmission and also a phase shift ranging from 0 to 2*pi. I will attach the code below.
num_theta = length(theta);
# Initialize variables
selected_w1_idx = zeros(num_theta, 1);
selected_w2_idx = zeros(num_theta, 1);
selected_w1 = zeros(num_theta, 1);
selected_w2 = zeros(num_theta, 1);
max_L_R_T = zeros(num_theta, 1);
selected_phase = zeros(num_theta, 1);
Â
### Define phase conditions for each theta index
#phase_conditions = [2*pi, 7*pi/4, 6*pi/4, 5*pi/4, pi, pi, 3*pi/4, 2*pi/4, pi/4];
phase_conditions = [2*pi, 8*pi/5, 6*pi/5, 4*pi/5, 2*pi/5, pi/5];
Â
## Loop through each theta value
for (k = 1:num_theta) {
current_theta_index = k; # Current theta index
max_L_R_T(k) = 0; # Initialize to a very low value to ensure it gets updated
selected_w1_idx(k) = 0;
selected_w2_idx(k) = 0;
selected_w1(k) = 0;
selected_w2(k) = 0;
Â
# Loop through w1 and w2 dimensions for the current theta
for (i = 1:length(w1)) {
for (j = 1:length(w2)) {
current_phase = L_R_phase_T(1, 1, i, j, current_theta_index);
current_L_R_T = L_R_T(1, 1, i, j, current_theta_index);
Â
# Print the current values for debugging
?"w1(" + num2str(i) + ") = " + num2str(w1(i)) + ", w2(" + num2str(j) + ") = " + num2str(w2(j));
?"current_phase = " + num2str(current_phase) + ", current_L_R_T = " + num2str(current_L_R_T);
Â
# Check if phase meets the condition for the current theta
if (current_phase <= phase_conditions(k)) {
# Update max_L_R_T if the current transmission coefficient is higher
if (current_L_R_T > max_L_R_T(k)) {
max_L_R_T(k) = current_L_R_T;
selected_w1_idx(k) = i;
selected_w2_idx(k) = j;
selected_w1(k) = w1(i);
selected_w2(k) = w2(j);
selected_phase(k) = current_phase; # Save the corresponding phase value
}
}
}
}
Â
# Print the results for the current theta
?"Results for theta = " + num2str(theta(k)) + ":";
?"Maximum value of T: " + num2str(max_L_R_T(k));
?"This occurs at w1 index = " + num2str(selected_w1_idx(k)) + " and w2 index = " + num2str(selected_w2_idx(k));
?"Selected w1: " + num2str(selected_w1(k));
?"Selected w2: " + num2str(selected_w2(k));
?"Selected phase: " + num2str(selected_phase(k));
}
Â
## Plotting of phase and Transmission coefficients for a particular set of dimensions:
plot(theta,selected_phase *180/pi,"phase (degree)","theta (degrees)","","linewidth=2");
plot(theta,max_L_R_T,"phase (degree)","Transmission","","linewidth=2");
setplot("y min",0);setplot("y max",1);setplot("show legend",false);
Now I am struck with how to find the theta_interpolation just like in the metalens Example.Â
In the metalens, unitcell file, to get the radius_interp = spline(radius phase, phase_interp) was used, where phase_interp = linspace(0, 2*pi, 361).
For my case, I have other parameters namely w1, w2 along with theta to get constant Transmission coefficients along with the phase shifts ranging from 0 to 2*pi, Now I have to find theta_interp value corresponding to every phase_interp value. The dimension of the theta_interp will be [361,1], Now I have to adjust w1, and w2, values for each 361 theta value, such that I get a 0 to 2*pi phase along with the nearly constant transmission coefficients. How do I go about it?Â
I tried to write a code, but nothing worked. The code is attached below.Â
### Define phase_interp with dimension [361,1]phase_interp = linspace(0, 2*pi, 361); # 361 points from 0 to 2*pi
## Initialize the resulting array for interpolated phases
w1_w2_theta_interp = matrix(361, 6, 6, 6);
Â
theta_test = pinch(theta);
Â
# Iterate over w1 and w2 to interpolate L_R_phase for each phase_interp
for (i = 1; i <= length(w1); i = i + 1) {
for (j = 1; j <= length(w2); j = j + 1) {
Â
# Extract the slice of L_R_phase for the current w1, w2, and theta
L_R_phase_slice = pinch(L_R_phase_T(1, 1, i, j, :));
Â
# Ensure L_R_phase_slice is a 1D array
L_R_phase_slice = reshape(L_R_phase_slice, length(theta_test));
Â
# Perform spline interpolation for each phase_interp value
for (p = 1; p <= length(phase_interp); p = p + 1) {
w1_w2_theta_interp(p, i, j, :) = spline(theta_test, L_R_phase_slice, phase_interp(p));
}
}
}
Â
?size(w1_w2_theta_interp);
I am sure this approach is wrong. It would be great if someone could help me write the code or even tell me how to approach it instead of just telling use for loop and so on.
I am looking forward to your reply. Thanks in advance! -
July 3, 2024 at 4:26 amAmrita PatiAnsys Employee
Hi Bharathy,
I apologize for the delay in getting back to you. The forum was under maintenance, so we were unable to write back to you. Since it has been a while since you posted, I would like to ask if you were able to create the code. In the meantime, I will go through it and suggest modifications if needed.
Regards,
Amrita
-
- The topic ‘Doubts in Interpolation in Metalens Example’ is closed to new replies.
- Difference between answers in version 2024 and 2017 lumerical mode solution
- Errors Running Ring Modulator Example on Cluster
- INTERCONNECT – No results unless rerun simulation until it gives any
- Import material .txt file with script
- Trapezoidal ring
- Help for qINTERCONNECT
- Absorption cross-section of AuNR excited by prism-based TIR
- Issues with getting result from interconnent analysis script
- How to measure transmission coefficients on a given plane .
- Topology Optimization Error
-
1416
-
599
-
591
-
565
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.