Active and Passive Lumped Elements
4.2 DEFINITION, INITIALIZATION, AND SIMULATION OF LUMPED ELEMENTS
4.2.4 Initialization of Updating Coefficients
After initializing the lumped element components by determining the indices of nodes identifying their positions in the FDTD problem space grid and by setting other parameters necessary to characterize them, we can construct the FDTD updating coefficients. We calculate and store updating coefficients in three-dimensional arrays before the FDTD time-marching loop begins and use them while updating the fields during the time-marching loop. The initialization of the updating coefficients is done in the subroutine initialize updating coefficients, which is given in Listing 4.5.
37 . / ( 2 * m u r z *mu 0 + d t * s i g m a m z ) ;
In Chapter 1 we obtained the set of equations (1.26)–(1.31) as the general form of the updating equations. One can notice that the form of the updating equations obtained for the lumped elements is the same as the general form. The only difference is that for some types of lumped elements the terms associated with the impressed currents are replaced by some other terms; for instance, for a voltage source the impressed current term is replaced by a voltage source term in the updating equation. Furthermore, as discussed in Section 4.2.2, the impressed current terms in (1.26)–(1.31) are used to establish the voltage–current relations for the lumped elements, and they vanish in updating equations modeling media that does not include any lumped components.
Therefore, in an FDTD simulation before the time-marching iteration starts the updating coefficients can be calculated for the whole problem space using the general updating equation coefficients appearing in (1.26)–(1.31) and excluding the impressed current terms. Then the up-dating coefficients can be recalculated only for the position indices where the lumped components exist. The additional coefficients required for the lumped elements (e.g., voltage sources, current sources, and inductors), can be calculated and stored in separate arrays associated with these com-ponents. Then during the FDTD time-marching iterations, at every time step, the electric field components can be updated using the general updating equations (1.26)–(1.31) excluding the im-pressed current terms, and then the additional terms can be added to the electric field components at the respective position indices where the lumped elements exist. In this section we illustrate the implementation of the previous discussion in the MATLAB program. The vector type operation in MATLAB is being used to efficiently generate these arrays.
In Listing 4.5 the updating coefficients, except for the impressed current terms, defined in the general updating equations (1.26)–(1.31) are constructed using the material component arrays that have been initialized in the subroutine initialize fdtd material grid. The sizes of the coefficient arrays are the same as the sizes of the material component arrays that have been used to construct them. Then the updating coefficients related to the lumped element components are constructed in respective subroutines as shown in Listing 4.5.
4.2.4.1 Initialization of Voltage Source Updating Coefficients The updating coefficients related to the voltage sources are constructed in the subroutine initialize voltage source updating coefficients as implemented in Listing 4.6. The indices of the nodes identifying the positions of the voltage sources, is, js, ks, ie, je, and ke, were determined while initializing the voltage sources as shown in Listing 4.3. For instance, consider the z-directed voltage source defined between the nodes (is, js , ks ) and (ie, je, ke) and the associated electric field components as illustrated in Fig. 4.10.
These indices of the nodes are used to identify the indices of the field components that need the special updates due to the voltage sources. The indices of the field components are determined by taking into account the directions of the voltage sources. Since these field components will be
Simulation of Lumped Elements 99
Figure 4.10 A z-directed voltage source defined between the nodes (i s, js, ks) and (ie, je, ke).
accessed frequently, they can be stored in a parameter, field indices, associated with the voltage sources for an easy access. The field components under consideration are usually accessed using three index values, such as
C e z e ( i s : i e , j s : j e , k s : ke−1)
since the field arrays are three-dimensional. An alternative way of accessing an element of a multidimensional array is to use the nice feature of MATLAB called linear indexing. Using linear indexing the three indices of a three-dimensional array can be mapped to a single index. Therefore, a single index would be sufficient. For the case where a number of elements need to be indexed, a vector can be constructed in which each value holds the index of the respective element in the three-dimensional array. Therefore, as shown in Listing 4.6, a temporary array of indices, fi, is constructed using
f i = c r e a t e l i n e a r i n d e x l i s t ( e p s r z , i s : i e , j s : j e , k s : ke−1);
Here create linear index list is a function that takes three parameters indicating the range of indices of a subsection of a three-dimensional array and converts it to a one-dimensional linear index array. While doing this conversion, it uses the MATLAB function sub2ind, which needs the size of the three-dimensional array. Therefore, the first argument of create linear index list is the three-dimensional array under consideration. The implementation of create linear index list is given in Listing 4.7. After the linear indices array is constructed, instead of accessing a subsection of an array by
C e z e ( i s : i e , j s : j e , k s : ke−1) one can simply implement
C e z e ( f i )
Listing 4.6initialize voltage source updating coefficients.m
Simulation of Lumped Elements 101
Once the field component indices needing special updates are determined as fi in Listing 4.6, the respective components of the general updating coefficients are recalculated based on the voltage source updating equations as given in (4.10).
One can notice that there exists an additional term in (4.10), given by Ce zs(i, j, k) × Vsn+12(i, j, k), for updating Ezn+1(i, j, k). The term Vsn+12(i, j, k) is the value of the voltage source waveform at time instant (n+12)× t, and this value is stored in the parameter voltage sources(i).waveform.
The other term Ce zs is the additional coefficient term for the voltage source. This term is con-structed based on (4.10) as the parameter Cezs and associated with the respective voltage source as voltage sources(i).Cezs. Similarly, if the voltage source updates the electric field compo-nents Ex the parameter voltage sources(i).Cexs can be constructed, whereas if the voltage source updates Ey the parameter voltage sources(i).Ceys can be constructed, based on the direction of the voltage sources as implemented in Listing 4.6. Finally, the parameter voltage -sources(i).field indices is constructed from fi. Then the parameter field indices are used to access the respective field components while updating the electric field components during the time-marching loop.
4.2.4.2 Initialization of Current Source Updating Coefficients The initialization of current source updating coefficients is performed in the subroutine initialize current source updating -coefficients, which is shown in Listing 4.8. The initialization of current source coefficients is the same as the initialization of voltage source coefficients and follows the updating equation given in (4.15).
Listing 4.8initialize current source updating coefficients.m
Simulation of Lumped Elements 103
4.2.4.3 Initialization of Inductor Updating Coefficients The updating coefficients for modeling in-ductors are initialized in the subroutine initialize inductor updating coefficients, which is shown in Listing 4.9, based on the updating equation (4.24). Comparing (4.24) with (1.28) one can ob-serve that the form of the updating equation modeling an inductor is the same as the form of the general updating equation. Therefore, there is no need to recalculate the coefficients that have been initialized as general updating coefficients. However, a coefficient term Ce zj has not been defined in the implementation of the general updating equations. Therefore, the coefficient term Ce zj associated with the inductor is defined as inductors(i).Cezj in Listing 4.9. Furthermore, the Ji zterm is also associated with the inductor, and it is also defined as inductors(i).Jiz and is initialized with zeros.
As discussed in Section 4.1.6, during the FDTD time-marching iteration, at every time step the new value of Ji zn+12(i, j, k) is to be calculated by (4.23) using Ezn(i, j, k) and Ji zn−12(i, j, k) before
sw i t ch
updating Ezn+1(i, j, k) using (4.24). Equation (4.23) can be rewritten as
Jn+
1 2
i z (i, j, k) = Ji zn−12(i, j, k) + tz
LxyEnz(i, j, k)
= Ji zn−12(i, j, k) + Cj e z(i, j, k) × Ezn(i, j, k), where
Cj e z(i, j, k) = tz Lxy.
Therefore, Cj e zis an additional coefficient that can be initialized before the time-marching loop.
Hence, the parameter inductors(i).Cjez is constructed as shown in Listing 4.9.
4.2.4.4 Initialization of Resistor Updating Coefficients The initialization of updating coefficients related to resistors is performed in the subroutine initialize resistor updating coefficients, which is shown in Listing 4.10. The initialization of resistor coefficients is straightforward; the indices of field components associated with a resistor are determined in the temporary parameter fi, and the elements of the general coefficient arrays are accessed through fi and are recalculated based on the resistor updating equation (4.16).
4.2.4.5 Initialization of Capacitor Updating Coefficients The initialization of updating coefficients related to capacitors is performed in the subroutine initialize capacitor updating coefficients, which is shown in Listing 4.11. The initialization of capacitor coefficients is similar to the initial-ization of resistor coefficients and is based on the updating equation (4.20).
4.2.4.6 Initialization of Diode Updating Coefficients The algorithm for modeling diodes is signifi-cantly different compared with other lumped element components, and it requires the initializa-tion of a different set of parameters. The updating coefficients for modeling diodes are initial-ized in initialize diode updating coefficients, and implementation of this subroutine is shown in Listing 4.12.
As mentioned in Section 4.2.3, only one electric field component is associated with a diode;
therefore, it needs a special updating based on the equations in Section 4.1.8. For example, for a diode oriented in the positive z direction and defined between the nodes (is, js , ks ) and (ie, je, ke), only the field component Ez(is, js , ks ) is updated as illustrated in Fig. 4.9.
As discussed in Section 4.1.8, the new value of the electric field component associated with a diode is obtained by the solution of the equation
AeBx+ x + C = 0, (4.42)
where
x= Ezn+1(i, j, k), A = −Ce zd(i, j, k)eB×Ezn(i, j,k), B = (qz/2kT),
C = Ce ze(i, j, k) × Enz(i, j, k) + Ce zhy(i, j, k) ×
Hyn+12(i, j, k) − Hyn+12(i− 1, j, k) + Ce zhx(i, j, k) ×
Hxn+12(i, j, k) − Hxn+12(i, j − 1, k)
+ Ce zd(i, j, k).
Simulation of Lumped Elements 105
Listing 4.11initialize capacitor updating coefficients.m
Simulation of Lumped Elements 107
Here the Ezn+1(i, j, k) is the electric field component that is sought. The term B is a constant that can be constructed before the time-marching loop starts and stored as parameter diodes(i).B.
However, the parameters A and C are expressions that have to be recalculated at every time step of the time-marching iteration using the previous values of electric and magnetic field components.
sw i t ch
Comparing the first three terms on the right-hand side of the equation expressing C in (4.34) with the updating equation for general media (1.28), one can see that their forms are the same and that the coefficients Ce ze, Ce zhy, and Ce zhxare different only by a minus sign. These coefficients were initialized as Ceze, Cezhy, and Cezhx in the subroutine initialize updating coefficients, and there is no need to redefine them. We only need to keep in mind that the components of these parameters with the indices (is, js , ks )—Ceze(is,js,ks), Cezhy(is,js,ks), and Cezhz(is,js,ks)—
are the negatives of the coefficients that are used to recalculate C while updating Enz+1(is, js , ks ) as associated with a diode.
However, the fourth term in the expression of C includes a coefficient, Ce zd(i, j, k), which has not been defined before. Therefore, a parameter, diodes(i).Cezd, is defined to store the value of Ce zd(is, js , ks ) in Listing 4.12.
An additional parameter that is defined and initialized with zero in Listing 4.12 is diodes(i).Ezn.
This parameter stores Enz(is, js , ks ), which is the value of electric field component at the previ-ous time step. This parameter is used to recalculate the coefficient C at every time step, and it should be available when recalculating C. Therefore, at every time step the value of Ezn(is, js , ks ) is stored in the parameter diodes(i).Ezn to have it available at the next time step for the calculation of C.