Ansys Learning Forum Forums Discuss Simulation Photonics Optimization script writing Reply To: Optimization script writing

Afroditi Petropoulou
Ansys Employee

Dear Bailin,

 

An indicative script for the optimization that you describe is the following:

 

lambda_cond=450e-9; # wavelength to be used as a condition

 

lambda=grating_orders.lambda;

Ts=grating_orders.Ts_grating; # result that we need to optimize

target_order_b = 1; # the diffraction order for blue

target_order_rg = 0; # the diffraction order for red and green

 

n = grating_orders.n;

index_b = find(n, target_order_b);

index_rg = find(n, target_order_rg);

 

fom=0;

 

for (i=1:length(lambda)) {

    if (lambda(i)

        fom=fom+Ts(i,1,index_b,1);

    } else {

        fom=fom+Ts(i,1,index_rg,1);

    }

}

 

In this case you need to use maximize in the optimization fom type:

 


 

In the above script the transmission for s-polarized light is used for the optimization. You can change it to p-polarization or you can use the average of the two.

 

Also, please keep in mind that the fom used in the script is the maximum transmission for all three wavelengths (the sum of transmission of red in 0th order, of green in 0th order and blue in 1st order). If you have other constrains you can add them to the script.

 

For the simulation you can set the wavelengths in the excitation tab of RCWA (in order to have the specific three wavelengths) as below:

 


 

Best regards,

Afroditi