None Notebook

This notebook contains material from cbe30338-2021; content is available on Github.

< 3.1 Case Study: Thermal Cycling for PCR | Contents | Tag Index | 3.3 Relay Control >

Open in Colab

Download

3.2 Setpoints

Setpoints are functions of time that establish target values for key control variables. This notebook describes typical nomenclature used in describing setpoint functions, and shows how to creatd setpoint functions in Python.

3.2.1 Setpoint profiles

Example descriptions from commercial vendors:

Common descriptions for setpoint functions include so-called step changes, and ramp and soak periods.


Study Question: Classify all of the segments in the sample setpoint profile.

Study Question: What is the ramp rate of the first ramp in the example above.

Study Question: Modify the data in the above example to remove the step. Replace it with a single raamp from the initial condition to the soak period that begins at t=170 at a temperature of 170C.


3.2.2 Creating setpoint functions

For feedback control we would like functions that return the value of a setpoint for any point in time. Functions are in the form $SP_1(t)$ and $SP_2(t)$, for example, are straightfoward to use inside in control applications.

In the section we show how to write a function that accepts points defining a piecewise linear setpoint profile, then produce a function to compute the setpoint for any point in time.

3.2.2.1 Specifying piecewise linear setpoint profiles

Describiing the setpoint as a series of a step/ramp/soak periods naturally leads a piecewise linear function. The start and end of each line segment are spceified by (time, value) pairs. Ordering these points into a list provides a straightforward specification of the setpoint,

Here we show the points for a typical setpoint.

3.2.2.2 A functon to create functions

Python functions are frequently written to accept data, perform calculations, and return values. What may be less familiar is that functions can also return function. This is just what we neeed - a function that accepts a series of (time, value) pairs describing a setpoint profile, then returns a function that can be used to find values of the setpoint at any point in time.

3.2.2.3 Example of a setpoint function

The following example creates a setpoint function that produces setpoints corresponding the profile described in the introduction to this notebook.

We can use the setpoint function to create plots.

3.2.2.4 Creating multiple setpoint functions

The next cell demonstrates the use of create_setpoint_function to create multiple independent setpoint functions.

3.2.3 Case Study: PCR Thermal Cycler Protocols

The goal of this next section is to create a function that returns the value of a setpoint profile for a PCR thermal cycler. We'll break this into a series of steps:

3.2.3.1 Typcial PCR thermal cycler protocols

Here's an example of a PCR thermal cycler protocol:

The details of these protocols vary depending on the nature of the test, the reagents used, and the type of detection that will be employed. In real-time PCR, the number of cycling steps will end once a positive result is obtained.

3.2.3.2 Representing PCR protocols in Python

The PCR protocol is a series of (time, temperature) pairs. The code in the next cell represents a protocol as a sequence of (time, temperature) pairs in a Python list. The list is constructed by concatenating subprotocols denoting the activation, cycling and extension steps in a PCR protocol

3.2.3.3 Converting to ramp, soak specifications

Each step in a PCR protocol consists of an initial ramp to the specified temperature, followed by a soak for the specified time and temperature. We begin the coding by demonstrating how to interpret the protocol specification as a series of ramp and soak periods.

The next step is to introduce a ramp rate and add variables to track the start time and temperature for each segment. We will assume all ramp rates have the same absolute value.

3.2.3.4 Finding the start and finish of each segment

Finally, we create a two column numpy array representing the setpoint profile. The first row in the array is the starting time and temperature. Each subsequent row constains the ending time and temperature of a segment.

3.2.3.5 Finding the setpoint function by interpolating the start and end of each segment

To implement control algorithms we will need to find values of the setpoint function at arbitrary points in time, not just at the start and finish of ramp or soak periods. The standard numpy library includes a linear interpolation function numpy.interp well suited to this purpose.

3.2.3.6 Creating a setpoint function for PCR thermal cycler

The last step is to put all of these steps together to create a function that generates a setpoint function. This is an example of a very powerful coding technique of nested functions.


Study Question: Change the protocol to include 30 thermal cycles, then create the setpoint function with PCR_setpoint() and plot the results.

Study Question: To better reflect the unequal heating and cooling rates available in most PCR devices, modify PCR_setpoint() to provide differing ramp rates for positive going and negative going ramps. Demonstrate the result using a postive ramp_rate of 2.5 degC/sec and a negative ramp_rate of -0.5 degC/sec.


< 3.1 Case Study: Thermal Cycling for PCR | Contents | Tag Index | 3.3 Relay Control >

Open in Colab

Download