Skip to content

Commit

Permalink
feat: add support for additional trig functions (#383)
Browse files Browse the repository at this point in the history
Fixes #382
  • Loading branch information
travisfranck authored Oct 26, 2023
1 parent 4f2ec63 commit 1dd1e32
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 0 deletions.
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
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 1dd1e32

Please sign in to comment.