# Difference between revisions of "Gradient"

1. First, we will need two stocks, let’s call them `stock_1` and `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_2` to the right of `stock_1`, but be sure to leave space for a flow in between them.
2. Now we will need a flow connecting the two stocks. For the sake of this model, we will just name it `flow` and 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.
4. 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_1` > `stock_2`) it will diffuse in the forward direction, and if the difference is negative (`stock_2` > `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.
5. 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.