{"id":17495760,"url":"https://github.com/iraikov/salt","last_synced_at":"2026-01-05T19:12:45.842Z","repository":{"id":148366890,"uuid":"38016556","full_name":"iraikov/salt","owner":"iraikov","description":"Hybrid dynamical systems modeling.","archived":false,"fork":false,"pushed_at":"2020-08-01T22:26:54.000Z","size":434,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T16:28:25.162Z","etag":null,"topics":["chicken-scheme","chicken-scheme-eggs","differential-equation","dynamical","dynamical-systems","equation-based","hybrid-dynamical-system","modeling","neural","neuron","neuroscience","ode","scheme-language","simulation"],"latest_commit_sha":null,"homepage":null,"language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iraikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-06-24T23:26:39.000Z","updated_at":"2024-01-21T12:49:04.000Z","dependencies_parsed_at":"2023-05-19T21:30:19.282Z","dependency_job_id":null,"html_url":"https://github.com/iraikov/salt","commit_stats":{"total_commits":330,"total_committers":1,"mean_commits":330.0,"dds":0.0,"last_synced_commit":"ee85ddaeaa75eb340e488e85dfdd0ad39c5cf2f3"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fsalt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fsalt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fsalt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fsalt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iraikov","download_url":"https://codeload.github.com/iraikov/salt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245525803,"owners_count":20629832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chicken-scheme","chicken-scheme-eggs","differential-equation","dynamical","dynamical-systems","equation-based","hybrid-dynamical-system","modeling","neural","neuron","neuroscience","ode","scheme-language","simulation"],"created_at":"2024-10-19T14:28:02.010Z","updated_at":"2026-01-05T19:12:40.794Z","avatar_url":"https://github.com/iraikov.png","language":"Scheme","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# salt\n\nA [Chicken Scheme](http://www.call-cc.org/) library for equation-based\nmodeling and simulations.\n\n## Usage\n\nsalt [options...] [input files ...]\n\n## Introduction\n\n\nSALT is an implementation of a domain-specific language for\nequation-based model. This implementation follows the work of Tom\nShort and the Julia Sims.jl library\n(http:https://github.com/tshort/Sims.jl), which is in turn based on\nDavid Broman's MKL simulator and the work of George Giorgidze and\nHenrik Nilsson in functional hybrid modeling.  Following Sims.jl, a\nnodal formulation is used based on David Broman's thesis\n(http://www.bromans.com/david/publ/thesis-2010-david-broman.pdf) :\n\n```\nDavid Broman. Meta-Languages and Semantics for\nEquation-Based Modeling and Simulation. PhD thesis, Thesis No\n1333. Department of Computer and Information Science, Linköping\nUniversity, Sweden,; 2010. \n```\n\n\n\n\n## Library procedures\n\n```\nparse :: DECLARATIONS -\u003e ASTDECLS\n```\n\nParses equation declarations in the syntax described in the next\nsection, and returns an abstract syntax tree structure.\n\n```\nelaborate :: ASTDECLS -\u003e EQUATIION-SET\n```\n\nPerforms flattening of the given declarations and returns an equation set.\nThe main steps in flattening are:\n\n- Creation of a name resolution environment (parameters,fields,externals,constants,variables,functions).\n- Replacing of fixed initial values.\n- Flattening models and populating equation, definition, function lists.\n- Populating list of initials.\n- Populating event list from event and structural event definitions.\n- Handles structural events.\n\n```\nsimcreate :: EQUATION-SET -\u003e SIMRUNTIME\n```\n\nGiven an equation set, creates a simulation runtime representation.\n\n\n```\ncodegen-ODE :: SIMRUNTIME -\u003e ODE LIST\n```\n\nGiven a simulation runtime representation, creates an abstract code\nrepresentation aimed at ODE solvers.\n\n\n```\ncodegen-ODE/ML\n```    \n\nGiven a simulation runtime representation, creates a code\nrepresentation aimed at ODE solvers in the Standard ML language.\n\n## Model description language\n\n### Definitions\n\nDefinitions serve to define unknowns (state variables), parameters\n(constants during integration), and units of measurement.\n\n\n``` \n    (define millivolt = unit Potential (1e-3 * volt)) \n\n    (define Vinit = parameter (dim Potential) -65.0 * millivolt) \n\n    (define v = unknown (dim Potential) -65.0 * mV) \n```\n\n### Equations\n\nEquations serve to define differential and algebraic equations.\n\n```\n     ((der(u)) = (s - u) / tau)\n     ((s) = b * ((v - a) ^ 3))\n```\n\n\n### Events\n\n```\n     (event (v - Vthreshold)\n            ((v := Vreset))\n            )\n```\n\n\n## Examples\n\n```scheme\n\n;; Van der Pol oscillator\n(define vdp \n  (parse \n   `(\n     (define x = unknown -0.25)\n     (define y = unknown 1.0)\n     ((der(x)) = (1 - y ^ 2) * x - y )\n     ((der(y)) = x)\n     )\n   ))\n\n\n;; Izhikevich Fast Spiking neuron\n(define izhfs \n  (parse \n   `(\n     (define millivolt = unit Potential (1e-3 * volt))\n\n     (define Isyn = parameter (dim Current) 0.0 * nA)\n     (define Iext = parameter (dim Current) 400.0 * nA)\n\n     (define k     = parameter 1.0)\n     (define Vinit = parameter (dim Potential)  -65.0 * millivolt)\n     (define Vpeak = parameter (dim Potential)   25.0 * mV)\n     (define Vt    = parameter (dim Potential)  -55.0 * mV)\n     (define Vr    = parameter (dim Potential)  -40.0 * mV)\n     (define Vb    = parameter (dim Potential)  -55.0 * mV)\n     (define Cm    = parameter (dim Capacitance) 20.0 * uF)\n\n     (define FS_a = parameter  0.2)\n     (define FS_b = parameter  (dim Current)   0.025 * nA)\n     (define FS_c = parameter  (dim Potential) -45.0 * mV)\n     (define FS_U = parameter  (dim Current) FS_b * (Vinit / mV))\n\n     (define v  = unknown (dim Potential) -65.0 * mV)\n     (define u  = unknown (dim Current) FS_U)\n     (define s  = unknown (dim Current) 0.0 * nA)\n\n     ((der(v)) = (((k * (v - Vr) * (v - Vt) / millivolt) + (((- u) + Iext) * megaohm)) / Cm) / megaohm)\n     ((der(u)) = (FS_a * (s - u)) / ms)\n     ((s) = FS_b * ((v - Vb) / mV) ^ 3)\n\n\n     (event (v - Vpeak)\n            ((v := FS_c)\n             (u := u)\n             (s := s)\n             )\n            )\n     ))\n  )\n\n\n;; A routine to generate and compile Standard ML code \n(define (compile-model name model #!key (solver 'rk4b) (compile #f) (dir \"tests\"))\n  (pp model)\n\n  (define elab (elaborate model))\n  (print \"elaborate is done\")\n  (pp elab)\n\n  (define sim (simcreate elab))\n  (pp sim)\n  (pp (codegen-ODE sim solver))\n  (let* ((sml-path (make-pathname dir (string-append (-\u003estring name) \".sml\")))\n         (mlb-path (make-pathname dir (string-append (-\u003estring name) \"_run.mlb\")))\n         (port (open-output-file sml-path)))\n    (codegen-ODE/ML sim out: port solver: solver libs: '(interp))\n    (close-output-port port)\n    (if compile\n        (run (mlton -mlb-path-var ,(sprintf \"'SALT_HOME ~A'\" SALT-DIR)\n                    -mlb-path-var ,(sprintf \"'RK_LIB $(SALT_HOME)/sml-lib/rk'\")\n                    -mlb-path-var ,(sprintf \"'DYNAMICS_LIB $(SALT_HOME)/sml-lib/dynamics'\")\n                    ,mlb-path))))\n\n)\n\n(compile-model 'vdp vdp)\n(compile-model 'izhfs izhfs)\n\n\n```\n\n\n## Version history\n\n- 0.22-0.28 : Various refactorings in support of CHICKEN 5\n- 0.21 : Added step size controller\n- 0.20 : Support for precise event time interpolation and adaptive solvers\n- 0.5 : Support for using assigned quantities in external init equations \n- 0.1 : Initial release\n\n## License\n\n\u003e\n\u003e Copyright 2015-2020 Ivan Raikov\n\u003e \n\u003e This program is free software: you can redistribute it and/or modify\n\u003e it under the terms of the GNU General Public License as published by\n\u003e the Free Software Foundation, either version 3 of the License, or (at\n\u003e your option) any later version.\n\u003e \n\u003e This program is distributed in the hope that it will be useful, but\n\u003e WITHOUT ANY WARRANTY; without even the implied warranty of\n\u003e MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n\u003e General Public License for more details.\n\u003e \n\u003e A full copy of the GPL license can be found at\n\u003e \u003chttp://www.gnu.org/licenses/\u003e.\n\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firaikov%2Fsalt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firaikov%2Fsalt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firaikov%2Fsalt/lists"}