You are on page 1of 70

Flow Separation Control Utilizing Plasma

Actuators

Stefan Nilsson

Space Engineering, master's level


2018

Luleå University of Technology


Department of Computer Science, Electrical and Space Engineering
Abstract

The goal of this thesis was to both theoretically and experimentally show the effect of a plasma actuator for flow
separation control. In the theoretical part a solver was implemented in MATLAB code, to solve the governing
equations describing the plasma actuator. The experimental part included PIV (Particle Image Velocimetry)
measurements of the velocity field induced by the plasma actuator, visualization of the effect in a wind tunnel
and the development of a simple model of the plasma actuator based on the empirical result whose purpose is
to be used in CFD (Computational Fluid Dynamics).

The PIV measurements were performed with an acceptable result even though a lot of disturbance occurred
in and near the plasma region. The empirical result was used to develop the empirical plasma actuator model
for CFD, which showed some interesting result. The model implies that the induced force by the plasma ac-
tuator grows exponential with the applied peak-to-peak voltage. The model was also used to predict airfoil
performance with plasma actuators which showed an increase of the lift coefficient on a NACA0012 with a chord
length of 0.1m. Simulations were done for free-stream velocities up to 20m/s with three different configurations,
without plasma actuator for comparison, with one actuator at the quarter-chord and one with three actuators
on the airfoil. With three actuators the increase of the lift coefficient was 108 percent at 5m/s and 14 percent
at 20m/s. The simulations with one actuator were only performed up to 10m/s were the effect of the actuator
still could be seen but for higher velocities the effect would probably be minor.

The wind tunnel experiment clearly showed the effect and the advantages of utilizing plasma actuators for
flow separation control. The experiment showed that a single plasma actuator placed at the quarter chord of
a fully stalled NACA0012 airfoil with a chord length of 0.1m, at approximately 20 degrees angle of attack and
with a free-stream velocity of 1.5m/s, was able to reattach the flow behind the actuator.

The result of the theoretical part was inconclusive, the code could not run with the appropriate voltage
and frequency of the plasma actuator. Some result was however obtained, implying that the time-average force
induced by the plasma actuator was in the expected direction. The theoretical model is however considered to
have potential, the major problems concern the code which requires further development.
Contents

1 Introduction 4
1.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

I Theoretical Study 6
2 Theoretical Plasma Actuator Model 7
2.1 Introduction to DBD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Flow Separation Control with Plasma Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Governing Equations of the Plasma Actuator Model . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4 Source Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Boundary and Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 Numerical Solution of the Plasma Actuator Model 14


3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Discretization of the Transport Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 Discretization of Poisson’s Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 Iterative method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4 Simulations Result and Discussion 21


4.1 Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Discussion on the Theoretical Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

II Empirical Study 23
5 Equipment 24
5.1 High Voltage Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.2 Plasma Actuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

6 PIV and Wind Tunnel Experiments 28


6.1 Introduction to PIV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.2 Considerations Utilizing PIV in Plasma Experiment . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.3 PIV Experiment Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.4 PIV Measurement Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.5 Visualization in Wind Tunnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

7 Discussion on the Empirical Part 38

III Empirical Plasma Actuator Model 39


8 Empirical Plasma Actuator Model 40
8.1 CFD Plasma Actuator Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.2 Airfoil Performance with Plasma Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.3 Discussion on CFD Plasma Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
IV Final Discussions and Conclusions 46
9 Discussion, Conclusion and future work 47

Bibliography 48

A MATLAB Code 49
Nomenclature

Acronyms
AoA Angle of Attack
CFD Computational Fluid Dynamics
DBD Dielectric Barrier Discharge

ISA International Standard Atmosphere


MSI Modified Strongly Implicit
PIV Particle Image Velocimetry

PtP Peak-to-Peak
SOR Successive OverRelaxation
UDF User Defined Function

3
Chapter 1

Introduction

Flow control is an important and a topic under continuous development, not at least in the aerospace and auto-
mobile industry. Flow control could either be passive or active. A passive flow control device is fixed and does
not require any energy whereas an active flow control device requires an actuator and thus requires energy. The
main purpose of a flow control device may be different, for instance increasing lift, reducing drag or reducing
noise. Sometimes the main purpose can be to prevent flow separation and is then often called flow separation
control. However, even though the main purpose is, for instance to increase the lift, flow separation must be
considered. A leading-edge slat on an aircraft wing for example, increases the camber of the wing and thereby
increases the lift. Ignoring any separation, it would theoretically work without the gap between the slat and
the main wing but most likely the flow would separate in reality. The gap allows the fluid to pass between the
slat and the main wing, hence seen from the slat, there is a new surface downstream and hence a new boundary
layer on the main wing and flow separation could be avoided around the curvature on the front part of the wing.
In most cases flow control means that in some way modify the laminar-to-turbulent transition of the boundary
layer and suppress separation.

All modern aircraft are equipped with some type of flow control, for instance adjustable guide vanes in gas
turbines, high-lift devices such as flaps and leading-edge slats. These examples have in common that they all
consist of complex moving parts which have as disadvantage that they are expensive to develop and manufac-
ture, they wear down and requires expensive maintenance. Utilizing plasma actuators for flow control is a topic
that currently is under development. The plasma actuator adds momentum to the flow without any moving
part, and thereby prevent or delay flow separation. Plasma actuators may be used stand-alone, or together
with other flow control devices to increase their performance. But also the plasma actuator has some major
disadvantages where perhaps the most obvious is the presence of high voltage which drives the actuator. The
high voltage is hazardous and it may also prevent the use of any conducting material in the vicinity of the
actuator.

Development of plasma actuators for flow control is a huge task were expertise from several disciplines are
required and includes fluid dynamics, plasma physics, electromagnetism, chemistry, electrical engineering and
others. Because of the wide field of knowledge that are required, this thesis will focus on the most important
things regarding the plasma actuator and its use for flow control.

4
1.1 Purpose
The purpose of this thesis is to both theoretically and experimentally show the effect of a plasma actuator,
obtain empirical data through measurements of the velocity field induced by the plasma actuator and develop
a simple model of the plasma actuator based on the empirical result whose purpose is to be used in CFD
(Computational Fluid Dynamics).

1.2 Objectives
The main objectives of this thesis are:

• Obtain a theoretical solution of the force field induced by the plasma actuator.
• Develop a high voltage AC source and other equipment necessary for the experiments. This issue is critical
for the remaining work and must therefore be considered as a main objective.
• Perform a wind tunnel experiment with the main purpose to visualize the effect of the plasma actuator

• Perform PIV (Particle Image Velocimetry) measurements of the plasma actuator with varying PtP (Peak-
to-Peak) voltage to obtain empirical data of the velocity field.
• Develop a simple empirical plasma actuator model based on the PIV measurements with the purpose to
be used in CFD, with the PtP voltage as the dependent variable.

• Utilize the previous developed empirical plasma actuator model to study the performance of an airfoil
equipped with actuators.

1.3 Thesis Outline


The thesis is divided into four parts as follows:
I. Theoretical Study. The first part contains the theory used for the simulations of the plasma actuator and
subsequently the result is presented.
II. Empirical study. This part contains the PIV measurements and the wind tunnel experiment as well as the
development of the necessary equipment to perform the empirical study.
III. Empirical Plasma Actuator Model. This part will handle the development of the empirical plasma actuator
model and subsequently the model will be used to study the performance of an airfoil.
IV. Final Discussions and Conclusions. In this final part the thesis will be summarized and discussed and
future work that may be done as a continuation of this work will be suggested.

5
Part I

Theoretical Study

6
Chapter 2

Theoretical Plasma Actuator Model

2.1 Introduction to DBD


A dielectric barrier discharge (DBD) is as the name implies an electrical discharge between two electrodes,
which are separated by a dielectric barrier. In this thesis DBD plasma actuators will be utilized for flow control.
Most commonly a DBD is driven by sinusoidal voltage of 1 − 20kV with frequencies in the range 0.05 − 20kHz
[1]. Looking at a running DBD plasma actuator in air at room conditions; it seems to emit visible light
continuously. However, at this conditions the DBD is nonuniform and consists of numerous microdischarges [1].
The plasma formation process is an electric breakdown phenomenon that may be described by the Townsend
breakdown mechanism. Electric breakdown is a multistage threshold process that occurs when the electric
field strength reaches some critical value [2]. During the breakdown period the nonconducting gas becomes
conductive and a plasma is generated as a result. The breakdown mechanism starts with an electron avalanche,
i.e. multiplication of one or more primary electrons. Considering a free electron in an electric field between two
electrodes; the electron drift towards the anode and ionizing the gas along its path, subsequently the new free
electrons contribute to the ionization process and an electron avalanche is generated. The process is illustrated
in figure 2.1.

Figure 2.1: Townsend mechanism.

The positive ions generated in the process drifts toward the cathode. If the ions have a sufficient energy there
is a chance of secondary electron emission when the ions hit the surface. The secondary electrons drifts toward
the anode and continues the process. The secondary emission depends on material, surface condition, type of
gas and the strength of the electric field which defines the ion energy. The equation describing this process may
for instance be found in Plasma Physics and Engineering [2] but is not introduced here. The equations show
that if the electric field becomes sufficient strong a self-sustained current, i.e. a breakdown, takes place in the
gap between the anode and cathode. In the case of a DBD a surface charge builds up on the dielectric surface,
when the surface charge is sufficient the local electric field collapses which leads to a self-termination of the
discharge.

7
2.2 Flow Separation Control with Plasma Actuators
Some different types, or ways to use DBD plasma actuators have been suggested for flow control; this thesis will
stick to one of these types. The geometry of the plasma actuator used in this thesis will throughout the thesis
be the same, both in the theoretical part as well as in the experimental part. Figure 2.2 shows an illustration
in two dimensions of the actuator.

Figure 2.2: Illustration of a DBD plasma actuator.

With this geometry of the plasma actuator the asymmetry, i.e. the grounded electrode is covered by the
dielectric whereas the other electrode is exposed to the atmosphere, leads to an induced force with a distinct
direction. The induced force originates from the charged particles accelerated in the electric field and by col-
lisions between the charged particles and neutrals. By placing the actuator in the span-wise direction of, for
example a wing section, the induced force adds momentum into the boundary layer in the stream-wise direction.
Using a plasma actuator like this for flow control is similar to using a jet or blowing with the exception that no
additional mass is inserted into the flow.

The width of the two electrodes i.e. the horizontal length of the electrodes in figure 2.2, is equal and is
chosen to be 10mm. The thickness of the dielectric material is 0.2mm, which is the thickness of the material
used later in the experiments. In the simulations the thickness of the electrode will be neglected.

2.3 Governing Equations of the Plasma Actuator Model


The full model describing the plasma actuator and the aerodynamic interaction, and its effects is very complex
and includes Navier-Stokes equation, Maxwells equations, law of mass action including quantum chemical physics
for nonequilibrium chemical reactions, and gas kinetics for transport properties [3]. Hence it is a huge task to
find a solution to the full set of equations, not least considering a reasonable computation time. One of the
major concerns that strongly affects the computation time is that for each particle species included in the model
a continuity equation must be solved. In a discharge in air, perhaps several thousand different species will be
present, electrons, different neutrals in different energy states, different ions species with different charge and
energy states and so on. Therefore, in this thesis, the model will be limited to just include neutrals, electrons and
positive and negative ions. In most papers on the topic the magnetic field is neglected or simplified and will be
neglected in this thesis as well. Since Maxwells equations include vector products of the magnetic field it is not
straight forward to formulate a two-dimensional set of the equations for the problem. To overcome this problem,
it has been proposed to introduce an effective electric field strength that includes all the electromagnetic effects
by restricting the magnetic flux density to the z-coordinate (out of plane coordinate in figure 2.2) [4]. By doing
so the equations becomes similar to the case where the magnetic field is neglected. Also, according to J.S Shang
and P.G Huang [3] the induced magnetic flux density ∂B ∂t is in most flow control cases negligible in comparison
to an externally applied field which may be concluded through the magnetic Reynolds number. Neglecting the
induced magnetic flux density makes it possible to decouple Faradays law of induction from the rest of Maxwells

8
equations. Further, by neglecting the magnetic field both Ampère’s law and Gausss law for magnetism may be
decoupled as well, leaving only Gauss’s law for the electric field to be solved,

ρ
∇·E = , (2.1)
ε0 εr

where E~ is the electric field, ε0 is the permittivity of free space and εr is the relative permittivity. The space
charge density ρ is given by

X
ρ= qp np , (2.2)
p

where q is the charge, n is the particle number density and the index p indicate electrons e or an ion species.
For every particle species the time evolution of the number density is given by the continuity equation

∂np
+ ∇ · Γp = Sp , (2.3)
∂t
where S is the particle source term which will be treated later. The flux Γ is given by the well-known
drift-diffusion equation which is derived from the momentum balance equation, which not will be shown in
detail here; the interested reader may find the derivation in for example, Introduction to Plasma Physics and
Controlled Fusion by Francis F. Chen [5].

Γp = −Dp ∇np + sgn (qp )µp E, (2.4)

where D is the diffusion coefficient, µ is the mobility. The first term in eq. (2.4) is the diffusion due to the
concentration gradient i.e. the ordinary diffusion, the second term is the drift due to the electric field. Here it
should be mentioned that a third drift term would be present if the magnetic field was not neglected, the force
diffusion caused by the Lorentz acceleration. The mobility and diffusion coefficients cannot be considered to be
constant. For the charged particle transport, it is assumed that the Einstein relation is satisfied,

kB Tp µp
Dp = , (2.5)
e
where kB is the Boltzmann constant, T is the temperature and e is the elementary charge. For ions the
local field approximation is assumed, which assumes a direct relation between the particle energy distribution
and the electric field, i.e. the ion mobility and diffusion coefficients are functions of the local magnitude of
the electric field. Here these functions will be constructed of table-values from literature which will be linearly
interpolated between the two closest values for a given magnitude of the electric field. The transport properties
was taken from , Transport Properties of Gaseous Ions Over a Wide Energy Range, page 203 [6], the chosen
data is for nitrogen ions with a charge of plus one in nitrogen gas. Later, in the computation also the negative
ion species was given the same properties as the positive ones, since at this stage the most important was to
have ion properties of the correct order of magnitude. The ion temperature is related to the electric field by
[7],[8],

mp + mg
kB Tp = kB Tg + mg (µp |E|)2 , (2.6)
5mp + 3mg
where mp is the mass of ion p and mg is the mass of the neutral gas particle. The local field approximation is
not satisfactory for electrons because of the huge mass difference between electrons and neutrals which leads to
poor modelling result due to the poor energy transfer in electron-neutral collisions [7]. A more accurate approach
is to assume that the electron diffusion and mobility are functions of the mean electron energy. This approach
is for example described by G. J. M. Hagelaar [7], the disadvantage of this approach is that an additionally
energy balance equation must be solved. The energy balance equation has the form of the continuity equation
eq. (2.3), but the computation is more complex. Here, the energy balance equation will not be used, instead
values of the electron drift velocity will be taken from Handbook of Physical Quantities, page 540-541 [9], where
from the mobility is calculated by

vdrif t,e
µe = , (2.7)
|E|

9
where vdrif t,e is the electron drift velocity. Values for the electron diffusion coefficient were taken from the
same table in Handbook of Physical Quantities. Rather than using the electric field E as a variable the electric
potential φ will later be used in the numerical model. The electric potential connects to the electric field through

E = −∇φ. (2.8)

The electrostatic force F induced by the plasma actuator during the discharge is given by [3]

F = ρE. (2.9)

Considering eq. (2.9); it is not obvious that the induced force will have a distinct direction as indicated in
figure 2.2, since the electric field continuously change its direction as the AC voltage change over the plasma
actuator. The time-averaged electrostatic force over one period T is therefore evaluated as

ˆ
1
Favg = F (x, y, t)dt. (2.10)
T

2.4 Source Terms


To simplify the computation of the source terms an empiric model is used and is given by [3, 10, 11]


Se = α |E| |Γe | − βn+ ne − νa ne + κd nn n− , (2.11)


S+ = α |E| |Γe | − βn+ ne − βi n+ n− , (2.12)

S− = νa ne − κd nn n− − βi n+ n− , (2.13)

where the indices e, +, and − refers to electrons, positive and negative ions respectively. The plasma
is considered to be a low-ionized plasma and therefor the number density of neutral species nn is treated
as a constant and is given the value that corresponds to the number density at sea level according to ISA
(International Standard Atmosphere), which is,

nn = 1.55 · 1019 , cm−3 . (2.14)

The ionization coefficient α is given by

 
α −365
= 15 exp , cm−1 torr−1 , (2.15)
P |E|/P

where P is the pressure which is set equal to 760 torr and corresponds to 101325 Pa which is the sea level
pressure according to ISA. The recombination coefficient β is a constant and is set to

β = 2 · 10−7 , cm3 s−1 . (2.16)

10
The attachment frequency νa is defined as

 
αa
νa = vdrif t,e P, (2.17)
P
where,

 
αa
= 0.005, cm−1 torr−1 , (2.18)
P

and the electron drift velocity vdrif t,e is given by eq. (2.7). The ion-ion recombination coefficient βi is as
well a constant and was set to have a value of

βi = 1.6 · 10−7 , cm3 s−1 . (2.19)

Finally, the detachment coefficient κd is estimated to be in the range

10−14 < κd < 8.6 · 10−10 , cm3 s−1 , (2.20)

in the computations the coefficient was set to κd = 10−12 cm3 s−1 .

2.5 Boundary and Initial Conditions


The boundary conditions are a very important part of the description of the problem, but they are not obvious
and different conditions have been suggested by different authors. Here, the boundary conditions suggested by
G. J. M. Hagelaar [7, 8] will be used at the surfaces in the plasma actuator model. These boundary conditions
include some details of the physics which are omitted in other suggestions. The boundary condition separates
the secondary electron number density from the primary electron number density at the boundary and thereby
describes the physics more properly. The boundary conditions are briefly outlined here, for details the reader
is referred to Hagelaars papers [7, 8]. In the papers by Hagelaar a particle reflection parameter is also included
in the equations for the boundary conditions. The reflection parameter which is omitted from the equations in
this thesis simply states the fraction of particles reflected by the surface. The fraction of reflection is unknown
for this application and therefore the reflection parameter is set to zero i.e. zero reflection of particles at the
surface. In Hagelaars dissertation the parameter was as well set to zero for their application, because of the
same reason, lack of data. The boundary condition for electrons in given by

1 1 X
Γe · n̂ = −(2ae − 1)µe (E · n̂)ne + vth,e ne − vth,e nγ − 2(1 − ae ) γj (Γj · n̂), (2.21)
2 2 j

and for ions the boundary condition is

1
Γp · n̂ = (2ap − 1) sgn (qp )µp (E · n̂)np + vth,p np . (2.22)
2
The boundary conditions for electrons and ions are hence basically the same with the exception that the two
terms describing the secondary electron emission are omitted from the equation for the ion boundary condition.
The normal vector n̂ in eq. (2.21) and eq. (2.22) is the vector pointing toward the wall. The parameter a is
describing whether the drift velocity is directed toward the wall. If the drift velocity is directed toward the wall
a is set to one and to zero otherwise, thus a is given by

(
1, sgn (qp )µp E · n̂ > 0
ap = (2.23)
0, sgn (qp )µp E · n̂ ≤ 0

11
The thermal velocity is defined by

s
8kB Tp
vth,p = . (2.24)
πmp

As mentioned the boundary condition for electrons eq. (2.21) have two terms describing the secondary
electron emission. The variable nγ is the number density of emitted γ-electrons [7, 8],

" s #
1 X 1 8mg (mp + mg )
nγ = (1 − ae ) γp µp np (2ap − 1) sgn (qp ) + , (2.25)
µe p 2 πmp (5mp + 3mg )

The secondary emission coefficient γ in eq. (2.21) is the average number of electrons emitted per incident
ion. This coefficient depends on ion species and material properties. The exact values for this application is
not known and is set to 0.1 for the exposed electrode and 0.01 for the dielectric surface.

The boundary conditions for the particles in the far-field of the fluid may either be a Neumann or a Dirichlet
boundary condition, the most appropriate choice may depend on the size of the computational domain and
perhaps also on the initial condition. To start the discharge it is required to have presence of free electrons,
hence the initial number density of electrons must be nonzero. With a nonzero electron number density, it is
reasonable to also have a nonzero initial number density of the positive ions since the fluid may be assumed to be
neutral in whole. Therefore, the positive ion number density is set equal to the electron number density and the
negative ion density is set to zero such that the initial condition represents a quasineutral gas. Returning to the
far-field boundary conditions; it would be appropriate to use Dirichlet boundary conditions at the far-field for
all particle spices. However, this would require a large computational domain such that the electrical field tends
to zero at the far-field boundary and thus leaves the particles unaffected. On the other hand, a small domain is
preferred considering the computational time, suggesting that a Neumann condition with a zero gradient may
be utilized. This would allow the values on the boundary nodes to change, but with a to small domain the risk
is that the particles ”leaves the system” and no further ionization is then possible. Because of this it is perhaps
not a great advantage to use a Neumann condition rather than a Dirichlet boundary condition. Both boundary
conditions are artificial and the choice is not obvious, both conditions will be tested and discussed in the final
section of this part of the thesis.

The initial values for the electric potential is set to zero everywhere and the potential on the exposed
electrode change with time according to

φP kP
φ= sin (ωt), (2.26)
2
where φP tP is the Peak-to-Peak (PtP) voltage, ω is the angular frequency and t is the time. The second
electrode embedded in the dielectric material (the grounded electrode) is retained at zero electric potential. At
the far-field a Neumann boundary condition is applied for the electric potential, both in the fluid domain as
well as in the dielectric domain. Also in this case, this boundary condition is artificial and nonphysical but may
be implemented without any further concerns.

The final boundary condition is for the electric potential on the surface between the fluid and the dielectric
domain, in terms of the electric field the following condition must be satisfied for the surface charge density ρs
[12],

ρs = ε0 εP D Ey − ε0 εDD Ey , (2.27)

where εP D and εDD is the relative permittivity of the Plasma Domain and Dielectric Domain respectively
and the index y refer to the y-component of the electric field. The relative permittivity in the dielectric domain
will be set to 5 whereas it will be set to one in the fluid domain. The surface charge density is given by

∂ρs X
= qp Γp,y . (2.28)
∂t p

It should be stressed that in both eq. (2.27) and eq. (2.28) the direction of the surface normal vector have
been accounted for to fit this case, indicated by the y indices. The positive normal vector in y-direction is

12
taken to be from the surface and perpendicular with the surface and pointing into the fluid domain; the positive
normal vector in x-direction is taken to be from the exposed electrode and parallel with the surface and pointing
at the direction where the grounded electrode is at.

13
Chapter 3

Numerical Solution of the Plasma


Actuator Model

3.1 Introduction
All equations in the plasma actuator model are solved for in two cartesian spatial dimensions, x and y. The
equations are solved on a uniform grid with node spacing δx and δy such that x = iδx and y = jδy, where
i = 1, 2, 3, ..., N and j = 1, 2, 3, ..., M . The same grid is used for all equations, but the plasma equations are
only solved in the fluid domain whereas the Poisson’s equation for the electric potential is solved in the fluid
domain as well as in the dielectric domain. The electrodes are treated as to have zero volume, i.e. the electrodes
only span over a number of nodes in the x-direction. All vector quantities are evaluated midway between the
grid points e.g. Xi+1/2,j and Xi,j+1/2 where X is an arbitrary variable. Scalar quantities are evaluated at the
grid points Xi,j , and their values midway the points are evaluated as the average value midway the points e.g.
Xi+1/2 = (Xi+1,j + Xi,j )/2.

The equations are solved by a semi-implicit finite difference method used for instance by G. J. M. Hagelaar
[7]. The method is far more advantageous when compared to a strictly explicit method, allowing larger time
steps with increased numerical stability. Treating the equations explicitly would lead to hard restrictions of
the length of the time step to achieve numerical stability, some tests of solving Poisson’s equation explicit and
implicit were done. For the explicit solver the time step was restricted to thousandths of a nanosecond whereas
the implicit solver without any problems could handle time steps of several nanoseconds. However, large time
steps also increase the error in the solution. The length of the time steps is denoted as δt and upper index k
denotes at which time step a quantity is evaluated. The computational scheme has the following form:

First the electric field is computed at time k + 1

X
∇ · (ε0 εr E k+1 ) = qp ñk+1
p (3.1)
p

where ñk+1
p is an estimate of the number density at time k + 1,

nk+1
p = nkp + δt∇ · Γp (nkp , E k+1 , µkp , Dpk ). (3.2)

Next, the number density for each species are evaluated from

nk+1
p − nkp
+ ∇ · Γ(nk+1
p , E k+1 , µkp , Dpk ) = Spk . (3.3)
δt
All transport properties, µ and D and the source terms S are evaluated explicitly.

14
3.2 Discretization of the Transport Equations
The particle transport term in the continuity equation, eq. (3.3) are discretized by the central difference for
each species

Γx,i+1/2,j − Γx,i−1/2,j Γy,i,j+1/2 − Γy,i,j−1/2


(∇ · Γ)i,j = + . (3.4)
∆x ∆y
For implicit treatment of the number density in the drift-diffusion flux in the transport term the exponential
scheme of Scharfetter and Gummel [13] is utilized, as done in reference [7, 14, 15].

For the x-terms the flux is given by

 
1
Γx,i+1/2,j = − Di+1/2,j f1 (zx,i+1/2,j )ni+1,j − f2 (zx,i+1/2,j )ni,j (3.5)
δx

 
1
Γx,i−1/2,j = − Di−1/2,j f1 (zx,i−1/2,j )ni,j − f2 (zx,i−1/2,j )ni−1,j , (3.6)
δx

where

sgn (q)µi+1/2,j Ex,i+1/2,j δx


zx,i+1/2,j = (3.7)
Di+1/2,j

sgn (q)µi−1/2,j Ex,i−1/2,j δx


zx,i−1/2,j = (3.8)
Di−1/2,j

and

 z
 , z 6= 0
f1 (z) = exp{z} − 1 (3.9)
1, z=0

 f (z) + z = z exp{z} , z 6= 0

1
f2 (z) = exp{z} − 1 (3.10)

1, z=0

The corresponding equations for the y-term are analogous and are not written here. Substituting the
equations eq. (3.4) to eq. (3.10) together with the analogous equations for the y-component into eq. (3.3) yields
the discretized continuity equation which has the form of a linear five-point equation that relates the number
density in a point (Central) to its four neighbouring nodes, East, West, North and South

k+1 W k+1 N k+1 k+1 C k+1


aE S
i,j ni+1,j + ai,j ni−1,j + ai,j ni,j+1 + ai,j ni,j−1 + ai,j ni,j = Ai,j (3.11)

where

δt
aE
i,j = − D 1 f1 (zi+ 12 ,j ) (3.12)
δx2 i+ 2 ,j

δt
aW
i,j = − D 1 f2 (zi− 12 ,j ) (3.13)
δx2 i− 2 ,j

δt
aN
i,j = − D 1 f1 (z
i,j+ 21 ) (3.14)
δy 2 i,j+ 2

15
δt
aSi,j = − D 1 f2 (z
i,j− 12 ) (3.15)
δy 2 i,j− 2

aC E W N S
i,j = 1 − ai−1,j − ai+1,j − ai,j−1 − ai,j+1 (3.16)

Ai,j = nki,j + δtSi,j (3.17)

The coefficients eq. (3.12) to eq. (3.17) apply to every node in the fluid domain except at the boundary to
the dielectric domain. The boundary conditions eq. (2.21) and eq. (2.22) for electrons and ions respectively are
discretized as

  
1
(Γp · n̂)i,j = (2ap − 1) sgn (qp )µp np (Ey,i,j+1/2 · n̂) + vth,p np
i,j 2
 (3.18)
1 X
− vth,p nγ − 2(1 − ap )i,j γp (Γp · n̂)i,j .
2 i,j p

This equation applies for both electrons and ions with the exception that the terms including the secondary
emission shall be omitted for ions. Substituting eq. (3.18) into the discretized continuity equation gives the
five-point coefficients:

aE W S
i,j = ai,j = ai,j = 0 (3.19)

δt
aN
i,j = − D 1 f1 (z
i,j+ 21 ) (3.20)
δy 2 i,j+ 2

1 δt δt
aC
i,j = − aSi,j+1 − (2ai,j − 1) sgn (q)µi,j Ei,j+ 12 + vth,i,j (3.21)
2 δy 2δy

1 k δt δt 2δt X
Ai,j = ni,j + Si,j + vth,i,j nγ,i,j + (1 − ai,j ) γp (Γ~p · ~n)i,j . (3.22)
2 2 2δy δy p

The factor 1/2 in the first term in eq. (3.21) and the two first terms in eq. (3.22) results from that eq. (3.4)
has been evaluated over the distance δy/2. It should be stressed again that the secondary emission terms
shall be omitted from the coefficients for ions. Also, the coefficients only apply for a boundary oriented as the
boundary between the fluid- and dielectric domain with its associated coordinate system, as in this case.

16
3.3 Discretization of Poisson’s Equation
The central difference method is used to discretize the left hand side of Poissons equation, eq. (3.1)

εi+1/2,j Ex,i+1/2,j − εi−1/2,j Ex,i−1/2,j εi,j+1/2 Ey,i,j+1/2 − εi,j−1/2 Ey,i,j−1/2


(∇ · εE)i,j = + , (3.23)
δx δy
where

ε = ε0 εr . (3.24)

The right hand side of the semi-implicit equation which contain transport terms the exponential scheme is
utilized and the discretized form of one of the x-components of the flux becomes for each species [7]

 k k+1
 
Γx,i+1/2,j = sgn (q)µi+1/2,j g1 (zx,i+1/2,j )ni+1,j − g2 (zx,i+1/2,j )ni,j Ex,i+1/2,j
p
 k (3.25)
ni+1,j − ni,j
− Di+1/2,j h(zx,i+1/2,j ) ,
δx p

where

2
 f (z) − ∂f1 (z) z = f (z) − ∂f2 (z) z = z exp{z} , z 6= 0

1 2
h(z) = ∂z ∂z (exp{z} − 1)2 (3.26)

1, z=0

 ∂f1 (z) = (1 − z) exp{z} − 1 , z 6= 0


g1 (z) = ∂z (exp{z} − 1)2 (3.27)


−1/2,

z=0

 ∂f2 (z) = exp{z} exp{z} − (1 + z) , z 6= 0


g2 (z) = ∂z (exp{z} − 1)2 (3.28)



1/2, z=0

The corresponding equations for the other terms are analogous. Making use of eq. (2.8) and discretizing it
yields

φi+1,j − φi,j
Ex,i+1/2,j = − . (3.29)
δx
Substituting eq. (3.23) to eq. (3.29) into eq. (3.1) gives the following five-point equation and associated
coefficients:

k+1 W k+1 N k+1 S k+1 C k+1


aE
i,j φi+1,j + ai,j φi−1,j + ai,j φi,j+1 + ai,j φi,j−1 + ai,j φi,j = Ai,j (3.30)

 k
 
1 δt X
aE
i,j = ε i+1/2,j − |q|µ g (z
i+1/2,j 1 x,i+1/2,j )n i+1,j − g (z
2 x,i+1/2,j )n i,j (3.31)
δx2 δx2 p p

 k
 
1 δt X
aW
i,j = 2 εi−1/2,j − 2 |q|µi−1/2,j g1 (zx,i−1/2,j )ni,j − g2 (zx,i−1/2,j )ni−1,j (3.32)
δx δx p p

 k
 
1 δt X
aN
i,j = 2 εi,j+1/2 − 2 |q|µi,j+1/2 g1 (zy,i,j+1/2 )ni,j+1 − g2 (zy,i,j+1/2 )ni,j (3.33)
δy δy p p

17
 k
 
1 δt X
aSi,j = ε i,j−1/2 − |q|µi,j−1/2 g1 (zy,i,j−1/2 )n i,j − g2 (z y,i,j−1/2 )n i,j−1 (3.34)
δy 2 δy 2 p p

aC E W N S
i,j = −ai,j − ai,j − ai,j − ai,j (3.35)

"
X qδt qδt
Ai,j = − qni,j +D
2 i−1/2,j
h(zx,i−1/2,j )(ni,j − ni−1,j ) − 2 Di+1/2,j h(zx,i+1/2,j )(ni+1,j − ni,j )
p
δx δx
#k (3.36)
qδt qδt
+ 2 Di,j−1/2 h(zy,i,j−1/2 (ni,j − ni,j−1 ) − 2 Di,j+1/2 h(zy,i,j+1/2 )(ni,j+1 − ni,j ) .
δy δy
p

The surface charge density is evaluated semi-implicit, eq. (2.27) and eq. (2.28) are discretized as

(ρs )i,j = εi,j+1/2 Ey,i,j+1/2 − εi,j−1/2 Ey,i,j−1/2 , (3.37)

(ρs )k+1 k
i,j − (ρs )i,j
X
= qp Γp,y,i,j+1/2 , (3.38)
δt p

where the fluxes are given by eq. (3.25). Dividing eq. (3.37) by δy makes the equation take the form of the
discretized Poisson’s equation and solving for the coefficients of the five-point equation yields

1
aE
i,j = εi+1/2,j (3.39)
δx2

1
aW
i,j = εi−1/2,j (3.40)
δx2

 k
 
1 δt X
aN
i,j = 2 εi,j+1/2 − 2 |q|µi,j+ 21 g1 (zi,j+ 12 )ni,j+1 − g2 (zi,j+ 21 )ni,j (3.41)
δy δy p p

1
aSi,j = εi,j−1/2 (3.42)
δy 2

aC E W N S
i,j = −ai,j − ai,j − ai,j − ai,j (3.43)

k k
σi,j

δt X
Ai,j =− + 2 qDi,j+ 2 h(zi,j+ 2 )(ni,j+1 − ni,j )
1 1 (3.44)
δy δy p p

18
3.4 Iterative method
The five-point equations which have the form

aE W N S C
i,j Xi+1,j + ai,j Xi−1,j + ai,j Xi,j+1 + ai,j Xi,j−1 + ai,j Xi,j = Ai,j , (3.45)

where X is an arbitrary quantity are iterated to a certain convergence criterion for each time step. The
Modified Strongly Implicit (MSI) method developed by Schneider and Zedan [16] is utilized for the iterative
procedure of the five-point equations. The method is also used and modified for increased stability by G. J. M.
Hagelaar [7], here the modified version is used as well. According to G. J. M. Hagelaar the method is usually far
more powerful than SOR (Successive OverRelaxation) which is a very common method. In addition to the MSI
method, at each time step before the iterative procedure the quantity X will be initialized by the solution of
the previous time step, which is a good guess for the next time step. The MSI method is implemented as follows:

First the coefficients for the method are evaluated for each node:

 S
 2ai,j ,
 1-αfi,j−1 fi+1,j−1 < 1/2
bi,j = aSi,j (3.46)
 , 1 - fi,j−1 fi+1,j−1 ≥ 1/2
1 − αfi,j−1 fi+1,j−1

ci,j = −bi,j fi,j−1 (3.47)

 W
 2ai,j ,
 1 + 2αgi−1,j < 1/2
di,j W
= ai,j − bi,j gi,j−1 (3.48)
 , 1 + 2αgi−1,j ≥ 1/2
1 + 2αgi−1,j

Φ1i,j = ci,j fi+1,j−1 (3.49)

Φi,j 4 = di,j gi−1,j (3.50)

ei,j = aC 1 4
i,j − bi,j hi,j−1 − ci,j gi+1,j−1 − di,j fi−1,j + 2α(Φi,j + Φi,j ) (3.51)

aÊ i,j − ci,j hi+1,j−1 − 2αΦ1i,j


fi,j = (3.52)
ei,j

di,j hi−1,j
gi,j = − (3.53)
ei,j

aN 4
i,j − αφi,j
hi,j = (3.54)
ei,j

where α is a convergence parameter with a value between 0 and 1, usually a value about 0.9 for α gives a
fast convergence [7]. The coefficients, eq. (3.46) to eq. (3.54), has to be evaluated only ones each time step. The
iterative procedure requires four steps and is as following:

First the residual vector r is evaluated

ri,j = Ai,j − aE W N S C
i,j Xi+1,j − ai,j Xi−1,j − ai,j Xi,j+1 − ai,j Xi,j−1 − ai,j Xi,j . (3.55)

19
Secondly an intermediate vector v is found by a forward substitution

1
vi,j = (ri,j − bi,j ri,j−1 − ci,j ri+1,j−1 − di,j ri−1,j ) (3.56)
ei,j

Then a backward substitution of v gives the change vector δ:

δi,j = vi,j − fi,j vi+1,j − gi,j vi−1,j+1 − hi,j vi,j+1 (3.57)

And finally the change is added to X

Xi,j = Xi,j + δi,j (3.58)

This four steps are repeated until the norm of the residual satisfy the convergence criterion

|r| < (|A| + |aC ||X|) · 10−6 , (3.59)

where the last factor may be change to increase or decrease the convergence criterion.

3.5 Implementation
The discretized equations for the plasma actuator model were implemented in a MATLAB script. MATLAB
was used because of its ease of implementation, troubleshooting and evaluation of the result. The code could
probably be written more efficient concerning computational time and memory allocation, for instance some
matrices could be reused for several variables instead of defining each one of them. However, these matrices
just contain data for one time step and are small in comparison to the matrices containing the electric potential
and the number densities which contain data for all time steps. For the assessment of the result it is important
to save the time evolution of the electric potential and the number densities, but the size of the matrices may
be of concern, it is also necessary to run the simulations for more than one period since it is reasonable to
assume that the first period may differ from the succeeding periods. Simulations were done with different
values for the plasma actuator parameters, PtP voltage and frequency and also the size of the computational
domain and grid spacing. The goal was of course to use values that were used in the experiments that will be
presented in the next part of the thesis, to make it possible to compare the theoretic result with the experiments.
Therefor it should be mentioned here that a frequency of 8kHz and a PtP voltage up to 16200V were used in the
experiments. The script was running on an ordinary PC with a 3.6GHz six-core processor and with 32GB RAM.
The implementation of the code and the values of the parameter will be further discussed in the discussion later
on. The code is attached in appendix A.

20
Chapter 4

Simulations Result and Discussion

4.1 Result
Figure 4.1 shows the time averaged force from a simulation with a PtP voltage of 500V and with a frequency
of 40kHz. The time averaged force field is computed with eq. (2.10).

Figure 4.1: Time averaged electrostatic force. The exposed electrode positioned at y = 0, and at negative x
values ending at x = 0. The grounded electrode starts at x = 0 and with a negative y-cordinate

4.2 Discussion on the Theoretical Part


Although a lot of effort was put on this part of the thesis, any conclusive results were not obtained. Figure 4.1
shows the time averaged electrostatic force from the second period. However, this result was obtained from a
simulation with low PtP voltage (500V), high frequency (40kHz), relative small computational domain (4×2cm),
grid spacing dx = dy = 5 · 10−5 m and with a time step of one nanosecond. The low voltage allows larger grid
spacing, the high frequency reduces the number of time steps in a period and the small domain reduces the
number of grid points, all together reducing the size of the computational matrices, which was one of the major
problem. Because of the out-of-range values it is not possible to do a comparison with empirical result and the
simulation does not provide that much information. The one thing that is interesting is the direction of the

21
vector field, showing that the time-averaged force is directed as expected, from the exposed electrode, toward
and fairly horizontal over the grounded electrode. The magnitude of the vector field is not that interesting
because of the low voltage, the small area over which the force is acting is also because of the low voltage. The
size of the time step was kept relative low even though it was possible to run the code with significant larger
time steps and larger steps would require fewer steps in total. It was found that the total computational time
actually was shorter with more but smaller time steps. The reason to this is that every time step is initialized
with the solution of the previous time step and shorter time steps means that the solutions are more similar
and fewer iterations are required to find the new solution.

The different boundary conditions, Dirichlet and Neumann, for the particles at the far-field was also tested.
The force field in figure 4.1 was calculated from a solution where Dirichlet boundary condition was used. This
resulted in large gradients of the number density at the far-field boundaries which are not physical. With the
Neumann boundary condition, the number densities rapidly decreased in the domain which is a problem since
the density cannot rise again at the boundary when the electric field alter its direction. The conclusion is that
in both cases the computational domain has to be significantly larger.

It was not possible to run the code with the same values of the parameters as were used in the experiments,
the large matrices require more memory than what was available. The computational domain has to be large,
the grid spacing have to be small to restrict the gradient of the electric potential between two adjacent grid
points. Moreover, the time must be small in comparison to the time of a period. There are several possible ways
to avoid this problem, and some attempt was performed. To decrease the number of nodes in the computational
domain a nonuniform, stretched mesh was introduced. The discretized equations presented in this thesis are
not valid for a nonuniform mesh, therefore the equations were recalculated for this purpose. The new equations
were together with a stretched mesh implemented in the code. The stretched mesh has high node density at
areas of large gradients of the electric potential, i.e. where the electrodes are close together. Unfortunately,
the solution only converged with a small stretching of the mesh and the number of nodes did not decrease
significantly. Due to time limitations this issue has not been further investigated. Since it wasn’t possible to
run the code with the appropriate values, the code may not be validated through comparison with empirical
data or other simulations, it is possible that the code contains errors.

Perhaps the most efficient way to reduce the size of the computational matrices would be to just have the
two time steps k and k + 1 in the memory. The time integration of the electrostatic force field may be per-
formed at each time step instead of as now, afterwards when all solutions are known. Some knowledge of the
time evolution is however important, one suggestion is to save the solution for example at every hundred time
step. This suggestion has not been implemented and tested, the memory problem would vanish, at least if the
solution is saved seldom enough. Besides the memory problem due to the number of nodes and number of time
steps, the computational time which also are dependent of these parameters is of major concern. The code may
be written more efficient but it should also be considered to write the code in for example Fortran or some other
high-level languish which are much more efficient than MATLAB.

In addition to the MATLAB code, with the ongoing issues with the code, some attempts were done to
solve the governing equations with COMSOL Multiphysics. The equations were implemented as user-defined
equations and no particular COMSOL module were used. The issues utilizing COMSOL were broadly the same
to the issues with the MATLAB code, unable to handle large PtP voltages and a long computational time.
But in fact, COMSOL could handle slightly higher voltages, probably because COMSOL’s greater meshing
capabilities. The great disadvantage of using COMSOL is however the difficulty to investigate issues, such as
numeric instabilities for example.

22
Part II

Empirical Study

23
Chapter 5

Equipment

The development of the equipment, the PIV measurements and the wind tunnel test that will be presented in
this chapter were conducted in collaboration with Oscar Eriksson and his master thesis at Luleå university of
Technology.

5.1 High Voltage Source


The high voltage source required to perform the experiments are no standard equipment and had to be designed
and built as a part of this thesis. There are some manufactures of high voltage sources for discharge applications
but the narrowly limited budget for this thesis did not allow any purchase of any high voltage source. The
experience of electrical engineering is limited concerning the author of the thesis, therefore the final product
is somewhat a product of trial and error. Because of the limited knowledge some reasoning concerning the
electrical design may be flawed or wrong.

The basic idea was to use a sinusoidal wave from a signal-generator and via a current-amplifier connect it
to a transformer and thereby increase the voltage. The current-amplifier was the critical issue of this idea and
initially the ideas of a solution were few. As mentioned the final design is based on trial and error and the
development are not that interesting and will not be discussed in detail. In the final design the current-amplifier
consist of a single N-Channel Power MOSFET transistor as showed in figure 5.1, and should perhaps not be
called a current-amplifier. It was found that by connecting the signal-generator and a DC power supply via the
transformer to the transistor, an approximate sinusoidal-like high voltage could be measured over the plasma
actuator. The full electrical circuit are shown in figure 5.1.

Figure 5.1: Electrical schematics of the AC high voltage power supply.

24
The measured sinusoidal-like wave is due to the inductance in the transformer and due to the characteristics
of the transistor. Whether the wave could be considered to be sinusoidal-like or not turned out to be dependent
of the frequency. It was found that a frequency of 8kHz gave the best result considering both the shape of the
wave and the amount of visible light emitted from the plasma actuator, here it was assumed that the stronger
light from the actuator, the stronger effect of the actuator. Because the design limits the frequency range it
was determined that all experiments should be performed with a frequency of 8kHz. The PtP voltage could
still be varied and did not significantly affect the shape of the wave, apart from the amplitude of course. The
lowest PtP voltage that gave a visible plasma was found to be 5400V, which required a voltage of 6V from the
DC power supply. This setting is lower than the voltage required for the cooling fan and the power-on warning
light that was added to the design, which requires 12V, but it could be used with this setting without any
major problems, but the cooling is less efficient. The upper PtP voltage limit was determined by the maximum
current the DC power supply could deliver, which was 3.1A. The DC voltage was with this setting 26V and the
PtP voltage over the plasma actuator was 16200V, figure 5.2 shows the AC voltage over the plasma actuator
and the voltage over the transistor for this setting. The transistor develops a lot of heat and needs to be cooled;
a heat sink was therefore mounted on the transistor. A diode was also added to the circuit as seen in figure 5.1,
to protect the transistor from high-voltage spikes. The transformer used in the circuit is actually an ignition
coil from the ignition system of a car which have a suitable winding turns ratio. The transformer can be seen
in figure 5.3 together with a plasma actuator in operation.

Figure 5.2: Upper curve shows the PtP voltage over the plasma actuator and the lower curve shows the voltage
over the transistor.

25
Figure 5.3: Transformer together with a plasma actuator in operation.

A circuit board was etched and the electrical components were soldered to the board. The transistor was
mounted with a screw-connector on the circuit board such that it could be replaced with ease. The circuit board
was together with the cooling fan and other components mounted in a box built of Plexiglas and a 3D printed
frame. 4mm female banana-connectors was mounted on the sides in the Plexiglas for the DC power supply,
output to the transformer and for the signal-generator input. Also the power-on warning light was mounted on
the Plexiglas, the final construction of the AC power supply for the transformer is seen in figure 5.4.

(a) Rear view. (b) Front view.

(c) Top view.

Figure 5.4: AC power supply.

The design turned out to be fairly reliable and worked well throughout the experiments. However, a few
times the transistor broke and had to be replaced. This issue occurred however when there was some issue with
the plasma actuator resulting in sparks between the electrodes or at some other place.

26
5.2 Plasma Actuator
The plasma actuators were manufactured from thin adhesive copper strips as electrodes and adhesive polyimide
film as dielectric. The polyimide film is 0.05mm thick and one layer was not enough, with just one layer sparking
occurred through the film. It was found that four layers gave a reliable actuator, thus the total thickness of
the polyimide film is 0.2mm. The length of all plasma actuators used was 10cm and the width was as earlier
mentioned 10mm. Figure 5.5 shows a plasma actuator mounted on a wing section that later was used in a wind
tunnel test. For the other experiments the actuators were built on a flat Plexiglas sheet as seen in figure 5.6,
were the actuator is turned on.

Figure 5.5: Plasma actuator mounted on a wing section.

Figure 5.6: Running plasma actuator on a flat plexiglas sheet.

27
Chapter 6

PIV and Wind Tunnel Experiments

6.1 Introduction to PIV


PIV, or Particle Image Velocimetry as it stands for, is as the names implies a method to measure an instantaneous
velocity field by utilizing images of particles in a flow taken by a camera. The particles are inserted to the flow
and are usually referred to as seeding particles. The seeding particles must be small enough and is preferred
to have a similar density as the fluid such that they follow the flow of the fluid [17]. The choice of seeding
particles thus depends on the fluid, for instance small glass beads, flakes or oil droplets may be used. To make it
possible for the camera to see the particles they are illuminated by a pulsed laser during the short duration when
the pictures are taken such that the particles are ”frozen” without any visible streaks behind. A picture-pair
is taken at some frequency that sometimes have to be adjusted dependent of the kind of flow. If the flow is
laminar and may be seen as stationary the frequency is of minor importance but if the flow is turbulent and
irrational the frequency must be rather high to capture the fluctuations over time. The time between the two
pictures in a pair is of great importance in all cases, the time must be adjusted such a single seeding particle
can be distinguished and seen in both pictures. After a measurement sequence the images is analyzed by a
PIV-software that calculates the velocity field of the fluid.

6.2 Considerations Utilizing PIV in Plasma Experiment


Since the PIV method uses laser to illuminate the seeding particles it is not ideal to have other light sources
in the measurement area. This is a problem that is hard to avoid in this experiment since the plasma region
continuously will radiate visible light during the discharges. This may most likely cause disturbance of the
measurements inside and perhaps also in the vicinity of the plasma region. In addition, the seeding particles
may get affected in different way by the strong electric field. These effects are not known and nor it will be a
subject of further study in this work. It was considered to try to shield the plasma area such that the camera
could not see this radiation directly, but by doing so some data perhaps would go lost that in fact was obtainable.
Moreover, the shield would not prevent the radiation from the plasma to illuminate seeding particles outside the
shielded area. Therefore it was decided not to use any shield at all during the experiments. If the disturbances
are too great with poor measurements as a result this may have to be reconsidered.

28
6.3 PIV Experiment Setup
The PIV measurements was performed with the plasma actuator placed in an enclosed Plexiglas box as can
be seen in figure 6.1. The goal with this setup was to capture the induced velocity field from the actuator
without any other flow present. The transformer was placed directly underneath the Plexiglas plate with the
plasma actuator, to avoid long high voltage wires. As seeding particles, an ordinary smoke machine for flow
visualization was used, which uses its appurtenant oil to produce the smoke. The smoke was inserted into the
box and left to settle about five minutes before any measurements begun. Very little smoke was required and
was not visible after a few minutes. Two measurements sequences were performed, with different measurement
areas. In the first sequence the camera was placed such that the area was approximately 50 × 50mm, and in
the second sequence the camera was replaced such that the area was approximately 25 × 25mm. The plasma
actuator is located in the lower part of the measurement area and the upper part is of little interest, therefore
only the lower half part will be shown in the result. In both cases the measurement area started just before the
exposed electrode, i.e. up-streams.

Figure 6.1: Experiment box together with the PIV camera and some of the electrical equipment used.

The measurements were performed with a voltage sweep, the voltage was increased in steps of one volt on
the DC voltage source, i.e. at the low voltage side of the transformer. The lowest voltage set was 6V which
gave a PtP voltage of 5400V over the plasma actuator, which was the lowest setting giving a visible plasma.
The highest voltage tested was 26V on the low voltage side which gave 16200V PtP over the actuator. For
each voltage setting a series of 100 picture-pairs was taken over a duration of ten seconds, i.e. the capture
frequency was 10Hz. The time between the two pictures in a pair was set to 50 µs. Each measurement began
and continued with the plasma actuator turned on and the result was post-processed such that a time-averaged
velocity field was determined, i.e. the steady-state velocity field. The steady-state velocity field is the result of
greatest interest in this work; however, some measurements were performed in addition to the two measurement
sequences with the actuator turned off at the start of the measurement, in this way it was possible to capture
the start-up vortex.

29
6.4 PIV Measurement Results
In this section the results of the PIV experiment are presented. Each measurement is here presented as the
contour of the time averaged velocity field except figure 6.2 and 6.3 which shows the velocity field and streamlines
of a start-up vortex.

Figure 6.2: Velocity field of a start-up vortex. Velocity components below 0.2m/s are set to zero in this figure,
to somewhat improve the visibility of the velocity field.

Figure 6.3: Streamlines of start up vortex. The ”cross” seen is due to the streamline seeding points.

30
(a) (b)

(c) (d)

(e) (f)

(g) (h)

Figure 6.4: (a)-(h) shows the contours of the magnitude of the velocity from measurement sequence one, PtP
voltages between 5400V and 10200V.

31
(a) (b)

(c) (d)

(e) (f)

(g) (h)

Figure 6.5: (a)-(h) shows the contours of the magnitude of the velocity from measurement sequence one, PtP
voltages between 10600V and 13600V.

32
(a) (b)

(c) (d)

(e)

Figure 6.6: (a)-(e) shows the contours of the magnitude of the velocity from measurement sequence one, PtP
voltages between 14200V and 16200V.

33
(a) (b)

(c) (d)

(e) (f)

(g) (h)

Figure 6.7: (a)-(h) shows the contours of the magnitude of the velocity from measurement sequence two, PtP
voltages between 5400V and 10200V.

34
(a) (b)

(c) (d)

(e) (f)

(g) (h)

Figure 6.8: (a)-(h) shows the contours of the magnitude of the velocity from measurement sequence two, PtP
voltages between 10600V and 13600V.

35
(a) (b)

(c) (d)

(e)

Figure 6.9: (a)-(e) shows the contours of the magnitude of the velocity from measurement sequence two, PtP
voltages between 14200V and 16200V.

36
6.5 Visualization in Wind Tunnel
In addition to the PIV measurements a test was performed in a wind tunnel, mainly for visualization purpose
and no further measurements were done. The plasma actuator was placed at the quarter chord on a NACA0012
with a chord length of 0.1 metres and as in previous experiments the plasma actuator was 10cm long. The free
stream speed was set to approximately 1.5m/s, the Reynolds number at this condition is about 10000. The wing
was placed at a high angle of attack in the wind tunnel, about 20 degrees which is well above the stall angle at
this low Reynolds number. The stall angle is about 10 degrees according to AirfoilTools.com [18], which also
later will be confirmed by CFD in the next section. The high AoA and low free stream velocity were chosen
because it should be easy to visually see the effect of the plasma actuator. This test was only performed with
the highest setting of the voltage, namely 16200 V PtP. During the visualization in the wind tunnel a stream of
smoke was induced 10 − 20cm in front of the leading edge. The test was filmed using a Gopro camera standing
inside the wind tunnel. A LED-light was used in the dimmed room to illuminate the smoke during filming.
Figure 6.10 shows two snapshots from the wind tunnel film, one with the actuator turned off and the second
with the plasma actuator turned on.

(a) (b)

Figure 6.10: Flow over wing section, (a) plasma actuator off, (b) plasma actuator on.

37
Chapter 7

Discussion on the Empirical Part

The results of the first PIV measurements sequence, figure 6.4 to 6.6, shows as expected a lot of disturbance
at the plasma region. However, the intense disturbance is concentrated to the small area where the plasma
is located and the overall velocity field is clearly captured in the measurements. But also outside the plasma
region there are some disturbances in the measurements, but these are not all that clear to see in the figures
presented here, the individual vector field for a certain time have to be studied to see this. These disturbances
may probably be seen as normal due to the method used. A fluid with higher density and viscosity such as water
is most likely easier to perform PIV measurements without these disturbances seen in this result. Unreasonable
values in the result can directly be filtered by the PIV software and so was done. The interesting result in this
work was the time averaged velocity field and by increasing the duration of the measurement, the accuracy
could easy be increased.

The second measurement sequence with the smaller test area shows a higher degree of noise as seen in figure
6.7 to 6.9. This is not that surprising since the smaller area increases the resolution. It is possible that an
adjustment of the time between the picture pairs would reduce the noise, but this may give other bad effects.
One disadvantage of the PIV method is that the optimal time between the picture pairs is dependent of the
local velocity. In measurement areas with significant different velocities, one cannot have the optimal time for
all regions.

Figure 6.10 shows two snapshots from the wind tunnel test film. Figure 6.10(a) shows the flow with the
plasma actuator turned off. Here, the flow separates near the leading edge and there is a large area of recir-
culating fluid above the wing. It is clear that the wing is well above the stall angle and hence is completely
stalled. In figure 6.10(b) the plasma actuator is in operation and a large difference in the flow behaviour can
be seen. The flow still separates near the leading edge, but the flow is reattached behind the plasma actuator.
This test clearly shows the potential use of plasma actuators for flow separation control; however, the velocity
is very low during this test.

38
Part III

Empirical Plasma Actuator Model

39
Chapter 8

Empirical Plasma Actuator Model

8.1 CFD Plasma Actuator Model


The purpose of this part of the thesis is to develop a simple model of the plasma actuator that may be used
in CFD, to study the effects of the actuator and the effects for different peak to peak voltages. The model will
be based on the empirical data obtained from the PIV measurements. The model is developed with the use of
user defined function (UDF) in ANSYS Fluent. An UDF in Fluent consists of a C-code file that have to be
compiled before the CFD is started. The CFD simulations were performed in two dimensions in a rectangular
area with zero initial velocity inside, similar to how the PIV measurements were performed. The UDF was then
the only source of momentum in the simulation. The UDF consist of a single momentum source within an area
where the plasma actuator was considered to produce momentum. The fluid flow model used was a standard
Spalart–Allmaras model.

From the PIV measurements is was concluded that the length over which the fluid is accelerated behind
the actuator is increasing with increasing voltage but there is no significant increase in height of this area with
increased voltage. Therefore the height of the momentum source area was determined to be 0.5mm, starting
0.5mm above the surface and that the length L of the area will be varied linear with the voltage according to,

0.0175 − 0.003
L= (φpp − 5400) + 0.003 m. (8.1)
16200 − 5400
The plasma area hence starts at the end of the exposed electrode and extends 3mm behind it when the
PtP voltage is 5400V, and increases to 17.5mm behind when the voltage is 16200V. The value given to the
momentum source within the plasma area have been determined by trial and error through comparing velocity
profiles behind the plasma actuator from the PIV measurements with velocity profiles from the CFD simulations.
Figure 8.1 shows two examples from the comparison of velocity profiles. The velocity profiles from the PIV
measurements which is used for comparison are taken from the first measurement sequence. It was considered
that the best place to compare the velocity profile is behind the plasma actuator where the flow has ceased
to accelerate. For the highest voltages this is outside the measurement area for the second PIV measurement
sequence, therefore it was determined to only use the first sequence. The velocity profiles are taken at different
x-coordinates, depending on the PtP voltage. For the highest voltage the velocity profiles were compared 4cm
behind the exposed electrode, and for lower voltages the distance was decreased.

40
(a) (b)

Figure 8.1: (a): Velocity profile 4cm behind the exposed electrode with PtP voltage 16200V. (b): Velocity
profile 2cm behind the exposed electrode with PtP voltage 7800V.

The values of the strength of the source that gave approximately the corresponding velocity profile as the
PIV measurements is seen in figure 8.2, however this values of the source affects different areas, depending on
the length according to eq. (8.1) and with the height 0.5mm. The effect of the plasma actuator is better seen
by multiplying the source values by the area where the source is acting, resulting in a dependence of only the
PtP voltage and units of force per metre. The result of this is seen in figure 8.3, to this set of data points a
curve fitting was done, the fitted function is according to eq. (8.2), and is also seen in the figure.

Figure 8.2: The x-momentum values for the source as function of the PtP voltage.

41
Figure 8.3: Force per metre as function of the PtP voltage.

F 0 = 9.951 · 10−12 φ3.432


pp + 36.37 N/m (8.2)

To show and compare the overall flow pattern the streamlines for a particular case is showed in figure 8.4,
figure 8.4(a) from PIV measurement and 8.4(b) from CFD.

(a) (b)

Figure 8.4: (a) streamlines from PIV measurements and (b) from CFD. PtP voltage set to13600V.

42
A CFD simulation of the wind tunnel test case was also performed to further validate the CFD plasma model
by comparison with empirical evidence. The CFD was setup with the same geometry as in the wind tunnel and
with 16200V PtP according to the CFD plasma model. The CFD was two-dimensional and as before a standard
Spalart–Allmaras model in ANSYS Fluent was used. Figure 8.5 shows the result and can be compared with
figure 6.10 from the wind tunnel.

(a) (b)

Figure 8.5: CFD simulation of wind tunnel case, (a) plasma actuator off, (b) plasma actuator on.

43
8.2 Airfoil Performance with Plasma Actuators
The CFD plasma model was used to predict the airfoil performance with plasma actuators. The same model as
used for the wind tunnel comparison in the previous section was utilized and hence has the same dimensions and
airfoil profile. The Spalart–Allmaras model in two dimensions in ANSYS Fluent was used for the simulations.
Simulations were done for a free stream velocity of 5m/s, 10m/s, 15m/s and 20m/s. The AoA was varied,
starting at zero and increased by one degree for each simulation until the lift coefficient started to decrease and
hence the airfoil section was stalled. For the cases with a free-stream velocity of 5m/s and 10m/s three different
simulations were done, one without plasma actuator for comparison, one with a single plasma actuator at the
quarter chord and one with three plasma actuators. With three actuators, one plasma actuator was placed near
the leading edge, one at the quarter-chord and one at a quarter of the chord length from the trailing edge. In
the cases with a free-stream velocity of 15m/s and 20m/s simulations were only done without and with three
actuators. The result of these simulations is shown in figure 8.6.

(a) (b)

(c) (d)

Figure 8.6: Lift coefficient Cl as function of AoA, (a) free-stream velocity 5m/s, (b) 10m/s, (c) 15m/s and (d)
20m/s.

44
8.3 Discussion on CFD Plasma Model
The CFD plasma model is simple but powerful and could also be used in three-dimensional CFD simulations.
Surprisingly it was easy to find values for the momentum source for the CFD simulation such that the ve-
locity profiles behind the actuator become similar to the velocity profiles from the PIV measurements. Also
surprisingly, the velocity profiles became more similar than expected. Figure 8.3 shows an interesting result,
an extrapolation of the curve with increasing voltage would give a relative large increase of the force, the force
seems to grow exponentially with the voltage. This implies that it would be interesting to use a different DC
source that could deliver more current such that the PtP voltage could be increased. An increase of the voltage
may however lead to problems, for instance it is likely that the plasma actuator would develop a lot of heat
that destroys the actuator, which not was a severe problem during the experiments. The model may not be
considered to be very accurate because of its simplicity, not at least because of the simplicity of the analysis
method. However the comparisons, figure 8.1, 8.4 and 8.5 compared with 6.10 shows a relative good result and
the model capture the general flow field. One disadvantage with the model is that since it is based on empirical
data from a plasma actuator with a certain geometry the model cannot be assumed to be correct for an actuator
with a different geometry. The length of the actuator however may be changed, but this should be confirmed
by experiments before it could be determined by certainty.

Figure 8.6 shows the result of the airfoil performance simulations. With three actuators it can be said that
there is a significant increase of the maximum lift coefficient in all cases. At 20m/s the maximum lift coefficient
is increased with about 14 percent and at 5m/s it is increased by 108 percent compared to the case without
any plasma actuator. With one actuator however, the effect of the plasma actuator is minor already at 10m/s
and may be assumed to be insignificant at higher velocities. The result is interesting and shows the potential
of using plasma actuators. However, the simulations are done on a relative small airfoil and the effect of the
plasma actuator rapidly decrease with increased speed of the flow.

45
Part IV

Final Discussions and Conclusions

46
Chapter 9

Discussion, Conclusion and future work

The theoretical part of this thesis was somewhat a drawback, with inconclusive results. The few results provided
implied some of the expected result; the time averaged force was pointing in the right direction, as figure 4.1
shows. But due to the low voltage and high frequency in the simulation, definitive conclusions cannot be stated.
The model is however worth continuing with further work and is still considered to have potential. As earlier
discussed, there are suggestions to improve the code and its setup to make conditions such that the code can
run with the appropriate frequency and voltage. Rewrite the code in a more time-efficient language, fewer time
steps in the memory and continuing investigate the use of a nonuniform grid, are some of the suggested actions
that may solve the issues.

Utilizing PIV to measure the effect of the plasma actuator gave an acceptable result, at least for the purpose
of this thesis. The disturbances due to the actuator itself are however probably unavoidable, the flow in and
near the plasma region cannot be captured by the PIV camera. In a future work it could be considered to use
a different measurement technique to capture the flow in more detail in the plasma region.

The empirical plasma actuator model showed interesting result, both figure 8.3 which implies that an increase
of the maximum PtP voltage would give a significant increase of the induced force; and figure 8.6 shows the
potential of utilizing plasma actuators for flow control. Despite the simplicity of the model, it shows promising
results, the overall flow pattern is similar to that of the empirical result. The lift coefficient curves have however
not been confirmed by experiment, but such experiment could easily be conducted, at least for the case with
one actuator. The same setup as used to visualize the effect of the plasma actuator in this thesis could be
used. In the case of three actuators some potential problems must be considered. Can the high voltage power
supply deliver enough current to power three actuators? Probably there will be a voltage drop, leading to a
reduced maximum PtP voltage. This is however a problem that may be overcame fairly easy, by a redesign
of the voltage supply or by manufacturing of additional power supplies. But there is a more severe problem,
there must be some distance between the actuators such that they don’t affect each other. This may be hard
to achieve on the relatively small wing section used.
If more accurate result is required, a lot more effort may be put on the empirical plasma actuator model. A
more sophisticated methodology may be used instead of just comparing the velocity profiles behind the actuator.
But if it should be worth the effort, perhaps more accurate empirical data is required as well, especially in the
plasma region.

To sum up, the use of plasma actuators for flow control is interesting and shows promising result. However, at
present the effect is limited to relatively low flow-speeds; which limits the area of practical application. Perhaps
the most importance of future work lies in the development of a code that efficiently solves the governing
equations of the plasma actuator, thereby the effect of the plasma actuator could be studied more efficiently.

47
Bibliography

[1] Dmitry F. Opaits. Dielectric Barrier Discharge Plasma Actuator for flow control. NASA Center for
Aerospace information, http: www.sti.nasa.gov, 2012.
[2] Lawrence A. Kennedy Alexander Fridman. Plasma Physics and Engineering. CRC Press, 2004.
[3] P. G. Huang J.S. Shang. Modeling surface plasma actuator for flow control. Conference Paper, AIAA,
January 2014, 2014.

[4] Sergey T.Surzhikov Joseph S.Shang. Two-component plasma model for two-dimensional glow discharge in
magnetic field. Journal of Computational Physics, 199:437–464, 2004.
[5] F. Francis Chen. Introduction to plasma physics and controlled fusion. Plenum Press, 233 Spring Street,
New York, N.Y. 10013, 1984.
[6] R. Y. PAI H. W. ELLIS and E. W. MCDANIEL. Transport properties of gaseous ions over a wide energy
range. Atomic Data and Nuclear Tables, 17(3):203, 1976.
[7] Gerardus Johannes Maria Hagelaar. MODELING OF MICRODISCHARGES FOR DISPLAY TECHNOL-
OGY. Universiteitsdrukkerij Technische Universiteit Eindhoven, Eindhoven, 2000.
[8] F. J. de Hoog G. J. M. Hagelaar and G. M. W. Kroesen. Boundary conditions in fluid models of gas
discharges. PHYSICAL REVIEW E, 62(1), 2000.
[9] Alexandre A. Radzig Igor S Grigoriev, Evgenii Z. Meilikhov. Handbook of Physical Quantities. Taylor
Francis Inc, Bosa Roca, United States, 1996.
[10] Richard B. Miles Sergey O. Macheret, Mikhail N. Shneider. Modeling of air plasma generation by repetitive
high-voltage nanosecond pulses. IEEE TRANSACTIONS ON PLASMA SCIENCE, 30(3), 2002.

[11] Dmitry F. Opaits Richard B. Miles Alexandre V. Likhanskii, Mikhail N. Shneider. Numerical modeling of
dbd plasma actuators and the induced air flow. AIAA Plasmadynamics and Lasers Conference, 38, 2007.
[12] Matthew N.O. Sadiku. Elements of Electromagnetics. Oxford University Press, Inc, 198 Madison Avenue,
New York, New York 10016, 2011.

[13] D.L. Scharfetter and H.K. Gummel. Large-signal analysis of a silicon read diode oscillator. IEEE Trans.
Electron Devices, ED-16(1), 1969.
[14] J. D. P. Passchier and W. J. Goedheer. A two-dimensional model for an argon rf discharge. J. Appl. Phys,
74(6), 1993.

[15] E.A.G. Hamers W.G.J.H. van Sark G.J. Nienhuis, W.J. Goedheer and J. Bezemer. A self-consistent fluid
model for radio-frequency discharges in sih4-h2 compared to experiments. J. Appl. Phys, 82(5), 1997.
[16] G. E. Schneider and M. Zedan. A modified strongly implicit procedure for the numerical solution of field
problems. Numerical Heat Transfer, 4(1-19), 1981.
[17] Willert C.E. Wereley S. Kompenhans J. Raffel, M. Particle Image Velocimetry. Springer-Verlag Berlin
Heidelberg, 2007.
[18] Airfoil Tools. http://airfoiltools.com/airfoil/details?airfoil=n0012-il.

48
Appendix A

MATLAB Code

Plasma 2D.m
1 clc ; clear ; close all ;
2 % Program t h a t s o l v e s t h e d r i f t −d i f f u s i o n e q u a t i o n s t o g e t h e r with
3 % p a s s i o n s e q u a t i o n f o r t h e plasma a c t u a t o r problem .
4 % Author : S t e f a n N i l s s o n , 2017
5 %% Geometry and mesh
6
7 L domain = 0 . 1 ; % l e n g t h o f c o m p u t a t i o n a l domain i n x−d i r e c t i o n [m]
8 H domain = 0 . 0 2 5 ; % l e n g t h o f c o m p u t a t i o n a l domain i n y−d i r e c t i o n [m]
9
10 N = 6001; % number o f nodes i n x−d i r e c t i o n
11 M = 1501; % number o f nodes i n y−d i r e c t i o n
12
13 dx = L domain / (N−1) ; % s t e p l e n g t h i n x−d i r e c t i o n , [m] , x = dx ∗ ( i −1)
14 dy = H domain / (M−1) ; % s t e p l e n g t h i n y−d i r e c t i o n , [m] , y = dy ∗ ( j −1)
15
16 % Node numbers of exposed e l e c t r o d e
17 i exposed start = round ( ( 0 . 0 1 + dx ) /dx ) ; % s t a r t , x−d i r .
18 i exposed end = round ( ( 0 . 0 2 + dx ) /dx ) ; % end , x−d i r .
19 j exposed = round ( ( 0 . 0 0 2 + dy ) /dy ) ; % y−d i r .
20
21 % Node numbers o f grounded e l e c t r o d e
22 i g r o u n d e d s t a r t = round ( ( 0 . 0 2 + dx ) /dx ) ; % s t a r t , x−d i r .
23 i grounded end = round ( ( 0 . 0 3 + dx ) /dx ) ; % end , x−d i r .
24 j grounded = j e x p o s e d − round ( ( 0 . 0 0 0 5 + dy ) /dy ) ; % y−d i r .
25
26 % p l o t geometry
27 % f i g u r e ( ) ; c l f ; h o l d on ;
28 % plot ( [ i exposed start i exposed end ] , [ j exposed j exposed ] ) ;
29 % plot ( [ i grounded start i grounded end ] , [ j grounded j grounded ] ) ;
30 % a x i s ( [ 0 N 0 M] ) ;
31
32 %% C o n s t a n t s
33
34 % Data used f o r e l e c t r o n m o b i l i t y , d i f f u s i o n and t e m p e r a t u r e
35 % Reduced e l e c t r i c f i e l d s t r e n g t h , used f o r e l e c t r o n p r o p e r t i e s , [Vmˆ 2 ]
36 E o v e r N v e c t o r = [ 0 . 0 3 0 . 0 5 0 . 0 7 0 . 1 0 . 3 0 . 5 0 . 7 1 3 5 7 10 30 50 70 100 200 . . .
37 300 500 800 1 0 0 0 ] . ∗ 1 e −17.∗1 e −4;
38
39 % E l e c t r o n d r i f t v e l o c i t y , [ msˆ −1]
40 V d r i f t N 2 e = [ 1 . 1 1 . 6 2 2 . 4 3 . 1 3 . 5 3 . 9 4 . 4 7 . 5 11 14 18 42 61 79 100 200 . . .
41 290 420 530 5 9 0 ] . ∗ 1 e5 . ∗ 1 e −2;
42
43 % r a t i o ( e ∗D) /mu, [ eV ]
44 DoverMue N2 = [0.028 0.031 0.035 0.042 0.1 0.16 0.20 0.28 0.61 0.74 0.84 ...
45 0.93 1.2 1.4 1.5 1.9 3.4 4.2 5.2 6.2 7 ] ;
46
47 % Reduced e l e c t r i c f i e l d s t r e n g t h , used f o r i o n p r o p e r t i e s , [Vmˆ 2 ]
48 E o v e r N v e c t o r p = [ 6 8 10 12 15 20 25 30 40 50 60 80 100 120 150 200 250 300 . . .
49 400 500 600 8 0 0 ] . ∗ 1 e −17.∗1 e −4;
50
51 % I o n m o b i l i t y , [mˆ2/Vs ]
52 mu p vector = [ 1 . 9 1.89 1.88 1.88 1.87 1.85 1.84 1.83 1.80 1.76 1.72 1.66 1.60 1.54 . . .
53 1.47 1.37 1.28 1.20 1.10 1.02 0.95 0 . 8 5 ] . ∗ 1 e −4./((760/760) ∗(273.16/300) ) ;
54
55 nn = 2 . 6 9 e19 ∗ 1 0 ˆ 6 ; % Number d e n s i t y o f n e u t r a l g a s p a r t i c l e s , [mˆ −3]
56 e = 1.60217646∗10ˆ −19; % Elementary c h a r g e , [ C ]

49
57 q e = −e ; % E l e c t r o n charge , [C]
58 q p = e; % P o s i t i v e ion charge , [C]
59 q m = −e ; % Negative ion charge , [C]
60 k b = 1 . 3 8 0 6 5 0 e −23; % Boltzmann c o n s t a n t , [ J∗Kˆ −1]
61 m e = 9 . 1 0 9 3 8 1 9 e −31; % E l e c t r o n mass , [ kg ]
62 m proton = 1 . 6 7 2 6 2 1 6 e −27; % Proton mass , [ kg ]
63 eps 0 = 8 . 8 5 4 1 8 7 8 1 7 e −12; % P e r m i t t i v i t y o f f r e e s p a c e , [ ( As ) / (Vm) ]
64 kd = 10ˆ( −12) / 1 0 ˆ 6 ; % Detachment c o e f f i c i e n t , [mˆ3/ s ]
65 beta = 2 e −7∗10ˆ −6; % Recombination c o e f f i c i e n t , [mˆ3/ s ]
66 betai = 1.6∗10ˆ −7/10ˆ6; % Ion−i o n r e c o m b i n a t i o n c o e f f i c i e n t , [mˆ3/ s ]
67 a aOverP = 0.005∗100; % Parameter f o r attachment f r e q u e n c y , [ 1 / (m∗ t o r r ) ]
68
69 %%
70
71 V 0 = 8 e3 ; % Amplitude f o r e l e c t r i c p o t e n t i a l , [V]
72 frequency = 8 e3 ; % AC f r e q u e n c y f o r e l e c t r i c p o t e n t i a l , [ Hz ]
73 time end = 4/ f r e q u e n c y ; % T o t a l s i m u l a t i o n time , [ s ]
74 dt = 1 e −9; % s t e p s i z e i n time , [ s ] , time = dt ∗ ( t −1)
75 T = round ( ( t i m e e n d+dt ) / dt ) ; % Number o f s t e p s i n time
76
77 T e = 3 2 5 . ∗ o n e s (N,M) ; % E l e c t r o n t e m p e r a t u r e , [K]
78 T p = 3 0 0 . ∗ o n e s (N,M) ; % P o s i t i v e i o n t e m p e r a t u r e , [K]
79 T m = 3 0 0 . ∗ o n e s (N,M) ; % N e g a t i v e i o n t e m p e r a t u r e , [K]
80
81 D e = 0 . 0 3 8 2 . ∗ o n e s (N,M) ; % D i f f u s i o n e l e c t r o n s , [mˆ2/ s ]
82 mu e = 1 . 3 6 3 1 . ∗ o n e s (N,M) ; % E l e c t r o n m o b i l i t y , [mˆ2/ Vs ]
83
84 mu p = m u p v e c t o r ( 1 ) . ∗ o n e s (N,M) ; % P o s i t i v e i o n m o b i l i t y , [mˆ2/ Vs ]
85 mu m = m u p v e c t o r ( 1 ) . ∗ o n e s (N,M) ; % N e g a t i v e i o n m o b i l i t y , [mˆ2/ Vs ]
86
87 D p = ( ( k b ∗T p ( 1 , 1 ) ∗mu p ( 1 , 1 ) ) / e ) . ∗ o n e s (N,M) ; % D i f f u s i o n p o s i t i v e i o n s , [mˆ2/ s ]
88 D m = ( ( k b ∗T m ( 1 , 1 ) ∗mu m ( 1 , 1 ) ) / e ) . ∗ o n e s (N,M) ; % D i f f u s i o n n e g a t i v e i o n s , [mˆ2/ s ]
89
90 m p = 2∗28∗ m proton ; % P o s i t i v e i o n mass , [ kg ]
91 m m = 2∗28∗ m proton ; % N e g a t i v e i o n mass , [ kg ]
92 m g = 2∗28∗ m proton ; % Gas p a r t i c l e mass , [ kg ]
93
94 e p s = e p s 0 . ∗ o n e s (N,M) ; % p e r m i t t i v i t y , [ ( As ) / (Vm) ]
95 eps dialectric = 5; % Relative permittivity of d i a l e c t r i c material
96 e p s ( : , 1 : j e x p o s e d ) = e p s ( : , 1 : j e x p o s e d ) ∗ e p s d i a l e c t r i c ; % p e r m i t t i v i t y , [ ( As ) / (Vm) ]
97
98 maxit = 2000; % Max i t e r a t i o n s f o r p o t e n t i a l and a l l number d e n s i t i e s
99 tol = 1 e −6; % Convergence t o l e r a n c e p o t e n t i a l
100 tol e = 1 e −10; % Convergence t o l e r a n c e e l e c t r o n s
101 tol p = 1 e −10; % Convergence t o l e r a n c e p o s i t i v e i o n s
102 tol m = 1 e −10; % Convergence t o l e r a n c e n e g a t i v e i o n s
103
104 n e = z e r o s (N,M, T) ; % E l e c t r o n number d e n s i t y
105 n 0 = 1 e12 ; % I n i t i a l e l e c t r o n number d e n s i t y
106 n e ( 1 : N, ( j e x p o s e d ) :M, 1 ) = n 0 ; % I n i t i a l e l e c t r o n number d e n s i t y
107
108 % secondary emission constants
109 gamma em p dialectric = 0 . 0 1 ;
110 gamma em p exposed = 0.1;
111 gamma em p = g a m m a e m p d i a l e c t r i c . ∗ o n e s (N, 1 ) ;
112 gamma em p ( i e x p o s e d s t a r t : i e x p o s e d e n d ) = gamma em p exposed ;
113
114 % MSI c o n v e r g e n c e p a r a m e t e r s
115 alpha MSI = 0.9;
116 alpha MSI p = 0 . 9 ;
117 alpha MSI m = 0 . 9 ;
118 alpha MSI e = 0 . 9 ;
119
120 ToBig = 2 0 0 ; % p a r a m e t e r used t o a v o i d NaN
121 ToSmall = −200; % p a r a m e t e r used t o a v o i d NaN
122 CloseToZero = 1 e −6; % used i n s t e a d o f z e r o t o a v o i d NaN
123
124 %%
125 sigma = z e r o s (N, T) ; % Surface charge
126 V = z e r o s (N,M, T) ; % P o t e n t i a l , [V]
127 n p = z e r o s (N,M, T) ; % P o s i t i v e i o n d e n s i t y , [mˆ −3]
128 n m = z e r o s (N,M, T) ; % N e g a t i v e i o n d e n s i t y , [mˆ −3]
129 n p ( 1 : N, ( j e x p o s e d ) :M, 1 ) = n 0 ; % I n i t i a l i o n d e n s i t y , [mˆ −3]
130
131 % computational matrices
132 S e = z e r o s (N,M) ; S p = z e r o s (N,M) ; S m = z e r o s (N,M) ;

50
133 aE e = z e r o s (N,M) ; aE p = z e r o s (N,M) ; aE m = z e r o s (N,M) ;
134 aW e = z e r o s (N,M) ; aW p = z e r o s (N,M) ; aW m = z e r o s (N,M) ;
135 aN e = z e r o s (N,M) ; aN p = z e r o s (N,M) ; aN m = z e r o s (N,M) ;
136 aS e = z e r o s (N,M) ; aS p = z e r o s (N,M) ; aS m = z e r o s (N,M) ;
137 aC e = z e r o s (N,M) ; aC p = z e r o s (N,M) ; aC m = z e r o s (N,M) ;
138 A e = z e r o s (N,M) ; A p = z e r o s (N,M) ; Am = z e r o s (N,M) ;
139
140 z e i plus = z e r o s (N,M) ; z p i plus = z e r o s (N,M) ; z m i plus = z e r o s (N,M) ;
141 z e i minus = z e r o s (N,M) ; z p i minus = z e r o s (N,M) ; z m i minus = z e r o s (N,M) ;
142 z e j plus = z e r o s (N,M) ; z p j plus = z e r o s (N,M) ; z m j plus = z e r o s (N,M) ;
143 z e j minus = z e r o s (N,M) ; z p j minus = z e r o s (N,M) ; z m j minus = z e r o s (N,M) ;
144
145 g1 e i plus = z e r o s (N,M) ; g1 e i minus = z e r o s (N,M) ; g 1 e j p l u s = z e r o s (N,M) ;
146 g2 e i plus = z e r o s (N,M) ; g2 e i minus = z e r o s (N,M) ; g 2 e j p l u s = z e r o s (N,M) ;
147 h e i plus = z e r o s (N,M) ; h e i minus = z e r o s (N,M) ; h e j p l u s = z e r o s (N,M) ;
148 f1 e i plus = z e r o s (N,M) ; f1 e i minus = z e r o s (N,M) ; f 1 e j p l u s = z e r o s (N,M) ;
149 f2 e i plus = z e r o s (N,M) ; f2 e i minus = z e r o s (N,M) ; f 2 e j p l u s = z e r o s (N,M) ;
150
151 g1 e j minus = z e r o s (N,M) ; g1 p i plus = z e r o s (N,M) ; g1 p i minus = z e r o s (N,M) ;
152 g2 e j minus = z e r o s (N,M) ; g2 p i plus = z e r o s (N,M) ; g2 p i minus = z e r o s (N,M) ;
153 h e j minus = z e r o s (N,M) ; h p i plus = z e r o s (N,M) ; h p i minus = z e r o s (N,M) ;
154 f1 e j minus = z e r o s (N,M) ; f1 p i plus = z e r o s (N,M) ; f1 p i minus = z e r o s (N,M) ;
155 f2 e j minus = z e r o s (N,M) ; f2 p i plus = z e r o s (N,M) ; f2 p i minus = z e r o s (N,M) ;
156
157 g1 p j plus = z e r o s (N,M) ; g1 p j minus = z e r o s (N,M) ; g1 m i plus = z e r o s (N,M) ;
158 g2 p j plus = z e r o s (N,M) ; g2 p j minus = z e r o s (N,M) ; g2 m i plus = z e r o s (N,M) ;
159 h p j plus = z e r o s (N,M) ; h p j minus = z e r o s (N,M) ; h m i plus = z e r o s (N,M) ;
160 f1 p j plus = z e r o s (N,M) ; f1 p j minus = z e r o s (N,M) ; f1 m i plus = z e r o s (N,M) ;
161 f2 p j plus = z e r o s (N,M) ; f2 p j minus = z e r o s (N,M) ; f2 m i plus = z e r o s (N,M) ;
162
163 g1 m i minus = z e r o s (N,M) ; g1 m j plus = z e r o s (N,M) ; g1 m j minus = z e r o s (N,M) ;
164 g2 m i minus = z e r o s (N,M) ; g2 m j plus = z e r o s (N,M) ; g2 m j minus = z e r o s (N,M) ;
165 h m i minus = z e r o s (N,M) ; h m j plus = z e r o s (N,M) ; h m j minus = z e r o s (N,M) ;
166 f1 m i minus = z e r o s (N,M) ; f1 m j plus = z e r o s (N,M) ; f1 m j minus = z e r o s (N,M) ;
167 f2 m i minus = z e r o s (N,M) ; f2 m j plus = z e r o s (N,M) ; f2 m j minus = z e r o s (N,M) ;
168
169 b MSI = z e r o s (N,M) ; b MSI p = z e r o s (N,M) ; b MSI m = z e r o s (N,M) ;
170 c MSI = z e r o s (N,M) ; c MSI p = z e r o s (N,M) ; c MSI m = z e r o s (N,M) ;
171 d MSI = z e r o s (N,M) ; d MSI p = z e r o s (N,M) ; d MSI m = z e r o s (N,M) ;
172 p h i M S I 1 = z e r o s (N,M) ; p h i M S I 1 p = z e r o s (N,M) ; phi MSI 1 m = z e r o s (N,M) ;
173 p h i M S I 4 = z e r o s (N,M) ; p h i M S I 4 p = z e r o s (N,M) ; phi MSI 4 m = z e r o s (N,M) ;
174 e MSI = z e r o s (N,M) ; e MSI p = z e r o s (N,M) ; e MSI m = z e r o s (N,M) ;
175 f MSI = z e r o s (N,M) ; f MSI p = z e r o s (N,M) ; f MSI m = z e r o s (N,M) ;
176 g MSI = z e r o s (N,M) ; g MSI p = z e r o s (N,M) ; g MSI m = z e r o s (N,M) ;
177 h MSI = z e r o s (N,M) ; h MSI p = z e r o s (N,M) ; h MSI m = z e r o s (N,M) ;
178
179 b MSI e = z e r o s (N,M) ; dnedx = z e r o s (N,M) ; MagG = z e r o s (N,M) ;
180 c MSI e = z e r o s (N,M) ; dnedy = z e r o s (N,M) ; alph = z e r o s (N,M) ;
181 d MSI e = z e r o s (N,M) ; dnpdx = z e r o s (N,M) ; nua = z e r o s (N,M) ;
182 p h i M S I 1 e = z e r o s (N,M) ; dnpdy = z e r o s (N,M) ; a p = z e r o s (N, 1 ) ;
183 p h i M S I 4 e = z e r o s (N,M) ; dVdx = z e r o s (N,M) ; a m = z e r o s (N, 1 ) ;
184 e MSI e = z e r o s (N,M) ; dVdy = z e r o s (N,M) ;
185 f MSI e = z e r o s (N,M) ; Gamma e x = z e r o s (N,M) ;
186 g MSI e = z e r o s (N,M) ; Gamma e y = z e r o s (N,M) ;
187 h MSI e = z e r o s (N,M) ; MagE = z e r o s (N,M) ;
188
189 r it = z e r o s (N,M) ; r i t p = z e r o s (N,M) ; r i t m = z e r o s (N,M) ;
190 v it = z e r o s (N,M) ; v i t p = z e r o s (N,M) ; v i t m = z e r o s (N,M) ;
191 d e l t a i t = z e r o s (N,M) ; d e l t a i t p = z e r o s (N,M) ; d e l t a i t m = z e r o s (N,M) ;
192
193 r it e = z e r o s (N,M) ; aE = z e r o s (N,M) ; aS = z e r o s (N,M) ;
194 v it e = z e r o s (N,M) ; aW = z e r o s (N,M) ; aC = z e r o s (N,M) ;
195 d e l t a i t e = z e r o s (N,M) ; aN = z e r o s (N,M) ; A = z e r o s (N,M) ;
196
197 %% Time l o o p
198 f o r t =1:T−1
199
200 f o r i =2:N−1
201 f o r j =2:M−1
202 z e i plus (i , j ) = ( s i g n ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i +1 , j ) ) / 2 ) ∗ . . .
203 ( −(V( i +1 , j , t )−V( i , j , t ) ) /dx ) ∗dx ) / ( ( D e ( i , j )+D e ( i +1 , j ) ) / 2 ) ;
204 z e i m i n u s ( i , j ) = ( s i g n ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i −1 , j ) ) / 2 ) ∗ . . .
205 ( −(V( i , j , t )−V( i −1 , j , t ) ) /dx ) ∗dx ) / ( ( D e ( i , j )+D e ( i −1 , j ) ) / 2 ) ;
206 z e j p l u s ( i , j ) = ( s i g n ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j +1) ) / 2 ) ∗ . . .
207 ( −(V( i , j +1 , t )−V( i , j , t ) ) /dy ) ∗dy ) / ( ( D e ( i , j )+D e ( i , j +1) ) / 2 ) ;
208 z e j m i n u s ( i , j ) = ( s i g n ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j −1) ) / 2 ) ∗ . . .

51
209 ( −(V( i , j , t )−V( i , j −1 , t ) ) /dy ) ∗dy ) / ( ( D e ( i , j )+D e ( i , j −1) ) / 2 ) ;
210 z p i plus (i , j ) = ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i +1 , j ) ) / 2 ) ∗ . . .
211 ( −(V( i +1 , j , t )−V( i , j , t ) ) /dx ) ∗dx ) / ( ( D p ( i , j )+D p ( i +1 , j ) ) / 2 ) ;
212 z p i minus ( i , j ) = ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i −1 , j ) ) / 2 ) ∗ . . .
213 ( −(V( i , j , t )−V( i −1 , j , t ) ) /dx ) ∗dx ) / ( ( D p ( i , j )+D p ( i −1 , j ) ) / 2 ) ;
214 z p j plus (i , j ) = ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j +1) ) / 2 ) ∗ . . .
215 ( −(V( i , j +1 , t )−V( i , j , t ) ) /dy ) ∗dy ) / ( ( D p ( i , j )+D p ( i , j +1) ) / 2 ) ;
216 z p j minus ( i , j ) = ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j −1) ) / 2 ) ∗ . . .
217 ( −(V( i , j , t )−V( i , j −1 , t ) ) /dy ) ∗dy ) / ( ( D p ( i , j )+D p ( i , j −1) ) / 2 ) ;
218 z m i plus ( i , j ) = ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i +1 , j ) ) / 2 ) ∗ . . .
219 ( −(V( i +1 , j , t )−V( i , j , t ) ) /dx ) ∗dx ) / ( (D m( i , j )+D m( i +1 , j ) ) / 2 ) ;
220 z m i minus ( i , j ) = ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i −1 , j ) ) / 2 ) ∗ . . .
221 ( −(V( i , j , t )−V( i −1 , j , t ) ) /dx ) ∗dx ) / ( (D m( i , j )+D m( i −1 , j ) ) / 2 ) ;
222 z m j plus ( i , j ) = ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j +1) ) / 2 ) ∗ . . .
223 ( −(V( i , j +1 , t )−V( i , j , t ) ) /dy ) ∗dy ) / ( (D m( i , j )+D m( i , j +1) ) / 2 ) ;
224 z m j minus ( i , j ) = ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j −1) ) / 2 ) ∗ . . .
225 ( −(V( i , j , t )−V( i , j −1 , t ) ) /dy ) ∗dy ) / ( (D m( i , j )+D m( i , j −1) ) / 2 ) ;
226
227 i f abs ( z e i p l u s ( i , j ) ) < CloseToZero
228 g 1 e i p l u s ( i , j ) = −0.5;
229 g2 e i plus (i , j ) = 0.5;
230 h e i plus (i , j ) = 1.0;
231 f1 e i plus (i , j ) = 1.0;
232 f2 e i plus (i , j ) = 1.0;
233 e l s e i f z e i p l u s ( i , j ) > ToBig
234 g1 e i plus (i , j ) = 0.0;
235 g2 e i plus (i , j ) = 1.0;
236 h e i plus (i , j ) = 0.0;
237 f1 e i plus (i , j ) = 0.0;
238 f2 e i plus (i , j ) = z e i plus (i , j ) ;
239 e l s e i f z e i p l u s ( i , j ) < ToSmall
240 g 1 e i p l u s ( i , j ) = −1.0;
241 g2 e i plus (i , j ) = 0.0;
242 h e i plus (i , j ) = 0.0;
243 f1 e i plus (i , j ) = z e i plus (i , j ) ;
244 f2 e i plus (i , j ) = 0.0;
245 else
246 g 1 e i p l u s ( i , j ) = ((1 − z e i p l u s ( i , j ) ) ∗ exp ( z e i p l u s ( i , j ) ) −1)/ . . .
247 ( exp ( z e i p l u s ( i , j ) ) −1) ˆ 2 ;
248 g 2 e i p l u s ( i , j ) = exp ( z e i p l u s ( i , j ) ) ∗ ( ( exp ( z e i p l u s ( i , j ) )− . . .
249 (1+ z e i p l u s ( i , j ) ) ) / ( exp ( z e i p l u s ( i , j ) ) −1) ˆ 2 ) ;
250 h e i plus (i , j ) = z e i p l u s ( i , j ) ˆ2 ∗ ( exp ( z e i p l u s ( i , j ) ) / . . .
251 ( exp ( z e i p l u s ( i , j ) ) −1) ˆ 2 ) ;
252 f 1 e i p l u s ( i , j ) = z e i p l u s ( i , j ) / ( exp ( z e i p l u s ( i , j ) ) −1) ;
253 f 2 e i p l u s ( i , j ) = ( z e i p l u s ( i , j ) ∗ exp ( z e i p l u s ( i , j ) ) ) / . . .
254 ( exp ( z e i p l u s ( i , j ) ) −1) ;
255 end
256
257 i f abs ( z e i m i n u s ( i , j ) ) < CloseToZero
258 g 1 e i m i n u s ( i , j ) = −0.5;
259 g2 e i minus ( i , j ) = 0.5;
260 h e i minus ( i , j ) = 1.0;
261 f1 e i minus ( i , j ) = 1.0;
262 f2 e i minus ( i , j ) = 1.0;
263 e l s e i f z e i m i n u s ( i , j ) > ToBig
264 g1 e i minus ( i , j ) = 0.0;
265 g2 e i minus ( i , j ) = 1.0;
266 h e i minus ( i , j ) = 0.0;
267 f1 e i minus ( i , j ) = 0.0;
268 f2 e i minus ( i , j ) = z e i minus ( i , j ) ;
269 e l s e i f z e i m i n u s ( i , j ) < ToSmall
270 g 1 e i m i n u s ( i , j ) = −1.0;
271 g2 e i minus ( i , j ) = 0.0;
272 h e i minus ( i , j ) = 0.0;
273 f1 e i minus ( i , j ) = z e i minus ( i , j ) ;
274 f2 e i minus ( i , j ) = 0.0;
275 else
276 g 1 e i m i n u s ( i , j ) = ((1 − z e i m i n u s ( i , j ) ) ∗ exp ( z e i m i n u s ( i , j ) ) −1)/ . . .
277 ( exp ( z e i m i n u s ( i , j ) ) −1) ˆ 2 ;
278 g 2 e i m i n u s ( i , j ) = exp ( z e i m i n u s ( i , j ) ) ∗ ( ( exp ( z e i m i n u s ( i , j ) )− . . .
279 (1+ z e i m i n u s ( i , j ) ) ) / ( exp ( z e i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
280 h e i m i n u s ( i , j ) = z e i m i n u s ( i , j ) ˆ2 ∗ ( exp ( z e i m i n u s ( i , j ) ) / . . .
281 ( exp ( z e i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
282 f 1 e i m i n u s ( i , j ) = z e i m i n u s ( i , j ) / ( exp ( z e i m i n u s ( i , j ) ) −1) ;
283 f 2 e i m i n u s ( i , j ) = ( z e i m i n u s ( i , j ) ∗ exp ( z e i m i n u s ( i , j ) ) ) / . . .
284 ( exp ( z e i m i n u s ( i , j ) ) −1) ;

52
285 end
286
287 i f abs ( z e j p l u s ( i , j ) ) < CloseToZero
288 g 1 e j p l u s ( i , j ) = −0.5;
289 g2 e j plus (i , j ) = 0.5;
290 h e j plus (i , j ) = 1.0;
291 f1 e j plus (i , j ) = 1.0;
292 f2 e j plus (i , j ) = 1.0;
293 e l s e i f z e j p l u s ( i , j ) > ToBig
294 g1 e j plus (i , j ) = 0.0;
295 g2 e j plus (i , j ) = 1.0;
296 h e j plus (i , j ) = 0.0;
297 f1 e j plus (i , j ) = 0.0;
298 f2 e j plus (i , j ) = z e j plus (i , j ) ;
299 e l s e i f z e j p l u s ( i , j ) < ToSmall
300 g 1 e j p l u s ( i , j ) = −1.0;
301 g2 e j plus (i , j ) = 0.0;
302 h e j plus (i , j ) = 0.0;
303 f1 e j plus (i , j ) = z e j plus (i , j ) ;
304 f2 e j plus (i , j ) = 0.0;
305 else
306 g 1 e j p l u s ( i , j ) = ((1 − z e j p l u s ( i , j ) ) ∗ exp ( z e j p l u s ( i , j ) ) −1)/ . . .
307 ( exp ( z e j p l u s ( i , j ) ) −1) ˆ 2 ;
308 g 2 e j p l u s ( i , j ) = exp ( z e j p l u s ( i , j ) ) ∗ ( ( exp ( z e j p l u s ( i , j ) )− . . .
309 (1+ z e j p l u s ( i , j ) ) ) / ( exp ( z e j p l u s ( i , j ) ) −1) ˆ 2 ) ;
310 h e j plus (i , j ) = z e j p l u s ( i , j ) ˆ2 ∗ ( exp ( z e j p l u s ( i , j ) ) / . . .
311 ( exp ( z e j p l u s ( i , j ) ) −1) ˆ 2 ) ;
312 f 1 e j p l u s ( i , j ) = z e j p l u s ( i , j ) / ( exp ( z e j p l u s ( i , j ) ) −1) ;
313 f 2 e j p l u s ( i , j ) = ( z e j p l u s ( i , j ) ∗ exp ( z e j p l u s ( i , j ) ) ) / . . .
314 ( exp ( z e j p l u s ( i , j ) ) −1) ;
315 end
316
317 i f abs ( z e j m i n u s ( i , j ) ) < CloseToZero
318 g 1 e j m i n u s ( i , j ) = −0.5;
319 g2 e j minus ( i , j ) = 0.5;
320 h e j minus ( i , j ) = 1.0;
321 f1 e j minus ( i , j ) = 1.0;
322 f2 e j minus ( i , j ) = 1.0;
323 e l s e i f z e j m i n u s ( i , j ) > ToBig
324 g1 e j minus ( i , j ) = 0.0;
325 g2 e j minus ( i , j ) = 1.0;
326 h e j minus ( i , j ) = 0.0;
327 f1 e j minus ( i , j ) = 0.0;
328 f2 e j minus ( i , j ) = z e j minus ( i , j ) ;
329 e l s e i f z e j m i n u s ( i , j ) < ToSmall
330 g 1 e j m i n u s ( i , j ) = −1.0;
331 g2 e j minus ( i , j ) = 0.0;
332 h e j minus ( i , j ) = 0.0;
333 f1 e j minus ( i , j ) = z e j minus ( i , j ) ;
334 f2 e j minus ( i , j ) = 0.0;
335 else
336 g 1 e j m i n u s ( i , j ) = ((1 − z e j m i n u s ( i , j ) ) ∗ exp ( z e j m i n u s ( i , j ) ) −1)/ . . .
337 ( exp ( z e j m i n u s ( i , j ) ) −1) ˆ 2 ;
338 g 2 e j m i n u s ( i , j ) = exp ( z e j m i n u s ( i , j ) ) ∗ ( ( exp ( z e j m i n u s ( i , j ) )− . . .
339 (1+ z e j m i n u s ( i , j ) ) ) / ( exp ( z e j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
340 h e j m i n u s ( i , j ) = z e j m i n u s ( i , j ) ˆ2 ∗ ( exp ( z e j m i n u s ( i , j ) ) / . . .
341 ( exp ( z e j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
342 f 1 e j m i n u s ( i , j ) = z e j m i n u s ( i , j ) / ( exp ( z e j m i n u s ( i , j ) ) −1) ;
343 f 2 e j m i n u s ( i , j ) = ( z e j m i n u s ( i , j ) ∗ exp ( z e j m i n u s ( i , j ) ) ) / . . .
344 ( exp ( z e j m i n u s ( i , j ) ) −1) ;
345 end
346
347 i f abs ( z p i p l u s ( i , j ) ) < CloseToZero
348 g 1 p i p l u s ( i , j ) = −0.5;
349 g2 p i plus ( i , j ) = 0.5;
350 h p i plus ( i , j ) = 1.0;
351 f1 p i plus (i , j ) = 1.0;
352 f2 p i plus (i , j ) = 1.0;
353 e l s e i f z p i p l u s ( i , j ) > ToBig
354 g1 p i plus ( i , j ) = 0.0;
355 g2 p i plus ( i , j ) = 1.0;
356 h p i plus ( i , j ) = 0.0;
357 f1 p i plus (i , j ) = 0.0;
358 f2 p i plus (i , j ) = z p i plus (i , j ) ;
359 e l s e i f z p i p l u s ( i , j ) < ToSmall
360 g 1 p i p l u s ( i , j ) = −1.0;

53
361 g2 p i plus ( i ,j) = 0.0;
362 h p i plus ( i , j) = 0.0;
363 f1 p i plus (i ,j) = z p i plus (i , j ) ;
364 f2 p i plus (i ,j) = 0.0;
365 else
366 g1 p i plus ( i , j ) = (1− z p i p l u s ( i , j ) ) ∗ ( ( exp ( z p i p l u s ( i , j ) ) −1)/ . . .
367 ( exp ( z p i p l u s ( i , j ) ) −1) ˆ 2 ) ;
368 g2 p i plus ( i , j ) = exp ( z p i p l u s ( i , j ) ) ∗ ( ( exp ( z p i p l u s ( i , j ) )− . . .
369 (1+ z p i p l u s ( i , j ) ) ) / ( exp ( z p i p l u s ( i , j ) ) −1) ˆ 2 ) ;
370 h p i plus ( i , j ) = z p i p l u s ( i , j ) ˆ2 ∗ ( exp ( z p i p l u s ( i , j ) ) / . . .
371 ( exp ( z p i p l u s ( i , j ) ) −1) ˆ 2 ) ;
372 f1 p i plus (i , j ) = z p i p l u s ( i , j ) / ( exp ( z p i p l u s ( i , j ) ) −1) ;
373 f2 p i plus (i , j ) = ( z p i p l u s ( i , j ) ∗ exp ( z p i p l u s ( i , j ) ) ) / . . .
374 ( exp ( z p i p l u s ( i , j ) ) −1) ;
375 end
376
377 i f abs ( z p i m i n u s ( i , j ) ) < CloseToZero
378 g 1 p i m i n u s ( i , j ) = −0.5;
379 g2 p i minus ( i , j ) = 0 . 5 ;
380 h p i minus ( i , j ) = 1 . 0 ;
381 f1 p i minus ( i , j ) = 1.0;
382 f2 p i minus ( i , j ) = 1.0;
383 e l s e i f z p i m i n u s ( i , j ) > ToBig
384 g1 p i minus ( i , j ) = 0 . 0 ;
385 g2 p i minus ( i , j ) = 1 . 0 ;
386 h p i minus ( i , j ) = 0 . 0 ;
387 f1 p i minus ( i , j ) = 0.0;
388 f2 p i minus ( i , j ) = z p i minus ( i , j ) ;
389 e l s e i f z p i m i n u s ( i , j ) < ToSmall
390 g 1 p i m i n u s ( i , j ) = −1.0;
391 g2 p i minus ( i , j ) = 0 . 0 ;
392 h p i minus ( i , j ) = 0 . 0 ;
393 f1 p i minus ( i , j ) = z p i minus ( i , j ) ;
394 f2 p i minus ( i , j ) = 0.0;
395 else
396 g 1 p i m i n u s ( i , j ) = ((1 − z p i m i n u s ( i , j ) ) ∗ exp ( z p i m i n u s ( i , j ) ) −1)/ . . .
397 ( exp ( z p i m i n u s ( i , j ) ) −1) ˆ 2 ;
398 g 2 p i m i n u s ( i , j ) = exp ( z p i m i n u s ( i , j ) ) ∗ ( ( exp ( z p i m i n u s ( i , j ) )− . . .
399 (1+ z p i m i n u s ( i , j ) ) ) / ( exp ( z p i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
400 h p i m i n u s ( i , j ) = z p i m i n u s ( i , j ) ˆ2 ∗ ( exp ( z p i m i n u s ( i , j ) ) / . . .
401 ( exp ( z p i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
402 f 1 p i m i n u s ( i , j ) = z p i m i n u s ( i , j ) / ( exp ( z p i m i n u s ( i , j ) ) −1) ;
403 f 2 p i m i n u s ( i , j ) = ( z p i m i n u s ( i , j ) ∗ exp ( z p i m i n u s ( i , j ) ) ) / . . .
404 ( exp ( z p i m i n u s ( i , j ) ) −1) ;
405 end
406
407 i f abs ( z p j p l u s ( i , j ) ) < CloseToZero
408 g 1 p j p l u s ( i , j ) = −0.5;
409 g2 p j plus ( i , j ) = 0.5;
410 h p j plus ( i , j ) = 1.0;
411 f1 p j plus (i , j ) = 1.0;
412 f2 p j plus (i , j ) = 1.0;
413 e l s e i f z p j p l u s ( i , j ) > ToBig
414 g1 p j plus ( i , j ) = 0.0;
415 g2 p j plus ( i , j ) = 1.0;
416 h p j plus ( i , j ) = 0.0;
417 f1 p j plus (i , j ) = 0.0;
418 f2 p j plus (i , j ) = z p j plus (i , j ) ;
419 e l s e i f z p j p l u s ( i , j ) < ToSmall
420 g 1 p j p l u s ( i , j ) = −1.0;
421 g2 p j plus ( i , j ) = 0.0;
422 h p j plus ( i , j ) = 0.0;
423 f1 p j plus (i , j ) = z p j plus (i , j ) ;
424 f2 p j plus (i , j ) = 0.0;
425 else
426 g 1 p j p l u s ( i , j ) = ((1 − z p j p l u s ( i , j ) ) ∗ exp ( z p j p l u s ( i , j ) ) −1)/ . . .
427 ( exp ( z p j p l u s ( i , j ) ) −1) ˆ 2 ;
428 g 2 p j p l u s ( i , j ) = exp ( z p j p l u s ( i , j ) ) ∗ ( ( exp ( z p j p l u s ( i , j ) )− . . .
429 (1+ z p j p l u s ( i , j ) ) ) / ( exp ( z p j p l u s ( i , j ) ) −1) ˆ 2 ) ;
430 h p j plus ( i , j ) = z p j p l u s ( i , j ) ˆ2 ∗ ( exp ( z p j p l u s ( i , j ) ) / . . .
431 ( exp ( z p j p l u s ( i , j ) ) −1) ˆ 2 ) ;
432 f 1 p j p l u s ( i , j ) = z p j p l u s ( i , j ) / ( exp ( z p j p l u s ( i , j ) ) −1) ;
433 f 2 p j p l u s ( i , j ) = ( z p j p l u s ( i , j ) ∗ exp ( z p j p l u s ( i , j ) ) ) / . . .
434 ( exp ( z p j p l u s ( i , j ) ) −1) ;
435 end
436

54
437 i f abs ( z p j m i n u s ( i , j ) ) < CloseToZero
438 g 1 p j m i n u s ( i , j ) = −0.5;
439 g2 p j minus ( i , j ) = 0 . 5 ;
440 h p j minus ( i , j ) = 1 . 0 ;
441 f1 p j minus ( i , j ) = 1.0;
442 f2 p j minus ( i , j ) = 1.0;
443 e l s e i f z p j m i n u s ( i , j ) > ToBig
444 g1 p j minus ( i , j ) = 0 . 0 ;
445 g2 p j minus ( i , j ) = 1 . 0 ;
446 h p j minus ( i , j ) = 0 . 0 ;
447 f1 p j minus ( i , j ) = 0.0;
448 f2 p j minus ( i , j ) = z p j minus ( i , j ) ;
449 e l s e i f z p j m i n u s ( i , j ) < ToSmall
450 g 1 p j m i n u s ( i , j ) = −1.0;
451 g2 p j minus ( i , j ) = 0 . 0 ;
452 h p j minus ( i , j ) = 0 . 0 ;
453 f1 p j minus ( i , j ) = z p j minus ( i , j ) ;
454 f2 p j minus ( i , j ) = 0.0;
455 else
456 g 1 p j m i n u s ( i , j ) = ((1 − z p j m i n u s ( i , j ) ) ∗ exp ( z p j m i n u s ( i , j ) ) −1)/ . . .
457 ( exp ( z p j m i n u s ( i , j ) ) −1) ˆ 2 ;
458 g 2 p j m i n u s ( i , j ) = exp ( z p j m i n u s ( i , j ) ) ∗ ( ( exp ( z p j m i n u s ( i , j ) )− . . .
459 (1+ z p j m i n u s ( i , j ) ) ) / ( exp ( z p j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
460 h p j m i n u s ( i , j ) = z p j m i n u s ( i , j ) ˆ2 ∗ ( exp ( z p j m i n u s ( i , j ) ) / . . .
461 ( exp ( z p j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
462 f 1 p j m i n u s ( i , j ) = z p j m i n u s ( i , j ) / ( exp ( z p j m i n u s ( i , j ) ) −1) ;
463 f 2 p j m i n u s ( i , j ) = ( z p j m i n u s ( i , j ) ∗ exp ( z p j m i n u s ( i , j ) ) ) / . . .
464 ( exp ( z p j m i n u s ( i , j ) ) −1) ;
465 end
466
467 i f abs ( z m i p l u s ( i , j ) ) < CloseToZero
468 g 1 m i p l u s ( i , j ) = −0.5;
469 g2 m i plus ( i , j ) = 0.5;
470 h m i plus ( i , j ) = 1.0;
471 f1 m i plus ( i , j ) = 1.0;
472 f2 m i plus ( i , j ) = 1.0;
473 e l s e i f z m i p l u s ( i , j ) > ToBig
474 g1 m i plus ( i , j ) = 0.0;
475 g2 m i plus ( i , j ) = 1.0;
476 h m i plus ( i , j ) = 0.0;
477 f1 m i plus ( i , j ) = 0.0;
478 f2 m i plus ( i , j ) = z m i plus ( i , j ) ;
479 e l s e i f z m i p l u s ( i , j ) < ToSmall
480 g 1 m i p l u s ( i , j ) = −1.0;
481 g2 m i plus ( i , j ) = 0.0;
482 h m i plus ( i , j ) = 0.0;
483 f1 m i plus ( i , j ) = z m i plus ( i , j ) ;
484 f2 m i plus ( i , j ) = 0.0;
485 else
486 g 1 m i p l u s ( i , j ) = ((1 − z m i p l u s ( i , j ) ) ∗ exp ( z m i p l u s ( i , j ) ) −1)/ . . .
487 ( exp ( z m i p l u s ( i , j ) ) −1) ˆ 2 ;
488 g 2 m i p l u s ( i , j ) = exp ( z m i p l u s ( i , j ) ) ∗ ( ( exp ( z m i p l u s ( i , j ) )− . . .
489 (1+ z m i p l u s ( i , j ) ) ) / ( exp ( z m i p l u s ( i , j ) ) −1) ˆ 2 ) ;
490 h m i plus ( i , j ) = z m i p l u s ( i , j ) ˆ2 ∗ ( exp ( z m i p l u s ( i , j ) ) / . . .
491 ( exp ( z m i p l u s ( i , j ) ) −1) ˆ 2 ) ;
492 f 1 m i p l u s ( i , j ) = z m i p l u s ( i , j ) / ( exp ( z m i p l u s ( i , j ) ) −1) ;
493 f 2 m i p l u s ( i , j ) = ( z m i p l u s ( i , j ) ∗ exp ( z m i p l u s ( i , j ) ) ) / . . .
494 ( exp ( z m i p l u s ( i , j ) ) −1) ;
495 end
496
497 i f abs ( z m i m i n u s ( i , j ) ) < CloseToZero
498 g1 m i minus ( i , j ) = −0.5;
499 g2 m i minus ( i , j ) = 0 . 5 ;
500 h m i minus ( i , j ) = 1 . 0 ;
501 f1 m i minus ( i , j ) = 1 . 0 ;
502 f2 m i minus ( i , j ) = 1 . 0 ;
503 e l s e i f z m i m i n u s ( i , j ) > ToBig
504 g1 m i minus ( i , j ) = 0 . 0 ;
505 g2 m i minus ( i , j ) = 1 . 0 ;
506 h m i minus ( i , j ) = 0 . 0 ;
507 f1 m i minus ( i , j ) = 0 . 0 ;
508 f2 m i minus ( i , j ) = z m i minus ( i , j ) ;
509 e l s e i f z m i m i n u s ( i , j ) < ToSmall
510 g1 m i minus ( i , j ) = −1.0;
511 g2 m i minus ( i , j ) = 0 . 0 ;
512 h m i minus ( i , j ) = 0 . 0 ;

55
513 f1 m i minus ( i , j ) = z m i minus ( i , j ) ;
514 f2 m i minus ( i , j ) = 0 . 0 ;
515 else
516 g 1 m i m i n u s ( i , j ) = ((1 − z m i m i n u s ( i , j ) ) ∗ exp ( z m i m i n u s ( i , j ) ) −1)/ . . .
517 ( exp ( z m i m i n u s ( i , j ) ) −1) ˆ 2 ;
518 g 2 m i m i n u s ( i , j ) = exp ( z m i m i n u s ( i , j ) ) ∗ ( ( exp ( z m i m i n u s ( i , j ) )− . . .
519 (1+ z m i m i n u s ( i , j ) ) ) / ( exp ( z m i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
520 h m i m i n u s ( i , j ) = z m i m i n u s ( i , j ) ˆ2 ∗ ( exp ( z m i m i n u s ( i , j ) ) / . . .
521 ( exp ( z m i m i n u s ( i , j ) ) −1) ˆ 2 ) ;
522 f 1 m i m i n u s ( i , j ) = z m i m i n u s ( i , j ) / ( exp ( z m i m i n u s ( i , j ) ) −1) ;
523 f 2 m i m i n u s ( i , j ) = ( z m i m i n u s ( i , j ) ∗ exp ( z m i m i n u s ( i , j ) ) ) / . . .
524 ( exp ( z m i m i n u s ( i , j ) ) −1) ;
525 end
526
527 i f abs ( z m j p l u s ( i , j ) ) < CloseToZero
528 g 1 m j p l u s ( i , j ) = −0.5;
529 g2 m j plus ( i , j ) = 0.5;
530 h m j plus ( i , j ) = 1.0;
531 f1 m j plus ( i , j ) = 1.0;
532 f2 m j plus ( i , j ) = 1.0;
533 e l s e i f z m j p l u s ( i , j ) > ToBig
534 g1 m j plus ( i , j ) = 0.0;
535 g2 m j plus ( i , j ) = 1.0;
536 h m j plus ( i , j ) = 0.0;
537 f1 m j plus ( i , j ) = 0.0;
538 f2 m j plus ( i , j ) = z m j plus ( i , j ) ;
539 e l s e i f z m j p l u s ( i , j ) < ToSmall
540 g 1 m j p l u s ( i , j ) = −1.0;
541 g2 m j plus ( i , j ) = 0.0;
542 h m j plus ( i , j ) = 0.0;
543 f1 m j plus ( i , j ) = z m j plus ( i , j ) ;
544 f2 m j plus ( i , j ) = 0.0;
545 else
546 g 1 m j p l u s ( i , j ) = ((1 − z m j p l u s ( i , j ) ) ∗ exp ( z m j p l u s ( i , j ) ) −1)/ . . .
547 ( exp ( z m j p l u s ( i , j ) ) −1) ˆ 2 ;
548 g 2 m j p l u s ( i , j ) = exp ( z m j p l u s ( i , j ) ) ∗ ( ( exp ( z m j p l u s ( i , j ) )− . . .
549 (1+ z m j p l u s ( i , j ) ) ) / ( exp ( z m j p l u s ( i , j ) ) −1) ˆ 2 ) ;
550 h m j plus ( i , j ) = z m j p l u s ( i , j ) ˆ2 ∗ ( exp ( z m j p l u s ( i , j ) ) / . . .
551 ( exp ( z m j p l u s ( i , j ) ) −1) ˆ 2 ) ;
552 f 1 m j p l u s ( i , j ) = z m j p l u s ( i , j ) / ( exp ( z m j p l u s ( i , j ) ) −1) ;
553 f 2 m j p l u s ( i , j ) = ( z m j p l u s ( i , j ) ∗ exp ( z m j p l u s ( i , j ) ) ) / . . .
554 ( exp ( z m j p l u s ( i , j ) ) −1) ;
555 end
556
557 i f abs ( z m j m i n u s ( i , j ) ) < CloseToZero
558 g1 m j minus ( i , j ) = −0.5;
559 g2 m j minus ( i , j ) = 0 . 5 ;
560 h m j minus ( i , j ) = 1 . 0 ;
561 f1 m j minus ( i , j ) = 1 . 0 ;
562 f2 m j minus ( i , j ) = 1 . 0 ;
563 e l s e i f z m j m i n u s ( i , j ) > ToBig
564 g1 m j minus ( i , j ) = 0 . 0 ;
565 g2 m j minus ( i , j ) = 1 . 0 ;
566 h m j minus ( i , j ) = 0 . 0 ;
567 f1 m j minus ( i , j ) = 0 . 0 ;
568 f2 m j minus ( i , j ) = z m j minus ( i , j ) ;
569 e l s e i f z m j m i n u s ( i , j ) < ToSmall
570 g1 m j minus ( i , j ) = −1.0;
571 g2 m j minus ( i , j ) = 0 . 0 ;
572 h m j minus ( i , j ) = 0 . 0 ;
573 f1 m j minus ( i , j ) = z m j minus ( i , j ) ;
574 f2 m j minus ( i , j ) = 0 . 0 ;
575 else
576 g 1 m j m i n u s ( i , j ) = ((1 − z m j m i n u s ( i , j ) ) ∗ exp ( z m j m i n u s ( i , j ) ) −1)/ . . .
577 ( exp ( z m j m i n u s ( i , j ) ) −1) ˆ 2 ;
578 g 2 m j m i n u s ( i , j ) = exp ( z m j m i n u s ( i , j ) ) ∗ ( ( exp ( z m j m i n u s ( i , j ) )− . . .
579 (1+ z m j m i n u s ( i , j ) ) ) / ( exp ( z m j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
580 h m j m i n u s ( i , j ) = z m j m i n u s ( i , j ) ˆ2 ∗ ( exp ( z m j m i n u s ( i , j ) ) / . . .
581 ( exp ( z m j m i n u s ( i , j ) ) −1) ˆ 2 ) ;
582 f 1 m j m i n u s ( i , j ) = z m j m i n u s ( i , j ) / ( exp ( z m j m i n u s ( i , j ) ) −1) ;
583 f 2 m j m i n u s ( i , j ) = ( z m j m i n u s ( i , j ) ∗ exp ( z m j m i n u s ( i , j ) ) ) / . . .
584 ( exp ( z m j m i n u s ( i , j ) ) −1) ;
585 end
586 end
587 end
588

56
589 %% P o t e n t i a l
590 f o r i =2:N−1
591 f o r j =2:M−1
592 i f j==j e x p o s e d
593 aE ( i , j ) = ( 1 / dx ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i +1 , j ) ) / 2 ) ;
594 aW( i , j ) = ( 1 / dx ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i −1 , j ) ) / 2 ) ;
595 aN( i , j ) = ( 1 / dy ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i , j +1) ) / 2 ) − . . .
596 ( dt /dy ˆ 2 ) ∗ ( abs ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j +1) ) / 2 ) ∗ . . .
597 ( n e ( i , j +1 , t ) ∗ g 1 e j p l u s ( i , j )−n e ( i , j , t ) ∗ g 2 e j p l u s ( i , j ) ) ) − . . .
598 ( dt /dy ˆ 2 ) ∗ ( abs ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j +1) ) / 2 ) ∗ . . .
599 ( n p ( i , j +1 , t ) ∗ g 1 p j p l u s ( i , j )−n p ( i , j , t ) ∗ g 2 p j p l u s ( i , j ) ) ) − . . .
600 ( dt /dy ˆ 2 ) ∗ ( abs ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j +1) ) / 2 ) ∗ . . .
601 ( n m ( i , j +1 , t ) ∗ g 1 m j p l u s ( i , j )−n m ( i , j , t ) ∗ g 2 m j p l u s ( i , j ) ) ) ;
602 aS ( i , j ) = ( 1 / dy ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i , j −1) ) / 2 ) ;
603 aC ( i , j ) = −aE ( i , j ) − aW( i , j ) − aN( i , j ) − aS ( i , j ) ;
604 A( i , j ) = −(sigma ( i , t ) /dy ) + . . .
605 ( dt /dy ˆ 2 ) ∗ q e ∗ ( ( D e ( i , j )+D e ( i , j +1) ) / 2 ) ∗ h e j p l u s ( i , j ) ∗ . . .
606 ( n e ( i , j +1 , t )−n e ( i , j , t ) ) + ( dt /dy ˆ 2 ) ∗ q p ∗ ( ( D p ( i , j )+ . . .
607 D p ( i , j +1) ) / 2 ) ∗ h p j p l u s ( i , j ) ∗ ( n p ( i , j +1 , t )−n p ( i , j , t ) ) + . . .
608 ( dt /dy ˆ 2 ) ∗q m ∗ ( (D m( i , j )+D m( i , j +1) ) / 2 ) ∗ h m j p l u s ( i , j ) ∗ . . .
609 ( n m ( i , j +1 , t )−n m ( i , j , t ) ) ;
610 else
611 aE ( i , j ) = ( 1 / dx ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i +1 , j ) ) / 2 ) − . . .
612 ( dt /dx ˆ 2 ) ∗ ( abs ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i +1 , j ) ) / 2 ) ∗ ( n e ( i +1 , j , t ) ∗ . . .
613 g 1 e i p l u s ( i , j )−n e ( i , j , t ) ∗ g 2 e i p l u s ( i , j ) ) ) − . . .
614 ( dt /dx ˆ 2 ) ∗ ( abs ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i +1 , j ) ) / 2 ) ∗ ( n p ( i +1 , j , t ) ∗ . . .
615 g 1 p i p l u s ( i , j )−n p ( i , j , t ) ∗ g 2 p i p l u s ( i , j ) ) ) − . . .
616 ( dt /dx ˆ 2 ) ∗ ( abs ( q m ) ∗ ( ( mu m( i , j )+mu m( i +1 , j ) ) / 2 ) ∗ . . .
617 ( n m ( i +1 , j , t ) ∗ g 1 m i p l u s ( i , j )−n m ( i , j , t ) ∗ g 2 m i p l u s ( i , j ) ) ) ;
618 aW( i , j ) = ( 1 / dx ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i −1 , j ) ) / 2 ) − . . .
619 ( dt /dx ˆ 2 ) ∗ ( abs ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i −1 , j ) ) / 2 ) ∗ ( n e ( i , j , t ) ∗ . . .
620 g 1 e i m i n u s ( i , j )−n e ( i −1 , j , t ) ∗ g 2 e i m i n u s ( i , j ) ) ) − . . .
621 ( dt /dx ˆ 2 ) ∗ ( abs ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i −1 , j ) ) / 2 ) ∗ ( n p ( i , j , t ) ∗ . . .
622 g 1 p i m i n u s ( i , j )−n p ( i −1 , j , t ) ∗ g 2 p i m i n u s ( i , j ) ) ) − . . .
623 ( dt /dx ˆ 2 ) ∗ ( abs ( q m ) ∗ ( ( mu m( i , j )+mu m( i −1 , j ) ) / 2 ) ∗ ( n m ( i , j , t ) ∗ . . .
624 g 1 m i m i n u s ( i , j )−n m ( i −1 , j , t ) ∗ g 2 m i m i n u s ( i , j ) ) ) ;
625 aN( i , j ) = ( 1 / dy ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i , j +1) ) / 2 ) − . . .
626 ( dt /dy ˆ 2 ) ∗ ( abs ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j +1) ) / 2 ) ∗ ( n e ( i , j +1 , t ) ∗ . . .
627 g 1 e j p l u s ( i , j )−n e ( i , j , t ) ∗ g 2 e j p l u s ( i , j ) ) ) − . . .
628 ( dt /dy ˆ 2 ) ∗ ( abs ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j +1) ) / 2 ) ∗ ( n p ( i , j +1 , t ) ∗ . . .
629 g 1 p j p l u s ( i , j )−n p ( i , j , t ) ∗ g 2 p j p l u s ( i , j ) ) ) − . . .
630 ( dt /dy ˆ 2 ) ∗ ( abs ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j +1) ) / 2 ) ∗ ( n m ( i , j +1 , t ) ∗ . . .
631 g 1 m j p l u s ( i , j )−n m ( i , j , t ) ∗ g 2 m j p l u s ( i , j ) ) ) ;
632 aS ( i , j ) = ( 1 / dy ˆ 2 ) ∗ ( ( e p s ( i , j )+e p s ( i , j −1) ) / 2 ) − . . .
633 ( dt /dy ˆ 2 ) ∗ ( abs ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j −1) ) / 2 ) ∗ ( n e ( i , j , t ) ∗ . . .
634 g 1 e j m i n u s ( i , j )−n e ( i , j −1 , t ) ∗ g 2 e j m i n u s ( i , j ) ) ) − . . .
635 ( dt /dy ˆ 2 ) ∗ ( abs ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j −1) ) / 2 ) ∗ ( n p ( i , j , t ) ∗ . . .
636 g 1 p j m i n u s ( i , j )−n p ( i , j −1 , t ) ∗ g 2 p j m i n u s ( i , j ) ) ) − . . .
637 ( dt /dy ˆ 2 ) ∗ ( abs ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j −1) ) / 2 ) ∗ ( n m ( i , j , t ) ∗ . . .
638 g 1 m j m i n u s ( i , j )−n m ( i , j −1 , t ) ∗ g 2 m j m i n u s ( i , j ) ) ) ;
639 aC ( i , j ) = −aE ( i , j ) − aW( i , j ) − aN( i , j ) − aS ( i , j ) ;
640
641 A( i , j ) = −( q e ∗ n e ( i , j , t ) − . . .
642 ( dt /dx ˆ 2 ) ∗ q e ∗ ( ( D e ( i , j )+D e ( i +1 , j ) ) / 2 ) ∗ h e i plus ( i , j )∗ . . .
643 ( n e ( i +1 , j , t )−n e ( i , j , t ) ) + . . .
644 ( dt /dx ˆ 2 ) ∗ q e ∗ ( ( D e ( i , j )+D e ( i −1 , j ) ) / 2 ) ∗ h e i minus ( i , j )∗ . . .
645 ( n e ( i , j , t )−n e ( i −1 , j , t ) ) − . . .
646 ( dt /dy ˆ 2 ) ∗ q e ∗ ( ( D e ( i , j )+D e ( i , j +1) ) / 2 ) ∗ h e j plus ( i , j )∗ . . .
647 ( n e ( i , j +1 , t )−n e ( i , j , t ) ) + . . .
648 ( dt /dy ˆ 2 ) ∗ q e ∗ ( ( D e ( i , j )+D e ( i , j −1) ) / 2 ) ∗ h e j minus ( i , j )∗ . . .
649 ( n e ( i , j , t )−n e ( i , j −1 , t ) ) ) . . .
650 −( q p ∗ n p ( i , j , t ) − . . .
651 ( dt /dx ˆ 2 ) ∗ q p ∗ ( ( D p ( i , j )+D p ( i +1 , j ) ) / 2 ) ∗ h p i plus ( i , j )∗ . . .
652 ( n p ( i +1 , j , t )−n p ( i , j , t ) ) + . . .
653 ( dt /dx ˆ 2 ) ∗ q p ∗ ( ( D p ( i , j )+D p ( i −1 , j ) ) / 2 ) ∗ h p i minus ( i , j )∗ . . .
654 ( n p ( i , j , t )−n p ( i −1 , j , t ) ) − . . .
655 ( dt /dy ˆ 2 ) ∗ q p ∗ ( ( D p ( i , j )+D p ( i , j +1) ) / 2 ) ∗ h p j plus ( i , j )∗ . . .
656 ( n p ( i , j +1 , t )−n p ( i , j , t ) ) + . . .
657 ( dt /dy ˆ 2 ) ∗ q p ∗ ( ( D p ( i , j )+D p ( i , j −1) ) / 2 ) ∗ h p j minus ( i , j )∗ . . .
658 ( n p ( i , j , t )−n p ( i , j −1 , t ) ) ) . . .
659 −(q m∗n m ( i , j , t ) − . . .
660 ( dt /dx ˆ 2 ) ∗q m ∗ ( (D m( i , j )+D m( i +1 , j ) ) / 2 ) ∗ h m i plus ( i , j )∗ . . .
661 ( n m ( i +1 , j , t )−n m ( i , j , t ) ) + . . .
662 ( dt /dx ˆ 2 ) ∗q m ∗ ( (D m( i , j )+D m( i −1 , j ) ) / 2 ) ∗ h m i minus ( i , j ) ∗ . . .
663 ( n m ( i , j , t )−n m ( i −1 , j , t ) ) − . . .
664 ( dt /dy ˆ 2 ) ∗q m ∗ ( (D m( i , j )+D m( i , j +1) ) / 2 ) ∗ h m j plus ( i , j )∗ . . .

57
665 ( n m ( i , j +1 , t )−n m ( i , j , t ) ) + . . .
666 ( dt /dy ˆ 2 ) ∗q m ∗ ( (D m( i , j )+D m( i , j −1) ) / 2 ) ∗ h m j m i n u s ( i , j ) ∗ . . .
667 ( n m ( i , j , t )−n m ( i , j −1 , t ) ) ) ;
668 end
669 end
670 end
671
672 %%
673 f MSI ( : , : ) = 0 ;
674 g MSI ( : , : ) = 0 ;
675 h MSI ( : , : ) = 0 ;
676
677 f o r i =2:N−1
678 f o r j =2:M−1
679
680 i f 1−alpha MSI ∗ f MSI ( i , j −1)∗ f MSI ( i +1 , j −1) <0.5
681 b MSI ( i , j ) = 2∗ aS ( i , j ) ;
682 else
683 b MSI ( i , j ) = aS ( i , j ) /(1− alpha MSI ∗ f MSI ( i , j −1)∗ f MSI ( i +1 , j −1) ) ;
684 end
685
686 c MSI ( i , j ) = −b MSI ( i , j ) ∗ f MSI ( i , j −1) ;
687
688 i f 1+2∗ alpha MSI ∗ g MSI ( i −1 , j ) <0.5
689 d MSI ( i , j ) = 2∗aW( i , j ) ;
690 else
691 d MSI ( i , j ) = (aW( i , j )−b MSI ( i , j ) ∗ g MSI ( i , j −1) ) /(1+2∗ alpha MSI ∗ g MSI ( i −1 , j ) ) ;
692 end
693
694 p h i M S I 1 ( i , j ) = c MSI ( i , j ) ∗ f MSI ( i +1 , j −1) ;
695 p h i M S I 4 ( i , j ) = d MSI ( i , j ) ∗ g MSI ( i −1 , j ) ;
696 e MSI ( i , j ) = aC ( i , j ) − b MSI ( i , j ) ∗h MSI ( i , j −1) − c MSI ( i , j ) ∗ . . .
697 g MSI ( i +1 , j −1) − d MSI ( i , j ) ∗ f MSI ( i −1 , j ) + . . .
698 2∗ alpha MSI ∗ ( p h i M S I 1 ( i , j )+p h i M S I 4 ( i , j ) ) ;
699 f MSI ( i , j ) = ( aE ( i , j ) − c MSI ( i , j ) ∗h MSI ( i +1 , j −1) − . . .
700 2∗ alpha MSI ∗ p h i M S I 1 ( i , j ) ) / e MSI ( i , j ) ;
701 g MSI ( i , j ) = −((d MSI ( i , j ) ∗h MSI ( i −1 , j ) ) / e MSI ( i , j ) ) ;
702 h MSI ( i , j ) = (aN( i , j )−alpha MSI ∗ p h i M S I 4 ( i , j ) ) / e MSI ( i , j ) ;
703
704 end
705 end
706
707 V ( : , : , t +1) = V ( : , : , t ) ;
708 r i t ( : , : ) = 0;
709 it V = 0;
710 w h i l e ( norm ( r i t ) > t o l ∗ ( norm (A)+norm ( aC ) ∗norm (V ( : , : , t +1) ) ) && i t V<=maxit ) | | i t V==0
711 f o r i =1:N
712 f o r j =1:M
713 i f ( j==j e x p o s e d ) && ( i >=i e x p o s e d s t a r t ) && ( i <=i e x p o s e d e n d )
714 V( i , j , t +1) = V 0 ∗ s i n ( f r e q u e n c y ∗2∗ p i ∗ t ∗ dt ) ;
715 r it (i , j) = 0;
716 v it (i , j ) = 0;
717 delta it ( i , j ) = 0;
718 e l s e i f ( j==j g r o u n d e d ) && ( i >=i g r o u n d e d s t a r t ) && ( i <=i g r o u n d e d e n d )
719 V( i , j , t +1) = 0;
720 r it (i , j) = 0;
721 v it (i , j ) = 0;
722 delta it ( i , j ) = 0;
723 e l s e i f i ==1
724 V( i , j , t +1) = V( i +1 , j , t +1) ;
725 e l s e i f i==N
726 V( i , j , t +1) = V( i −1 , j , t +1) ;
727 e l s e i f j==1
728 V( i , j , t +1) = V( i , j +1 , t +1) ;
729 e l s e i f j==M
730 V( i , j , t +1) = V( i , j −1 , t +1) ;
731 else
732 r it (i , j) = A( i , j ) − aE ( i , j ) ∗V( i +1 , j , t +1) − aW( i , j ) ∗ . . .
733 V( i −1 , j , t +1) − aN( i , j ) ∗V( i , j +1 , t +1) − . . .
734 aS ( i , j ) ∗V( i , j −1 , t +1) − aC ( i , j ) ∗V( i , j , t +1) ;
735 v it (i , j ) = ( r i t ( i , j ) − b MSI ( i , j ) ∗ r i t ( i , j −1) − . . .
736 c MSI ( i , j ) ∗ r i t ( i +1 , j −1) − d MSI ( i , j ) ∗ . . .
737 r i t ( i −1 , j ) ) / e MSI ( i , j ) ;
738 d e l t a i t ( i , j ) = v i t ( i , j ) − f MSI ( i , j ) ∗ v i t ( i +1 , j ) − . . .
739 g MSI ( i , j ) ∗ v i t ( i −1 , j +1) − . . .
740 h MSI ( i , j ) ∗ v i t ( i , j +1) ;

58
741 V( i , j , t +1) = V( i , j , t +1) + d e l t a i t ( i , j ) ;
742 % V( i , j , t +1) = (A( i , j ) − aE ( i , j ) ∗V( i +1 , j , t +1) − . . .
743 % aW( i , j ) ∗V( i −1 , j , t +1) − aN( i , j ) ∗ . . .
744 % V( i , j +1 , t +1) − aS ( i , j ) ∗V( i , j −1 , t +1) ) /aC ( i , j ) ;
745 end
746 end
747 end
748 it V = it V + 1;
749 end
750
751 % normalized r e s i d u a l
752 i f abs ( t o l ∗ ( norm (A)+norm ( aC ) ∗norm (V ( : , : , t +1) ) ) ) > 0
753 n o r m r i t V = abs ( norm ( r i t ) / ( t o l ∗ ( norm (A)+norm ( aC ) ∗norm (V ( : , : , t +1) ) ) ) ) ;
754 else
755 norm r it V = 0;
756 end
757
758 %% s u r f a c e charge
759 j = j exposed ;
760 f o r i =2:N−1
761 i f i >=i e x p o s e d s t a r t && i <=i e x p o s e d e n d
762 sigma ( i , t +1) = sigma ( i , t ) + . . .
763 dt ∗ q p ∗ ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j +1) ) / 2 ) ∗ . . .
764 ( g 1 p j p l u s ( i , j ) ∗ n p ( i , j +1 , t ) − g 2 p j p l u s ( i , j ) ∗ ...
765 n p ( i , j , t ) ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) − . . .
766 ( ( D p ( i , j )+D p ( i , j +1) ) / 2 ) ∗ h p j p l u s ( i , j ) ∗ . . .
767 ( ( n p ( i , j +1 , t )−n p ( i , j , t ) ) /dy ) ) + . . .
768 dt ∗q m ∗ ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j +1) ) / 2 ) ∗ . . .
769 ( g 1 m j p l u s ( i , j ) ∗n m ( i , j +1 , t ) − g 2 m j p l u s ( i , j ) ∗ ...
770 n m ( i , j , t ) ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) − . . .
771 ( ( D m( i , j )+D m( i , j +1) ) / 2 ) ∗ h m j p l u s ( i , j ) ∗ . . .
772 ( ( n m ( i , j +1 , t )−n m ( i , j , t ) ) /dy ) ) ;
773 else
774 sigma ( i , t +1) = sigma ( i , t ) + . . .
775 dt ∗ q e ∗ ( s i g n ( q e ) ∗ ( ( mu e ( i , j )+mu e ( i , j +1) ) / 2 ) ∗ . . .
776 ( g 1 e j p l u s ( i , j ) ∗ n e ( i , j +1 , t ) − g 2 e j p l u s ( i , j ) ∗ ...
777 n e ( i , j , t ) ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) − . . .
778 ( ( D e ( i , j )+D e ( i , j +1) ) / 2 ) ∗ h e j p l u s ( i , j ) ∗ . . .
779 ( ( n e ( i , j +1 , t )−n e ( i , j , t ) ) /dy ) ) + . . .
780 dt ∗ q p ∗ ( s i g n ( q p ) ∗ ( ( mu p ( i , j )+mu p ( i , j +1) ) / 2 ) ∗ . . .
781 ( g 1 p j p l u s ( i , j ) ∗ n p ( i , j +1 , t ) − g 2 p j p l u s ( i , j ) ∗ ...
782 n p ( i , j , t ) ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) − . . .
783 ( ( D p ( i , j )+D p ( i , j +1) ) / 2 ) ∗ h p j p l u s ( i , j ) ∗ . . .
784 ( ( n p ( i , j +1 , t )−n p ( i , j , t ) ) /dy ) ) + . . .
785 dt ∗q m ∗ ( s i g n ( q m ) ∗ ( ( mu m( i , j )+mu m( i , j +1) ) / 2 ) ∗ . . .
786 ( g 1 m j p l u s ( i , j ) ∗n m ( i , j +1 , t ) − g 2 m j p l u s ( i , j ) ∗ ...
787 n m ( i , j , t ) ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) − . . .
788 ( ( D m( i , j )+D m( i , j +1) ) / 2 ) ∗ h m j p l u s ( i , j ) ∗ . . .
789 ( ( n m ( i , j +1 , t )−n m ( i , j , t ) ) /dy ) ) ;
790 end
791 end
792
793 %% S o u r c e s
794
795 f o r i =2:N−1
796 f o r j=j e x p o s e d +1:M−1
797 dnedx ( i , j ) = ( n e ( i +1 , j , t )−n e ( i −1 , j , t ) ) / ( 2 ∗ dx ) ;
798 dnedy ( i , j ) = ( n e ( i , j +1 , t )−n e ( i , j −1 , t ) ) / ( 2 ∗ dy ) ;
799 dnpdx ( i , j ) = ( n p ( i +1 , j , t )−n p ( i −1 , j , t ) ) / ( 2 ∗ dx ) ;
800 dnpdy ( i , j ) = ( n p ( i , j +1 , t )−n p ( i , j −1 , t ) ) / ( 2 ∗ dy ) ;
801 dVdx ( i , j ) = (V( i +1 , j , t )−V( i −1 , j , t ) ) / ( 2 ∗ dx ) ;
802 dVdy ( i , j ) = (V( i , j +1 , t )−V( i , j −1 , t ) ) / ( 2 ∗ dy ) ;
803
804 Gamma e x ( i , j ) = −D e ( i , j ) ∗ dnedx ( i , j ) + mu e ( i , j ) ∗ n e ( i , j , t ) ∗dVdx ( i , j ) ;
805 Gamma e y ( i , j ) = −D e ( i , j ) ∗ dnedy ( i , j ) + mu e ( i , j ) ∗ n e ( i , j , t ) ∗dVdy ( i , j ) ;
806
807 MagE( i , j ) = s q r t (( −dVdx ( i , j ) ) ˆ2+(−dVdy ( i , j ) ) ˆ 2 ) ;
808 MagG( i , j ) = s q r t ( ( Gamma e x ( i , j ) ) ˆ2+(Gamma e y ( i , j ) ) ˆ 2 ) ;
809
810 i f MagE( i , j ) ˜=0
811 a l p h ( i , j ) = 1500∗760∗ exp ( −365∗100/( abs (MagE( i , j ) ) / 7 6 0 ) ) ;
812 else
813 alph ( i , j ) = 0 ;
814 end
815
816 nua ( i , j ) = abs (−a aOverP ∗760∗ mu e ( i , j ) ∗MagE( i , j ) ) ;

59
817
818 S e ( i , j ) = a l p h ( i , j ) ∗MagG( i , j ) − b e t a ∗ n p ( i , j , t ) ∗ n e ( i , j , t ) + . . .
819 kd∗nn∗n m ( i , j , t ) − nua ( i , j ) ∗ n e ( i , j , t ) ;
820 S p ( i , j ) = a l p h ( i , j ) ∗MagG( i , j ) − b e t a ∗ n p ( i , j , t ) ∗ n e ( i , j , t ) − . . .
821 b e t a i ∗ n p ( i , j , t ) ∗n m ( i , j , t ) ;
822 S m ( i , j ) = nua ( i , j ) ∗ n e ( i , j , t ) − kd∗nn∗n m ( i , j , t ) − b e t a i ∗ n p ( i , j , t ) ∗n m ( i , j , t ) ;
823 end
824 end
825
826 %% p o s i t i v e i o n s
827
828 f o r i =2:N−1
829 f o r j=j e x p o s e d +1:M−1
830 aE p ( i , j ) = −(dt /dx ˆ 2 ) ∗ ( ( D p( i , j )+D p ( i +1 , j ) ) / 2 ) ∗ f 1 p i plus (i , j);
831 aW p ( i , j ) = −(dt /dx ˆ 2 ) ∗ ( ( D p( i , j )+D p ( i −1 , j ) ) / 2 ) ∗ f 2 p i minus ( i ,j);
832 aN p ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( ( D p( i , j )+D p ( i , j +1) ) / 2 ) ∗ f 1 p j plus (i , j);
833 aS p ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( ( D p( i , j )+D p ( i , j −1) ) / 2 ) ∗ f 2 p j minus ( i ,j);
834 end
835 end
836
837 f o r i =2:N−1
838 f o r j=j e x p o s e d +1:M−1
839 aC p ( i , j ) = 1 − aE p ( i −1 , j ) − aW p ( i +1 , j ) − aN p ( i , j −1) − aS p ( i , j +1) ;
840 A p ( i , j ) = n p ( i , j , t ) + dt ∗ S p ( i , j ) ;
841 end
842 end
843
844 j=j e x p o s e d ;
845 f o r i =2:N−1
846 i f s i g n ( q p ) ∗mu p ( i , j ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) ∗( −1) >0
847 a p ( i ) = 1;
848 else
849 a p ( i ) = 0;
850 end
851
852 v t h p = s q r t ( ( 8 ∗ k b ∗T p ( i , j ) ) / ( p i ∗m p ) ) ;
853
854 aE p ( i , j) = 0;
855 aW p ( i , j) = 0;
856 aS p ( i , j) = 0;
857 aN p ( i , j) = −(dt /dy ˆ 2 ) ∗ ( ( D p ( i , j )+D p ( i , j +1) ) / 2 ) ∗ f 1 p j p l u s ( i , j ) ;
858 aC p ( i , j) = 0 . 5 − aS p ( i , j +1) − ( dt /dx ) ∗ ( 2 ∗ a p ( i ) −1)∗ s i g n ( q p ) ∗mu p ( i , j ) ∗ . . .
859 ( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) + ( dt / ( 2 ∗ dy ) ) ∗ v t h p ;
860 A p( i , j ) = 0 . 5 ∗ n p ( i , j ) +0.5∗ dt ∗ S p ( i , j ) ;
861 end
862
863
864 f MSI p ( : , : ) = 0 ;
865 g MSI p ( : , : ) = 0 ;
866 h MSI p ( : , : ) = 0 ;
867
868 f o r i =2:N−1
869 f o r j=j e x p o s e d :M−1
870
871 i f 1−alpha MSI p ∗ f M S I p ( i , j −1)∗ f M S I p ( i +1 , j −1) <0.5
872 b MSI p ( i , j ) = 2∗ aS p ( i , j ) ;
873 else
874 b MSI p ( i , j ) = aS p ( i , j ) /(1− alpha MSI p ∗ f M S I p ( i , j −1)∗ f M S I p ( i +1 , j −1) ) ;
875 end
876
877 c MSI p ( i , j ) = −b MSI p ( i , j ) ∗ f M S I p ( i , j −1) ;
878
879 i f 1+2∗ alpha MSI p ∗ g MSI p ( i −1 , j ) <0.5
880 d MSI p ( i , j ) = 2∗aW p ( i , j ) ;
881 else
882 d MSI p ( i , j ) = ( aW p ( i , j )−b MSI p ( i , j ) ∗ g MSI p ( i , j −1) ) / . . .
883 (1+2∗ alpha MSI p ∗ g MSI p ( i −1 , j ) ) ;
884 end
885
886 p h i M S I 1 p ( i , j ) = c MSI p ( i , j ) ∗ f M S I p ( i +1 , j −1) ;
887 p h i M S I 4 p ( i , j ) = d MSI p ( i , j ) ∗ g MSI p ( i −1 , j ) ;
888 e MSI p ( i , j ) = aC p ( i , j ) − b MSI p ( i , j ) ∗ h MSI p ( i , j −1) − c MSI p ( i , j ) ∗ . . .
889 g MSI p ( i +1 , j −1) − d MSI p ( i , j ) ∗ f M S I p ( i −1 , j ) + . . .
890 2∗ alpha MSI p ∗ ( p h i M S I 1 p ( i , j )+p h i M S I 4 p ( i , j ) ) ;
891 f MSI p ( i , j ) = ( aE p ( i , j ) − c MSI p ( i , j ) ∗ h MSI p ( i +1 , j −1) − . . .
892 2∗ alpha MSI p ∗ p h i M S I 1 p ( i , j ) ) / e MSI p ( i , j ) ;

60
893 g MSI p ( i , j ) = −(( d MSI p ( i , j ) ∗ h MSI p ( i −1 , j ) ) / e MSI p ( i , j ) ) ;
894 h MSI p ( i , j ) = ( aN p ( i , j )−alpha MSI p ∗ p h i M S I 4 p ( i , j ) ) / e MSI p ( i , j ) ;
895 end
896 end
897
898 n p ( : , : , t +1) = n p ( : , : , t ) ;
899 r it p ( : , : ) = 0;
900 it p = 0;
901
902 w h i l e ( norm ( r i t p )>t o l p ∗ ( norm ( A p )+norm ( aC p ) ∗norm ( n p ( : , : , t +1) ) )&&i t p <=maxit ) ...
903 | | i t p ==0
904
905 f o r i =2:N−1
906 f o r j=j e x p o s e d :M−1
907
908 % if i ==1
909 % n p ( i , j , t +1) = n p ( i +1 , j , t +1) ;
910 % e l s e i f i == N
911 % n p ( i , j , t +1) = n p ( i −1 , j , t +1) ;
912 % e l s e i f j == M
913 % n p ( i , j , t +1) = n p ( i , j −1 , t +1) ;
914 % else
915
916 r it p (i , j ) = A p ( i , j ) − aE p ( i , j ) ∗ n p ( i +1 , j , t +1) − aW p ( i , j ) ∗ . . .
917 n p ( i −1 , j , t +1) − aN p ( i , j ) ∗ n p ( i , j +1 , t +1) − . . .
918 aS p ( i , j ) ∗ n p ( i , j −1 , t +1) − aC p ( i , j ) ∗ n p ( i , j , t +1) ;
919 v it p ( i , j ) = ( r i t p ( i , j ) − b MSI p ( i , j ) ∗ r i t p ( i , j −1) − . . .
920 c MSI p ( i , j ) ∗ r i t p ( i +1 , j −1) − d MSI p ( i , j ) ∗ . . .
921 r i t p ( i −1 , j ) ) / e MSI p ( i , j ) ;
922 d e l t a i t p ( i , j ) = v i t p ( i , j ) − f M S I p ( i , j ) ∗ v i t p ( i +1 , j ) − . . .
923 g MSI p ( i , j ) ∗ v i t p ( i −1 , j +1) − h MSI p ( i , j ) ∗ v i t p ( i , j +1) ;
924 n p ( i , j , t +1) = n p ( i , j , t +1) + d e l t a i t p ( i , j ) ;
925
926 % n p ( i , j , t +1) = ( A p ( i , j ) − aE p ( i , j ) ∗ n p ( i +1 , j , t +1) − . . .
927 % aW p ( i , j ) ∗ n p ( i −1 , j , t +1) − aN p ( i , j ) ∗ n p ( i , j +1 , t +1) − . . .
928 % aS p ( i , j ) ∗ n p ( i , j −1 , t +1) ) / aC p ( i , j ) ;
929 % end
930 end
931 end
932 i t p=i t p +1;
933 end
934
935 % normalized r e s i d u a l
936 i f abs ( t o l p ∗ ( norm ( A p )+norm ( aC p ) ∗norm ( n p ( : , : , t +1) ) ) ) > 0
937 n o r m r i t p = abs ( norm ( r i t p ) / ( t o l p ∗ ( norm ( A p )+norm ( aC p ) ∗norm ( n p ( : , : , t +1) ) ) ) ) ;
938 else
939 norm r it p = 0;
940 end
941
942 %% n e g a t i v e i o n s
943
944 f o r i =2:N−1
945 f o r j=j e x p o s e d +1:M−1
946 aE m ( i , j ) = −(dt /dx ˆ 2 ) ∗ ( (D m( i , j )+D m( i +1 , j ) ) / 2 ) ∗ f 1 m i plus ( i , j);
947 aW m( i , j ) = −(dt /dx ˆ 2 ) ∗ ( (D m( i , j )+D m( i −1 , j ) ) / 2 ) ∗ f 2 m i minus ( i ,j);
948 aN m ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( (D m( i , j )+D m( i , j +1) ) / 2 ) ∗ f 1 m j plus ( i , j);
949 aS m ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( (D m( i , j )+D m( i , j −1) ) / 2 ) ∗ f 2 m j minus ( i ,j);
950 end
951 end
952
953 f o r i =2:N−1
954 f o r j=j e x p o s e d +1:M−1
955 aC m ( i , j ) = 1 − aE m ( i −1 , j ) − aW m( i +1 , j ) − aN m ( i , j −1) − aS m ( i , j +1) ;
956 A m( i , j ) = n m ( i , j , t ) + dt ∗S m ( i , j ) ;
957 end
958 end
959
960 j=j e x p o s e d ;
961 f o r i =2:N−1
962 i f s i g n ( q m ) ∗mu m( i , j ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) ∗( −1) >0
963 a m( i ) = 1;
964 else
965 a m( i ) = 0;
966 end
967
968 v th m = s q r t ( ( 8 ∗ k b ∗T m( i , j ) ) / ( p i ∗m m) ) ;

61
969
970 aE m ( i , j) = 0;
971 aW m( i , j) = 0;
972 aS m ( i , j) = 0;
973 aN m ( i , j) = −(dt /dy ˆ 2 ) ∗ ( (D m( i , j )+D m( i , j +1) ) / 2 ) ∗ f 1 m j p l u s ( i , j ) ;
974 aC m ( i , j) = 0 . 5 − aS m ( i , j +1) − ( dt /dx ) ∗ ( 2 ∗ a m ( i ) −1)∗ s i g n ( q m ) ∗mu m( i , j ) ∗ . . .
975 ( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) + ( dt / ( 2 ∗ dy ) ) ∗ v th m ;
976 A m( i , j ) = 0 . 5 ∗ n m ( i , j ) +0.5∗ dt ∗S m ( i , j ) ;
977 end
978
979 f MSI m ( : , : ) = 0 ;
980 g MSI m ( : , : ) = 0 ;
981 h MSI m ( : , : ) = 0 ;
982
983 f o r i =2:N−1
984 f o r j=j e x p o s e d :M−1
985
986 i f 1−alpha MSI m ∗ f MSI m ( i , j −1)∗ f MSI m ( i +1 , j −1) <0.5
987 b MSI m ( i , j ) = 2∗ aS m ( i , j ) ;
988 else
989 b MSI m ( i , j ) = aS m ( i , j ) /(1− alpha MSI m ∗ f MSI m ( i , j −1)∗ f MSI m ( i +1 , j −1) ) ;
990 end
991
992 c MSI m ( i , j ) = −b MSI m ( i , j ) ∗ f MSI m ( i , j −1) ;
993
994 i f 1+2∗alpha MSI m ∗g MSI m ( i −1 , j ) <0.5
995 d MSI m ( i , j ) = 2∗aW m( i , j ) ;
996 else
997 d MSI m ( i , j ) = (aW m( i , j )−b MSI m ( i , j ) ∗g MSI m ( i , j −1) ) / . . .
998 (1+2∗ alpha MSI m ∗g MSI m ( i −1 , j ) ) ;
999 end
1000
1001 phi MSI 1 m ( i , j ) = c MSI m ( i , j ) ∗ f MSI m ( i +1 , j −1) ;
1002 phi MSI 4 m ( i , j ) = d MSI m ( i , j ) ∗g MSI m ( i −1 , j ) ;
1003 e MSI m ( i , j ) = aC m ( i , j ) − b MSI m ( i , j ) ∗h MSI m ( i , j −1) − c MSI m ( i , j ) ∗ . . .
1004 g MSI m ( i +1 , j −1) − d MSI m ( i , j ) ∗ f MSI m ( i −1 , j ) + . . .
1005 2∗ alpha MSI m ∗ ( phi MSI 1 m ( i , j )+phi MSI 4 m ( i , j ) ) ;
1006 f MSI m ( i , j ) = ( aE m ( i , j ) − c MSI m ( i , j ) ∗h MSI m ( i +1 , j −1) − . . .
1007 2∗ alpha MSI m ∗ phi MSI 1 m ( i , j ) ) / e MSI m ( i , j ) ;
1008 g MSI m ( i , j ) = −((d MSI m ( i , j ) ∗h MSI m ( i −1 , j ) ) / e MSI m ( i , j ) ) ;
1009 h MSI m ( i , j ) = ( aN m ( i , j )−alpha MSI m ∗ phi MSI 4 m ( i , j ) ) / e MSI m ( i , j ) ;
1010
1011 end
1012 end
1013
1014 n m ( : , : , t +1) = n m ( : , : , t ) ;
1015 r it m ( : , : ) = 0;
1016 i t m =0;
1017 w h i l e ( norm ( r i t m )>t o l m ∗ ( norm (A m)+norm ( aC m ) ∗norm ( n m ( : , : , t +1) ) )&&it m<=maxit ) ...
1018 | | i t m==0
1019
1020 f o r i =2:N−1
1021 f o r j=j e x p o s e d :M−1
1022
1023 % if i ==1
1024 % n m ( i , j , t +1) = n m ( i +1 , j , t +1) ;
1025 % e l s e i f i==N
1026 % n m ( i , j , t +1) = n m ( i −1 , j , t +1) ;
1027 % e l s e i f j==M
1028 % n m ( i , j , t +1) = n m ( i , j −1 , t +1) ;
1029 % else
1030 r it m ( i , j ) = A m( i , j ) − aE m ( i , j ) ∗n m ( i +1 , j , t +1) − aW m( i , j ) ∗ . . .
1031 n m ( i −1 , j , t +1) − aN m ( i , j ) ∗n m ( i , j +1 , t +1) − . . .
1032 aS m ( i , j ) ∗n m ( i , j −1 , t +1) − aC m ( i , j ) ∗n m ( i , j , t +1) ;
1033 v it m ( i , j ) = ( r i t m ( i , j ) − b MSI m ( i , j ) ∗ r i t m ( i , j −1) − . . .
1034 c MSI m ( i , j ) ∗ r i t m ( i +1 , j −1) − d MSI m ( i , j ) ∗ . . .
1035 r i t m ( i −1 , j ) ) / e MSI m ( i , j ) ;
1036 d e l t a i t m ( i , j ) = v i t m ( i , j ) − f MSI m ( i , j ) ∗ v i t m ( i +1 , j ) − . . .
1037 g MSI m ( i , j ) ∗ v i t m ( i −1 , j +1) − h MSI m ( i , j ) ∗ v i t m ( i , j +1) ;
1038 n m ( i , j , t +1) = n m ( i , j , t +1) + d e l t a i t m ( i , j ) ;
1039
1040 % n m ( i , j , t +1) = (A m( i , j ) − aE m ( i , j ) ∗n m ( i +1 , j , t +1) − . . .
1041 % aW m( i , j ) ∗n m ( i −1 , j , t +1) − aN m ( i , j ) ∗n m ( i , j +1 , t +1)− . . .
1042 % aS m ( i , j ) ∗n m ( i , j −1 , t +1) ) /aC m ( i , j ) ;
1043 % end
1044 end

62
1045 end
1046 it m = it m + 1 ;
1047 end
1048
1049 % normalized r e s i d u a l
1050 i f abs ( t o l m ∗ ( norm (A m)+norm ( aC m ) ∗norm ( n m ( : , : , t +1) ) ) ) > 0
1051 n o r m r i t m = abs ( norm ( r i t m ) / ( t o l m ∗ ( norm (A m)+norm ( aC m ) ∗norm ( n m ( : , : , t +1) ) ) ) ) ;
1052 else
1053 norm r it m = 0;
1054 end
1055
1056 %% E l e c t r o n s
1057 f o r i =2:N−1
1058 f o r j=j e x p o s e d +1:M−1
1059 aE e ( i , j ) = −(dt /dx ˆ 2 ) ∗ ( ( D e(i , j )+D e ( i +1 , j ) ) / 2 ) ∗ f 1 e i plus (i , j);
1060 aW e ( i , j ) = −(dt /dx ˆ 2 ) ∗ ( ( D e(i , j )+D e ( i −1 , j ) ) / 2 ) ∗ f 2 e i minus ( i ,j);
1061 aN e ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( ( D e(i , j )+D e ( i , j +1) ) / 2 ) ∗ f 1 e j plus (i , j);
1062 a S e ( i , j ) = −(dt /dy ˆ 2 ) ∗ ( ( D e(i , j )+D e ( i , j −1) ) / 2 ) ∗ f 2 e j minus ( i ,j);
1063 end
1064 end
1065
1066 f o r i =2:N−1
1067 f o r j=j e x p o s e d +1:M−1
1068 aC e ( i , j ) = 1 − aE e ( i −1 , j ) − aW e ( i +1 , j ) − aN e ( i , j −1) − a S e ( i , j +1) ;
1069 A e ( i , j ) = n e ( i , j , t ) + dt ∗ S e ( i , j ) ;
1070 end
1071 end
1072
1073 j=j e x p o s e d ;
1074 f o r i =2:N−1
1075 i f s i g n ( q e ) ∗mu e ( i , j ) ∗( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) ∗( −1) > 0
1076 a e = 1;
1077 else
1078 a e = 0;
1079 end
1080
1081 v t h e = s q r t ( ( 8 ∗ k b ∗ T e ( i , j ) ) / ( p i ∗m e ) ) ;
1082 n gamma = (1− a e ) ∗ ( 1 / mu e ( i , j ) ) ∗gamma em p ( i ) ∗ ( ( 2 ∗ a p ( i ) −1)∗ s i g n ( q p ) + . . .
1083 0 . 5 ∗ s q r t ( ( 8 ∗ m g ∗ ( m p+m g ) ) / ( p i ∗m p ∗ ( 5 ∗ m p+3∗m g ) ) ) ) ∗ . . .
1084 mu p ( i , j ) ∗ n p ( i , j , t +1) ;
1085
1086 aE e(i , j) = 0;
1087 aW e( i , j) = 0;
1088 aS e(i , j) = 0;
1089 aN e(i , j) = −(dt /dy ˆ 2 ) ∗ ( ( D e ( i , j )+D e ( i , j +1) ) / 2 ) ∗ f 1 e j p l u s ( i , j ) ;
1090 aC e(i , j) = 0 . 5 − a S e ( i , j +1) − ( dt /dy ) ∗ ( 2 ∗ a e −1)∗ s i g n ( q e ) ∗mu e ( i , j ) ∗ . . .
1091 ( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) + ( dt / ( 2 ∗ dy ) ) ∗ v t h e ;
1092
1093 A e(i , j ) = 0 . 5 ∗ n e ( i , j , t ) + ( dt / 2 ) ∗ S e ( i , j ) + ( dt / ( 2 ∗ dy ) ) ∗ v t h e ∗n gamma + . . .
1094 ( ( 2 ∗ dt ) /dy ) ∗(1− a e ) ∗gamma em p ( i ) ∗ ( ( 2 ∗ a p ( i ) −1)∗ s i g n ( q p ) ∗mu p ( i , j ) ∗ . . .
1095 ( −(V( i , j +1 , t +1)−V( i , j , t +1) ) /dy ) ∗ n p ( i , j , t +1) − 0 . 5 ∗ v t h p ∗ . . .
1096 n p ( i , j , t +1) + ( 2 ∗ a m ( i ) −1)∗ s i g n ( q m ) ∗mu m( i , j ) ∗( −(V( i , j +1 , t +1)− . . .
1097 V( i , j , t +1) ) /dy ) ∗n m ( i , j , t +1) − 0 . 5 ∗ v th m ∗n m ( i , j , t +1) ) ;
1098 end
1099
1100 f MSI e ( : , : ) = 0;
1101 g MSI e ( : , : ) = 0 ;
1102 h MSI e ( : , : ) = 0 ;
1103
1104 f o r i =2:N−1
1105 f o r j=j e x p o s e d :M−1
1106
1107 i f 1−a l p h a M S I e ∗ f M S I e ( i , j −1)∗ f M S I e ( i +1 , j −1) <0.5
1108 b MSI e ( i , j ) = 2∗ a S e ( i , j ) ;
1109 else
1110 b MSI e ( i , j ) = a S e ( i , j ) /(1− a l p h a M S I e ∗ f M S I e ( i , j −1)∗ f M S I e ( i +1 , j −1) ) ;
1111 end
1112
1113 c M S I e ( i , j ) = −b MSI e ( i , j ) ∗ f M S I e ( i , j −1) ;
1114
1115 i f 1+2∗ a l p h a M S I e ∗ g MSI e ( i −1 , j ) <0.5
1116 d MSI e ( i , j ) = 2∗aW e ( i , j ) ;
1117 else
1118 d MSI e ( i , j ) = ( aW e ( i , j )−b MSI e ( i , j ) ∗ g MSI e ( i , j −1) ) / . . .
1119 (1+2∗ a l p h a M S I e ∗ g MSI e ( i −1 , j ) ) ;
1120 end

63
1121
1122 p h i M S I 1 e ( i , j ) = c M S I e ( i , j ) ∗ f M S I e ( i +1 , j −1) ;
1123 p h i M S I 4 e ( i , j ) = d MSI e ( i , j ) ∗ g MSI e ( i −1 , j ) ;
1124 e MSI e ( i , j ) = aC e ( i , j ) − b MSI e ( i , j ) ∗ h MSI e ( i , j −1) − . . .
1125 c M S I e ( i , j ) ∗ g MSI e ( i +1 , j −1) − d MSI e ( i , j ) ∗ . . .
1126 f M S I e ( i −1 , j ) + 2∗ a l p h a M S I e ∗ . . .
1127 ( p h i M S I 1 e ( i , j )+p h i M S I 4 e ( i , j ) ) ;
1128 f MSI e ( i , j ) = ( aE e ( i , j ) − c M S I e ( i , j ) ∗ h MSI e ( i +1 , j −1) − . . .
1129 2∗ a l p h a M S I e ∗ p h i M S I 1 e ( i , j ) ) / e M S I e ( i , j ) ;
1130 g MSI e ( i , j ) = −(( d MSI e ( i , j ) ∗ h MSI e ( i −1 , j ) ) / e M S I e ( i , j ) ) ;
1131 h MSI e ( i , j ) = ( aN e ( i , j )−a l p h a M S I e ∗ p h i M S I 4 e ( i , j ) ) / e M S I e ( i , j ) ;
1132
1133 end
1134 end
1135
1136 n e ( : , : , t +1) = n e ( : , : , t ) ;
1137 r i t e ( : , : ) = 0;
1138 i t e = 0;
1139 w h i l e ( norm ( r i t e )> t o l e ∗ ( norm ( A e )+norm ( aC e ) ∗norm ( n e ( : , : , t +1) ) )&&i t e <=maxit ) ...
1140 | | i t e ==0
1141
1142 f o r i =2:N−1
1143 f o r j=j e x p o s e d :M−1
1144 % i f i ==1
1145 % i f V 0 ∗ s i n ( f r e q u e n c y ∗2∗ p i ∗ t ∗ dt ) > 0
1146 % n e ( i , j , t +1) = n 0 ;
1147 % else
1148 % n e ( i , j , t +1) = n e ( i +1 , j , t +1) ;
1149 % end
1150 % e l s e i f i==N
1151 % i f V 0 ∗ s i n ( f r e q u e n c y ∗2∗ p i ∗ t ∗ dt ) > 0
1152 % n e ( i , j , t +1) = n e ( i −1 , j , t +1) ;
1153 % else
1154 % n e ( i , j , t +1) = n 0 ;
1155 % end
1156 % e l s e i f j==M
1157 % n e ( i , j , t +1) = n e ( i , j −1 , t +1) ;
1158 % else
1159 r it e (i , j) = A e ( i , j ) − aE e ( i , j ) ∗ n e ( i +1 , j , t +1) − aW e ( i , j ) ∗ . . .
1160 n e ( i −1 , j , t +1) − aN e ( i , j ) ∗ n e ( i , j +1 , t +1) − . . .
1161 a S e ( i , j ) ∗ n e ( i , j −1 , t +1) − aC e ( i , j ) ∗ n e ( i , j , t +1) ;
1162 v it e (i , j ) = ( r i t e ( i , j ) − b MSI e ( i , j ) ∗ r i t e ( i , j −1) − . . .
1163 c M S I e ( i , j ) ∗ r i t e ( i +1 , j −1) − d MSI e ( i , j ) ∗ . . .
1164 r i t e ( i −1 , j ) ) / e M S I e ( i , j ) ;
1165 d e l t a i t e ( i , j ) = v i t e ( i , j ) − f M S I e ( i , j ) ∗ v i t e ( i +1 , j ) − . . .
1166 g MSI e ( i , j ) ∗ v i t e ( i −1 , j +1) − h MSI e ( i , j ) ∗ v i t e ( i , j +1) ;
1167 n e ( i , j , t +1) = n e ( i , j , t +1) + d e l t a i t e ( i , j ) ;
1168
1169 % n e ( i , j , t +1) = ( A e ( i , j ) − aE e ( i , j ) ∗ n e ( i +1 , j , t +1) − . . .
1170 % aW e ( i , j ) ∗ n e ( i −1 , j , t +1) − aN e ( i , j ) ∗ n e ( i , j +1 , t +1) − . . .
1171 % a S e ( i , j ) ∗ n e ( i , j −1 , t +1) ) / aC e ( i , j ) ;
1172 % end
1173 end
1174 end
1175 i t e = i t e +1;
1176 end
1177
1178 % normalized r e s i d u a l
1179 i f abs ( t o l e ∗ ( norm ( A e )+norm ( aC e ) ∗norm ( n e ( : , : , t +1) ) ) ) > 0
1180 n o r m r i t e = abs ( norm ( r i t e ) / ( t o l e ∗ ( norm ( A e )+norm ( aC e ) ∗norm ( n e ( : , : , t +1) ) ) ) ) ;
1181 else
1182 norm r it e = 0;
1183 end
1184
1185 %% c a l c u l a t e D and mu
1186
1187 f o r i =2:N−1
1188 f o r j =2:M−1
1189 dVdx ( i , j ) = (V( i +1 , j , t +1)−V( i −1 , j , t +1) ) / ( 2 ∗ dx ) ;
1190 dVdy ( i , j ) = (V( i , j +1 , t +1)−V( i , j −1 , t +1) ) / ( 2 ∗ dy ) ;
1191 MagE( i , j ) = s q r t (( −dVdx ( i , j ) ) ˆ2+(−dVdy ( i , j ) ) ˆ 2 ) ;
1192
1193 EoverN = (MagE( i , j ) /nn ) ;
1194
1195 i f EoverN < E o v e r N v e c t o r ( 1 )
1196 EoverN = EoverN vector (1) ;

64
1197 V drift e = V drift N2 e (1) ;
1198 mu e ( i , j ) = V d r i f t e / ( nn∗EoverN ) ;
1199 D e ( i , j ) = DoverMue N2 ( 1 ) ∗mu e ( i , j ) ;
1200 T e ( i , j ) = ( D e ( i , j ) ∗ e ) / ( k b ∗mu e ( i , j ) ) ;
1201 e l s e i f EoverN > E o v e r N v e c t o r ( l e n g t h ( E o v e r N v e c t o r ) )
1202 EoverN = E o v e r N v e c t o r ( l e n g t h ( E o v e r N v e c t o r ) ) ;
1203 V drift e = V drift N2 e ( length ( V drift N2 e ) ) ;
1204 mu e ( i , j ) = V d r i f t e / ( nn∗EoverN ) ;
1205 D e ( i , j ) = DoverMue N2 ( l e n g t h ( DoverMue N2 ) ) ∗mu e ( i , j ) ;
1206 T e ( i , j ) = ( D e ( i , j ) ∗ e ) / ( k b ∗mu e ( i , j ) ) ;
1207 else
1208 d i f f E o v e r N = E o v e r N v e c t o r −EoverN ;
1209 [ ˜ , i n d e x ] = min ( abs ( E o v e r N v e c t o r −EoverN ) ) ;
1210 i f d i f f E o v e r N ( i n d e x )<0
1211 V d r i f t e = V d r i f t N 2 e ( i n d e x ) + ( ( V d r i f t N 2 e ( i n d e x +1)− . . .
1212 V d r i f t N 2 e ( i n d e x ) ) / ( E o v e r N v e c t o r ( i n d e x +1)− . . .
1213 E o v e r N v e c t o r ( i n d e x ) ) ) ∗ ( EoverN−E o v e r N v e c t o r ( i n d e x ) ) ;
1214 mu e ( i , j ) = V d r i f t e / ( nn∗EoverN ) ;
1215 D e ( i , j ) = ( DoverMue N2 ( i n d e x ) + ( ( DoverMue N2 ( i n d e x +1)− . . .
1216 DoverMue N2 ( i n d e x ) ) / ( E o v e r N v e c t o r ( i n d e x +1)− . . .
1217 E o v e r N v e c t o r ( i n d e x ) ) ) ∗ ( EoverN−E o v e r N v e c t o r ( i n d e x ) ) ) ∗ . . .
1218 mu e ( i , j ) ;
1219 T e ( i , j ) = ( D e ( i , j ) ∗ e ) / ( k b ∗mu e ( i , j ) ) ;
1220 else
1221 V d r i f t e = V d r i f t N 2 e ( index −1) + ( ( V d r i f t N 2 e ( i n d e x )− . . .
1222 V d r i f t N 2 e ( index −1) ) / ( E o v e r N v e c t o r ( i n d e x )− . . .
1223 E o v e r N v e c t o r ( index −1) ) ) ∗ ( EoverN−E o v e r N v e c t o r ( index −1) ) ;
1224 mu e ( i , j ) = V d r i f t e / ( nn∗EoverN ) ;
1225 D e ( i , j ) = ( DoverMue N2 ( index −1) + ( ( DoverMue N2 ( i n d e x )− . . .
1226 DoverMue N2 ( index −1) ) / ( E o v e r N v e c t o r ( i n d e x )− . . .
1227 E o v e r N v e c t o r ( index −1) ) ) ∗ . . .
1228 ( EoverN−E o v e r N v e c t o r ( index −1) ) ) ∗mu e ( i , j ) ;
1229 T e ( i , j ) = ( D e ( i , j ) ∗ e ) / ( k b ∗mu e ( i , j ) ) ;
1230 end
1231 end
1232 end
1233 end
1234
1235 j=M;
1236 f o r i =1:N
1237 mu e ( i , j ) = mu e ( i , j −1) ;
1238 D e(i , j ) = D e ( i , j −1) ;
1239 end
1240 i = 1;
1241 f o r j =1:M
1242 mu e ( i , j ) = mu e ( i +1 , j ) ;
1243 D e(i , j ) = D e ( i +1 , j ) ;
1244 end
1245 i=N;
1246 f o r j =1:M
1247 mu e ( i , j ) = mu e ( i −1 , j ) ;
1248 D e(i , j ) = D e ( i −1 , j ) ;
1249 end
1250
1251 % Ions
1252 f o r i =2:N−1
1253 f o r j =2:M−1
1254 EoverN = (MagE( i , j ) /nn ) ;
1255
1256 i f EoverN < E o v e r N v e c t o r p ( 1 )
1257 EoverN = EoverN vector p (1) ;
1258 mu p ( i , j ) = m u p v e c t o r ( 1 ) ;
1259 T p ( i , j ) = 300 +(1/ k b ) ∗ ( ( m p+m g ) / ( 5 ∗ m p+3∗m g ) ) ∗m g∗ . . .
1260 ( mu p ( i , j ) ∗MagE( i , j ) ) ˆ 2 ;
1261 D p ( i , j ) = ( k b ∗T p ( i , j ) ∗mu p ( i , j ) ) / e ;
1262 e l s e i f EoverN > E o v e r N v e c t o r p ( l e n g t h ( E o v e r N v e c t o r p ) )
1263 EoverN = E o v e r N v e c t o r p ( l e n g t h ( E o v e r N v e c t o r p ) ) ;
1264 mu p ( i , j ) = m u p v e c t o r ( l e n g t h ( m u p v e c t o r ) ) ;
1265 T p ( i , j ) = 300 +(1/ k b ) ∗ ( ( m p+m g ) / ( 5 ∗ m p+3∗m g ) ) ∗m g∗ . . .
1266 ( mu p ( i , j ) ∗MagE( i , j ) ) ˆ 2 ;
1267 D p ( i , j ) = ( k b ∗T p ( i , j ) ∗mu p ( i , j ) ) / e ;
1268 else
1269 d i f f E o v e r N = E o v e r N v e c t o r p −EoverN ;
1270 [ ˜ , i n d e x ] = min ( abs ( E o v e r N v e c t o r p −EoverN ) ) ;
1271 i f d i f f E o v e r N ( i n d e x )<0
1272 mu p ( i , j ) = m u p v e c t o r ( i n d e x ) + ( ( m u p v e c t o r ( i n d e x +1)− . . .

65
1273 m u p v e c t o r ( i n d e x ) ) / ( E o v e r N v e c t o r p ( i n d e x +1)− . . .
1274 E o v e r N v e c t o r p ( i n d e x ) ) ) ∗ ( EoverN−E o v e r N v e c t o r p ( i n d e x ) ) ;
1275 T p( i , j ) = 300 +(1/ k b ) ∗ ( ( m p+m g ) / ( 5 ∗ m p+3∗m g ) ) ∗m g∗ . . .
1276 ( mu p ( i , j ) ∗MagE( i , j ) ) ˆ 2 ;
1277 D p( i , j ) = ( k b ∗T p ( i , j ) ∗mu p ( i , j ) ) / e ;
1278 else
1279 mu p ( i , j ) = m u p v e c t o r ( index −1) + ( ( m u p v e c t o r ( i n d e x )− . . .
1280 m u p v e c t o r ( index −1) ) / ( E o v e r N v e c t o r p ( i n d e x )− . . .
1281 E o v e r N v e c t o r p ( index −1) ) ) ∗ . . .
1282 ( EoverN−E o v e r N v e c t o r p ( index −1) ) ;
1283 T p ( i , j ) = 300 +(1/ k b ) ∗ ( ( m p+m g ) / ( 5 ∗ m p+3∗m g ) ) ∗m g∗ . . .
1284 ( mu p ( i , j ) ∗MagE( i , j ) ) ˆ 2 ;
1285 D p ( i , j ) = ( k b ∗T p ( i , j ) ∗mu p ( i , j ) ) / e ;
1286 end
1287 end
1288 end
1289 end
1290 mu m = mu p ;
1291 D m = D p;
1292 T m = T p;
1293
1294 %%
1295 % d i s p ( [ num2str ( t ) , ’ / ’ , num2str (T−1) ] ) ;
1296
1297 f p r i n t f ( [ ’ Time s t e p : ’ , num2str ( t ) , ’ / ’ , num2str (T−1) , . . .
1298 ’ Potential : I t e r a t i o n s : ’ , num2str ( i t V ) , ’ residual : ’ , . . .
1299 num2str ( n o r m r i t V ) , ’ \n ’ . . .
1300 ’ P o s i t i v e I o n s : I t e r a t i o n s : ’ , num2str ( i t p ) , . . .
1301 ’ r e s i d u a l : ’ , num2str ( n o r m r i t p ) , ’ \n ’ . . .
1302 ’ N e g a t i v e I o n s : I t e r a t i o n s : ’ , num2str ( i t m ) , . . .
1303 ’ r e s i d u a l : ’ , num2str ( n o r m r i t m ) , ’ \n ’ . . .
1304 ’ Electrons : I t e r a t i o n s : ’ , num2str ( i t e ) , . . .
1305 ’ r e s i d u a l : ’ , num2str ( n o r m r i t e ) , ’ \n ’ . . .
1306 ’ max mu e : ’ , num2str (max(max( mu e ) ) ) , ’ min mu e : ’, ...
1307 num2str ( min ( min ( mu e ) ) ) , ’ \n ’ . . .
1308 ’ max D e : ’ , num2str (max(max( D e ) ) ) , ’ min D e : ’, ...
1309 num2str ( min ( min ( D e ) ) ) , ’ \n ’ . . .
1310 ’ max T e : ’ , num2str (max(max( T e ) ) ) , ’ min T e : ’, ...
1311 num2str ( min ( min ( T e ) ) ) , ’ \n ’ . . .
1312 ’ max mu p : ’ , num2str (max(max( mu p ) ) ) , ’ min mu p : ’, ...
1313 num2str ( min ( min ( mu p ) ) ) , ’ \n ’ . . .
1314 ’ max D p : ’ , num2str (max(max( D p ) ) ) , ’ min D p : ’, ...
1315 num2str ( min ( min ( D p ) ) ) , ’ \n ’ . . .
1316 ’ max T p : ’ , num2str (max(max( T p ) ) ) , ’ min T p : ’, ...
1317 num2str ( min ( min ( T p ) ) ) , ’ \n\n ’ ] ) ;
1318
1319 end
1320
1321 %% Save r e s u l t
1322 % s a v e ( ’V. mat ’ , ’ V’ , ’−v7 . 3 ’ ) ;
1323 % s a v e ( ’ ne . mat ’ , ’ n e ’ , ’−v7 . 3 ’) ;
1324 % s a v e ( ’ np . mat ’ , ’ n p ’ , ’−v7 . 3 ’) ;
1325 % s a v e ( ’nm . mat ’ , ’ n m ’ , ’−v7 . 3 ’) ;
1326 % s a v e ( ’ p a r a m e t e r s . mat ’ , ’N’ , ’M’ , ’T’ , ’ dx ’ , ’ dy ’ , ’ dt ’ , ’−v7 . 3 ’ ) ;
1327
1328 %% p l o t r e s u l t
1329 f o r t = 1 : 5 0 :T
1330 figure (1) ; c l f ;
1331 c o n t o u r (V ( : , : , t ) ’ , ’ ShowText ’ , ’ on ’ ) ;
1332 t i t l e ( ’ P o t e n t i a l [V] ’ ) ;
1333 x l a b e l ( ’ s t e p i n x−d i r e c t i o n ’ ) ;
1334 y l a b e l ( ’ s t e p i n y−d i r e c t i o n ’ ) ;
1335
1336 figure (2) ; c l f ;
1337 c o n t o u r ( n e ( : , : , t ) ’ , ’ ShowText ’ , ’ o f f ’ ) ;
1338 t i t l e ( ’ Electron density ’ ) ;
1339 x l a b e l ( ’ s t e p i n x−d i r e c t i o n ’ ) ;
1340 y l a b e l ( ’ s t e p i n y−d i r e c t i o n ’ ) ;
1341
1342 figure (3) ; c l f ;
1343 c o n t o u r ( n p ( : , : , t ) ’ , ’ ShowText ’ , ’ o f f ’ ) ;
1344 t i t l e ( ’ P o s i t i v e Ion Density ’ ) ;
1345 x l a b e l ( ’ s t e p i n x−d i r e c t i o n ’ ) ;
1346 y l a b e l ( ’ s t e p i n y−d i r e c t i o n ’ ) ;
1347
1348 figure (4) ; clf ;

66
1349 c o n t o u r ( n m ( : , : , t ) ’ , ’ ShowText ’ , ’ o f f ’ ) ;
1350 t i t l e ( ’ Negative Ion Density ’ ) ;
1351 x l a b e l ( ’ s t e p i n x−d i r e c t i o n ’ ) ;
1352 y l a b e l ( ’ s t e p i n y−d i r e c t i o n ’ ) ;
1353
1354 drawnow
1355 disp ( t )
1356 end

67

You might also like