Skip to content

Commit

Permalink
support for SLV26
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 9, 2023
1 parent 31bed58 commit 482133d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions export-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ This is the updated version of SLV export format which supports compartment volu
| ---------|------|----------|---------|-----|-------------|
| powTransform | "keep" / "operator" / "function" | | "keep" | | This is option describing if the transformation of x^y and pow(x, y) is required. |
| groupConstBy | string/path | | `tags[0]` | | How to group const in Initial Values of DBSolve file. Should be written in format of JSON path |
| version | string | | `26` | | SLV file version: `26` (for DBSolveOptimum 2020) or `25` (for earlier versions) |

### Output files

Expand Down
6 changes: 4 additions & 2 deletions src/dbsolve-export/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { AbstractExport } = require('../core/abstract-export');
/* global compiledTemplates */
const _ = require('lodash');
const _get = require('lodash/get');
require('./expression');
const { ajv } = require('../utils');
Expand All @@ -10,6 +9,7 @@ const schema = {
properties: {
groupConstBy: {type: 'string', pattern: '^[\\w\\d.\\[\\]]+$'},
powTransform: {type: 'string', enum: ['keep', 'operator', 'function'] },
version: {enum: ['25', '26', 25, 26]},
}
};

Expand All @@ -33,6 +33,7 @@ class DBSolveExport extends AbstractExport{
} else if (typeof q.spaceFilter === 'string') {
this.spaceFilter = [q.spaceFilter];
}
this.version = q.version ? q.version + '' : '26'; // force string

if (q.defaultTask) this.defaultTask = q.defaultTask;
}
Expand Down Expand Up @@ -254,10 +255,11 @@ class DBSolveExport extends AbstractExport{
processes,
matrix,
powTransform: this.powTransform,
version: this.version,
timeEvents,
discreteEvents,
continuousEvents,
groupedConst
groupedConst,
};
}
getSLVCode(image = {}){
Expand Down
4 changes: 3 additions & 1 deletion src/matlab-export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ class MatlabExport extends AbstractExport {
});
// add from events
let const_len = constants.length;
events.forEach((x, i) => pTranslator.push([x.switcher.id + '_', `p(${const_len + i + 1})`]));
events.forEach((x, i) => {
pTranslator[x.switcher.id + '_'] = `p(${const_len + i + 1})`;
});

let functionDefArray = [...ns.container.functionDefStorage.values()];

Expand Down
12 changes: 11 additions & 1 deletion src/templates/dbsolve-model.slv.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
{%- set freeConstants = population.selectByClassName('Const') | selectattr('free') %}
{%- set species = population.selectByInstanceOf('Species') -%}
{%- set timeScales = population.selectByInstanceOf('TimeScale') | exclude2('id', 't') -%}

{% if version == '26' -%}
DBSolve Optimum 2020 (new parser) 1 Jul 2006
SLV26.00*
{%- else -%}
DBSolve Optimum (new parser) 1 Jul 2006
SLV25.00*
{%- endif %}
Number of rows in matrix (Number of activities) #{{ processes|length }}
Number of cols in matrix (Number of compounds) #{{ dynamicRecords|length }}
Initial System dimension #{{ dynamicRecords|length }}
Expand Down Expand Up @@ -856,6 +860,12 @@ k1
1
0.000010
1000000
{%- if version == '26' %}
p1
0.000000
0.000000
10
{%- endif %}
{{ 0 if eventsOff else 1 }}
{% block events -%}
{{ timeEvents.length }}
Expand Down

0 comments on commit 482133d

Please sign in to comment.