From d04fb0516b22325425cb9d0582d09a99f7e66615 Mon Sep 17 00:00:00 2001 From: Travis Franck <11573160+travisfranck@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:36:39 -0400 Subject: [PATCH 1/3] Added four trig functions and model to test six common trig functions. --- models/trig-functions/trig-functions.dat | 41 ++++++++ models/trig-functions/trig-functions.mdl | 127 +++++++++++++++++++++++ packages/cli/src/c/vensim.h | 5 + 3 files changed, 173 insertions(+) create mode 100644 models/trig-functions/trig-functions.dat create mode 100644 models/trig-functions/trig-functions.mdl diff --git a/models/trig-functions/trig-functions.dat b/models/trig-functions/trig-functions.dat new file mode 100644 index 00000000..2bf025e3 --- /dev/null +++ b/models/trig-functions/trig-functions.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-functions/trig-functions.mdl b/models/trig-functions/trig-functions.mdl new file mode 100644 index 00000000..6a7c27df --- /dev/null +++ b/models/trig-functions/trig-functions.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/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); From 9e0983bd1080cd5e57089d5f777af555c5c7f1fd Mon Sep 17 00:00:00 2001 From: Travis Franck <11573160+travisfranck@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:32:05 -0400 Subject: [PATCH 2/3] Dash to underscore in filenames --- .../trig-functions.dat => trig_functions/trig_functions.dat} | 0 .../trig-functions.mdl => trig_functions/trig_functions.mdl} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename models/{trig-functions/trig-functions.dat => trig_functions/trig_functions.dat} (100%) rename models/{trig-functions/trig-functions.mdl => trig_functions/trig_functions.mdl} (100%) diff --git a/models/trig-functions/trig-functions.dat b/models/trig_functions/trig_functions.dat similarity index 100% rename from models/trig-functions/trig-functions.dat rename to models/trig_functions/trig_functions.dat diff --git a/models/trig-functions/trig-functions.mdl b/models/trig_functions/trig_functions.mdl similarity index 100% rename from models/trig-functions/trig-functions.mdl rename to models/trig_functions/trig_functions.mdl From 8233ef202d2e5299c16552889835e76a71f88f38 Mon Sep 17 00:00:00 2001 From: Travis Franck <11573160+travisfranck@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:37:54 -0400 Subject: [PATCH 3/3] =?UTF-8?q?Removed=20=E2=80=9Cfunctions=E2=80=9D=20fro?= =?UTF-8?q?m=20filenames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/{trig_functions/trig_functions.dat => trig/trig.dat} | 0 models/{trig_functions/trig_functions.mdl => trig/trig.mdl} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename models/{trig_functions/trig_functions.dat => trig/trig.dat} (100%) rename models/{trig_functions/trig_functions.mdl => trig/trig.mdl} (100%) diff --git a/models/trig_functions/trig_functions.dat b/models/trig/trig.dat similarity index 100% rename from models/trig_functions/trig_functions.dat rename to models/trig/trig.dat diff --git a/models/trig_functions/trig_functions.mdl b/models/trig/trig.mdl similarity index 100% rename from models/trig_functions/trig_functions.mdl rename to models/trig/trig.mdl