This blog post illustrates a simple way to visualize how the shape of a function changes as we tune a parameter in the function. We use the IJulia Notebook with the Gadfly and Interact packages.

As an example, the Langmuir equation is a ubiquitous model in chemical engineering to describe the adsorption of molecules on a surface as a function of concentration in the bulk phase. The Langmuir equation is:

The variables in this function are:

- : the number of molecules adsorbed on the surface
- : pressure of gas phase in contact with the surface

The parameters in the funtion are:

- : the total number of adsorption sites on the surface
- : Langmuir constant describing affinity of the molecule for the surface

We are interested in how the parameters and affect the shape of the Langmuir equation . Using Gadfly, we start by plotting for a given value of and .

To get an idea of how and affect , we could manually change and in the above code and plot several times. With the Julia package Interact, there is a much nicer way. The Interact package creates a slider bar with the parameters and so that we can interact with the Gadfly plot and see how changes somewhat continuously.

The `@manipulate`

macro in the Interact package creates the interactive plot with sliders to change the parameters. We can choose the parameter space of and to explore in the interactive plot. The code below explores and in increments of 0.1.

A screenshot of the result is below.

In the IJulia Notebook, we can play with the sliders to gain insight into how the parameters and affect the shape of the Langmuir equation. The IJulia notebook with this example is here.

At a high enough pressure, as the adsorption sites become filled with molecules. Intuitively, determines the value of at large pressures.

The Langmuir constant determines the initial slope of the adsorption curve at low pressures for a given . In other words, it determines the pressure at which the adsorption curve starts to saturate. If we note that , is inversely related to the pressure at which the adsorption sites are half-filled with molecules. Molecules with a high affinity with the surface will fill the adsorption sites at a relatively low pressure ; their adsorption curve will exhibit a high slope at low pressures. Therefore, a high affinity of the adsorbing molecule for the surface implies a high in the Langmuir model.

comments powered by Disqus