Tutorials‎ > ‎

Lesson 4: Optimization with Variables

Lesson 4: Optimization with variables

Motivation

Shifting the design work as much as possible to the computer increases the productivity of the designer. A secondary effect is that by making it relatively easy to try new things, the motivated designer can experiment with different ideas, trying to find a better circuit. In this lesson, we will experiment with modifying the quarter-wave transformer and attempt to improve on the bandwidth of the initial design. Finally, we will use the computer to optimize the design.

It is often convenient to use variables, rather than hard numbers, when performing simulations. For example, many transmission lines might have the same impedance, or it might be advantageous to maintain certain physical relationships. This this section, we will variables for the impedance and for the electrical lengths of some of the transmission lines. In particular, we want to keep the sum of the two transmission lines to stay constant (keeping the circuit length fixed), but allow the proportions to vary.

Optimization with Variables


Section 1: First Attempt at Improving the Quarter-Wave Transformer

In the previous lesson, we simulated a quarter-wave transformer. The quarter-wave transformer minimized the return loss at particular frequencies; in particular, the circuit had good performance over a 40% bandwidth (defined as better than 20dB return loss). We would like to improve this bandwidth.

Consider the equation for return loss:  

Equation 4.1

We can make the return loss smaller if the transition is smaller. The circuit in Figure 4.1 breaks the 90º line length of the transmission line “T1” into two 45º transmission lines, “T2” and “T3”. Therefore, the total length is the same, but rather than one 70.7Ώ line we will gradually increase the impedance. Therefore, we will go from the 50Ώ source impedance to a 65Ώ transmission line, to an 85Ώ transmission line, to a 100Ώ transmission line.


In order to make the circuit in Figure 4.1, you will need the variables and calculation blocks which can be found the the “mason” library, along with the port, flag, and frequency blocks from before.

Figure 4.1: First circuit to try to improve quarter-wave transformer performance

Simulating this circuit, we find that the performance of the two transmission line circuit does have a wider bandwidth... but that bandwidth is not centered at our design frequency. In particular, the circuit has an 80% bandwidth but that is centered at 2GHz, twice our design frequency. We note that the individual transmission lines of “T2” and “T3” are each half the electrical length, which means that they are effective at twice the frequency of “T1”.

An important (and useful) tip: if you replace the “Ref” of the optimization block with “_NoOpt1” or the statistical block with “_NoStat1” (or even a variable block with “_NoVar1”, if you're getting tricksy), you turn off that block. Useful for toggling between optimization runs and single runs.

Figure 4.2: Simulation of a two transmission line circuit

Main Point

Adding more matching elements does improve the bandwidth of the matching performance, however it appears that we might have to increase the physical size of the circuit to cover the band of interest.

Questions:

4.1.1 Can you improve the values by hand?

4.1.2 If the line is 90° at 1GHz, how many degrees is the line at 3GHz? What relationship can we see? Why do we see the second null for the S22 at 3GHz? Where would we predict the third null?


Section 2: Second Attempt at Improving the Quarter-Wave Transformer

We will attempt to frequency shift the circuit in Figure 4.3 by adjusting the line lengths. We are now using multiple quarter-wave elements, rather than playing with two quarter wave elements. We will also adjust the simulation frequency.


Circuit check list:

  • Start from the circuit in the previous section

  • Change the frequency limits to “500 MHz” to “2 GHz”

Figure 4.3: Second attempt at widening the bandwidth
Figure 4.4: Wider bandwidth using multiple quarter-wave elements

Main Point

The bandwidth is improved (by defining bandwidth as better than -20dB return loss), but the circuit is now twice as long and the nulls are no longer as deep. These are typical design trades that have to be made in engineering.

Questions:

4.2.1: Can you improve the values by hand?

4.2.2: What does the simulation look like if you run from 500MHz to 4GHz? Why might this be the case?


Section 3: Using the optimizer

We have made improvements in the overall performance by guessing some values. While engineering by intuition is a great starting place, one does not want to be guilty of engineering by guessing. We could experiment by trying a large number of guesses, perhaps even trying to estimate a gradient and create an optimal solution... but this is the soft of tedious exercise that computers excel at.

In Figure 4.8, we have added the optimizer block, and we have modified the variables (Figure 4.9). The optimizer will attempt to minimize the “error”, in this case minimize how much the calculation is outside of the minimum and maximum values, defined here as “-200” to “-20”.

The optimization block has two optimizers defined: random using 100 iterations, and simplex using 2 iterations. The random optimizer takes guesses at what the best answer might be, just much faster than a person could. A simplex is a non-linear gradient optimization whose details are beyond the scope of this lab... but one can think of it as a gradient search which always finds at least the local best solution. Combining a random search with a simplex search is fairly efficient, in that the random search reduces the odds that the optimizer will get caught in a local minimum.


Advanced concept:

The optimizer will generally work over the entire frequency of the run, so one may wish to change the simulation frequencies depending on whether an optimization run is desired, or a simulation run for plot. This will be explored by example later. Technically, one can limit the frequency of the optimization independent of the limits of the simulation by using the fact that “frequency” is an implicit variable. Specifically, the following optimization uses conditionals to set the calculation to “-20” if “frequency” is outside of the range of 500MHz to 1.5GHz; “-20” is within the acceptable range and so will not be counted against the circuit.  

Figure 4.5: Optimization parameters

Running an optimization requires multiple steps. After the circuit is designed in the schematic editor,the simulation is run and the results are plotted. Next, the optimization has to be set up (we'll show how to in this section). The optimizer is run using the same button as before, the 'M' button. After the optimizers finish running, the new circuit values are saved to a new file, but the old file with the old values is still open in TinyCAD. If the plotted results look good, update the values by pressing the 'U' button. This will load the new file (but will not erase the old file). If for whatever reason the new values have a problem, one can still load the old file at this point. However, the 'S' button will save the new file (with the new values) over the old file name- the old file will be gone.

Figure 4.6: The Mason Toolbar in TinyCAD
   

The Mason Toolbar in TinyCAD performs five functions.

        M: Runs Mason

        C: Opens the console

        P: Runs the Plotting program

        U: Updates the values in TinyCAD, opens the new file created by the optimizer

        S: Save the new values over the old values (overwrites the old values with the new)

Figure 4.7: Process for running the optimizer

Advanced concept:

The optimizer stores the new values in a file which uses the original file name and appends the extension “.msn.xml.opt.dsn”. The various extensions track the different file formats which need to be generated in order to convert from the TinyCAD file format to Mason's file format.


Circuit check list:

  • Start from the circuit in the previous section

  • Change the frequency limits to “500 MHz” to “1.5 GHz”

  • Add the “optimizer” block from the “mason” library

  • Modify the “optimizer” block to the values as shown in Figure 4.8

  • Change the variables as shown in Figure 4.9

  • Run Mason ('M' button)

  • After the simulation is done, update the values ('U') and save them ('S')

Figure 4.8: Circuit using the optimizer to improve the match over frequency

The optimizer is allowed to change the length of the individual transmission lines T2 and T3, but the overall length is fixed at 180°. The impedances are allowed to vary (Figure 4.9), Z1 is allowed to be between 50Ώ and 70.7Ώ, and Z2 is allowed to vary between 70.7Ώ and 100Ώ. Even when using the optimizer, we are still guessing somewhat on how we should set the limits.

Figure 4.9: Variable Tool Box (seen by clicking on the variable block)

Note that the optimization values for the variables does not show up on the schematic. This allows the schematic to look a bit neater, at the expense of not showing all of the details in one view. Even simulation tools have to make engineering trades.

Figure 4.10: Results after running the optimizer

Finally, we would like to turn off the optimizer (without deleting all the stuff we typed into it), and run the simulation at a wider band. If we run the simulation at a wider bandwidth with the optimizer turned on, we will be asking too much of the optimizer and will not get good results.

Circuit check list:

  • Start from the circuit in the previous section

  • Change the frequency limits to “500 MHz” to “2 GHz”

  • Change the name of the optimizer block from “_Opt1” to “_NoOpt1” (this turns off the optimizers)

  • Run Mason ('M' button)

Figure 4.11: Modified optimization block
Figure 4.12: Wider band plot of optimized circuit

Questions:

3.1: The ranges for Z1 and Z2 were somewhat arbitrarily chosen. Why might these be good values to start? Can we find a better circuit if you change these values?

3.2: How does the optimizer perform if the initial values of Z1 and Z2 are 1 and 1000, respectively, and the range is from 1 to 1000 for each?

Figure 4.13: Variable values for question 2

3.3: What happens if you optimize over a larger bandwidth, such as from “500 MHz” to “2 GHz”? Why might explain the results?

Main Point

The use of optimizers dramatically simplifies the design process for the engineer. The computer is able to solve for hundreds or even thousands of different cases in a few seconds. The optimizer has several limits that require careful consideration- the optimizer does not replace a solid understanding of design principles:

  1. The designer still needs to create a circuit which works reasonably well- the design should be good if not optimal

  2. The design limits on the variables need to be restricted to reasonable values- if the solution space is too large, then the optimizer will have trouble finding the best solution

  3. The optimization goals need to be kept to reasonable values- if the problem is too hard (e.g., if the bandwidth over which a good match is expected is too large) then the optimizers will find the closest approximation to a good solution, but probably isn't a good solution