Repository navigation
New Features
-
Julia builder (experimental). The new pysd.translate_to_julia() translates Vensim and XMILE models to Julia, to run them with PySD.jl and SciML’s solvers. Translated models need PySD.jl 0.14.0. See Julia Builder. (@rogersamso)
-
Two backends. backend="dsl" (the default) writes the model in PySD.jl’s language for models, to read and edit as Julia code. backend="mtk" writes a ModelingToolkit.jl system, for symbolic work on the model.
-
DSL backend output: one file per view (split_views=True), titled with the view’s name. Every variable is declared with its name as written in the model, its unit, its description and its limits. The output also holds the subscript ranges as dimensions, the Excel sheets the model reads, the units Unitful.jl doesn’t know, and names.tsv with Vensim’s names. The folder is a Julia package, so Julia saves the compiled model (@precompile_model) and later sessions load it in seconds. PySD.jl adds derivatives and uncertainties through a run (ForwardDiff.jl, Measurements.jl), any SciML ODE solver (run_model(m, solver), ODEProblem(m)), results as tables (DataFrame(r), DimStack(r)), new constants, lookups and data between runs, and a web page to explore a model (PySDExplorer).
-
MTK backend output: a ModelingToolkit System (ModelingToolkit 10 or 11, with Symbolics 6 or 7). The results are written to NetCDF, and DATA variables can come from another model’s results (nc_data_files) or .tab files (tab_data_files). External data can be written to a JSON file read at start-up (data_format="json") instead of reading Excel at run time.
-
Coverage of Vensim’s functions and the Python builder’s semantics: stocks, lookups, GET XLS/GET DIRECT data, constants, lookups and subscripts (.xlsx, .xls and delimited text files), all the delays, smooths, TREND, FORECAST, SAMPLE IF TRUE, INITIAL, ACTIVE INITIAL, the RANDOM functions, the VECTOR functions, ALLOCATE AVAILABLE and ALLOCATE BY PRIORITY, GET TIME VALUE, INVERT MATRIX and the maths, logic and array functions. It also covers subscripts in any number of dimensions, with subranges, mapping, :EXCEPT: and variables defined in parts, plus macros (expanded in place) and time settings that change during the run. A function the builder doesn’t translate stops the model when it is evaluated, with an error naming it, as in the Python builder.
-
Results as in the Python builder. The Python pathway’s test models match Vensim’s output with the DSL backend (186 of 186) and the MTK backend (185; one rounding test differs in the last digit). The maths functions give Python PySD’s last digits (C maths library, numpy’s order of summation, LAPACK’s inverse) and NaN outside their domain.
-
Any solver. Fixed delays, SAMPLE IF TRUE and switches on Time (STEP, PULSE, …) are exact at the model’s ticks with any SciML solver, and RANDOM functions draw once per tick, seeded, the same in every run. A run warns once about equations written for Euler steps of TIME STEP. Euler steps of TIME STEP (the default) match Vensim.
-
Known limitations, listed in Julia Builder: no step-by-step runs, no set_components during a run, no export/import_ of the state, no select_submodel, and macros with several outputs can’t be parsed.
-
Bug fixes
-
Fix setting parmas with dimensions (issue #484). (@enekomartinmartinez)
-
Fix Model.state / Model.ddt() failing with “could not broadcast” when stock states share their leading dimensions but differ after that, e.g. a (3, 2) stock next to a 3D stock defined element by element on its last dimension (issue #497). (@rogersamso)
-
No deprecation warnings with pandas 3.1: results are indexed by time without inplace, and spreadsheets are read with an explicit engine (openpyxl for .xlsx/.xlsm, as before; calamine for .xls when it’s installed, as xlrd is deprecated). (@rogersamso)
Documentation
- New page Julia Builder: installing Julia and PySD.jl, each backend, external data, choosing a solver, the comparison with the Python builder and the limitations. (@rogersamso)
Internal Changes
-
The pysd/builders/julia/PySD.jl submodule now points at https://github.com/SDXorg/PySD.jl over HTTPS, so it clones without SSH keys, at PySD.jl 0.14.1 (the same code as 0.14.0, released from SDXorg). Existing checkouts run git submodule sync. (@rogersamso)
-
The abstract model keeps the views’ names as written in the model (AbstractSection.view_titles, optional), for builders that show them. (@rogersamso)
-
Julia builder tests: the translation tests, and reference tests that run every test model of the Python integration pathways with both Julia backends and compare them with the reference outputs. CI runs them with coverage: all models with the DSL backend, a subset with the MTK backend, and the tests of fixed delays, samples, switches and RANDOM with any solver. (@rogersamso)
-
CI: the Python tests run on Ubuntu 24.04 (ubuntu-latest is now Ubuntu 26.04, which has no Python 3.9); the link check skips nbviewer’s links, which answer 202 or 503 while a notebook renders; the random statistics tests are seeded (issue #507), so they no longer fail now and then. (@rogersamso)