Skip to content

Sample Models

Todd Fincannon edited this page Sep 5, 2025 · 5 revisions

The SDEverywhere repository has a models directory that contains many sample Vensim models. These models can be used to exercise the SDEverywhere transpiler and to verify that it produces results that are functionally equivalent to what Vensim produces.

Refer to the Supported Vensim Functions page for the full list of Vensim functions that are currently supported in SDEverywhere.

Running the tests

There is a test runner script in tests/modeltests. For each model in the models directory, it:

  • uses sde to generate a C version of the model
  • compiles the C model to a native executable
  • runs the native executable
  • compares the model outputs to the dat file produced by Vensim

To run the entire integration test suite:

cd SDEverywhere
pnpm test:c-int

To test a single model:

cd SDEverywhere
pnpm test:c-int {modelname}

located in the models directory in a folder with the base name of the .mdl file. The C code will be written with the same base name in the build directory.

List of sample models

The following models are included as samples and test cases for various Vensim features.

Model Description
active_initial ACTIVE INITIAL function
allocate ALLOCATE AVAILABLE function
allocate_ptype priority curve types for allocation functions
arrays_cname 1-D and 2-D arrays with a variety of subscript references using C language var names
arrays_varname 1-D and 2-D arrays with a variety of subscript references using Vensim var names
comments Range, units, and documentation removal
delay DELAY and DELAY3 functions
delayfixed DELAY FIXED function
delayfixed2 DELAY FIXED function
directconst GET DIRECT CONSTANTS function
directdata GET DIRECT DATA function
directlookups GET DIRECT LOOKUPS function
directsubs GET DIRECT SUBSCRIPT function
elmcount ELMCOUNT function
except Exception equations
except2 Exception equations
extdata Loading external data from DAT files
getdata GET DATA BETWEEN TIMES function
index Apply-to-all and non-apply-to-all arrays
initial INITIAL function
interleaved Demonstrating a case where non-apply-to-all array elements are separated in eval order
lookup Lookup variables and functions
mapping Mapping subranges
multimap Mapping a subscript range to multiple ranges
npv NPV function
preprocess SDEverywhere preprocessor phase
prune Removing variables that are not referenced by input or output variables
pulsetrain PULSE TRAIN function
quantum QUANTUM function
ref An eval order that require an apply-to-all array to become non-apply-to-all
sample SAMPLE function
sir SIR infection model
smooth SMOOTH function
smooth3 SMOOTH3 function
specialchars Variables with special characters allowed by Vensim
subalias Subscript range aliasing with <->
subscript Subscript references in various orders
sum SUM expressions
sumif Handling nested subscripts within array function calls
trend TREND function
vector Vector functions

Directory structure

Each model directory contains some or all of the following files:

Filename Description
{model}.mdl Vensim model
{model}.dat Data file exported in DAT text format
{model}.txt SDEverywhere log file in DAT format with values for all time steps
{model}_spec.json Model specification including input and output variables of interest
{model}_vars.txt SDEverywhere variable analysis
{model}_check.sh Optional script that runs additional checks on the generated C code

Clone this wiki locally