Skip to content

Commit

Permalink
feat: implement QUANTUM function (#89)
Browse files Browse the repository at this point in the history
Fixes #87

Co-authored-by: Chris Campbell <[email protected]>
  • Loading branch information
ToddFincannon and chrispcampbell authored Jul 26, 2021
1 parent e37dc43 commit 42225f9
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
33 changes: 33 additions & 0 deletions models/quantum/quantum.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
a
0 1
1 1
b
0 0
1 0
c
0 0
1 0
d
0 -1
1 -1
e
0 110
1 110
f
0 48
1 48
FINAL TIME
0 1
g
0 378
1 378
h
0 10
1 10
INITIAL TIME
0 0
SAVEPER
0 1
1 1
TIME STEP
0 1
44 changes: 44 additions & 0 deletions models/quantum/quantum.mdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{UTF-8}
a = QUANTUM(1.9, 1.0) ~~~:SUPPLEMENTARY|
b = QUANTUM(0.9, 1.0) ~~~:SUPPLEMENTARY|
c = QUANTUM(-0.9, 1.0) ~~~:SUPPLEMENTARY|
d = QUANTUM(-1.9, 1.0) ~~~:SUPPLEMENTARY|
e = QUANTUM(112.3, 10.0) ~~~:SUPPLEMENTARY|
f = QUANTUM(50, 12) ~~~:SUPPLEMENTARY|
g = QUANTUM(423, 63) ~~~:SUPPLEMENTARY|
h = QUANTUM(10, 10) ~~~:SUPPLEMENTARY|

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

INITIAL TIME = 0 ~~|
FINAL TIME = 1 ~~|
TIME STEP = 1 ~~|
SAVEPER = TIME STEP ~~|

\\\---/// Sketch information - do not modify anything except names
V300 Do not put anything below this section - it will be ignored
*View 1
$0-0-0,0,|0||0-0-0|0-0-0|0-0-0|0-0-0|0-0-0|0,0,100,0
///---\\\
:L<%^E!@
9:quantum
15:0,0,0,0,0,0
19:100,0
27:2,
34:0,
5:FINAL TIME
35:Date
36:YYYY-MM-DD
37:2000
38:1
39:1
40:2
41:0
42:1
24:0
25:0
26:0
66 changes: 66 additions & 0 deletions models/quantum/quantum_vars.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
a: aux
= QUANTUM(1.9,1.0)
refId(_a)
hasInitValue(false)

b: aux
= QUANTUM(0.9,1.0)
refId(_b)
hasInitValue(false)

c: aux
= QUANTUM(-0.9,1.0)
refId(_c)
hasInitValue(false)

d: aux
= QUANTUM(-1.9,1.0)
refId(_d)
hasInitValue(false)

e: aux
= QUANTUM(112.3,10.0)
refId(_e)
hasInitValue(false)

f: aux
= QUANTUM(50,12)
refId(_f)
hasInitValue(false)

FINAL TIME: const
= 1
refId(_final_time)
hasInitValue(false)

g: aux
= QUANTUM(423,63)
refId(_g)
hasInitValue(false)

h: aux
= QUANTUM(10,10)
refId(_h)
hasInitValue(false)

INITIAL TIME: const
= 0
refId(_initial_time)
hasInitValue(false)

SAVEPER: aux
= TIME STEP
refId(_saveper)
hasInitValue(false)
refs(_time_step)

Time: const
=
refId(_time)
hasInitValue(false)

TIME STEP: const
= 1
refId(_time_step)
hasInitValue(false)

2 changes: 2 additions & 0 deletions src/c/vensim.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern "C" {
#define _MAX(a, b) fmax(a, b)
#define _MIN(a, b) fmin(a, b)
#define _MODULO(a, b) fmod(a, b)
#define _QUANTUM(a, b) ((b) <= 0 ? (a) : (b) * trunc((a) / (b)))

#define _SAMPLE_IF_TRUE(current, condition, input) (bool_cond(condition) ? (input) : (current))
#define _SIN(x) sin(x)
#define _SQRT(x) sqrt(x)
Expand Down

0 comments on commit 42225f9

Please sign in to comment.