Skip to content

Commit

Permalink
Merge branch 'main' into chris/356-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispcampbell authored Nov 13, 2023
2 parents c62234e + d8f79a2 commit 377e47b
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
push:
branches-ignore:
- main
pull_request:

env:
EM_DIR: 'emsdk'
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages/compile": "0.7.9",
"packages/cli": "0.7.13",
"packages/cli": "0.7.14",
"packages/build": "0.3.2",
"packages/check-core": "0.1.1",
"packages/check-ui-shell": "0.2.3",
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SDEverywhere    ![](https://github.com/climateinteractive/SDEverywhere/actions/workflows/build.yaml/badge.svg)

[SDEverywhere](http://sdeverywhere.org/) is a collection of libraries and command line tools that help you transform a [System Dynamics](http://www.systemdynamics.org/what-is-system-dynamics/) model into C, JavaScript, and WebAssembly code.
[SDEverywhere](http://sdeverywhere.org/) is a collection of libraries and command line tools that help you improve the quality and expand the reach of a [System Dynamics](http://www.systemdynamics.org/what-is-system-dynamics/) model.
SDEverywhere allows for unit testing, continuous integration, the ability to compare model runs, and a toolchain to transform a model into C, JavaScript, and WebAssembly code.

Using SDEverywhere, you can deploy interactive System Dynamics models in mobile, desktop, and web apps for policymakers and the public.
Using SDEverywhere, you can deploy interactive System Dynamics models on mobile, desktop, and the web for policymakers and the public.
Or you could perform model analysis using general-purpose languages, running the model as high-performance C code.

By following the ["Quick Start"](#quick-start) instructions below, within minutes you can turn a Vensim model like this:
Expand Down Expand Up @@ -146,7 +147,7 @@ Please fork our code and contribute!
Here are some prominent current limitations:

- Sketch information, the visual representation of the model, is not converted.
- Only the most common [Vensim functions](https://www.vensim.com/documentation/index.html?20770.htm) are implemented.
- Only the most common [Vensim functions](https://github.com/climateinteractive/SDEverywhere/wiki/Supported-Vensim-Functions) are implemented.
- All models run using the Euler integrator.
- Strings are not supported.
- You must rewrite tabbed arrays as separate, non-apply-to-all variables.
Expand Down
41 changes: 41 additions & 0 deletions models/trig/trig.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARCCOS calculation
0 1
1 1
2 1
3 1
ARCSIN calculation
0 1
1 1
2 1
3 1
ARCTAN calculation
0 1
1 1
2 1
3 1
COS calculation
0 0.540302
1 0.540302
2 0.540302
3 0.540302
FINAL TIME
0 3
INITIAL TIME
0 0
SAVEPER
0 1
1 1
2 1
3 1
SIN calculation
0 0.841471
1 0.841471
2 0.841471
3 0.841471
TAN calculation
0 1.55741
1 1.55741
2 1.55741
3 1.55741
TIME STEP
0 1
127 changes: 127 additions & 0 deletions models/trig/trig.mdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{UTF-8}
ARCCOS calculation=
ARCCOS( 0.540302 )
~ dmnl
~ ~ :SUPPLEMENTARY
|

ARCSIN calculation=
ARCSIN( 0.841471 )
~ dmnl
~ ~ :SUPPLEMENTARY
|

ARCTAN calculation=
ARCTAN( 1.55741 )
~ dmnl
~ ~ :SUPPLEMENTARY
|

COS calculation=
COS(1)
~ dmnl
~ Input is in radians from 0 to 2pi.
~ :SUPPLEMENTARY
|

SIN calculation=
SIN( 1 )
~ dmnl
~ Input is in radians from 0 to 2pi.
~ :SUPPLEMENTARY
|

TAN calculation=
TAN( 1 )
~ dmnl
~ Input is in radians from 0 to 2pi.
~ :SUPPLEMENTARY
|

********************************************************
.Control
********************************************************~
Simulation Control Parameters
|

FINAL TIME = 3
~ Month
~ The final time for the simulation.
|

INITIAL TIME = 0
~ Month
~ The initial time for the simulation.
|

SAVEPER =
TIME STEP
~ Month [0,?]
~ The frequency with which output is stored.
|

TIME STEP = 1
~ Month [0,?]
~ The time step for the simulation.
|

\\\---/// Sketch information - do not modify anything except names
V300 Do not put anything below this section - it will be ignored
*View 1
$-1--1--1,0,|12||-1--1--1|-1--1--1|-1--1--1|-1--1--1|-1--1--1|96,96,100,0
10,1,ARCSIN calculation,683,171,56,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
10,2,TAN calculation,283,432,47,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
10,3,SIN calculation,290,182,44,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
10,4,COS calculation,298,316,47,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
10,5,ARCCOS calculation,674,307,59,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
10,6,ARCTAN calculation,685,437,59,22,8,3,0,0,-1,0,0,0,0,0,0,0,0,0
12,7,0,1104,304,250,166,8,15,0,0,1,0,0,0,0,0,0,0,0,0
Table_of_Output
///---\\\
:TABLE Table_of_Output
:TITLE Table of Output
:PRETTYNUM
:VAR ARCCOS calculation
:DATASET *1
:VAR ARCSIN calculation
:DATASET *1
:VAR ARCTAN calculation
:DATASET *1
:VAR COS calculation
:DATASET *1
:VAR SIN calculation
:DATASET *1
:VAR TAN calculation
:DATASET *1
:L<%^E!@
1:current.vdfx
4:Time
5:TAN calculation
9:current
19:100,0
24:0
25:3
26:3
15:0,0,0,0,0,0
27:0,
34:0,
42:0
72:0
73:0
95:0
96:0
97:0
77:0
78:0
102:1
93:0
94:0
92:0
91:0
90:0
87:0
75:
43:
103:8,8,8,3,8
105:0,0,0,0,0,0,0,0,0,0
104:Lucida Grande|12||0-0-0|0-0-0|-1--1--1|0-0-255|192-192-192|-1--1--1
7 changes: 7 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.7.14](https://github.com/climateinteractive/SDEverywhere/compare/cli-v0.7.13...cli-v0.7.14) (2023-10-26)


### Features

* add support for additional trig functions ([#383](https://github.com/climateinteractive/SDEverywhere/issues/383)) ([1dd1e32](https://github.com/climateinteractive/SDEverywhere/commit/1dd1e32ef64f25249876c42403de3cdf45f70dfa)), closes [#382](https://github.com/climateinteractive/SDEverywhere/issues/382)

## [0.7.13](https://github.com/climateinteractive/SDEverywhere/compare/cli-v0.7.12...cli-v0.7.13) (2023-10-18)


Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sdeverywhere/cli",
"version": "0.7.13",
"version": "0.7.14",
"description": "Contains the `sde` command line interface for the SDEverywhere tool suite.",
"type": "module",
"files": [
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/c/vensim.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extern "C" {
// https://www.vensim.com/documentation/22300.html
//
#define _ABS(x) fabs(x)
#define _ARCCOS(x) acos(x)
#define _ARCSIN(x) asin(x)
#define _ARCTAN(x) atan(x)
#define _COS(x) cos(x)
#define _EXP(x) exp(x)
#define _GAME(x) (x)
Expand All @@ -33,6 +36,8 @@ extern "C" {
#define _SIN(x) sin(x)
#define _SQRT(x) sqrt(x)
#define _STEP(height, step_time) (_time + _time_step / 2.0 > (step_time) ? (height) : 0.0)
#define _TAN(x) tan(x)


double* _ALLOCATE_AVAILABLE(double* requested_quantities, double* priority_profiles, double available_resource, size_t num_requesters);
double _PULSE(double start, double width);
Expand Down

0 comments on commit 377e47b

Please sign in to comment.