Cerman: Software for simulating streamer propagation in dielectric liquids based on the Townsend–Meek criterion

We present a software to simulate the propagation of positive streamers in dielectric liquids. Such liquids are commonly used for electric insulation of high-power equipment. We simulate electrical breakdown in a needle–plane geometry, where the needle and the extremities of the streamer are modeled by hyperboloids, which are used to calculate the electric field in the liquid. If the field is sufficiently high, electrons released from anions in the liquid can turn into electron avalanches, and the streamer propagates if an avalanche meets the Townsend–Meek criterion. The software is written entirely in Python and released under an MIT license. We also present a set of model simulations demonstrating the capability and versatility of the software.


Streamers in liquids
Dielectric liquids, specifically transformer oils, are used as electric insulation in high-power equipment such as power transformers [1]. Equipment failure is always a possibility, and in a world with ever-growing need for energy, there is a continuous effort to make equipment better, cheaper, more compact, and more environmentally friendly. To prevent equipment failure due to electrical  while the stochasticity and branching of streamers can be introduced by adding impurities [10]. Such CFD-calculations often ignore the phase change from liquid to gas as well and are confined to a small region because of the computational complexity. However, for simplified, single-channel streamers, both the phase change and the processes in the channel can be simulated [11,12]. Code used for simulation of streamers in liquids is rarely published, in fact, we found just a single example [13].

Avalanche model
We have previously described our streamer model for positive streamers where the propagation is based on an electron avalanche mechanism [14]. The model has been extended to account for conductance in the streamer channel and capacitance between the streamer and the planar electrode [15], as well as photoionization in front of the streamer [16], the latter as a mechanism for the transition from slow to fast propagation.
Streamer propagation is simulated in a setup resembling model experiments, a needle-plane gap filled with a model liquid, see figure 1 for details. The needle and streamer give rise to an electric field, affecting charged particles in the liquid. A number of anions, "seeds" for electron avalanches, is modeled within a volume surrounding the streamer, a "region of interest" (ROI). Electrons released from the anions can create electron avalanches, and the streamer propagates when an avalanche meets the Townsend-Meek criterion, i.e. exceeds a critical number of electrons [14]. The needle and the streamer heads (the extremities of the streamer) are modeled as hyperboloids, which simplifies calculating the electrical field since the Laplacian is analytic in prolate spheroid coordinates [17]. The electric field and potential is calculated by considering electrostatic shielding [14], as well as the conductance in the channel and the capacitance towards the planar electrode [15]. The streamer undergoes a transition into a fast propagation mode when radiation from the streamer head can ionize molecules directly in front of the streamer [16]. More details on the model is given in section 3.
The main output of the simulations include the propagation speed, the streamer shape (branching), and propagation distance. In addition, properties such as the initiation time, the potential of individual streamer heads, electric breakdown within the streamer channel, and avalanche growth, can also be investigated. Simulations show how various parameters affect the results, where the gap size, applied voltage, and type of liquid are important parameters for a simulation. Furthermore, other parameters such as the size of a streamer head, the conductivity of the streamer channel, properties of additives, and avalanche growth parameters can be varied to validate whether the underlying physical models are reasonable.

Scope
The present work describes the use, functionality and implementation of Cerman [18], a software to do simulations with our model [14,15,16], with the purpose to make the software publicly available. Section 2 demonstrates how to set up, simulate, and evaluate results of a relevant problem. Further details on the model and its implementation are given in section 3, whereas section 4 outlines the current functionality and some prospects for the future. A summary is then given in section 5. Furthermore, details on the algorithm is included in Appendix A, simulation parameters in Appendix B, and simulation example input files in Appendix C.

Software overview
The software name Cerman is an abbreviation of ceraunomancy, which means to control lightning or to use lightning to gain information. The implementation is done in Python, an open-source, interpreted, high-level, dynamic programming language [19], and the software is available on GitHub [18] under an MIT license. The software is script-based, and controlled through the command cerman , Listing 1: Example of JSON-input file, cmsim.json , defining a simulation series with several values for the needle voltage V 0 and the threshold for breakdown in the streamer channel E bd , both with and without photoionization enabled. Furthermore, each permutation is to be carried out 10 times with different initial seed positions. Note, by setting alphakind to A1991, α is calculated by (5). See Appendix B for a description of the parameters.

Getting started
Download Cerman from GitHub [18] and install it by running pip install .
from the downloaded folder. This installs the python package and the script cerman. Python 3.6 or above is required, as well as the packages numpy [20], scipy [21], matplotlib , simplejson , and statsmodels. The dependencies are automatically installed by pip. The software has been developed in OSX and has been tested on Linux as well.

Create simulation input
Each simulation requires a JSON-formatted input file where the parameters are given. Such files can be created from a master input file, specifying the parameters for a simulation series. A master input file can be created from a regular input file by changing a parameter value into a list of values. More than one parameter can contain lists, and all possible combinations of values is found to create the input files for the simulation series. To demonstrate, we use cmsim.json in listing 1, which specifies a simulation series exploring the influence of various parameters. The ten values for the applied voltage are specified through a linspace-command, while the values for the threshold for breakdown in the channel and photoionization (fast mode) enabled are given in list form. Furthermore, simulation_runs specifies the number of similar simulations, only differing by random_seed . If random_seed is null , then each input file is created with a random number as random_seed, and when a number is specified, a range of number is generated, in this case, the numbers 1 through 10. Note that random_seed refers to the seed number for initializing the random number generator, not to the seeds within the ROI. However, a given random_seed does corresponds to a given initial positions of the seed anions. Defining fixed a random_seed for each simulation series makes it easier to see how a change in a given value affects the simulation, but for analyzing a larger assemble of simulations, it is usually preferable that the simulations are uncorrelated, i.e. have random initial anion placement.
Individual input files are created by running the cerman with the argument ci (create input) and specifying which file to expand with -f :

cerman ci -f < filename >
This command creates a a number of new files by permutation of all lists in the given input file. The permutation of 10 random seeds, 10 applied voltages, 5 breakdown thresholds, and 2 modes for photoionization in listing 1 results in 1000 files. By default, the random seed is expanded first, followed by the needle voltage, which is is useful to consider when designing a simulation series. Choosing an appropriate number of values for these two parameters makes it easier to search for simulation files with given properties. When expanding the example in listing 1, the least significant digit ??X indicates random seed number, the second digit ?X? indicates the needle voltage, while the most significant digit X?? indicates the threshold for breakdown in the streamer channel and whether photoionization is enabled or not.
The action pp (plot parameters) creates a matrix representation of the parameter variation in set of input files, and is used like cerman pp -g < pattern > The argument -g specifies the pattern to search (or "glob") for, e.g. cmsim_?00.json. The files are plotted at the x-axis and the varied parameters on the y-axis, see figure 2 for an example output. The name of the output file is based on the first file in the pattern.
After ensuring that the input parameter values are as desired, simulations are run using cerman sims -g < pattern > -m < no > which creates a queue of all files matching the pattern, and simulates a given number in parallel. For instance, cerman sims -g "cmsim_?5?.json" -m 15 , simulates all input files with the same voltage, creating a queue where up to 15 separate subprocesses each run one simulation. These python processes are single threaded, and works best if numpy is limited to a single thread as well. Each simulation dumps the input parameters and progress information to a log file. For each simulation we then have a parameter file, a log file, and one or more save files. The files are named by extending the name of the master file, e.g.

Evaluate results
The results are evaluated by parsing the data stored from one or more simulations. The input file, listing 1, defines two "save specifications" as true, i.e. enabled, each defining various simulation data to be dumped to disk at given intervals or occasions. The save_spec called stat saves iteration number, CPU time, simulation time, leading head z position, number of critical avalanches, and the position of each new streamer head, for every iteration. This enables evaluation of the shape of the streamer and its propagation speed. The save_spec called gp5 saves most of the data available, including the position of all the seeds (anions/electrons/avalanches), for every 5 percent of streamer propagation, i.e. a total of 20 times for a breakdown streamer. The data is saved using pickle and can be loaded to analyze a given iteration, a whole simulation, or by combining data from several simulation.
Evaluate iterations. Iteration data can be used to analyze the details of a simulation. This is particularly useful when evaluating the validity of the simulation parameters. Use for instance cerman pi seedheads -r < start stop > -g < pattern > where pi means "plot iteration" and seedheads is a scatter plot of avalanches and the streamer head configuration. The option -r controls the range of iterations to plot. Figure 28 in [14] shows a number of such plots.
Evaluate simulations. Use ps for simulation plots. These are mainly plotted with the z-position in the gap on the y-axis. Plotting the x-or y-position of streamer heads on the x-axis, using shadow, gives a "shadowgraphic" plot of the streamer:

cerman ps shadow -g < pattern > -o < options >
Similarly, plotting the propagation time on the x-axis is done in a streak plot. Options can be added to control the limits/extents of the plot, the figure size, the behavior of the legend, redefining the axis labels, starting each plot with an offset, saving the plotted data to a JSON-file, and much more. Use help to show available commands and options, for instance:

cerman help # for the main script cerman ps help # for plot simulation cerman ps shadow -o help # for shadow plot
Single simulation data may be of interest, but it is often better to compare several simulations in the same plot to visualize how the input parameters affect the results. The gp5 save requires a lot of disk space, but can be very useful in analyzing the data. For plotting the potential of each head, use cerman ps headsestr -g < pattern > -o < options > The current (active) heads of the streamer is selected, their potential is scaled (electrostatic shielding, using a nnls-approach, cf. [14]), and then, the electric field at their position is calculated. However, the options can be used to specify the method for scaling and which positions to calculate the field for, e.g. at the position of each appended (new) streamer head. The electric field strength and electric potential are presented as scatter plots against the z-position of each given position, as well as dashed line indicating the average value, see figure 4.
Evaluate a series of simulations. The difference in the simulated parameters can be visualized using pp and globbing for the pkl-files or log-files. An existing log-file indicates that a simulation was initiated. The command cerman psr -g < pattern > parses log files and plots the reasons why the simulations were terminated. An example of such a plot is shown in figure 5. This is a good way to verify that simulations have completed successfully.
When all simulations are completed and verified, parse all the save files and build a combined database of the results:

cerman ca -g < pattern > -o mode = reload
The option reload forces files to be parsed, even if they already are in the database. When parsing the save files, a number of properties are extracted or calculated. Results such as propagation length (ls), average propagation speed (psa), inception time (ita), average jump distance (jda), simulation time (st), and computational time (ct) are saved in the database. The results are plotted by using   Example, parsing the log files to visualize how simulations have terminated. "Unknown" implies that the simulation is not complete (ongoing or aborted).

cerman pr < parameter > -f < file > -o < options >
The parameter gives the x-axis of the plot, for instance v (needle voltage). The results to plot is given through the option, e.g. -o ykeys=ls_psa . The software inspects the database of parsed save files for varied parameters and automatically create plots of all possible permutations using colors and markers. Figure 6 shows a selection of such plots, where needle voltage is on the x-axis and the other parameters have been added automatically.
As illustrated, the software has been designed to facilitate simulating and analyzing a large simulations series in a semi-automatic fashion. The individual simulations have their parameters defined in dedicated files, while the behavior of the cerman-script is defined by command line arguments.

Model implementation
This section describes the implementation of our model [14,15,16] in more detail. An overview of the model is already given in section 1.3, and figure 1 is useful for understanding the principal setup, a needle-plane gap where electron avalanches grow from single electron seeds.
The electric field. The needle electrode and the streamer heads are modeled as hyperboloids. The Laplacian electric potential V i and electric field E i from a streamer head i is calculated analytically in prolate spheroid coordinates [14]. For a position r, the electric potential V (r) and field E(r) is given by the superposition principle, where the coefficients k i are introduced to account for electrostatic shielding. An optimization is performed such that the unshielded potential at the tip of any streamer head j equals the sum of all the shielded potentials at that position, [14].
Region of interest (ROI). The ROI is a cylindrical volume used to control the position of seeds, see figure 1. Note, the seeds in this respect include all anions, electrons, and even all avalanches. The number of seeds in a simulation is given by the specified density of seeds and the volume of the ROI. Initially, the seeds are placed at random positions within the ROI. When a seed falls behind the ROI, collides with the streamer, or creates a critical avalanche, it is removed and replaced by a new seed. The new seed is placed with a z-position one ROI-height closer to the plane, at a random xy-position (at a radius less than the ROI radius). The ROI volume is defined by a distance from the z-axis, and a given length above and below the leading streamer head, which is the part of the streamer closest to the planar electrode. When a new streamer head is created closer to the plane, the streamer propagates, and the ROI moves as well.
Anions, electrons, and electron avalanches. The electric field E is calculated for each seed and the seeds are classified as avalanches (E ≥ E c ), electrons (E ≥ E d ), or anions (E < E d ), where the avalanche threshold E c and detachment threshold E d are given as input parameters. Seeds move in the electric field with a speed dependent on their mobility µ, which gives the distance the seed moves, ∆s = Eµ∆t, for a time step ∆t. The number of electrons N e in an electron avalanche, starting from a single electron, can be calculated by [14] where α is the avalanche growth, µ e is the electron mobility, ∆t is the time step, and i is an iteration, whereas the avalanche growth parameters α m and E α have been obtained from experiments [14]. In practice, however, we only calculate and store the exponent in (2), Q e = ln N e , for each electron avalanche. When a low-IP additive is present, α is modified by adding a factor [14] α which is dependent on the mole fraction of the additive x add , and the difference in IP between the base liquid I b and the additive I a modified by a factor k α as prescribed by [22]. This is the default setting for the software. Another model for α given in [23] is also implemented: This method is applied in listing 1.
Expanding the streamer structure. According to the Townsend-Meek criterion [24], streamer breakdown occurs when an avalanche exceeds a critical number of electrons N c = exp(Q c ). When an avalanche obtains Q e > Q c , we place a new streamer head at its position [14]. The initial potential of a new streamer head is calculated by considering the capacitance and potential of the closest existing streamer heads [15]. If adding the new head implies removing another head (see the paragraph below), the potential changes slightly, mimicking transfer of charge. However, if both the new and the present head stays, they share the "charge", which gives a moderate reduction in the potential of both heads.
Optimizing the streamer structure. There are three criteria for removing heads. A streamer head i is removed if are satisfied for any other streamer head j [14]. The first condition checks whether the tip of one hyperbole (r i ) is inside another hyperbole, a collision (the ν-coordinate describes a hyperboloid, specifically the asymptotic angle). The second condition removes heads whose potential are to a high degree shielded by other heads (if the coefficient k i in (1) lower than a threshold k c ). The third condition checks whether two streamer heads are closer than d m and should be merged to a single head, where the one at the highest z-coordinate is removed. Conduction and breakdown in the streamer channel. Conduction in the streamer channel increases the potential of each streamer head i each iteration, The time constant τ i = RCτ 0 (for a given head i) is calculated from the resistance R in the channel and the capacitance C towards the plane [15] R ∝ , and C ∝ ln 4z + 2r s r s where is the channel length (distance to the needle), r s is the tip curvature radius of the streamer head, and z is the z-position of the streamer head. As such, each streamer head is treated as an individual RC-circuit, e.g. the three streamer heads in figure 1 would each have an individual resistance (channel) as well as an individual capacitance towards the planar electrode. If the conduction is low, the potential difference ∆V i increases as the streamer propagates, and the electric field within the streamer channel E s = ∆V i / i may increase as well.
If E s exceeds a threshold E b , a breakdown occurs, equalizing the potential of the streamer head and the needle, which is achieved by setting τ i = 0 in (7) for the given iteration. Photoionization. Photoionization is a possible mechanism for fast streamer propagation [25]. We have proposed a mechanism in which the propagation speed of a streamer increases if the liquid cannot absorb radiation energy to excited states, as a result of a strong electric field reducing the ionization potential [16]. Since the full model, considering fluorescent radiation from the streamer head, and a field-dependent photoionization absorption cross section, is computationally expensive, a simpler model is used in the simulations. Instead we calculate the field strength E w required to reduce the ionization potential below the energy of the fluorescent radiation. In each iteration, if the electric field E at the tip of a streamer head i exceeds the parameter E w , the head is moved a distance ∆s i towards the planar electrode, where v w is the photoionization speed, and Θ is the Heaviside step function. For more details on the entire model, see our previous work [14,15,16].

Current functionality and future prospects
The main function of the model and the software is to simulate streamers in a point-plane gap, using the Townsend-Meek criterion for propagation. The propagation criterion is met when electron avalanches obtain a given size. This model and the algorithm are fixed, but there are several parameters which can be adjusted. Changing experiment features such as needle tip radius, gap size, voltage, liquid properties, or the parameters of the algorithms, is straightforward. Proposals to extend the software to encompass new functionality is given in this section.
In [14] we explored the fundamental features off the model, i.e. a streamer consisting of charged hyperbolic streamer heads, and streamer growth by electron avalanches initiating from anions. The model predicts several aspects of streamer propagation, and shows how they are linked towards the values of given input parameters. The predicted propagation speed and the degree of branching were both lower than expected. We found how the speed was dependent mainly on the number of electron avalanches and their growth, while the branching was mainly related to how the streamer heads were configured and managed, which is mainly controlled by the parameters k c and d m in (6).
When new streamer heads were added, their potential was set assuming a constant electric field within the channel, resulting in a moderate voltage drop between the needle electrode and the streamer head [14]. To better represent the dynamics of the streamer channel, an RC-model was developed [15]. In the RC-model, the potential of new streamer heads is dependent of the potential of the closest existing streamer heads. If the conductance of the streamer channel is high, then the potential of the streamer head is kept close to that of the needle, giving results comparable to those without the RC-model. Conversely, having low conduction regulates the speed of the streamer, increasing the likelihood that more branches are able to propagate. Furthermore, the RC-model also allows for simulation of a breakdown within the streamer channel itself, which is likely what occurs during a re-illumination. This breakdown occurs when the electric field within the channel exceeds a given threshold.
The importance of photoionization during a streamer breakdown is unknown. We explored different aspects of photoionization in [16], and implemented a model for change to a fast propagating mode. Molecules excited by energetic processes, such as electron avalanches, can relax to a lower energy state by emitting radiation. We argued that fluorescent radiation can be important, and modeled how this radiation can cause ionization in high-field areas, since the high-field reduces the ionization potential.
In the current implementation, a square wave voltage is applied to the needle at the beginning of the simulation. It is easy to change the behavior to a voltage ramp, from zero to max over a given time. This can be the basis for a study on streamer inception where other parameters such as needle size and the electron properties of the liquid are investigated as well. Simulating a dynamic voltage, such as a lightning impulse, requires some more work, but is also achievable.
We have focused on cyclohexane since many of its properties are well known, but other non-polar insulating liquids can be studied by changing relevant parameters. The seed density n ion is based on the low-field conductivity σ and electron mobility µ e of the liquid, and the propagation speed scales linearly with both seed density n ion and electron mobility µ e . The electron avalanche growth parameters are also liquid-dependent, and E α in particular has a big impact on the results [14]. Streamer parameters, such as conductivity of the streamer channel and streamer head radius, need to be reevaluated as well for other liquids. The properties of the streamer channel are also important to simulate the effects of external pressure, which mainly affects processes in the gaseous phase [26].
The effect of additives with a low ionization potential (IP) are modeled as causing an increase in electron avalanche growth [22,14]. Other additives can easily be used as long as the IP of both the base liquid and the additive are known. Low-IP additives are known to facilitate the propagation of slow streamers and to increase the acceleration voltage, possibly as a result of increased branching [27], however the mechanisms involved are not known. It is possible that low-IP additives are sources of electrons that can initiate avalanches, produced for instance through photoionization or fluctuations in the electric field. Such mechanisms can be added to the model and simulated, but will require some work. Furthermore, the mechanisms of added electron scavengers can also be interesting for further investigation, and particularly if negative streamers are to be simulated [22].
Our primary concern have been with positive streamers, since these are more likely to lead to a complete breakdown than negative streamers. The model relies on electrons detaching from anions, moving towards regions where the field is higher, and then forming electron avalanches. The polarity of our model can easily be reversed, however, the electrons would then drift away and be unable to form avalanches. As such, a model for creation of new electrons is needed to simulate negative streamers with the software. Charge injection from the needle and the streamer can be one such mechanism [28]. Another option is to model electron generation (charge separation) in the high-field region surrounding the needle and the streamer. Such mechanisms are interesting for simulating positive streamers as well.
The hyperbole approximation simplifies the calculation of the electric field, both from the needle electrode and from the streamer heads. Other experimental geometries, such as plane-needle-plane, or even more realistic real-life geometries can be implemented. The challenge is to set the correct shielding or scaling of the streamer heads according to the influence of the geometry. Simpler geometric restrictions are easier to implement, for instance by manipulating the ROI. The streamer can be restricted to a tube by setting a low value for the maximum radius of the ROI. Another method is setting the "merge threshold" very high, such that the streamer is restricted to a single channel with a single head, which can be representative for a streamer in a tube [29].
There are many mechanisms that can be added to investigate different methods of streamer propagation, for instance effects of Joule heating or electrohydrodynamic cavitation [30]. There are also several parts of the existing model that can be improved. Better calculation and balancing of charges and energy would greatly improve the model. For instance an electric network model where the streamer is consisting of several interconnected parts, in contrast to the current implementation where all the streamer heads are individually "connected" to the needle. Such an approach can give a better understanding of the charge flow in the different parts and branches of the streamer, as well as a better representation of the electric field. Development towards a model for a spacecharge limited field [31] can further improve the electric field representation, however, possibly at a high computational cost.

Summary
We present a software for simulating the propagation of positive streamers in a needle-plane gap insulated by a dielectric liquid. The model is based on the Townsend-Meek criterion in which an electron avalanche have to obtain a given size for the streamer to propagate. The software was developed and used for simulating our models for electron avalanche growth [14], conductance and capacitance in the streamer channels [15], as well as photoionization in front of the streamer [16]. From the examples on how to set up, run, and evaluate simulations, others can recreate our previous results or create their own set of simulations. Furthermore, the overview of the implementation and algorithm serves as a good starting point for others to change or extend the functionality of the software.   Figure 7: The simulation algorithm consists of initialization, a loop where the seeds and the streamer structure is updated, and then a finalization. It the loop, first the seeds (anions, electrons avalanches) are affected by the electric field, then the streamer structure is modified and this changes the electric field, finally the region of interest (ROI) is updated and the data from the iteration is evaluated. The loop concludes when one (of several) criterion is met, typically low propagation speed or reaching the opposing electrode. Details on each step is found in Appendix A.
growth, the needle, the streamer, the region of interest (ROI), the seeds (anions, electron, avalanches), how to save data, and how to evaluate simulation data. The initiation of the log file includes dumping the input parameters to the file. Given the ROI volume and the seed density, a number of seeds is created and placed within the ROI at random positions. Then, the save files are initialized by dumping the initial data, mainly information concerning the needle and the seeds. Update seeds. The electric field E is calculated for each seed (applying (1)) and the seeds are classified as avalanches, electrons, and anions. All the avalanches move in the electric field and grow in size (see (2)). The procedure is repeated until an avalanche collides with a streamer head, an avalanche meets the Townsend-Meek criterion, or a total of N msn repetitions has been performed. The "time" spent in this inner loop sets the time step for the current iteration of the main simulation loop. Finally, all the electrons and anions are moved. The inner loop over just the avalanches save significant computational time since the calculation of the electric field is the most expensive part of the computation and the avalanches is usually a small fraction of all the seeds.
Photoionization. The electric field at the tip of each streamer head is calculated and compared with the threshold for photoionization. Each streamer head where E > E w is "moved" a distance v w ∆t towards z = 0. Moving implies creating a new head, setting the potential by "transferring charge", and removing the old head.
Manage new heads. For each critical avalanche a new head is created. If the simulation time step is set sufficiently low, there is usually zero or just one new head. The new head is discarded if it satisfies any of the criteria in (6), however, if adding it will cause another to be removed (later), the new head is classified as "merging". If none of the criteria in (6) is met by adding the new head, i.e. all heads are kept, then it is a "branching" head, since adding it is potentially the start of a new branch. The potential of "merging" is set by "charge transfer" from the closest head, while "branching" heads have their potential set by "sharing charge" with the closest head, where the latter method also modifies the potential of the existing head [15].
Manage streamer. The potential of each streamer head is relaxed towards the potential of the needle by applying (7). This step increases the potential of the streamer head to the potential of the needle when a breakdown in the channel occurs. As mentioned above, the calculation of the electric field for the seeds is computationally expensive, and it actually scales with both the number of seeds and the number of streamer heads. It is therefore preferable to keep the number of heads to a minimum. Superfluous heads are trimmed according to the criteria in (6). Then, the electrostatic shielding is set for the trimmed structure.
Update ROI. Seeds that have moved behind the ROI, collided with the streamer, or lead to a critical avalanche are removed and replaced by a new seed. When a seed is replaced, the new seed is placed a distance, equal to the height of the ROI, closer to the plane, at a random xy-position within the ROI radius. If the streamer has moved closer to the plane, the ROI moves as well, and seeds behind the new position are replaced. If a streamer head is close to the edge of the ROI, the ROI expands towards the maximum radius. New seeds are created at random position within the expanded region.
Evaluate iteration. Iteration data is extracted from the various classes to be saved for later use. The data is used to evaluate whether any stop condition is fulfilled, and stored to dedicated classes. Which data to store and how often to sample the data is controlled by the user input. The saved data is dumped to a file at regular intervals to keep memory requirements of the program low. Information to monitor the progress is printed to the screen, at regular intervals. Finally, a number of temporary variables, relevant only to the iteration is cleared, and the program is prepared for a new iteration.
Terminate? If none of the conditions for stopping a simulation are met, the next iteration is performed. These conditions includes low streamer speed, streamer head close to the plane (breakdown), simulation time exceeded, computation time exceeded, and more. When a criterion is met, any unsaved data is dumped to disk, and a final logging to file and screen is performed, before the program terminates.

Appendix B. Parameters
The parameters for a simulation is supplied by the user in a JSON-formatted file (see listing 1). A list of all important parameters are shown in table 1. The potential, position and size of the needle are important parameters in an experiment and included in the first section, followed by parameters controlling the creation and movement of seeds (anions, electrons, and avalanches). The third section contains parameters related to the threshold for electron detachment, electron avalanche growth, and critical avalanche size. The parameters for the streamer can be split in two groups. The first group controls creation of the streamer heads and how the streamer heads are treated in relation to each other, whereas the second groups is related to the RC-model, controlling the potential of the streamer heads and the electric field in the streamer channel. There is also the option to choose whether the electric field from the streamer, acting on the seeds, is calculated using 32-or 64-bit precision. The latter requires about twice the time to compute. The parameters in the last section are mainly related to the simulation algorithm itself. The time step and the number of steps per loop are essential for a good results. The random seed, used to initialize the random number engine, controls the initial placement of seed anions. Choosing the same random number enables the study of, for instance, changing voltage with the same initial seed configuration. Conversely, not setting the random number makes the simulations uncorrelated, which is better for statistics. The size of the ROI decides how many seeds that are included in a simulation. For instance, an ROI of 10 mm 3 in combination with a seed density of 2 × 10 12 /m 3 results in 20 000 seeds generated, a size which is easily treated by most computers. Finally, several parameters can be used to control how long a simulations will run, or to stop a simulation if the streamer stops or reaches the other electrode. There are also parameters controlling how often information is logged, and how detailed the logging should be. Table 1: Main parameters for simulation program. The experimental conditions specifies an overvoltage applied to medium size needle-plane gap. The values of the physical parameters in seeds and avalanches and streamer structure are justified in our previous work [14,15,16]. Parameter values related to the simulation algorithm, or the model in general, have also been discussed in previous work. See further description in Appendix B.

Property
Keyword This appendix contains a number of examples of possible simulations. The files in listings 2 to 5 are all included in the folder examples on GitHub [18].

Listing 2:
The example file small_gap.json specifies a small gap and a range of voltages along with many parameter values equal to the defaults (cf. table 1). Although all values used in a simulation is stored in the log, it is nice to be explicit in the input as well. By specifying 10 simulation_runs and 10 voltages, a total of 100 simulations is created from this file. Each simulation initiated with the seeds at uncorrelated positions since random_seed is none . Listing 3: The example file small_gap_mod.json builds on listing 2, but a number of parameters are modified, notably the seed density and the electron avalanche parameters, as well as several parameters for the streamer. All data is stored every 5th percent of propagation by gp5 and every 100th nanosecond by ta07 . Storing the properties of tens of thousands of seeds enables plotting of the development of seeds, but also requires a lot of disk space. Specifying streamer saves all the streamer heads every 0.1 percent of propagation and is used to evaluate the development of the streamer. Since random_seed is 1 and simulation_runs is 10, a range of random_seed from 1 through 10 is generated, giving the same 10 initial seed positions for each voltage. Listing 4: The example file rc.json specifies the low and high conductivity within the streamer channel, and a range of threshold fields for electric breakdown in the streamer channel. The linspace-command is a convenient method for creating a list of values. By combining 2 values for the conductivity and 5 values for breakdown with 10 values for the voltage, a total of 100 simulations are created from this file. Listing 5: The example file pi.json specifies electrical breakdown in the streamer channel, with and without photoionization enabled, The keyword user_comment does not affect the simulations, but can be convenient to set. 600 input files are created when expanding this file (100 voltages, with and without photoionization, for three different breakdown thresholds).