Using Vensim to Model Opioid Addiction

By: Grace Shen, Riddhi Bheda, Neethi Belur

The modeling software used for this activity is called Vensim. You can download the software here. Make sure to click the box labeled Vensim PLE. You will be emailed download instructions.

Let's take a moment to understand the context of this model...

What are opioids?

An opioid is a class of drug that are commonly used to treat pain, as they contain chemicals that can relax the body and relieve pain. Examples of prescribed opioids are oxycodone and fentanyl. Other opioids, like heroin, are used illegally.

What is the opioid epidemic?

The opioid epidemic is a current crisis that refers to the widespread misuse of opioid drugs which leads to opioid addiction - a chronic disease that can potentially cause major health, social, and economic problems. According to the National Institute on Drug Abuse, a study in 2018 showed that 128 people per day die in the US from opioid overdose and more than 2 million Americans and about 15 million people worldwide abuse opioids each year.

The tutorial is intended to help you better understand the opioid epidemic through systems thinking which you can read more about here.

We will walk you through the steps of recreating a modified version of the opioid epidemic model created by Professor Wayne Wakeland illustrated in the article Dynamic Model of Nonmedical Opioid Use Trajectories and Potential Policy Interventions.

💭 Recreating a scientific model is an example of scientific peer review! Peer review is extremely important in scientific and technological fields because it assesses the validity, quality, and the originality of articles for publication. It allows for published material to be revisited and revised!

Take a quick look at the article and make sure to pay attention to Figure 1, Figure 2, and Figure 3 which provide an introduction to the structure and logic of the model!

The goal of the modified model is to produce the same starting value of# of people initiating(~1.2 million) accurately to know that we are on track with the full model! The full model, once finished, should match the historical data from 1995-2011 shown in Figure 4A ➡️

Now that you understand the context of this model, let’s practice using Vensim…

Open up Vensim. Your screen should look like this:

This will be important later!

Then click on the File tab in the upper left-hand corner and click New Model. A small window called Model Settings will pop up and you will be given options to set values for FINAL TIME, INITIAL TIME, and TIME STEP, define Units for Time and Integration Type.

Let’s leave everything as default and click Ok for now! These values will be different later for the model! Your screen should return to looking like the one above.

⬆️ This is the top toolbar with all of the modeling tools!

  • The Lock tool locks the sketch.

  • The Move/Size tool can move and edit the sizes of objects in the system.

  • The Variable tool creates variables.

  • The Level tool creates stocks which represent a quantity or accumulation of materials.

  • The Arrow tool creates arrows which show relationships between different parts of a model.

  • The Rate tool creates rates or flows, which cause stocks to change.

  • The Shadow Variable tool adds an existing variable (without the causes) to the sketch view.

  • The IO Object tool adds input sliders and output graphs and tables to the sketch.

  • The Comment tool allows you to add commentary, graphics, and junction nodes to your sketch.

  • The Delete tool is used to delete specific parts of the model.

  • The Equations tool opens up the Equation Editor and allows us to add equations and units to variables.

  • The Reference mode tool is used to draw and edit reference modes.

Now we are ready to start adding to the work space!

Start by clicking on the Level tool, then click on a spot in your workspace. Type “Stock 1” in the text box and hit enter. You just created a stock! Now create another one named “Stock 2”.

Now click on the Rate tool! Create a flow by clicking on a starting point then an ending point. Create three flows and label them “Flow 1”, “Flow 2”, and “Flow 3” like so:

Let’s add some variables! Click on the Variable tool and then click on the workspace. Label this variable “Variable 1”. Create another and label it “Variable 2”!

The variables aren’t connected to the model yet so let’s connect them with arrows. Click on the Arrow tool. Create an arrow by clicking on the start variable and the end variable which can all either be stocks, flows, or other variables! You can also create straight or curved arrows which can later be adjusted with the Move/Size tool by dragging the open circle on the arrows. Create 3 arrows like so:

You can also change the color of an arrow and its thickness! Pick an arrow and change its color by clicking the circle on the arrow and selecting a color at the bottom toolbar. Change the arrows thickness by doing the same and selecting it at the bottom.

Don’t worry, you’re getting close! The next step is to add equations! Click on the Equations tool and notice that all of our stocks, flows, and variables turn black. This means they are highlighted and don’t have a valid equation in them yet! Once you input an equation in, they will turn white. Click on a stock, flow, and variable to see what they look like. Pay attention to the Units, Equations, Initial Value, Functions, and Variables section. We won’t be able to add a valid equation in this practice run but you will add them later!

Once you finish adding equations and units to a model, it is finished! But before you simulate a model, always check the model and units for errors which you can do either by clicking Model in the upper left hand bar or by pressing Crl+T/Crl+U. This model won't be able to simulate but the next one will! 😀

Congrats, you now know the basics of using Vensim! Save your practice model if you want or click File and New Model and let's bein to build the opioid epidemic model...

📄 Here are the materials you will want to keep open to reference while building the model:

  • Full model from the article as well as the equation sheet here!

  • Modified version of the model (the one you'll be building in the walkthrough) here!

  • Equations sheet for modified version here!

  • Full model to recreate in this activity here!

  • Equation sheet for full model to recreate here!

  1. Create a new model and set INITIAL TIME as 1995 and FINAL TIME as 2016. Set TIME STEP as 0.125 and the Units for Time as Year. Click OK.

💡 This model simulates opioid epidemic data gathered between 1995-2016. New data points will be generated every 0.125 years.

2. Create a stock and label it “Susceptible Population”. Then create a flow that goes into "Susceptible Population" and label it "growth in suscept pop". Your model should look like this:

3. Create two new variables above the flow you just made. Label the first “fraction of population receiving prescriptions” and the second “ann chg in # ppl rec. POA”. Connect them like so:

🔎 What is the relationship between all of these factors so far? Why does it make sense? Hint: look at their equations.

4. Continue adding variables until your model looks like this:

💡 Remember to save your work periodically so you don't lose it!

💡 POA: pharmaceutical opioid analgesics

5. Use the Level tool to create a variable “school education regarding risk” and change it into a hexagon. To change the shape of the variable you just made, right click on the variable and under Shape, select Hexagon. Then click OK. Then connect it to “fraction of youth perceiving little risk in opioid use”.

The hexagon represents a policy that is implemented that will impact different factors involved in the opioid epidemic. In this case, the "school education regarding risk" policy affects the amount of youths using opioids!

6. Let's add a shadow variable called "Time". To do so, select the Shadow Variable tool and click on the workspace near the variable “years in a year” A popup should show up. Select the variable “Time” and click OK. Connect “Time” to “us population 12 plus” and “people receiving POA for acute pain” with arrows.

💡 Remember, models are never a perfect reflection of reality. There will always be more to improve on! Keep this in mind while you are making and simulating the model!

7. Create a new variable and call it “suscept init value”. Use the Arrow tool to link it to “Susceptible Population”. Change the arrow color to gray.

8. Create a stock and label it “Free Users Without Use Disorder”. Link the stock “Susceptible Population” with this new one with two rates: label the first one “people initiating on their own” and the second “initiating via friends” like so:

💡 This one is tricky! Click on the Move/Size tool and press the Shift key to highlight something to select. Then you can use the 🔼 /🔽 keys on your keyboard to adjust their distance.

9. Continue adding more variables and arrows to your model. Remember to save as you go! Use the image below for guidance:

10. Connect the stock “Free Users Without Use Disorder” to the variable “number of infectives or free users” with an arrow. Change the color of the arrow to orange and make it thicker. This will help us identify the feedback loop we just created! Click on the Comment tool and click on the workspace above the variable “number of infectives or free users”. Select Loop Clkwse and set the color to orange. Label the comment “free users introduce friends”. Under Graphics, check Image and select the + icon. Click OK. Your model should look like this

🔎 What is a feeedback loop? How do you identify a positive and negative feedback loop?

11. Create a stock and label it “Free Users With Use Disorder”. Add a flow going out of the stock, and label it “FU UD quitting”. To change the direction of the flow, drag the small cloud downwards. To change the color of the text to blue, right click on the name and select the respective color. Continue building your model until it looks like the image below:

12. Time to add equations! Reference the equation sheet for the modified version of the model and input the equations and units for all of the variables, stocks, and flows.

🔎 Pay attention to the units and equations! How are relationships between stocks, variables, and flows affected by the direction of the arrows and flows? How is this shown in the equations? In the units? (The model should start making even more sense now!)

13. Before we start simulating, make sure to check the model and check the units for errors. Press Ctrl+T to Check Model and Ctrl+U to Check Units. If there are errors, go back and fix them. If not, we are ready to continue to simulating!

14. We are finally ready to simulate! Keep in mind that the result we are looking for is a starting value of roughly 1.2 million. Your graph should look like this:

Notice how although our graph does not reflect the one in the article, the starting value is the same! You will need to complete the full model to simulate the data more accurately.

15. Click on the SyntheSim button on the right in the top panel. You should see a bunch of sliders pop up for many of your variables which you can adjust to interactively view how one variable can change your entire model! Once you simulate your model, you now have a data set. Click on the variable "# of people initiating" and then click on the Table and/or Graph buttons to see in detail values of the variable. You can do this with any variable you choose to look into more!

Note: You can stop here but you also have the option of finishing the full model!

16. Now finish the rest of the model on your own to simulate the other values shown in the article! Reference the full model and full model equation sheet. For some variables, you may have to go back and change some equations or add more connections!

When you are finished, you will be able to simulate all of the graphs displayed in the article in Figure 4, Figure 6, and Figure 7! Once you are finished building and smulating the final model, the graphs for these variables should look like this:

💡 Models are never perfect and they can always be improved upon. This is why some of our graphs do not match the ones in the article exactly!
🔎 What are the similarities and differences between your graphs and the model-simulated ones in the articles? Can you find the reason behind why they are different?

🔎 How do these graphs compared to the actual historical data plotted in the article?

Congrats! You've finished this activity!


Dynamic Model of Nonmedical Opioid Use Trajectories and Potential Policy Interventions by Prof. Wakeland-

Opioid Overdose Crisis,

Opioid Misuse and Addiction,

Opioid Overdose, Centers For Disease Control and Prevention-

Fighting the Physics of Human Nature: Acceleration Mental Model Effects on Project Schedule and Cost Performance by Paul Newton-


Claudia Ludwig

Rachel Calder

Paul Newton

Wayne Wakeland

Project by Grace Shen, Neethi Belur, Riddhi Bheda 2020 ISB CMWG

The content of these pages was created by students for students with the help of educators, modelers, and scientists. The views expressed herein are those of the authors and do not necessarily reflect the views of NSF or ISB.