From 9d557e03c627fd40292f88e7502cca3f9f37da11 Mon Sep 17 00:00:00 2001 From: Todd Fincannon <66087780+ToddFincannonEI@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:29:51 -0700 Subject: [PATCH] feat: implement GAMMA LN (#344) (#376) Fixes #344 --- models/gamma_ln/gamma_ln.dat | 18 +++++++++++ models/gamma_ln/gamma_ln.mdl | 60 ++++++++++++++++++++++++++++++++++++ packages/cli/src/c/vensim.h | 3 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 models/gamma_ln/gamma_ln.dat create mode 100644 models/gamma_ln/gamma_ln.mdl diff --git a/models/gamma_ln/gamma_ln.dat b/models/gamma_ln/gamma_ln.dat new file mode 100644 index 00000000..f4a5deba --- /dev/null +++ b/models/gamma_ln/gamma_ln.dat @@ -0,0 +1,18 @@ +a +0 12.8018 +1 12.8018 +b +0 0.572365 +1 0.572365 +c +0 -3.41362e-11 +1 -3.41362e-11 +FINAL TIME +0 1 +INITIAL TIME +0 0 +SAVEPER +0 1 +1 1 +TIME STEP +0 1 diff --git a/models/gamma_ln/gamma_ln.mdl b/models/gamma_ln/gamma_ln.mdl new file mode 100644 index 00000000..915c68d5 --- /dev/null +++ b/models/gamma_ln/gamma_ln.mdl @@ -0,0 +1,60 @@ +{UTF-8} +a = GAMMA LN(10) ~~| +b = GAMMA LN(0.5) ~~| +c = GAMMA LN(1) ~~| + +******************************************************** + .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 +$-1--1--1,0,|12||-1--1--1|-1--1--1|-1--1--1|-1--1--1|-1--1--1|96,96,100,0 +///---\\\ +:L<%^E!@ +1:gamma_ln.vdfx +4:Time +5:FINAL TIME +9:gamma_ln +19:100,0 +24:0 +25:1 +26:1 +15:0,0,0,0,0,0 +27:2, +34:0, +42:1 +72:0 +73:0 +35:Date +36:YYYY-MM-DD +37:2000 +38:1 +39:1 +40:2 +41:0 +95:0 +96:0 +97:0 +77:0 +78:0 +102:0 +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:Courier|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 ca38e743..1d1b0061 100644 --- a/packages/cli/src/c/vensim.h +++ b/packages/cli/src/c/vensim.h @@ -13,12 +13,13 @@ extern "C" { // // Vensim functions // See the Vensim Reference Manual for descriptions of the functions. -// http://www.vensim.com/documentation/index.html?22300.htm +// https://www.vensim.com/documentation/22300.html // #define _ABS(x) fabs(x) #define _COS(x) cos(x) #define _EXP(x) exp(x) #define _GAME(x) (x) +#define _GAMMA_LN(x) lgamma(x) #define _IF_THEN_ELSE(c, t, f) (bool_cond(c) ? (t) : (f)) #define _INTEG(value, rate) ((value) + (rate) * _time_step) #define _INTEGER(x) trunc(x)