Skip to content

Commit

Permalink
GROK-17514: Diff Studio: DS-lib usage
Browse files Browse the repository at this point in the history
Implemented the use of of the Diff Studio library
  • Loading branch information
vmakarichev committed Feb 7, 2025
1 parent e715f59 commit 748624b
Show file tree
Hide file tree
Showing 39 changed files with 605 additions and 1,733 deletions.
7 changes: 6 additions & 1 deletion packages/DiffStudio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Diff Studio changelog

## 1.2.1 (2025-02-10)
## 1.2.2 (2025-02-10)

* Implemented the use of Diff Studio Lib solvers
* Added correctness tests

## 1.2.1 (2025-02-01)

Added facet grid plot

Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/bioreactor.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#argument: t
t0 = 0.0 {units: min; caption: Initial; category: Time} [Initial time of simulation]
t1 = 1000 {units: min; caption: Final; category: Time; min: 500; max: 1000} [Final time of simulation]
h = 1 {units: min; caption: Step; category: Time; min: 0.1; max: 2} [Time step of simlulation]
h = 1 {units: min; caption: Step; category: Time; min: 0.1; max: 2} [Time step of simulation]

#inits:
FFox = 0.2 {units: mmol/L; category: Initial values; min: 0.15; max: 0.25; step: 0.01} [FF oxidized]
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/chem-react.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
#argument: t
initial = 0 {units: min; caption: Initial; category: Time; min: 0; max: 5} [Initial time of simulation]
final = 6 {units: min; caption: Final; category: Time; min: 6; max: 10} [Final time of simulation]
step = 0.01 {units: min; caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simlulation]
step = 0.01 {units: min; caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simulation]

#tolerance: 5e-5
4 changes: 2 additions & 2 deletions packages/DiffStudio/files/library/energy-n-control.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// simple if-then-else custom function
func1 = (p, t) => (p < 8) ? ceil(t) : ceil(t**2 / 20)

// another custom function using the previouse one
// another custom function using the previous one
func2 = (p, t) => (p < 5) ? ceil(exp(-t) * 10) : func1(p, t);

// usage of custom function
Expand All @@ -44,6 +44,6 @@
#argument: t
start = 0 {caption: Initial; category: Time; min: 0; max: 10} [Initial time of simulation]
finish = 10 {caption: Final; category: Time; min: 10; max: 20} [Final time of simulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simlulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simulation]

#tolerance: 5e-5
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/fermentation.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#argument: t
initial = 0 {units: d; caption: Initial; category: Time; min: 0; max: 10} [Initial time of simulation]
final = 70 {units: d; caption: Final; category: Time; min: 15; max: 100} [Final time of simulation]
step = 0.01 {units: d; caption: Step; category: Time; min: 0.01; max: 1} [Time step of simlulation]
step = 0.01 {units: d; caption: Step; category: Time; min: 0.01; max: 1} [Time step of simulation]

#inits:
P = 4.276 {units: ml/ml; caption: ethanol, P; category: Initials; min: 3; max: 6} [Concentration of ethanol]
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/ga-production.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#argument: t, 1-st stage
start = 0 {units: h; caption: initial; category: Misc} [Start of the process]
stage1 = 60 {units: h; caption: 1-st stage; category: Durations; min: 20; max: 80} [Duration of the 1-st stage]
step = 0.1 {units: h; caption: step; category: Misc; min: 0.01; max: 1} [Time step of simlulation]
step = 0.1 {units: h; caption: step; category: Misc; min: 0.01; max: 1} [Time step of simulation]

#update: 2-nd stage
duration = overall - _t1
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/nimotuzumab.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#argument: t
start = 0 {caption: Initial; category: Time; min: 0; max: 10} [Initial time of simulation]
finish = 70 {caption: Final; category: Time; min: 50; max: 100} [Final time of simulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 1} [Time step of simlulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 1} [Time step of simulation]

#inits:
A1 = 0.43 {category: Initials; min: 0.2; max: 0.6} [Central]
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/pk-pd.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#argument: t
start = 0 {units: h; caption: begin; category: Dosing; min: 0; max: 1} [Begin of dosing interval]
final = 12 {units: h; caption: end; category: Dosing; min: 5; max: 15} [End of dosing interval]
step = 0.1 {units: h; caption: step; category: Dosing; min: 0.01; max: 0.1} [Time step of simlulation]
step = 0.1 {units: h; caption: step; category: Dosing; min: 0.01; max: 0.1} [Time step of simulation]

#inits:
depot = 0 {category: Initial values}
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/pk.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#argument: t
start = 0 {units: h; caption: begin; category: Dosing; min: 0; max: 1} [Begin of dosing interval]
final = 12 {units: h; caption: end; category: Dosing; min: 5; max: 15} [End of dosing interval]
step = 0.01 {units: h; caption: step; category: Dosing; min: 0.01; max: 0.1} [Time step of simlulation]
step = 0.01 {units: h; caption: step; category: Dosing; min: 0.01; max: 0.1} [Time step of simulation]

#inits:
depot = 0 {category: Initial values}
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/pollution.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#argument: t
t0 = 0 {units: min; caption: Initial; category: Time; min: 0; max: 0.9} [Initial time of simulation]
t1 = 60 {units: min; caption: Final; category: Time; min: 1; max: 100; step: 1} [Final time of simulation]
h = 0.1 {units: min; caption: Step; category: Time; min: 0.001; max: 0.1; step: 0.001} [Time step of simlulation]
h = 0.1 {units: min; caption: Step; category: Time; min: 0.001; max: 0.1; step: 0.001} [Time step of simulation]


#inits:
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/library/robertson.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#argument: t
start = 0 {units: sec; caption: Initial; category: Time; min: 0; max: 1} [Initial time of simulation]
finish = 40 {units: sec; caption: Final; category: Time; min: 2; max: 50} [Final time of simulation]
step = 0.01 {units: sec; caption: Step; category: Time; min: 0.01; max: 0.1} [Time step of simlulation]
step = 0.01 {units: sec; caption: Step; category: Time; min: 0.01; max: 0.1} [Time step of simulation]

#tolerance: 1e-7
2 changes: 1 addition & 1 deletion packages/DiffStudio/files/templates/extended.ivp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
#argument: t
start = 0 {caption: Initial; category: Time; min: 0; max: 10} [Initial time of simulation]
finish = 10 {caption: Final; category: Time; min: 10; max: 20} [Final time of simulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simlulation]
step = 0.01 {caption: Step; category: Time; min: 0.01; max: 0.1; step: 0.001} [Time step of simulation]

#tolerance: 5e-5
10 changes: 8 additions & 2 deletions packages/DiffStudio/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions packages/DiffStudio/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@datagrok/diff-studio",
"friendlyName": "Diff Studio",
"version": "1.2.1",
"version": "1.2.2",
"description": "WebAutoSolver tools for solving ODEs in a browser.",
"author": {
"name": "Viktor Makarichev",
Expand All @@ -21,7 +21,8 @@
"css-loader": "^6.10.0",
"datagrok-api": "^1.23.0",
"dayjs": "=1.11.10",
"style-loader": "^3.3.4"
"style-loader": "^3.3.4",
"@datagrok/diff-studio-tools": "../../../DiffStudioLib/ds-tools"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand Down Expand Up @@ -53,9 +54,7 @@
"canView": [
"All users"
],
"sources": [
"wasm/matrix-operations.js"
],
"sources": [],
"repository": {
"type": "git",
"url": "https://github.com/datagrok-ai/public.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/DiffStudio/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {getIVP, getScriptLines, getScriptParams, IVP, Input, SCRIPTING,
BRACE_OPEN, BRACE_CLOSE, BRACKET_OPEN, BRACKET_CLOSE, ANNOT_SEPAR,
CONTROL_SEP, STAGE_COL_NAME, ARG_INPUT_KEYS, DEFAULT_SOLVER_SETTINGS} from './scripting-tools';

import {CallbackAction, DEFAULT_OPTIONS} from './solver-tools/solver-defs';
import {CallbackAction, DEFAULT_OPTIONS} from './solver-tools';

import {unusedFileName, getTableFromLastRows, getInputsTable, getLookupsInfo, hasNaN, getCategoryWidget,
getReducedTable, closeWindows, getRecentModelsTable, getMyModelFiles, getEquationsFromFile,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Manager of callbacks

import {SolverOptions} from '../solver-defs';
import {SolverOptions} from '@datagrok/diff-studio-tools';
import {Callback} from './callback-base';
import {TimeCheckerCallback} from './time-checker-callback';
import {IterCheckerCallback} from './iter-checker-callback';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Callback} from './callback-base';
import {CallbackAction} from '../solver-defs';
import {CallbackAction} from '../solver-tools';

/** This callback terminates computations if the maximum iterations is exceeded */
export class IterCheckerCallback extends Callback {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Callback} from './callback-base';
import {CallbackAction} from '../solver-defs';
import {CallbackAction} from '../solver-tools';

/** This callback terminates computations if the maximum calculation time is exceeded */
export class TimeCheckerCallback extends Callback {
Expand Down
8 changes: 4 additions & 4 deletions packages/DiffStudio/src/demo-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as grok from 'datagrok-api/grok';
import * as ui from 'datagrok-api/ui';
import * as DG from 'datagrok-api/dg';

import {ros34prw} from './solver-tools/ros34prw-method';
import {solveDefault} from './solver-tools';
import '../css/app-styles.css';
import {LINK} from './ui-constants';

Expand Down Expand Up @@ -113,7 +113,7 @@ export function getBioreactorSim(t0: number, t1: number, h: number, FFox: number
'FKox(t)', 'MEA(t)', 'CO2(t)', 'yO2P(t)', 'CYST(t)', 'VL(t)'],
}; // odes

return ros34prw(odes);
return solveDefault(odes);
} // getBioreactorSim

/** Return dataframe with the PK-PD simulation */
Expand Down Expand Up @@ -157,7 +157,7 @@ export function getPkPdSim(dose: number, count: number, interval: number, KA: nu
solutionColNames: ['Depot', 'Central', 'Periferal', 'Effect'],
}; // odes

return ros34prw(odes);
return solveDefault(odes);
}; // oneStagePkPd

// solution dataframe
Expand Down Expand Up @@ -307,7 +307,7 @@ function getBallFlightTable(t1: number, velocity: number, angle: number, dB: num
solutionColNames: ['x', 'y', 'vx', 'vy'],
};

return ros34prw(odes);
return solveDefault(odes);
} // getBallFlightTable

/** Clip numeric table by min value of the specified column */
Expand Down
Loading

0 comments on commit 748624b

Please sign in to comment.