TAGGED: script
-
-
May 25, 2024 at 7:16 am
211123090062
SubscriberReference formula:
The error prompt:
My code is as follows:
setanalysis("wavelength",1.55e-6);
findmodes;
Ex1=getdata("mode1","Ex");
Ey1=getdata("mode1","Ey");
Ez1=getdata("mode1","Ez");
Hx1=getdata("mode1","Hx");
Hy1=getdata("mode1","Hy");
Hz1=getdata("mode1","Hz");
E11=getresult("mode1","E");
x1=getdata("mode1","x");
y1=getdata("mode1","y");
z1=getdata("mode1","z");
setanalysis("wavelength",0.775e-6);
findmodes;
Ex2=getdata("mode7","Ex");
Ey2=getdata("mode7","Ey");
Ez2=getdata("mode7","Ez");
Hx2=getdata("mode7","Hx");
Hy2=getdata("mode7","Hy");
Hz2=getdata("mode7","Hz");
E21=getresult("mode7","E");
x2=getdata("mode7","x");
y2=getdata("mode7","y");
z2=getdata("mode7","z");
E1=sqrt((abs(Ex1))^2+(abs(Ex1))^2+(abs(Ex1))^2);
E2=sqrt((abs(Ex2))^2+(abs(Ey2))^2+(abs(Ez2))^2);
I want to know how to solve this error problem. If there is an error in my code, how should I write the correct code? I would greatly appreciate it if you could provide an answer!
Â
-
May 27, 2024 at 5:37 pm
Amrita Pati
Ansys EmployeeHi 宇 范,
Are you using the intensities to caluclate the mode overlap? I believe the simplest approach would be to load the mode data into the global decks and then use the overlap script command. You can try something like this:
setanalysis("wavelength",1.55e-6);
findmodes;
copydcard("mode1","test_mode_1");
switchtolayout;
setanalysis("wavelength",0.775e-6);
findmodes;
copydcard("mode7","test_mode_2");
ol = overlap("test_mode_1","test_mode_2");Feel free to let me know if you have any questions or concerns.
Â
Regards,
AmritaÂ
-
May 27, 2024 at 9:36 pm
Amrita Pati
Ansys EmployeeHi 宇 范,
I just realized that the overlap will be different as this is for SHG. This looks like a size mismatch error to me. Would you be able to share the screenshot of the line of code that is causing the error? What I will suggest you to do is make sure that the individual data/matrix you are using have the right sizes. You can use the size script command to look at the size of each variable and make sure that when you are multiplying two matrices, their sizes are matching.Â
regards,
Amrita -
June 2, 2024 at 4:12 am
211123090062
SubscriberHello, I'm sorry for replying so late. The following is a screenshot of the code line that caused the error:
Where E11=getresult("mode1","E"),E1=sqrt((abs(Ex1))^2+(abs(Ex1))^2+(abs(Ex1))^2);
I entered the code based on the overlap coefficient calculation formula,and used the "size" you provided to check the size, but I don't know how to adjust it to avoid errors. If you could tell me the method, I would greatly appreciate it!
-
June 3, 2024 at 8:13 pm
Amrita Pati
Ansys EmployeeHi 宇 范,
You may first run your script. Although it will throw an error it will still store E11 and E1 in the local workspace.
Then you can run ?size(E11); in the Script Prompt. Followed by ?size(E1); The question mark will return the size as shown below:
What are the sizes returned by both matrices?
Regards,
Amrita -
June 4, 2024 at 5:15 am
211123090062
SubscriberHello, Dear Amrita Pati!
After running the script and checking the matrix size,it shows that E11 is not a matrix type:
I realized it could be a numerical value.But isn't it defined in the formula as the square of the electric intensity? So I changed the formula to the following:
E111=(abs(Ex1))^2+(abs(Ey1))^2+(abs(Ez1))^2;
E211=(abs(Ex2))^2+(abs(Ey2))^2+(abs(Ez2))^2;E1=sqrt((abs(Ex1))^2+(abs(Ey1))^2+(abs(Ez1))^2);
E2=sqrt((abs(Ex2))^2+(abs(Ey2))^2+(abs(Ez2))^2);
norm1 = integrate( E111*E1,1:2,x_new,y_new );
norm2 = integrate( E211*E2,1:2,x_new,y_new );
tempA = integrate( (conj( Ez1_temp))^2*Ez2_temp,[1,3],x_new,y_new );
overlap_result = tempA / (abs( norm1 ))^(2/3)/(abs(norm2))^(1/3);?'overlap_result' +' = '+ num2str(overlap_result);But after running, the following error occurred:Âand the sizes returned  are:I don't know where I went wrong...
-
- The topic ‘How to calculate modal overlap coefficient during the second harmonic generation’ is closed to new replies.
- Difference between answers in version 2024 and 2017 lumerical mode solution
- Errors Running Ring Modulator Example on Cluster
- Import material .txt file with script
- 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
- Edge Coupler EME Example Issue
- Problem on recording the E field in 2d polarizer simulation
-
1962
-
886
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.