diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c7db2e29..d5b0b77e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,6 +14,7 @@ on: push: branches-ignore: - main + pull_request: env: EM_DIR: 'emsdk' diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 129b93ba..d7475985 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -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", diff --git a/README.md b/README.md index e2bc4dc0..fe55c4fe 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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. diff --git a/models/trig/trig.dat b/models/trig/trig.dat new file mode 100644 index 00000000..2bf025e3 --- /dev/null +++ b/models/trig/trig.dat @@ -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 diff --git a/models/trig/trig.mdl b/models/trig/trig.mdl new file mode 100644 index 00000000..6a7c27df --- /dev/null +++ b/models/trig/trig.mdl @@ -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 diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index c001eb98..a0e8d93d 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -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) diff --git a/packages/cli/package.json b/packages/cli/package.json index b72d4a2b..cecd606d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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": [ diff --git a/packages/cli/src/c/vensim.h b/packages/cli/src/c/vensim.h index 1d1b0061..51e4e268 100644 --- a/packages/cli/src/c/vensim.h +++ b/packages/cli/src/c/vensim.h @@ -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) @@ -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);