-
-
September 2, 2024 at 2:51 pmtim.fuhrmannSubscriber
Hello,
I want to modify my measured material parameters in order to study the effect of perturbations of my measurements on my simulation.
To manipulate the data, I use MATLAB and save it as a .txt file. Then I want to import my data via a script from this .txt file. The .txt file is a three-column table with the first column being the wavelength, the second one is the real index, and the third one is the imaginary index. The material is not anisotropic. There is no problem at all with this type of file if I import it manually.
If I use the following script, I only use the wavelength and Re{index} column, to import my .txt file:
filename = "test.txt";
sampledData = readdata(filename);
rows = size(sampledData, 1);
sampledData_modi = zeros(rows,2);
sampledData_modi(:,1) = sampledData(:,1);
sampledData_modi(:,2) = sampledData(:,2);
test_material = addmaterial("Sampled 3D data");
setmaterial(test_material, "name", "4 Test");
setmaterial("4 Test", "sampled data", sampledData_modi);
setmaterial("4 Test", "Anisotropy", 0);
I get the correct wavelength imported as well as the correct real part of the refractive index.
If I now add one column and populate it with the imaginary part from the .txt file:
filename = "test.txt";
sampledData = readdata(filename);
rows = size(sampledData, 1);
sampledData_modi = zeros(rows,3);
sampledData_modi(:,1) = sampledData(:,1);
sampledData_modi(:,2) = sampledData(:,2);Â
sampledData_modi(:,3) = sampledData(:,3);
test_material = addmaterial("Sampled 3D data");
setmaterial(test_material, "name", "4 Test");
setmaterial("4 Test", "sampled data", sampledData_modi);
setmaterial("4 Test", "Anisotropy", 0);
I get the error: the number of columns for the data in 'sampled 3d data' should be either 2 or 4
If I just add one column of zeros:
filename = "test.txt";
sampledData = readdata(filename);
rows = size(sampledData, 1);
sampledData_modi = zeros(rows,4);
sampledData_modi(:,1) = sampledData(:,1);
sampledData_modi(:,2) = sampledData(:,2);
sampledData_modi(:,3) = sampledData(:,3);
test_material = addmaterial("Sampled 3D data");
setmaterial(test_material, "name", "4 Test");
setmaterial("4 Test", "sampled data", sampledData_modi);
setmaterial("4 Test", "Anisotropy", 0);
The table is not properly imported.
Is there a way so solve this issue or work around it?ÂBest regards,Â
Tim -
September 13, 2024 at 11:48 pmGuilin SunAnsys Employee
Sorry to reply you late as something happend.
When the material has complex refractive index or permittivity, please directly use the complex data.
Please refer to this example: https://optics.ansys.com/hc/en-us/articles/360034409654-setmaterial-Script-command
-
September 16, 2024 at 3:52 pmtim.fuhrmannSubscriber
Hello,
Thank you for your reply.Â
I am using the complex data. However, I have the following problem, when using the setmaterial function:- My data has three columns: wavelength, real part of the index, and imaginary part of the index
- setmaterial with the property name "sampled data" only takes 2 or 4 inputs.
- If I use only two,I don't get the imaginary part, if I take 4, even though I have only 3 in my data set (I set the last column to zero), I get wrong material parameters
Thank you for your help and best regrds,
TimÂ
-
- You must be logged in to reply to this topic.
-
1091
-
447
-
375
-
225
-
201
© 2024 Copyright ANSYS, Inc. All rights reserved.