Ansys Learning Forum Forums Discuss Simulation Photonics Exporting a large number of data sets into TXT from varFDTD Reply To: Exporting a large number of data sets into TXT from varFDTD

Matt Wilson
Subscriber

Apologies. I tweaked my code and it is now iterating through the range of wavelength values. I apear to have a seperate issue now though. I think there is a problem with how I am calculating the E field data from the Ex and Ey componants:

Ex = real(getdata("E_field", "Ex"));

Ey = real(getdata("E_field", "Ey"));

 

E_data = sqrt(Ex^2 + Ey^2);

 

x = getdata("E_field", "x");

y = getdata("E_field", "y");

z = getdata("E_field", "z");

f = getdata("E_field", "f");

 

x_max = length(x);

y_max = length(y);

z_max = length(z);

 

lambda = (c/f) * 10^9;

 

for (m=1:5){

fileName = num2str(lambda(m)) + "nm.txt";

E = E_data(1:x_max, 1:y_max, 1:z_max, m);

write(fileName, num2str(E(1:x_max, 1:y_max)), "overwrite");

}

The E field that is returned by my code differs from the E field that is seen in the monitor. I am pretty certain it is a misunderstanding on my end of how the E field is calculated from the raw data in the monitor. Can you advise how to fix this?