In this tutorial we will consider a system in which some currency is transferred from one stock to another in a manner that is dependent on some diffusion constant K multiplied by the difference in concentration between the two stocks. Thus, this is ultimately a model of diffusion, and this formulation can be applied to many kinds of natural phenomena.
- First, we will need two stocks, let’s call them
stock_2. You can imagine any kind of currency within these stocks: ions, water, nutrients, etc. Let’s set the initial conditions as
stock_1= 10 and
stock_2= 50. Place
stock_2to the right of
stock_1, but be sure to leave space for a flow in between them.
- Now we will need a flow connecting the two stocks. For the sake of this model, we will just name it
flowand you can imagine this flow as any number of paths or processes: the vasculature of a plant, an ion channel on a cell, and so on. Since this is the thing carrying our currency from one stock to another, it is quite analogous to vasculature or other mechanisms of nutrient transfer in living things. In this case, this flow should be a biflow, because the currency can diffuse in either direction depending on the gradient. Connect the clouds of this biflow to each stock.
- Next, we’ll need a diffusion constant. Click on the term button and click above our flow. Let’s name the constant K and we’ll say it has a value of 0.3.
- Now we need to configure the equation within our flow. Use red arrows to connect both stocks and K to the flow. Now, right click on the flow, and using the list displayed on the left of the window, set the equation =
K*(stock 1-stock2). Since this is a biflow, if the difference is positive (if
stock_2) it will diffuse in the forward direction, and if the difference is negative (
stock_1), it will diffuse in the backward direction. Click OK. Your model should now be ready to run, and should look something like the image on the right.
- Now lets make a graph to visually represent changes in stocks 1 and 2. Click on graph and click on the blank space next to your model. Let’s name the graph
diffusion. Right click on the graph, and select stocks 1 and 2 to be graphed in time series. For this model, let’s set both stocks on the same scale. To do this, select a stock, select “self” from the dropdown menu by scale, and set the scale of the y-axis from 0 to 60, then click set. Do this for both stocks, and then click “ok.” Plotting these on the same scale makes it much easier to observe diffusion in action.
- We are ready to run the model. Click on the lambda icon, then capture, load, and run, and graphical output should be visible on your graph. Notice how the two stocks meet in the middle at 30? Your stocks have reached equilibrium, and your graph should look something like this: