About script:
In most cases, the basic simulation modules available within OlympIOs
offer sufficient capabilities for optimization of the relevant component
parameters. However, in some cases lengthy and complex optimization procedures
require more flexibility. The script module offers this increased optimization
flexibility.
Script module benefits:
The script module allows for batch processing of many sequenential simulation
job. The scripting language provides direct access to most of the internal
capabilities of the software and includes conditional statements according
to its c-like syntax. Design engineers can now automatically change devices
based on the results of previous simulations to create optimum design
solutions that are practically impossible to achieve using the standard
one, two variables at a time optimization strategy.
Features:
- Batch processing of simulation sequences
- Compatibility with all other OlympIOs modules
- Direct access to simulation results via a variety of built-in functions
- Flexible optimization control (vary parameters with conditional
statements)<
Application example:
The following application note demonstrates the capabilities
of our script module. Full details will soon be available at our
website.
Evolutionary design of a spot-size converter using the script module:
An evolutionary algorithm is a robust, stochastic design method
based on the concepts of natural selection and evolution. The algorithm
is especially useful for finding (approximate) solutions to complex
design problems, in which a large number of unrelated variables
have to be optimized simultaneously. The algorithm simulates the
evolution of a group (population) of trial solutions (individuals)
by simulating the processes of birth and death. By promoting the
survival rate of the best-performing (fittest) individuals, the
population naturally evolves towards an optimum solution. After
a number of generations, the best-performing individual in the population
is taken as the solution to the design problem.
This application note describes the implementation of an evolutionary
algorithm using the script module of OlympIOs. The algorithm is
based on the work of Spühler et al [1],
in which a segmented-waveguide spot-size converter is designed.
After defining the simulation structure in the BPM module and programming
the algorithm using the scripting facilities, the genetic algorithm
is run automatically. The result returned is the best performing
structure (Figure 2) with substantially improved coupling efficiency
relative to the initial design (Figure 3). |



|
Script detailed examples
The script language gives access to large portions of OlympIOs. This can
be used for a variety of applications, but the section below will focus
on a few main tasks which are often applied. A few topics for more complex
applications are also addressed.
What is a script?
A script within OlympIOs works comparable to other scripting languages.
A series of commands is stored in a text file and can be used later to
perform the same actions again. If those actions are defined correctly,
you can also apply them on other designs and thus have a general tool.
The OlympIOs scripts look a lot like C, so if you are familiar with this
language this will help a lot in using scripts. The focus of a script is thus to automate things which you use often
or are too repeatative for human interaction. The OlympIOs scripts give
access to many parts of the program and using this you can customize it. The following paragraphs show potential scripts covering a wide range
of applications.
Menu actions
The script language gives access to most of the menues by using the special
script functions. A few examples script will be given which show the different
menues. The examples are not general, since this would increase the size
of the example without adding usefull information.
Open a file, start a simulation and save results
A typical application is to run a batch of simulations, which run during
the night. To reduce on the required amount of memory, it is easier to
start those things after each other then at the same time on a machine.
The following script shows this, for 2 files.
// The first run
file::open("/batch/file1.dev");
sim::bpm();
result::saveas("/batch/file1.ica");
// And the second
file::open("/batch/file2.dev");
sim::bpm();
result::saveas("/batch/file2.ica");
Alternative vary simulation
The normal vary run is able to vary one variable or in OlympIOs 2 variables
over an equidistant grid. This is not allways the thing you want. Suppose
for example that you have defined a structure with 3 variables (A, B and
C) which are varied in combination.
A script to do this might look like the following:
var i; // An internal script variable
series (i in [0,1,3,7]) {
A=i+2;B=10*i-7;C=cos(i); // Update our structure based on i
sim::bpm();
}
Sequence of simulations
Another application would be to run a series of simulations on a single
structure. Since some calculations can be time consuming, it is usefull
to start a script with those command rather then starting them manually.
// Use EIM method
sim::mode(); // Start a mode calculation
sim::fieldDim(); // and run a field dimension fit
sim::modeopt(opt_method='bend'); /* And change the mode solver */
sim::mode();
sim::fieldDim();
Report generation
Often a user defined output format is usefull to link the result of simulations
to external programs, eg. for post processing. Suppose we have a simple
design which is dependent on a variable A and has two simulate-overlap
elements called out1 and out2. Rather then having a few pictures we want
a simple table in a text file.
The following scripts give an indication of the possibilities.
Row output
The following script simply uses a line based table, with both input and
results on the same line.
f=open(file,"result.txt"); // Open the required file
fprintf(f,"i\tA\tout1\tout2\tout1/out2\n");
for(i=0;i<10;i++) {
A=5+i*3; // update structure
result::clear();
sim::bpm();
var o1=res_Plane_Overlap(0,"out1",0),o2=res_Plane_Overlap(0,"out2",0);
fprintf(f,"%g\t%g\t%g\t%g\t%g\n",i,A,o1,o2,o1/o2);
}
close(f);
Column output
Another form would be to have not row based information, but column based.
The script allows to have arrays, so we can simply store the intermediate
results in an array and write them at the end.
var i,cnt=0,aa[double,100],o1[double,100],o2[double,100];
for(i=0;i<10;i++) {
aa[cnt]=A=5+i*3; // update structure
result::clear();
sim::bpm();
o1[cnt]=res_Plane_Overlap(0,"out1",0);
o2[cnt]=res_Plane_Overlap(0,"out2",0);
cnt++;
}
var f;
f=open(file,"result.txt"); // Open the required file
fprintf(f,"A");
for(i=0;i<cnt;i++) fprintf(f,"\t%g",aa[i]);
fprintf(f,"\no1");
for(i=0;i<cnt;i++) fprintf(f,"\t%g",o1[i]);
fprintf(f,"\no2");
for(i=0;i<cnt;i++) fprintf(f,"\t%g",o2[i]);
fprintf(f,"\n");
close(f);
Matrix output
The normal 2D vary of OlympIOs puts the resulting numbers in a 2D picture,
which can not directly be postprocessed. Suppose that we are not interested
directly in out1 and out2, but in a formula like abs(out1-out2)/(out1+out2)
and add a second variable B to vary over the structure. We do want the
result again in a file.
var i,j,cnt,res[double,10][4];
for(i=0;i<10;i++) {
cnt=0;
series (j in [0,2,6,7]) {
A=5+i*3; // update structure
result::clear();
sim::bpm();
var o1=res_Plane_Overlap(0,"out1",0),o2=res_Plane_Overlap(0,"out2",0);
res[i][cnt++]=abs(o1-o2)/(o1+o2);
}
}
var f;f=open(file,"result.txt");
for(i=0;i<10;i++) {
for(j=0;j<cnt;j++)
fprintf(f,"%g\t",res[i][j]);
fprintf(f,"\n");
}
close(f); Optimization
Simulating a design gives a good idea of its potential performance and
gives insight in the behaviour of it. Although this is interesting in
itself, often more information is needed or a an optimization of a structure
with respect to some requirements is needed.
Since it is not possible to define a general way for an optimal design
due to varying boundary conditions, tolerance requirements and so on it
usefull to have a flexible approach for it. The following scripts show the essential part of changing your design
from a script, performing a simulation and use these results to optimize
a design.
Optimal throughput
A simple application for integrated optics would be to have a symmetric
1->2 power splitter, which should be optimized with respect to some
variable A (eg. a straight - bend offset). The amount of power should
be maximal. The output plane is labeled 'out'.
outmax=find (a in [0,100] max(res)) {
if(a<0) { // invalid range
res=0;
continue;
}
result::clear();
A=a;sim::bpm();
res=res_Plane_Overlap(0,"out",0);
}
printf("Maximal value %g for A=%g\n",outmax,a);
Maximum tolerance
Another optimization might be for tolerance. Suppose we have the same
splitter again, but now we want maximum tolerance for the waveguide width,
represented by a variable B. The tolerance is defined as outputpower(B)-outputpower(B*1.001).
outmax=find (a in [2,100] max(res)) {
result::clear();
// first simulation, normal waveguide width
B=a; sim::bpm();r1=res_Plane_Overlap(0,"out",0);
// first simulation, expanded waveguide width
B=a*1.001;sim::bpm();r2=res_Plane_Overlap(0,"out",0);
res=abs(r1-r2);
}
printf("Maximal value %g for A=%g\n",outmax,a);
1*many splitter
A more complex thing would be to obtain the best power throughput for
a 1 to many splitter. The amount of outputs is defined by the DEV variable
Nout and the outputs are called out0..outN. We can vary a few variables,
say A, B and C.
In addition to have maximum throughput we need require also that the power
variation should be minimal, so the optimal function is a bit more complex.
var nchan=Nout,a,b,c,res,oi[nchan];
find (a in [10,1],
b in [1,0.1], c in [5,2]
max(res)) {
if(a<2 || a>50 || b<-5 || b>100) { // invalid range
res=0;
continue;
}
result::clear();
A=a;B=b;C=c;sim::bpm();
var i,sum=0,maxdif=0,avg;
for(i=0;i<nchan;i++) {
oi[i]=res_Plane_Overlap(0,"out"+i,0);
sum=sum+oi[i];
}
avg=sum/nchan;
for(i=0;i<nchan;i++) {
var d=abs(avg-oi[i]);
if(d>maxdif) maxdif=d;
}
// The response function. We appreciate variation in power less then
total power
res=1/(maxdif+1E-3)*sum;
} Algorithms
Another very usefull topic is using OlympIOs as a base for the development
of your own algorithm. The mode solvers or BPM's are used within your
own program, which can be written in the script and the output can either
be written to file or the result database of OlympIOs.
A few algorithms which have been made are shown in the following list.
The scripts themselves are confidential and/or from customers and can
therefore not be published.
Mode propagation
The well-known Bidirectional Eigenmode Propagation can be improved for
certain applications by assuming that the mode coupling is slowly varying,
eg a tapered waveguide. The coupling coefficients between all modes can
be calculated using OlympIOs. With a specified input field it is therefore
possible to calculate the series of modes available at all Z-positions
and it is therefore possible to calculate the end field. Genetic algorithm
A general optimization method which assumes little of the structure is
the genetic algoritm. To apply this technique in OlympIOs is reasonably
straightforward and needs (apart from the genetic algorithm itself) a
way to define a structure, perform some simulation and use the results
from this in the genetic algorithm to define a fitness.
Since the input files for OlympIOs applications are ASCII it is possible
to generate them from a script using an approach as described at the Report
Generation. A simple version of such an algoritm would therefore be:
var vars[10],i
for(i=0;i<10;i++) vars[i]=i;
function write_dev_file(filename) {
var f;f=open(file,filename);
fprintf(f,"// DEV file from script\n");
fprintf(f,"include \"material.dev\";\n");
var i;
for(i=0;i<10;i++)
fprintf(f," variable(Name=\"A%d\",Value=%g);\n",i,vars[i]);
fprintf(f,"include \"structure.dev\";\n");
}
function genetic() {
// update vars[0..10] using a genetic algoritm
}
// Just run a 1000 iterations
for(i=0;i<1000) {
write_dev_file("/tmp/generated.dev");
file::open("/tmp/generated.dev");
sim::bpm();
// get simulation results, see other examples
getresults();
genetic();
} 1. M. Spühler et al, "A generalized evolutionary
optimization procedure applied to waveguide mode treatment in non-periodic
structures", ECIO 1997. |