Software

… powerful tools for your research & development!

Why Scriptable Simulation Software Is So Much More Versatile

Posted on 2026-10-07 as part of the RP Photonics Software News (available as e-mail newsletter!)

Permanent link: https://www.rp-photonics.com/software_news_2026_10_07.html

Author: Dr. Rüdiger Paschotta, RP Photonics AG

Abstract: Simulation software with a powerful script language can solve problems which its developer never anticipated. Examples from RP Coating and RP Fiber Power show how far that goes, and why users do not need to be programmers to profit from it.

Simple simulation software tools offer something like an input form for entering input parameters, and possibly also for showing calculated outputs. That's easy for a start, and as long as your problem fits into the given scheme, all is fine. But in research and development, problems often do not fit: You need a diagram which is not offered, a quantity which is not displayed, or even a calculation which the developer has simply not thought of.

Software which supports scripting behaves differently. Here, you describe in some text form what should be calculated and displayed, and that description may contain things which nobody else has anticipated. In this article, I want to show with concrete examples how much versatility results from that. I also want to address a common concern: that scripting is only for people with programming skills. That is not the case, as you will see.

A Simple Example

Let us begin with our thin-film design software RP Coating. Suppose that we want to analyze a Gires–Tournois interferometer (GTI) — a multilayer structure which is used for dispersion compensation in mode-locked lasers. It consists of a Bragg mirror, a thicker layer and a thin top layer. In a script, we can define it as follows:

l_Bragg := 1000  { Bragg wavelength }
N_Bragg := 10  { number of layer pairs }
d_t := 3.25 * l_Bragg / n_SiO2(l_Bragg * l_units)

beam from superstrate
substrate: BK7
for j := 1 to N_Bragg do
begin
* TiO2, l / 4 at l_Bragg
* SiO2, l / 4 at l_Bragg
end
* SiO2, d = d_t { thick  SiO2 layer }
* TiO2, l / 4 at l_Bragg
superstrate: air

I think you can read this without any explanations: There are ten pairs of quarter-wave layers, then the thick layer and the top layer. Note that the number of layer pairs is just one parameter. With a table-based user interface, you would have to enter twenty layers by hand, and need to inconveniently edit it if that number changes.

A diagram showing the reflectivity versus wavelength requires a few more lines:

diagram 1:

"Reflectivity Profile"

x: 800, 1200
"wavelength (nm)", @x
y: 0, 100
"reflectivity (%)", @y

f: 100 * R(x), color = red, width = 3

The last line is the interesting one: it says that the expression 100 * R(x) should be plotted. Similarly, you could plot any other expression — for example, the reflectivity for a different angle of incidence, the difference between two polarization directions, or the group delay dispersion.

Note that such a script is not a computer program in the usual sense. It is a description of what you want, written in a way close to how a physicist would write it down anyway.

Different Levels of Scripting

Scripting support can be provided on more or less advanced levels. Simple solutions may add little to the versatility, while advanced scripting support gives you enormous freedom. Some examples:

  1. Mathematical expressions: Instead of picking from a selection of things to plot, for example, you enter an expression which may depend on all sorts of variables, arrays, functions, etc. An example is the expression 100 * R(x) above. You are then no longer limited to quantities and shapes which the developer has offered explicitly.
  2. A complete language: With variables, loops, conditions, arrays and user-defined functions, you can describe whole calculation procedures. The loop over the layer pairs above is a simple case. It is also convenient, for example, to define a figure-of-merit function for optimizations which depends on multiple calculated properties. With an advanced script language, you may even go all the way to full-blown programming if you need to do tricky things.
  3. Access to the inner workings of the model: It makes a big difference whether the script can only retrieve the final results or also access internal quantities. In RP Coating, for example, you can access any calculated quantities, but there are also functions for modifying the layer structure.
  4. A numerical toolbox: Functions for Fourier transforms, numerical optimization, fitting to measured data, reading and writing files in arbitrary formats, matrix operations etc. allow you to process the results of the physical model further without leaving the software.
  5. File access: With flexible functions for file access, you can, for example, import data from input files or write results into output files, both with virtually arbitrary file formats (even including binary data). For example, you could process measured reflection spectra and then fit layer parameters to that.
  6. Freely defined graphics: 'Diagrams are defined in the script, including color plots, text labels with calculated values and additional drawing elements. So you get exactly the diagram which you need, not only one from a predefined list.
  7. User-defined forms: Finally, a script may even define its own user interface — a form with input and output fields, as explained further below.

Example Case: An Ultrashort Pulse Hits a GTI

Let's assume that you want to simulate how ultrashort pulses are reflected by a Gires–Tournois interferometer. That question becomes interesting when a pulse is so short that its spectrum extends over several resonances of the GTI, so that a single chromatic dispersion value says little.

Our RP Coating software does not explicitly offer features for ultrashort pulses; it was made for calculating properties of multilayer structures at given wavelengths. But due to its powerful scripting support, we have all that is needed and proceed as follows:

  • Decompose the input pulse into its frequency components with a Fourier transform. (We store the time-dependent complex amplitudes in an array, and a convenient FFT function is easily applied.)
  • Apply the complex reflection coefficient of the GTI to each component, using a reflectivity function offered by RP Coating.
  • Transform the result back to the time domain.

For a pulse with a duration of 10 fs, this is the result:

ultrashort pulse reflected on a GTI
Figure 1: Reflection of a 10-fs pulse at a GTI, calculated with RP Coating. The gray curve shows the incident pulse, the blue curve the reflected light: a whole sequence of pulses.

We can go one step further. As the script also has access to the electric field inside the structure for each frequency component, with a few additional lines of script code we can calculate how the optical intensity evolves in space and time:

ultrashort pulse in a GTI
Figure 2: Optical intensity as a function of time and position. The incoming pulse (upper left) is partly reflected at the surface; most of it enters the structure, is reflected at the Bragg mirror and then leaves the structure in several portions.

Here, one can directly see where the sequence of reflected pulses comes from: the light does several round trips between the Bragg mirror and the top layer. With a longer pulse, as one would normally use with such a GTI, these portions overlap and merge into a single pulse.

Admittedly, the script code for these two diagrams is not trivial; you find it with explanations on our demo page for the GTI. But note two things:

  • All this was possible without any change of the software. You wouldn't have to wait for a new software version containing an “ultrashort pulse module”.
  • You do not need to write such a script yourself. The one you saw is delivered with the software as a demo file. There, you can easily change the GTI design or input pulse parameters. And if you want different diagrams, that requires just a little extra code.
  • If you need a different type of script which we haven't anticipated, software support included in your user license can produce it.
  • Increasingly, one can even use AI to modify scripts or even create them from scratch.

Scripting is used in RP Coating for many other purposes — some examples:

  • You can define your own figure of merit for the numerical optimization of a coating design, containing whatever properties matter in your application.
  • You can simulate how the reflectivity develops during the growth of a layer structure, which is relevant for growth monitoring.
  • You can treat the reflection of a focused beam instead of a plane wave, or thermal effects in an etalon.
  • You can fit the parameters of a structure to measured data.
  • You can save calculated data in exactly the file format which some other software or a coating manufacturer requires.

Most of these things are already provided as demo scripts.

Scripting Behind Forms

Admittedly, changing parameters by editing values in a script is less convenient than changing values in a form. On the other hand, a form — defining a rigid structure — is naturally far less flexible. But both approaches can be combined:

Our programs like RP Coating and RP Fiber Power support custom forms — forms which are not hardwired in the software, but defined via scripts. You may start with a simple script and add code for a form. Basically, you define what is displayed on the script, where are the input and output forms, and which variables or expressions relate to them. The input parameters are then no longer stored in the script, but in extra parameter files, so that you can easily switch between different parameter sets.

An example for RP Coating, taken from a demo page:

form for Bragg mirror analysis

RP Fiber Power

Our software RP Fiber Power for fiber amplifiers and fiber lasers (but also for passive fiber optics) also gives powerful scripting support. Starting with a simpler example, we consider a passively mode-locked fiber laser. There is no hard-wired model for such a laser in the software. Instead, a script function defines what happens to the circulating pulse in one ring resonator round trip — in essence (with a few technical lines omitted):

DoResonatorRoundTrip() :=
  begin
    pp_loss(T_oc); { output coupler }
    pp_multiply_expr_f(sqrt(gaussh((f - f0) / df_filter))); { bandpass filter }
    pp_fiber(1, signal_passive1); { first passive fiber }
    pp_fiber(2, signal_active); { active fiber }
    pp_fiber(3, signal_passive2); { second passive fiber }
    pp_sat_abs(l_abs, 0, P_sat_abs); { saturable absorber }
  end

Each line sends the pulse through one optical component. See our demo case for a mode-locked fiber laser for more details.

If your laser has a different resonator design, you rearrange these lines or add others. That way, the same software handles ring lasers, linear resonators, figure-of-eight and figure-nine lasers, regenerative amplifiers, chirped-pulse amplifier systems and many other devices.

As in RP Coating, custom forms can be made, and in fact various demo scripts contain such forms. RP Fiber Power develops the concept even an important step further: It offers a set of particularly powerful forms, which we call Power Forms:

  • Technically, these are made as custom forms, i.e., defined in scripts. However, they are worked out far more in detail than our demo scripts, which we keep simple to illustrate the principles. For example, you can easily set up even sophisticated multi-stage fiber amplifier systems for chirped-pulse amplification systems. They make heavy use of advanced user interface features like tabs and combo boxes, parts of forms which are displayed only when needed, etc.
  • The Power Forms contain various input areas where script code can be entered. For example, this allows users to add a curve to an existing diagram by adding just one line of script code. Or to add whole new diagrams, additional processing of calculated outputs, storing outputs in files, etc.

So you can work with a convenient form in most cases and still have the full flexibility of scripting in reserve. I have described these concepts in more detail in an earlier article.

In such ways, the software became extremely flexible and still rather easy to use — a combination which is not achieved by most other simulation software: Usually, software is either easy to handle but limited in scope, or highly flexible but rather tricky to use.

Is It Suitable for Non-programmers?

Many physicists and engineers have relatively limited experience with programming and may then be concerned about the difficulties of using scripting. However, working with such scripts differs substantially from software development:

  • Start with a Power Form. In RP Fiber Power, the most typical applications are already covered by well worked-out Power Forms. So you can set up even most sophisticated fiber amplifier systems, for example, without directly touching any script code — it works for you in the background. Only when you need quite special additions, you may need a little script code — with a complexity far below the complexity of the whole simulation, and with support from us.
  • Tailored scripts: You do not start with an empty page. Our software comes with many demo scripts for typical cases. Usually, you pick the one which is closest to your problem and modify it, often only by changing parameter values.
  • A colleague's work serves the whole team. As mentioned above, one team member can provide scripts with custom forms which others simply use without looking at the code.
  • Artificial intelligence can help as well. It can meanwhile analyze and fix scripts, already by looking at the demo scripts only. Far more becomes possible with full access to the help files — which is possible as these are provided in HTML form. And we are working on even far better integration of AI support.

Of course, it takes some effort to become really proficient in a script language. But our experience is that users become productive surprisingly quickly, because they can proceed in small steps: First only change some numbers, then add a curve to a diagram, later perhaps a complete diagram or a small calculation.

Importance of Documentation

Note that scripting support must not only work properly, but must be fully documented to make it well usable for human users as well as by AI. So this is a vital part of quality of a software product. We thus carefully work to keep our documentation fully in line with the development of features, and improve its usability whenever we identify a potential for that.

Accessibility to AI has become another important aspect. Note that some documentation systems make that pretty hard, e.g. containing help information in some obscure format which is suitable only for display. But a few years ago we have changed our help system to HTML which is easy to digest by AI.

Conclusions

The versatility of simulation software depends strongly on whether it is scriptable — and on how far its scripting features go. With a powerful script language which has access to the inner workings of the physical model and offers a numerical toolbox and freely defined graphics, a software can answer questions for which it was never specifically made. The ultrashort pulse in the GTI, calculated with a thin-film software without any pulse features, is just one example.

Therefore, when you select simulation software, it is worth checking not only the list of features, but also what you can do when that list ends. Just take care: Scripting support may be rudimentary in some software, then bringing limited benefits, while other products have it fully worked out.

Finally, you do not need to be a programmer for that: demo scripts, forms, technical support and increasingly also artificial intelligence make sure that the power of scripting is available to you.


This article is a posting of the RP Photonics Software News, authored by Dr. Rüdiger Paschotta. You may link to this page, because its location is permanent.

Note that you can also receive the articles in the form of a newsletter or with an RSS feed.

Questions and Comments from Users

Here you can submit questions and comments. As far as they get accepted by the author, they will appear above this paragraph together with the author’s answer. The author will decide on acceptance based on certain criteria. Essentially, the issue must be of sufficiently broad interest.

Please do not enter personal data here. (See also our privacy declaration.) If you wish to receive personal feedback or consultancy from the author, please contact him, e.g. via email.

Spam check:

By submitting the information, you give your consent to the potential publication of your inputs on our website according to our rules. (If you later retract your consent, we will delete those inputs.) As your inputs are first reviewed by the author, they may be published with some delay.