diff-grok 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +45 -0
- package/.github/scripts/bump-js-api-version.sh +106 -0
- package/.github/scripts/check-output.sh +20 -0
- package/.github/scripts/iac-cfn-deploy.sh +90 -0
- package/.github/scripts/slack_api_request.sh +65 -0
- package/.github/scripts/test_package.sh +270 -0
- package/.github/workflows/libraries.yaml +305 -0
- package/LICENSE +21 -0
- package/README.MD +396 -0
- package/eslintrc.json +45 -0
- package/images/acid-prod.gif +0 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/index.ts +15 -0
- package/package.json +45 -0
- package/src/examples/basic-use.js +40 -0
- package/src/examples/basic-use.js.map +1 -0
- package/src/examples/basic-use.ts +44 -0
- package/src/examples/check-methods.js +45 -0
- package/src/examples/check-methods.js.map +1 -0
- package/src/examples/check-methods.ts +62 -0
- package/src/examples/corr-probs.js +130 -0
- package/src/examples/corr-probs.js.map +1 -0
- package/src/examples/corr-probs.ts +151 -0
- package/src/examples/cyclic-model.js +100 -0
- package/src/examples/cyclic-model.js.map +1 -0
- package/src/examples/cyclic-model.ts +110 -0
- package/src/examples/e5.js +30 -0
- package/src/examples/e5.js.map +1 -0
- package/src/examples/e5.ts +29 -0
- package/src/examples/hires.js +29 -0
- package/src/examples/hires.js.map +1 -0
- package/src/examples/hires.ts +29 -0
- package/src/examples/index.js +17 -0
- package/src/examples/index.js.map +1 -0
- package/src/examples/index.ts +18 -0
- package/src/examples/model-updates.js +112 -0
- package/src/examples/model-updates.js.map +1 -0
- package/src/examples/model-updates.ts +122 -0
- package/src/examples/orego.js +19 -0
- package/src/examples/orego.js.map +1 -0
- package/src/examples/orego.ts +19 -0
- package/src/examples/pipeline-use.js +87 -0
- package/src/examples/pipeline-use.js.map +1 -0
- package/src/examples/pipeline-use.ts +98 -0
- package/src/examples/pollution.js +110 -0
- package/src/examples/pollution.js.map +1 -0
- package/src/examples/pollution.ts +110 -0
- package/src/examples/robertson.js +14 -0
- package/src/examples/robertson.js.map +1 -0
- package/src/examples/robertson.ts +13 -0
- package/src/examples/scripting.js +31 -0
- package/src/examples/scripting.js.map +1 -0
- package/src/examples/scripting.ts +36 -0
- package/src/examples/vdpol.js +13 -0
- package/src/examples/vdpol.js.map +1 -0
- package/src/examples/vdpol.ts +12 -0
- package/src/pipeline/basic-pipeline-creator.js +21 -0
- package/src/pipeline/basic-pipeline-creator.js.map +1 -0
- package/src/pipeline/basic-pipeline-creator.ts +24 -0
- package/src/pipeline/constants.js +21 -0
- package/src/pipeline/constants.js.map +1 -0
- package/src/pipeline/constants.ts +21 -0
- package/src/pipeline/index.js +8 -0
- package/src/pipeline/index.js.map +1 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/input.js +45 -0
- package/src/pipeline/input.js.map +1 -0
- package/src/pipeline/input.ts +55 -0
- package/src/pipeline/loops-pipeline-creator.js +107 -0
- package/src/pipeline/loops-pipeline-creator.js.map +1 -0
- package/src/pipeline/loops-pipeline-creator.ts +138 -0
- package/src/pipeline/output.js +146 -0
- package/src/pipeline/output.js.map +1 -0
- package/src/pipeline/output.ts +196 -0
- package/src/pipeline/pipeline-creator.js +10 -0
- package/src/pipeline/pipeline-creator.js.map +1 -0
- package/src/pipeline/pipeline-creator.ts +16 -0
- package/src/pipeline/pipeline.js +71 -0
- package/src/pipeline/pipeline.js.map +1 -0
- package/src/pipeline/pipeline.ts +104 -0
- package/src/pipeline/updates-pipeline-creator.js +98 -0
- package/src/pipeline/updates-pipeline-creator.js.map +1 -0
- package/src/pipeline/updates-pipeline-creator.ts +125 -0
- package/src/scripting-tools/constants.js +53 -0
- package/src/scripting-tools/constants.js.map +1 -0
- package/src/scripting-tools/constants.ts +51 -0
- package/src/scripting-tools/index.js +4 -0
- package/src/scripting-tools/index.js.map +1 -0
- package/src/scripting-tools/index.ts +7 -0
- package/src/scripting-tools/model-error.js +17 -0
- package/src/scripting-tools/model-error.js.map +1 -0
- package/src/scripting-tools/model-error.ts +19 -0
- package/src/scripting-tools/scripting-tools.js +1032 -0
- package/src/scripting-tools/scripting-tools.js.map +1 -0
- package/src/scripting-tools/scripting-tools.ts +1375 -0
- package/src/solver-tools/callbacks/callback-base.js +10 -0
- package/src/solver-tools/callbacks/callback-base.js.map +1 -0
- package/src/solver-tools/callbacks/callback-base.ts +8 -0
- package/src/solver-tools/callbacks/callback-tools.js +14 -0
- package/src/solver-tools/callbacks/callback-tools.js.map +1 -0
- package/src/solver-tools/callbacks/callback-tools.ts +20 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js +16 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/iter-checker-callback.ts +21 -0
- package/src/solver-tools/callbacks/time-checker-callback.js +17 -0
- package/src/solver-tools/callbacks/time-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/time-checker-callback.ts +19 -0
- package/src/solver-tools/index.js +6 -0
- package/src/solver-tools/index.js.map +1 -0
- package/src/solver-tools/index.ts +6 -0
- package/src/solver-tools/lin-alg-tools.js +56 -0
- package/src/solver-tools/lin-alg-tools.js.map +1 -0
- package/src/solver-tools/lin-alg-tools.ts +75 -0
- package/src/solver-tools/mrt-method.js +210 -0
- package/src/solver-tools/mrt-method.js.map +1 -0
- package/src/solver-tools/mrt-method.ts +269 -0
- package/src/solver-tools/ros34prw-method.js +257 -0
- package/src/solver-tools/ros34prw-method.js.map +1 -0
- package/src/solver-tools/ros34prw-method.ts +335 -0
- package/src/solver-tools/ros3prw-method.js +233 -0
- package/src/solver-tools/ros3prw-method.js.map +1 -0
- package/src/solver-tools/ros3prw-method.ts +304 -0
- package/src/solver-tools/solver-defs.js +58 -0
- package/src/solver-tools/solver-defs.js.map +1 -0
- package/src/solver-tools/solver-defs.ts +100 -0
- package/src/worker-tools/index.js +3 -0
- package/src/worker-tools/index.js.map +1 -0
- package/src/worker-tools/index.ts +2 -0
- package/src/worker-tools/scripting.js +68 -0
- package/src/worker-tools/scripting.js.map +1 -0
- package/src/worker-tools/scripting.ts +95 -0
- package/src/worker-tools/solving.js +48 -0
- package/src/worker-tools/solving.js.map +1 -0
- package/src/worker-tools/solving.ts +60 -0
- package/tsconfig.json +71 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** High Irradiance Responses of photomorphogenesis (see https://archimede.uniba.it/~testset/problems/hires.php) */
|
|
2
|
+
export const hires = {
|
|
3
|
+
name: 'HIRES',
|
|
4
|
+
arg: {name: 't', start: 0, finish: 321.8122, step: 0.01},
|
|
5
|
+
initial: [1, 0, 0, 0, 0, 0, 0, 0.0057],
|
|
6
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
7
|
+
// extract function values
|
|
8
|
+
const y1 = y[0];
|
|
9
|
+
const y2 = y[1];
|
|
10
|
+
const y3 = y[2];
|
|
11
|
+
const y4 = y[3];
|
|
12
|
+
const y5 = y[4];
|
|
13
|
+
const y6 = y[5];
|
|
14
|
+
const y7 = y[6];
|
|
15
|
+
const y8 = y[7];
|
|
16
|
+
|
|
17
|
+
// compute output
|
|
18
|
+
output[0] = -1.71 * y1 + 0.43 * y2 + 8.32 * y3 + 0.0007;
|
|
19
|
+
output[1] = 1.71 * y1 - 8.75 * y2;
|
|
20
|
+
output[2] = -10.03 * y3 + 0.43 * y4 + 0.035 * y5;
|
|
21
|
+
output[3] = 8.32 * y2 + 1.71 * y3 - 1.12 * y4;
|
|
22
|
+
output[4] = -1.745 * y5 + 0.43 * y6 + 0.43 * y7;
|
|
23
|
+
output[5] = -280 * y6 * y8 + 0.69 * y4 + 1.71 * y5 - 0.43 * y6 + 0.69 * y7;
|
|
24
|
+
output[6] = 280 * y6 * y8 - 1.81 * y7;
|
|
25
|
+
output[7] = -280 * y6 * y8 + 1.81 * y7;
|
|
26
|
+
},
|
|
27
|
+
tolerance: 1e-10,
|
|
28
|
+
solutionColNames: ['y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8'],
|
|
29
|
+
}; // hires
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { robertson } from './robertson';
|
|
2
|
+
import { hires } from './hires';
|
|
3
|
+
import { vdpol } from './vdpol';
|
|
4
|
+
import { orego } from './orego';
|
|
5
|
+
import { e5 } from './e5';
|
|
6
|
+
import { pollution } from './pollution';
|
|
7
|
+
/** Problems for performance check */
|
|
8
|
+
export const perfProbs = [
|
|
9
|
+
robertson,
|
|
10
|
+
hires,
|
|
11
|
+
vdpol,
|
|
12
|
+
orego,
|
|
13
|
+
e5,
|
|
14
|
+
pollution,
|
|
15
|
+
];
|
|
16
|
+
export { corrProbs } from './corr-probs';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qCAAqC;AACrC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS;IACT,KAAK;IACL,KAAK;IACL,KAAK;IACL,EAAE;IACF,SAAS;CACV,CAAC;AAEF,OAAO,EAAC,SAAS,EAAc,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {robertson} from './robertson';
|
|
2
|
+
import {hires} from './hires';
|
|
3
|
+
import {vdpol} from './vdpol';
|
|
4
|
+
import {orego} from './orego';
|
|
5
|
+
import {e5} from './e5';
|
|
6
|
+
import {pollution} from './pollution';
|
|
7
|
+
|
|
8
|
+
/** Problems for performance check */
|
|
9
|
+
export const perfProbs = [
|
|
10
|
+
robertson,
|
|
11
|
+
hires,
|
|
12
|
+
vdpol,
|
|
13
|
+
orego,
|
|
14
|
+
e5,
|
|
15
|
+
pollution,
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export {corrProbs, CorrProblem} from './corr-probs';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/** This example shows how to apply pipelines and models with updates.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider gluconic acid (GA) production by Aspergillus niger modeling.
|
|
6
|
+
*/
|
|
7
|
+
import * as DGL from '../../index';
|
|
8
|
+
/** 1. Model specification */
|
|
9
|
+
const model = `#name: GA-production
|
|
10
|
+
#tags: model
|
|
11
|
+
#description: Gluconic acid (GA) production by Aspergillus niger modeling
|
|
12
|
+
#equations:
|
|
13
|
+
dX/dt = rX
|
|
14
|
+
dS/dt = -gamma * rX - lambda * X
|
|
15
|
+
dO/dt = Kla * (Cod - O) - delta * rX - phi * X
|
|
16
|
+
dP/dt = alpha * rX + beta * X
|
|
17
|
+
|
|
18
|
+
#expressions:
|
|
19
|
+
mu = muM * S / (Ks + S) * O / (Ko + O)
|
|
20
|
+
rX = mu * X
|
|
21
|
+
|
|
22
|
+
#argument: t, 1-st stage
|
|
23
|
+
_t0 = 0 {units: h; caption: initial; category: Misc} [Start of the process]
|
|
24
|
+
_t1 = 60 {units: h; caption: 1-st stage; category: Durations; min: 20; max: 80} [Duration of the 1-st stage]
|
|
25
|
+
step = 0.1 {units: h; caption: step; category: Misc; min: 0.01; max: 1} [Time step of simulation]
|
|
26
|
+
|
|
27
|
+
#update: 2-nd stage
|
|
28
|
+
duration = overall - _t1
|
|
29
|
+
S += 70
|
|
30
|
+
|
|
31
|
+
#inits:
|
|
32
|
+
X = 5 {units: kg/m³; caption: biomass; category: Initial concentrations; min: 1; max: 10} [Aspergillus niger biomass]
|
|
33
|
+
S = 150 {units: kg/m³; caption: glucose; category: Initial concentrations; min: 50; max: 200} [Glucose]
|
|
34
|
+
O = 7 {units: kg/m³; caption: oxygen; category: Initial concentrations; min: 1; max: 10} [Dissolved oxygen]
|
|
35
|
+
P = 0 {units: kg/m³; caption: acid; category: Initial concentrations; min: 0; max: 0.1} [Gluconic acid]
|
|
36
|
+
|
|
37
|
+
#output:
|
|
38
|
+
t {caption: time}
|
|
39
|
+
X {caption: biomass}
|
|
40
|
+
S {caption: glucose}
|
|
41
|
+
O {caption: oxygen}
|
|
42
|
+
P {caption: acid}
|
|
43
|
+
|
|
44
|
+
#parameters:
|
|
45
|
+
overall = 100 {units: h; category: Durations; min: 100; max: 140} [Overall duration]
|
|
46
|
+
muM = 0.668 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
47
|
+
alpha = 2.92 {category: Parameters} [Monod type model parameter]
|
|
48
|
+
beta = 0.131 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
49
|
+
gamma = 2.12 {category: Parameters} [Monod type model parameter]
|
|
50
|
+
lambda = 0.232 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
51
|
+
delta = 0.278 {category: Parameters} [Monod type model parameter]
|
|
52
|
+
phi = 4.87e-3 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
53
|
+
Ks = 1.309e2 {units: g/L; category: Parameters} [Monod type model parameter]
|
|
54
|
+
Ko = 3.63e-4 {units: g/L; category: Parameters} [Monod type model parameter]
|
|
55
|
+
Kla = 1.7e-2 {units: 1/s; category: Parameters} [Volumetric mass transfer coefficient]
|
|
56
|
+
Cod = 15 {units: kg/m³; category: Parameters} [Liquid phase dissolved oxygen saturation concentration]
|
|
57
|
+
|
|
58
|
+
#tolerance: 1e-9`;
|
|
59
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
60
|
+
const ivp = DGL.getIVP(model);
|
|
61
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
62
|
+
/** 3. Perform computations */
|
|
63
|
+
try {
|
|
64
|
+
// 3.1) Extract names of outputs
|
|
65
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
66
|
+
const outSize = outputNames.length;
|
|
67
|
+
// 3.2) Set model inputs
|
|
68
|
+
const inputs = {
|
|
69
|
+
_t0: 0,
|
|
70
|
+
_t1: 60,
|
|
71
|
+
_h: 1,
|
|
72
|
+
X: 5,
|
|
73
|
+
S: 150,
|
|
74
|
+
O: 7,
|
|
75
|
+
P: 0,
|
|
76
|
+
overall: 100,
|
|
77
|
+
muM: 0.668,
|
|
78
|
+
alpha: 2.92,
|
|
79
|
+
beta: 0.131,
|
|
80
|
+
gamma: 2.12,
|
|
81
|
+
lambda: 0.232,
|
|
82
|
+
delta: 0.278,
|
|
83
|
+
phi: 4.87e-3,
|
|
84
|
+
Ks: 1.309e2,
|
|
85
|
+
Ko: 3.63e-4,
|
|
86
|
+
Kla: 1.7e-2,
|
|
87
|
+
Cod: 15,
|
|
88
|
+
};
|
|
89
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
90
|
+
// 3.3) Create a pipeline
|
|
91
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
92
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
93
|
+
// 3.4) Apply pipeline to perform computations
|
|
94
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
95
|
+
// 3.5) Print results
|
|
96
|
+
// 3.5.1) Table header
|
|
97
|
+
let line = ' ';
|
|
98
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
99
|
+
console.log(line);
|
|
100
|
+
// 3.5.2) Table with solution
|
|
101
|
+
const length = solution[0].length;
|
|
102
|
+
for (let i = 0; i < length; ++i) {
|
|
103
|
+
line = '';
|
|
104
|
+
for (let j = 0; j < outSize; ++j)
|
|
105
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
106
|
+
console.log(line);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=model-updates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-updates.js","sourceRoot":"","sources":["model-updates.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B;;;;EAIE;AAEF,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,6BAA6B;AAC7B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiDG,CAAC;AAElB,oFAAoF;AACpF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAExC,8BAA8B;AAC9B,IAAI,CAAC;IACH,gCAAgC;IAChC,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC;IAEnC,wBAAwB;IACxB,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,EAAE;QACP,EAAE,EAAE,CAAC;QACL,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,OAAO,EAAE,GAAG;QACZ,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE,OAAO;QACZ,EAAE,EAAE,OAAO;QACX,EAAE,EAAE,OAAO;QACX,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,EAAE;KACR,CAAC;IACF,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC,MAAM,E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models with updates.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider gluconic acid (GA) production by Aspergillus niger modeling.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as DGL from '../../index';
|
|
9
|
+
|
|
10
|
+
/** 1. Model specification */
|
|
11
|
+
const model = `#name: GA-production
|
|
12
|
+
#tags: model
|
|
13
|
+
#description: Gluconic acid (GA) production by Aspergillus niger modeling
|
|
14
|
+
#equations:
|
|
15
|
+
dX/dt = rX
|
|
16
|
+
dS/dt = -gamma * rX - lambda * X
|
|
17
|
+
dO/dt = Kla * (Cod - O) - delta * rX - phi * X
|
|
18
|
+
dP/dt = alpha * rX + beta * X
|
|
19
|
+
|
|
20
|
+
#expressions:
|
|
21
|
+
mu = muM * S / (Ks + S) * O / (Ko + O)
|
|
22
|
+
rX = mu * X
|
|
23
|
+
|
|
24
|
+
#argument: t, 1-st stage
|
|
25
|
+
_t0 = 0 {units: h; caption: initial; category: Misc} [Start of the process]
|
|
26
|
+
_t1 = 60 {units: h; caption: 1-st stage; category: Durations; min: 20; max: 80} [Duration of the 1-st stage]
|
|
27
|
+
step = 0.1 {units: h; caption: step; category: Misc; min: 0.01; max: 1} [Time step of simulation]
|
|
28
|
+
|
|
29
|
+
#update: 2-nd stage
|
|
30
|
+
duration = overall - _t1
|
|
31
|
+
S += 70
|
|
32
|
+
|
|
33
|
+
#inits:
|
|
34
|
+
X = 5 {units: kg/m³; caption: biomass; category: Initial concentrations; min: 1; max: 10} [Aspergillus niger biomass]
|
|
35
|
+
S = 150 {units: kg/m³; caption: glucose; category: Initial concentrations; min: 50; max: 200} [Glucose]
|
|
36
|
+
O = 7 {units: kg/m³; caption: oxygen; category: Initial concentrations; min: 1; max: 10} [Dissolved oxygen]
|
|
37
|
+
P = 0 {units: kg/m³; caption: acid; category: Initial concentrations; min: 0; max: 0.1} [Gluconic acid]
|
|
38
|
+
|
|
39
|
+
#output:
|
|
40
|
+
t {caption: time}
|
|
41
|
+
X {caption: biomass}
|
|
42
|
+
S {caption: glucose}
|
|
43
|
+
O {caption: oxygen}
|
|
44
|
+
P {caption: acid}
|
|
45
|
+
|
|
46
|
+
#parameters:
|
|
47
|
+
overall = 100 {units: h; category: Durations; min: 100; max: 140} [Overall duration]
|
|
48
|
+
muM = 0.668 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
49
|
+
alpha = 2.92 {category: Parameters} [Monod type model parameter]
|
|
50
|
+
beta = 0.131 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
51
|
+
gamma = 2.12 {category: Parameters} [Monod type model parameter]
|
|
52
|
+
lambda = 0.232 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
53
|
+
delta = 0.278 {category: Parameters} [Monod type model parameter]
|
|
54
|
+
phi = 4.87e-3 {units: 1/h; category: Parameters} [Monod type model parameter]
|
|
55
|
+
Ks = 1.309e2 {units: g/L; category: Parameters} [Monod type model parameter]
|
|
56
|
+
Ko = 3.63e-4 {units: g/L; category: Parameters} [Monod type model parameter]
|
|
57
|
+
Kla = 1.7e-2 {units: 1/s; category: Parameters} [Volumetric mass transfer coefficient]
|
|
58
|
+
Cod = 15 {units: kg/m³; category: Parameters} [Liquid phase dissolved oxygen saturation concentration]
|
|
59
|
+
|
|
60
|
+
#tolerance: 1e-9`;
|
|
61
|
+
|
|
62
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
63
|
+
const ivp = DGL.getIVP(model);
|
|
64
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
65
|
+
|
|
66
|
+
/** 3. Perform computations */
|
|
67
|
+
try {
|
|
68
|
+
// 3.1) Extract names of outputs
|
|
69
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
70
|
+
const outSize = outputNames.length;
|
|
71
|
+
|
|
72
|
+
// 3.2) Set model inputs
|
|
73
|
+
const inputs = {
|
|
74
|
+
_t0: 0,
|
|
75
|
+
_t1: 60,
|
|
76
|
+
_h: 1,
|
|
77
|
+
X: 5,
|
|
78
|
+
S: 150,
|
|
79
|
+
O: 7,
|
|
80
|
+
P: 0,
|
|
81
|
+
overall: 100,
|
|
82
|
+
muM: 0.668,
|
|
83
|
+
alpha: 2.92,
|
|
84
|
+
beta: 0.131,
|
|
85
|
+
gamma: 2.12,
|
|
86
|
+
lambda: 0.232,
|
|
87
|
+
delta: 0.278,
|
|
88
|
+
phi: 4.87e-3,
|
|
89
|
+
Ks: 1.309e2,
|
|
90
|
+
Ko: 3.63e-4,
|
|
91
|
+
Kla: 1.7e-2,
|
|
92
|
+
Cod: 15,
|
|
93
|
+
};
|
|
94
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
95
|
+
|
|
96
|
+
// 3.3) Create a pipeline
|
|
97
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
98
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
99
|
+
|
|
100
|
+
// 3.4) Apply pipeline to perform computations
|
|
101
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
102
|
+
|
|
103
|
+
// 3.5) Print results
|
|
104
|
+
|
|
105
|
+
// 3.5.1) Table header
|
|
106
|
+
let line = ' ';
|
|
107
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
108
|
+
console.log(line);
|
|
109
|
+
|
|
110
|
+
// 3.5.2) Table with solution
|
|
111
|
+
const length = solution[0].length;
|
|
112
|
+
for (let i = 0; i < length; ++i) {
|
|
113
|
+
line = '';
|
|
114
|
+
|
|
115
|
+
for (let j = 0; j < outSize; ++j)
|
|
116
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
117
|
+
|
|
118
|
+
console.log(line);
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
122
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The OREGO model (see https://archimede.uniba.it/~testset/report/orego.pdf) */
|
|
2
|
+
export const orego = {
|
|
3
|
+
name: 'OREGO',
|
|
4
|
+
arg: { name: 't', start: 0, finish: 360, step: 0.01 },
|
|
5
|
+
initial: [1, 2, 3],
|
|
6
|
+
func: (t, y, output) => {
|
|
7
|
+
// extract function values
|
|
8
|
+
const y1 = y[0];
|
|
9
|
+
const y2 = y[1];
|
|
10
|
+
const y3 = y[2];
|
|
11
|
+
// compute output
|
|
12
|
+
output[0] = 77.27 * (y2 - y1 * y2 + y1 - 0.000008375 * y1 * y1);
|
|
13
|
+
output[1] = 1 / 77.27 * (-y2 - y1 * y2 + y3);
|
|
14
|
+
output[2] = 0.161 * (y1 - y3);
|
|
15
|
+
},
|
|
16
|
+
tolerance: 1e-8,
|
|
17
|
+
solutionColNames: ['y1', 'y2', 'y3'],
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=orego.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orego.js","sourceRoot":"","sources":["orego.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAC;IACnD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClB,IAAI,EAAE,CAAC,CAAS,EAAE,CAAe,EAAE,MAAoB,EAAE,EAAE;QACzD,0BAA0B;QAC1B,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhB,iBAAiB;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,WAAW,GAAG,EAAE,GAAG,EAAE,CAAE,CAAC;QACjE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;CACrC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The OREGO model (see https://archimede.uniba.it/~testset/report/orego.pdf) */
|
|
2
|
+
export const orego = {
|
|
3
|
+
name: 'OREGO',
|
|
4
|
+
arg: {name: 't', start: 0, finish: 360, step: 0.01},
|
|
5
|
+
initial: [1, 2, 3],
|
|
6
|
+
func: (t: number, y: Float64Array, output: Float64Array) => {
|
|
7
|
+
// extract function values
|
|
8
|
+
const y1 = y[0];
|
|
9
|
+
const y2 = y[1];
|
|
10
|
+
const y3 = y[2];
|
|
11
|
+
|
|
12
|
+
// compute output
|
|
13
|
+
output[0] = 77.27 * (y2 - y1 * y2 + y1 - 0.000008375 * y1 * y1 );
|
|
14
|
+
output[1] = 1 / 77.27 * (-y2 - y1 * y2 + y3);
|
|
15
|
+
output[2] = 0.161 * (y1 - y3);
|
|
16
|
+
},
|
|
17
|
+
tolerance: 1e-8,
|
|
18
|
+
solutionColNames: ['y1', 'y2', 'y3'],
|
|
19
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/** This example shows how to apply pipelines and models with customized outputs.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider modeling queues: https://en.wikipedia.org/wiki/M/M/c_queue
|
|
6
|
+
*/
|
|
7
|
+
import * as DGL from '../../index';
|
|
8
|
+
/** 1. Model specification: the M|M|2|2 model */
|
|
9
|
+
const model = `#name: M|M|2|2
|
|
10
|
+
#description: Modelling the system with two servers & two waiting places (EXPLAINED)
|
|
11
|
+
#equations:
|
|
12
|
+
dp0/dt = -la * p0 + mu * p1
|
|
13
|
+
dp1/dt = la * p0 - (la + mu) * p1 + 2 * mu * p2
|
|
14
|
+
dp2/dt = la * p1 - (la + 2 * mu) * p2 + 2 * mu * p3
|
|
15
|
+
dp3/dt = la * p2 - (la + 2 * mu) * p3 + 2 * mu * p4
|
|
16
|
+
|
|
17
|
+
#expressions:
|
|
18
|
+
la = 1 / arrival
|
|
19
|
+
mu = 1 / service
|
|
20
|
+
p4 = 1 - p0 - p1 - p2 - p3
|
|
21
|
+
busy = 1 - p0 - p1
|
|
22
|
+
queue = p3 + 2 * p4
|
|
23
|
+
|
|
24
|
+
#argument: t
|
|
25
|
+
_t0 = 0 {min: 0; max: 10; caption: start; category: Time; units: min} [Initial time of simulation]
|
|
26
|
+
_t1 = 60 {min: 20; max: 100; caption: finish; category: Time; units: min} [Final time of simulation]
|
|
27
|
+
_h = 1 {min: 0.01; max: 0.1; caption: step; category: Time; units: min} [Time step of simulation]
|
|
28
|
+
|
|
29
|
+
#inits:
|
|
30
|
+
p0 = 1 {min: 0; max: 1; category: Initial state; caption: empty} [Probability that initially there are NO customers]
|
|
31
|
+
p1 = 0 {min: 0; max: 1; category: Initial state; caption: single} [Probability that initially there is ONE customer]
|
|
32
|
+
p2 = 0 {min: 0; max: 1; category: Initial state; caption: two} [Probability that initially there are TWO customers]
|
|
33
|
+
p3 = 0 {min: 0; max: 1; category: Initial state; caption: three} [Probability that initially there are THREE customers]
|
|
34
|
+
|
|
35
|
+
#output:
|
|
36
|
+
t {caption: Time, min}
|
|
37
|
+
p0 {caption: P(Empty)}
|
|
38
|
+
busy {caption: P(Full load)}
|
|
39
|
+
queue {caption: E(Queue)}
|
|
40
|
+
|
|
41
|
+
#parameters:
|
|
42
|
+
arrival = 10 {min: 1; max: 100; category: Means; caption: arrival; units: min} [Mean arrival time]
|
|
43
|
+
service = 100 {min: 1; max: 100; category: Means; caption: service; units: min} [Mean service time]`;
|
|
44
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
45
|
+
const ivp = DGL.getIVP(model);
|
|
46
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
47
|
+
/** 3. Perform computations */
|
|
48
|
+
try {
|
|
49
|
+
// 3.1) Extract names of outputs
|
|
50
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
51
|
+
const outSize = outputNames.length;
|
|
52
|
+
// 3.2) Set model inputs
|
|
53
|
+
const inputs = {
|
|
54
|
+
_t0: 0, // Initial time of simulation
|
|
55
|
+
_t1: 60, // Final time of simulation
|
|
56
|
+
_h: 1, // Time step of simulation
|
|
57
|
+
p0: 1, // Probability that initially there are NO customers
|
|
58
|
+
p1: 0, // Probability that initially there is ONE customer
|
|
59
|
+
p2: 0, // Probability that initially there are TWO customers
|
|
60
|
+
p3: 0, // Probability that initially there are THREE customers
|
|
61
|
+
arrival: 10, // Mean arrival time
|
|
62
|
+
service: 100, // Mean service time
|
|
63
|
+
};
|
|
64
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
65
|
+
// 3.3) Create a pipeline
|
|
66
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
67
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
68
|
+
// 3.4) Apply pipeline to perform computations
|
|
69
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
70
|
+
// 3.5) Print results
|
|
71
|
+
// 3.5.1) Table header
|
|
72
|
+
let line = '';
|
|
73
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
74
|
+
console.log(line);
|
|
75
|
+
// 3.5.2) Table with solution
|
|
76
|
+
const length = solution[0].length;
|
|
77
|
+
for (let i = 0; i < length; ++i) {
|
|
78
|
+
line = '';
|
|
79
|
+
for (let j = 0; j < outSize; ++j)
|
|
80
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
81
|
+
console.log(line);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=pipeline-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-use.js","sourceRoot":"","sources":["pipeline-use.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B;;;;EAIE;AAEF,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,iDAAiD;AACjD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAkCyF,CAAC;AAExG,oFAAoF;AACpF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAExC,8BAA8B;AAC9B,IAAI,CAAC;IACH,gCAAgC;IAChC,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC;IAEnC,wBAAwB;IACxB,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,CAAC,EAAE,6BAA6B;QACrC,GAAG,EAAE,EAAE,EAAE,2BAA2B;QACpC,EAAE,EAAE,CAAC,EAAE,0BAA0B;QACjC,EAAE,EAAE,CAAC,EAAE,oDAAoD;QAC3D,EAAE,EAAE,CAAC,EAAE,mDAAmD;QAC1D,EAAE,EAAE,CAAC,EAAE,qDAAqD;QAC5D,EAAE,EAAE,CAAC,EAAE,uDAAuD;QAC9D,OAAO,EAAE,EAAE,EAAE,oBAAoB;QACjC,OAAO,EAAE,GAAG,EAAE,oBAAoB;KACnC,CAAC;IACF,MAAM,WAAW,GAAG,GAAG,CA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
+
/** This example shows how to apply pipelines and models with customized outputs.
|
|
3
|
+
This approach can be used for in-webworkers analysis of models.
|
|
4
|
+
|
|
5
|
+
Here, we consider modeling queues: https://en.wikipedia.org/wiki/M/M/c_queue
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as DGL from '../../index';
|
|
9
|
+
|
|
10
|
+
/** 1. Model specification: the M|M|2|2 model */
|
|
11
|
+
const model = `#name: M|M|2|2
|
|
12
|
+
#description: Modelling the system with two servers & two waiting places (EXPLAINED)
|
|
13
|
+
#equations:
|
|
14
|
+
dp0/dt = -la * p0 + mu * p1
|
|
15
|
+
dp1/dt = la * p0 - (la + mu) * p1 + 2 * mu * p2
|
|
16
|
+
dp2/dt = la * p1 - (la + 2 * mu) * p2 + 2 * mu * p3
|
|
17
|
+
dp3/dt = la * p2 - (la + 2 * mu) * p3 + 2 * mu * p4
|
|
18
|
+
|
|
19
|
+
#expressions:
|
|
20
|
+
la = 1 / arrival
|
|
21
|
+
mu = 1 / service
|
|
22
|
+
p4 = 1 - p0 - p1 - p2 - p3
|
|
23
|
+
busy = 1 - p0 - p1
|
|
24
|
+
queue = p3 + 2 * p4
|
|
25
|
+
|
|
26
|
+
#argument: t
|
|
27
|
+
_t0 = 0 {min: 0; max: 10; caption: start; category: Time; units: min} [Initial time of simulation]
|
|
28
|
+
_t1 = 60 {min: 20; max: 100; caption: finish; category: Time; units: min} [Final time of simulation]
|
|
29
|
+
_h = 1 {min: 0.01; max: 0.1; caption: step; category: Time; units: min} [Time step of simulation]
|
|
30
|
+
|
|
31
|
+
#inits:
|
|
32
|
+
p0 = 1 {min: 0; max: 1; category: Initial state; caption: empty} [Probability that initially there are NO customers]
|
|
33
|
+
p1 = 0 {min: 0; max: 1; category: Initial state; caption: single} [Probability that initially there is ONE customer]
|
|
34
|
+
p2 = 0 {min: 0; max: 1; category: Initial state; caption: two} [Probability that initially there are TWO customers]
|
|
35
|
+
p3 = 0 {min: 0; max: 1; category: Initial state; caption: three} [Probability that initially there are THREE customers]
|
|
36
|
+
|
|
37
|
+
#output:
|
|
38
|
+
t {caption: Time, min}
|
|
39
|
+
p0 {caption: P(Empty)}
|
|
40
|
+
busy {caption: P(Full load)}
|
|
41
|
+
queue {caption: E(Queue)}
|
|
42
|
+
|
|
43
|
+
#parameters:
|
|
44
|
+
arrival = 10 {min: 1; max: 100; category: Means; caption: arrival; units: min} [Mean arrival time]
|
|
45
|
+
service = 100 {min: 1; max: 100; category: Means; caption: service; units: min} [Mean service time]`;
|
|
46
|
+
|
|
47
|
+
/** 2. Generate IVP-objects: for the main thread & for computations in webworkers */
|
|
48
|
+
const ivp = DGL.getIVP(model);
|
|
49
|
+
const ivpWW = DGL.getIvp2WebWorker(ivp);
|
|
50
|
+
|
|
51
|
+
/** 3. Perform computations */
|
|
52
|
+
try {
|
|
53
|
+
// 3.1) Extract names of outputs
|
|
54
|
+
const outputNames = DGL.getOutputNames(ivp);
|
|
55
|
+
const outSize = outputNames.length;
|
|
56
|
+
|
|
57
|
+
// 3.2) Set model inputs
|
|
58
|
+
const inputs = {
|
|
59
|
+
_t0: 0, // Initial time of simulation
|
|
60
|
+
_t1: 60, // Final time of simulation
|
|
61
|
+
_h: 1, // Time step of simulation
|
|
62
|
+
p0: 1, // Probability that initially there are NO customers
|
|
63
|
+
p1: 0, // Probability that initially there is ONE customer
|
|
64
|
+
p2: 0, // Probability that initially there are TWO customers
|
|
65
|
+
p3: 0, // Probability that initially there are THREE customers
|
|
66
|
+
arrival: 10, // Mean arrival time
|
|
67
|
+
service: 100, // Mean service time
|
|
68
|
+
};
|
|
69
|
+
const inputVector = DGL.getInputVector(inputs, ivp);
|
|
70
|
+
|
|
71
|
+
// 3.3) Create a pipeline
|
|
72
|
+
const creator = DGL.getPipelineCreator(ivp);
|
|
73
|
+
const pipeline = creator.getPipeline(inputVector);
|
|
74
|
+
|
|
75
|
+
// 3.4) Apply pipeline to perform computations
|
|
76
|
+
const solution = DGL.applyPipeline(pipeline, ivpWW, inputVector);
|
|
77
|
+
|
|
78
|
+
// 3.5) Print results
|
|
79
|
+
|
|
80
|
+
// 3.5.1) Table header
|
|
81
|
+
let line = '';
|
|
82
|
+
outputNames.forEach((name) => line += name + ' ');
|
|
83
|
+
console.log(line);
|
|
84
|
+
|
|
85
|
+
// 3.5.2) Table with solution
|
|
86
|
+
const length = solution[0].length;
|
|
87
|
+
for (let i = 0; i < length; ++i) {
|
|
88
|
+
line = '';
|
|
89
|
+
|
|
90
|
+
for (let j = 0; j < outSize; ++j)
|
|
91
|
+
line += solution[j][i].toFixed(8) + ' ';
|
|
92
|
+
|
|
93
|
+
console.log(line);
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.log('Simulation failed: ', err instanceof Error ? err.message : 'Unknown problem!');
|
|
97
|
+
}
|
|
98
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Kintetic constants for the Pollution model */
|
|
2
|
+
var POL;
|
|
3
|
+
(function (POL) {
|
|
4
|
+
POL[POL["K1"] = 0.35] = "K1";
|
|
5
|
+
POL[POL["K2"] = 26.6] = "K2";
|
|
6
|
+
POL[POL["K3"] = 12300] = "K3";
|
|
7
|
+
POL[POL["K4"] = 0.00086] = "K4";
|
|
8
|
+
POL[POL["K5"] = 0.00082] = "K5";
|
|
9
|
+
POL[POL["K6"] = 15000] = "K6";
|
|
10
|
+
POL[POL["K7"] = 0.00013] = "K7";
|
|
11
|
+
POL[POL["K8"] = 24000] = "K8";
|
|
12
|
+
POL[POL["K9"] = 16500] = "K9";
|
|
13
|
+
POL[POL["K10"] = 9000] = "K10";
|
|
14
|
+
POL[POL["K11"] = 0.022] = "K11";
|
|
15
|
+
POL[POL["K12"] = 12000] = "K12";
|
|
16
|
+
POL[POL["K13"] = 1.88] = "K13";
|
|
17
|
+
POL[POL["K14"] = 16300] = "K14";
|
|
18
|
+
POL[POL["K15"] = 4800000] = "K15";
|
|
19
|
+
POL[POL["K16"] = 0.00035] = "K16";
|
|
20
|
+
POL[POL["K17"] = 0.0175] = "K17";
|
|
21
|
+
POL[POL["K18"] = 100000000] = "K18";
|
|
22
|
+
POL[POL["K19"] = 444000000000] = "K19";
|
|
23
|
+
POL[POL["K20"] = 1240] = "K20";
|
|
24
|
+
POL[POL["K21"] = 2.1] = "K21";
|
|
25
|
+
POL[POL["K22"] = 5.78] = "K22";
|
|
26
|
+
POL[POL["K23"] = 0.0474] = "K23";
|
|
27
|
+
POL[POL["K24"] = 1780] = "K24";
|
|
28
|
+
POL[POL["K25"] = 3.12] = "K25";
|
|
29
|
+
})(POL || (POL = {}));
|
|
30
|
+
; // POL
|
|
31
|
+
/** The chemical reaction part of the air pollution model (https://archimede.uniba.it/~testset/report/pollu.pdf) */
|
|
32
|
+
export const pollution = {
|
|
33
|
+
name: 'Pollution',
|
|
34
|
+
arg: { name: 't', start: 0, finish: 60, step: 0.002 },
|
|
35
|
+
initial: [0, 0.2, 0, 0.04, 0, 0, 0.1, 0.3, 0.01, 0, 0, 0, 0, 0, 0, 0, 0.007, 0, 0, 0],
|
|
36
|
+
func: (t, y, output) => {
|
|
37
|
+
// extract function values
|
|
38
|
+
const y1 = y[0];
|
|
39
|
+
const y2 = y[1];
|
|
40
|
+
const y3 = y[2];
|
|
41
|
+
const y4 = y[3];
|
|
42
|
+
const y5 = y[4];
|
|
43
|
+
const y6 = y[5];
|
|
44
|
+
const y7 = y[6];
|
|
45
|
+
const y8 = y[7];
|
|
46
|
+
const y9 = y[8];
|
|
47
|
+
const y10 = y[9];
|
|
48
|
+
const y11 = y[10];
|
|
49
|
+
const y12 = y[11];
|
|
50
|
+
const y13 = y[12];
|
|
51
|
+
const y14 = y[13];
|
|
52
|
+
const y15 = y[14];
|
|
53
|
+
const y16 = y[15];
|
|
54
|
+
const y17 = y[16];
|
|
55
|
+
const y18 = y[17];
|
|
56
|
+
const y19 = y[18];
|
|
57
|
+
const y20 = y[19];
|
|
58
|
+
// evaluate expressions
|
|
59
|
+
const r1 = POL.K1 * y1;
|
|
60
|
+
const r2 = POL.K2 * y2 * y4;
|
|
61
|
+
const r3 = POL.K3 * y5 * y2;
|
|
62
|
+
const r4 = POL.K4 * y7;
|
|
63
|
+
const r5 = POL.K5 * y7;
|
|
64
|
+
const r6 = POL.K6 * y7 * y6;
|
|
65
|
+
const r7 = POL.K7 * y9;
|
|
66
|
+
const r8 = POL.K8 * y9 * y6;
|
|
67
|
+
const r9 = POL.K9 * y11 * y2;
|
|
68
|
+
const r10 = POL.K10 * y11 * y1;
|
|
69
|
+
const r11 = POL.K11 * y13;
|
|
70
|
+
const r12 = POL.K12 * y10 * y2;
|
|
71
|
+
const r13 = POL.K13 * y14;
|
|
72
|
+
const r14 = POL.K14 * y1 * y6;
|
|
73
|
+
const r15 = POL.K15 * y3;
|
|
74
|
+
const r16 = POL.K16 * y4;
|
|
75
|
+
const r17 = POL.K17 * y4;
|
|
76
|
+
const r18 = POL.K18 * y16;
|
|
77
|
+
const r19 = POL.K19 * y16;
|
|
78
|
+
const r20 = POL.K20 * y17 * y6;
|
|
79
|
+
const r21 = POL.K21 * y19;
|
|
80
|
+
const r22 = POL.K22 * y19;
|
|
81
|
+
const r23 = POL.K23 * y1 * y4;
|
|
82
|
+
const r24 = POL.K24 * y19 * y1;
|
|
83
|
+
const r25 = POL.K25 * y20;
|
|
84
|
+
// compute output
|
|
85
|
+
output[0] = -(r1 + r10 + r14 + r23 + r24) + (r2 + r3 + r9 + r11 + r12 + r22 + r25);
|
|
86
|
+
output[1] = -r2 - r3 - r9 - r12 + r1 + r21;
|
|
87
|
+
output[2] = -r15 + r1 + r17 + r19 + r22;
|
|
88
|
+
output[3] = -r2 - r16 - r17 - r23 + r15;
|
|
89
|
+
output[4] = -r3 + 2 * r4 + r6 + r7 + r13 + r20;
|
|
90
|
+
output[5] = -r6 - r8 - r14 - r20 + r3 + 2 * r18;
|
|
91
|
+
output[6] = -r4 - r5 - r6 + r13;
|
|
92
|
+
output[7] = r4 + r5 + r6 + r7;
|
|
93
|
+
output[8] = -r7 - r8;
|
|
94
|
+
output[9] = -r12 + r7 + r9;
|
|
95
|
+
output[10] = -r9 - r10 + r8 + r11;
|
|
96
|
+
output[11] = r9;
|
|
97
|
+
output[12] = -r11 + r10;
|
|
98
|
+
output[13] = -r13 + r12;
|
|
99
|
+
output[14] = r14;
|
|
100
|
+
output[15] = -r18 - r19 + r16;
|
|
101
|
+
output[16] = -r20;
|
|
102
|
+
output[17] = r20;
|
|
103
|
+
output[18] = -r21 - r22 - r24 + r23 + r25;
|
|
104
|
+
output[19] = -r25 + r24;
|
|
105
|
+
},
|
|
106
|
+
tolerance: 1e-6,
|
|
107
|
+
solutionColNames: ['y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'y10', 'y11',
|
|
108
|
+
'y12', 'y13', 'y14', 'y15', 'y16', 'y17', 'y18', 'y19', 'y20'],
|
|
109
|
+
}; // pollution
|
|
110
|
+
//# sourceMappingURL=pollution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollution.js","sourceRoot":"","sources":["pollution.ts"],"names":[],"mappings":"AAAE,iDAAiD;AACjD,IAAK,GA0BJ;AA1BD,WAAK,GAAG;IACN,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,6BAAW,CAAA;IACX,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,6BAAU,CAAA;IACV,+BAAW,CAAA;IACX,6BAAU,CAAA;IACV,6BAAW,CAAA;IACX,8BAAS,CAAA;IACT,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,+BAAY,CAAA;IACZ,iCAAW,CAAA;IACX,iCAAY,CAAA;IACZ,gCAAY,CAAA;IACZ,mCAAS,CAAA;IACT,sCAAa,CAAA;IACb,8BAAU,CAAA;IACV,6BAAS,CAAA;IACT,8BAAU,CAAA;IACV,gCAAY,CAAA;IACZ,8BAAU,CAAA;IACV,8BAAU,CAAA;AACZ,CAAC,EA1BI,GAAG,KAAH,GAAG,QA0B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