# Modelling & Simulations

**URL:** https://discourse.julialang.org/c/domain/models/21.md?page=16

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 17

---

## [Pattern for splitting the state vector over multiple objects](https://discourse.julialang.org/t/pattern-for-splitting-the-state-vector-over-multiple-objects/121072)

<div class="topic-metadata">

**Author:** [@evan-wehi](https://discourse.julialang.org/u/evan-wehi)\
**Replies:** 0\
**Last updated:** [October 8, 2024, 11:28pm UTC](https://discourse.julialang.org/t/pattern-for-splitting-the-state-vector-over-multiple-objects/121072 "2024-10-08T23:28:31Z")

</div>

I’m writing a library that will be used to test ideas in immune cell population dynamics. A characteristic of this biology is that the population size, and hence the state vector length, can vary by orders of magnitude o…

---

## [Unobservable linearized model in ModelPredictiveControl.jl](https://discourse.julialang.org/t/unobservable-linearized-model-in-modelpredictivecontrol-jl/121052)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 7\
**Last updated:** [October 8, 2024, 3:57pm UTC](https://discourse.julialang.org/t/unobservable-linearized-model-in-modelpredictivecontrol-jl/121052 "2024-10-08T15:57:25Z")

</div>

I have a model that I am trying to linearize around x\_0 in order to use a linear MPC in ModelPredictiveControl.jl. println("linearize") linmodel = ModelPredictiveControl.linearize(model; x=x\_0) println("sim") u = \[100,…

---

## [Accuracy of TRBDF2 vs matlab's ode23tb?](https://discourse.julialang.org/t/accuracy-of-trbdf2-vs-matlabs-ode23tb/120801)

<div class="topic-metadata">

**Author:** [@pulk\_jain](https://discourse.julialang.org/u/pulk_jain)\
**Replies:** 15\
**Last updated:** [October 8, 2024, 10:17am UTC](https://discourse.julialang.org/t/accuracy-of-trbdf2-vs-matlabs-ode23tb/120801 "2024-10-08T10:17:52Z")

</div>

I noticed that trbdf2 solved my system the fastest but was much less accurate than matlab’s ode23tb. Some derivatives that should be zero are somehow non-zero even 100s of steps later. By this I mean, du\[m:n\]=0 from sol…

---

## [Simple Model using ModelingToolkit and Clapeyron failing](https://discourse.julialang.org/t/simple-model-using-modelingtoolkit-and-clapeyron-failing/120874)

<div class="topic-metadata">

**Author:** [@JarodMcCormick](https://discourse.julialang.org/u/JarodMcCormick)\
**Replies:** 5\
**Last updated:** [October 7, 2024, 11:57pm UTC](https://discourse.julialang.org/t/simple-model-using-modelingtoolkit-and-clapeyron-failing/120874 "2024-10-07T23:57:01Z")

</div>

I’ve been working on implementing some simple models utilizing both ModelingToolkit and Clapeyron. I put together this simple model of a generic compressor: using ModelingToolkit, NonlinearSolve using Clapeyron model =…

---

## [I find R's DSL for defining regression a bit mind blowing. GLM.jl and other have tried to "adopt" them. What would an ideal DSL for defining regression look like in Julia?](https://discourse.julialang.org/t/i-find-rs-dsl-for-defining-regression-a-bit-mind-blowing-glm-jl-and-other-have-tried-to-adopt-them-what-would-an-ideal-dsl-for-defining-regression-look-like-in-julia/120786)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 10\
**Last updated:** [October 4, 2024, 5:44pm UTC](https://discourse.julialang.org/t/i-find-rs-dsl-for-defining-regression-a-bit-mind-blowing-glm-jl-and-other-have-tried-to-adopt-them-what-would-an-ideal-dsl-for-defining-regression-look-like-in-julia/120786 "2024-10-04T17:44:45Z")

</div>

In R glm(x~-1+y+z) fits a GLM model without an intercept and using y and z as data, so there will be two coefficients from the model fit. I think GLM.jl has adopted the ~ DSL. But I’ve always found R’s DSL on regression…

---

## [Turing.jl Memory Issues](https://discourse.julialang.org/t/turing-jl-memory-issues/120925)

<div class="topic-metadata">

**Author:** [@willm](https://discourse.julialang.org/u/willm)\
**Replies:** 0\
**Last updated:** [October 4, 2024, 3:45pm UTC](https://discourse.julialang.org/t/turing-jl-memory-issues/120925 "2024-10-04T15:45:44Z")

</div>

Hi All, I designed a relatively simple hierarchical model for my research. To fit the model I initially wanted to use MCMC (NUTS). The other researchers in the lab tend to use R, so I started with rstan. Rstan worked pe…

---

## [Error on PEtab related to SciMLSensitivity package](https://discourse.julialang.org/t/error-on-petab-related-to-scimlsensitivity-package/120871)

<div class="topic-metadata">

**Author:** [@Nick1](https://discourse.julialang.org/u/Nick1)\
**Replies:** 0\
**Last updated:** [October 3, 2024, 9:19pm UTC](https://discourse.julialang.org/t/error-on-petab-related-to-scimlsensitivity-package/120871 "2024-10-03T21:19:59Z")

</div>

Hi, I am running a parameter estimation on PEtab and I get the following error when I use InterpolatingAdjoint(autojacvec = ReverseDiffVJP(true)) or InterpolatingAdjoint(autojacvec = EnzymeVJP())) type FakeIntegrator …

---

## [Why does GLM.jl fail to fit my logistic regression model but scikit learn and R has no issues? I think I found the reason](https://discourse.julialang.org/t/why-does-glm-jl-fail-to-fit-my-logistic-regression-model-but-scikit-learn-and-r-has-no-issues-i-think-i-found-the-reason/118553)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 5\
**Last updated:** [October 1, 2024, 2:43pm UTC](https://discourse.julialang.org/t/why-does-glm-jl-fail-to-fit-my-logistic-regression-model-but-scikit-learn-and-r-has-no-issues-i-think-i-found-the-reason/118553 "2024-10-01T14:43:54Z")

</div>

I have been trying to use GLM.jl to fit some logistic regression models and the fit failed. I don’t remember the exact error message but it was something about singularity. That annoyed me for a couple of years but I ne…

---

## [My system is overdetermined. Are there tools to find the culprit equation?](https://discourse.julialang.org/t/my-system-is-overdetermined-are-there-tools-to-find-the-culprit-equation/119947)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 4\
**Last updated:** [October 1, 2024, 1:29pm UTC](https://discourse.julialang.org/t/my-system-is-overdetermined-are-there-tools-to-find-the-culprit-equation/119947 "2024-10-01T13:29:57Z")

</div>

Recently I’ve updated a very big project to the latest version of MTK. I now get this warning: ┌ Warning: Initialization system is overdetermined. 1 equations for 0 unknowns. Initialization will default to using least …

---

## [How to make ODESystem with DataInterpolations latex output more readable?](https://discourse.julialang.org/t/how-to-make-odesystem-with-datainterpolations-latex-output-more-readable/120700)

<div class="topic-metadata">

**Author:** [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Replies:** 7\
**Last updated:** [September 30, 2024, 9:57am UTC](https://discourse.julialang.org/t/how-to-make-odesystem-with-datainterpolations-latex-output-more-readable/120700 "2024-09-30T09:57:03Z")

</div>

I have defined my model in ModelingToolkit.jl as such: # define model parameters @parameters Ci Ria Aw # define sub-model components @named C\_i = Capacitor(C=Ci) # thermal capacity of interior @named R\_ia = Resistor…

---

## [SymbolicRegression -- two simple questions](https://discourse.julialang.org/t/symbolicregression-two-simple-questions/119908)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 8:09am UTC](https://discourse.julialang.org/t/symbolicregression-two-simple-questions/119908 "2024-09-29T08:09:24Z")

</div>

I figured out the answers.

---

## [Trying to serialize runtime generated function and MTK ODESystem](https://discourse.julialang.org/t/trying-to-serialize-runtime-generated-function-and-mtk-odesystem/119961)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 5\
**Last updated:** [September 28, 2024, 11:52am UTC](https://discourse.julialang.org/t/trying-to-serialize-runtime-generated-function-and-mtk-odesystem/119961 "2024-09-28T11:52:37Z")

</div>

I have a system with around 1500 equations. It takes a long time to run the following function, so I want to serialize and deserialize f\_ip, dvs, psym and io\_sys so I can use them between sessions. (\_, f\_ip), dvs, psym,…

---

## [Switching stiff solvers when one is unstable](https://discourse.julialang.org/t/switching-stiff-solvers-when-one-is-unstable/119609)

<div class="topic-metadata">

**Author:** [@pulk\_jain](https://discourse.julialang.org/u/pulk_jain)\
**Replies:** 15\
**Last updated:** [September 25, 2024, 6:03pm UTC](https://discourse.julialang.org/t/switching-stiff-solvers-when-one-is-unstable/119609 "2024-09-25T18:03:59Z")

</div>

I am solving an ode (~40 variables) for many different initial conditions. Mostly TRBDF2 gives fastest results. But sometimes it shows that the system is unstable. In such cases I switched to Rodas5P or RadauIIA5 which g…

---

## [Is ModelingToolkit.getdefault deprecated?](https://discourse.julialang.org/t/is-modelingtoolkit-getdefault-deprecated/119748)

<div class="topic-metadata">

**Author:** [@kraqbi](https://discourse.julialang.org/u/kraqbi)\
**Replies:** 3\
**Last updated:** [September 25, 2024, 10:59am UTC](https://discourse.julialang.org/t/is-modelingtoolkit-getdefault-deprecated/119748 "2024-09-25T10:59:25Z")

</div>

Hello, In ModelingToolkit, I find it usefull to have a function to access the default values of parameters. It took me some times to find the function ModelingToolkit.getdefault() I could not find it in the tutorial a…

---

## [Initial and final affect for timed periodic event in ModelingToolkeit](https://discourse.julialang.org/t/initial-and-final-affect-for-timed-periodic-event-in-modelingtoolkeit/119849)

<div class="topic-metadata">

**Author:** [@jmaedler](https://discourse.julialang.org/u/jmaedler)\
**Replies:** 3\
**Last updated:** [September 25, 2024, 9:57am UTC](https://discourse.julialang.org/t/initial-and-final-affect-for-timed-periodic-event-in-modelingtoolkeit/119849 "2024-09-25T09:57:30Z")

</div>

Hi everyone, I am working on an adapter for virtual commissioning using ModelingToolkit.jl. More specifically, I use discrete callbacks (timed → periodic) to read inputs from and write output to a soft-controller. Is th…

---

## [Known disturbances in JuliaSimControl MPC](https://discourse.julialang.org/t/known-disturbances-in-juliasimcontrol-mpc/119810)

<div class="topic-metadata">

**Author:** [@bertrand](https://discourse.julialang.org/u/bertrand)\
**Replies:** 3\
**Last updated:** [September 25, 2024, 8:00am UTC](https://discourse.julialang.org/t/known-disturbances-in-juliasimcontrol-mpc/119810 "2024-09-25T08:00:49Z")

</div>

Hi, I’m writing an MPC with known external disturbances using JuliaSimControl. I’m currently passing the known disturbances w as part of the parameter vector into the dynamics function, i.e. function dynamics(x, u, p,…

---

## [How to loop through all the species and write additional reactions based on that](https://discourse.julialang.org/t/how-to-loop-through-all-the-species-and-write-additional-reactions-based-on-that/115438)

<div class="topic-metadata">

**Author:** [@Wenzhe\_Ma](https://discourse.julialang.org/u/Wenzhe_Ma)\
**Replies:** 2\
**Last updated:** [September 24, 2024, 7:52pm UTC](https://discourse.julialang.org/t/how-to-loop-through-all-the-species-and-write-additional-reactions-based-on-that/115438 "2024-09-24T19:52:15Z")

</div>

What I want to do is to build a few models based on ReactionSystem in Catalyst.jl, named as m1, m2… Each of them has some common species s1, s2… I want to have a function with m1, m2 as arguments, which will automaticall…

---

## [ModelPredictiveControl.jl vs JuliaSimControl](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 10\
**Last updated:** [September 24, 2024, 6:52am UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496 "2024-09-24T06:52:02Z")

</div>

What would be the advantages / disadvantages of using ModelPredictiveControl.jl over JuliaSimControl? I am trying to decide which one to use, and these were the first two packages I found.

---

## [Next\_step! resulting in slightly different results for the same inputs](https://discourse.julialang.org/t/next-step-resulting-in-slightly-different-results-for-the-same-inputs/119683)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 13\
**Last updated:** [September 23, 2024, 12:51pm UTC](https://discourse.julialang.org/t/next-step-resulting-in-slightly-different-results-for-the-same-inputs/119683 "2024-09-23T12:51:36Z")

</div>

I am using the following code to initialize an MTK model: dt = 0.05 tspan = (0.0, dt) solver = CVODE\_BDF() integrator = OrdinaryDiffEqCore.init(prob, solver; dt, abstol=0.0006, reltol=0.001, save\_on=false, dtmin=1e-…

---

## [MTK... linearization of zero dynamics](https://discourse.julialang.org/t/mtk-linearization-of-zero-dynamics/119546)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 7\
**Last updated:** [September 23, 2024, 4:19am UTC](https://discourse.julialang.org/t/mtk-linearization-of-zero-dynamics/119546 "2024-09-23T04:19:50Z")

</div>

\[What is the trick of hiding/folding/collapsing code blocks?\] Consider the well-known 4-tank model by K.H. Johansson: which has been designed to illustrate multivariable zero dynamics. The system has 2 control inputs…

---

## [Set defaults for a part of Symbolics.Arr](https://discourse.julialang.org/t/set-defaults-for-a-part-of-symbolics-arr/119678)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 1\
**Last updated:** [September 21, 2024, 3:51pm UTC](https://discourse.julialang.org/t/set-defaults-for-a-part-of-symbolics-arr/119678 "2024-09-21T15:51:30Z")

</div>

Is it possible to set defaults for only a part of a Symbolics.Arr when defining a model? So can I for example only set defaults for pos\[:, 4:8\], while not setting defaults for pos\[:, 1:3\] and pos\[:, 9:10\]? @variables …

---

## [ModelingToolkit 9.39 is broken, 9.40.1 works well](https://discourse.julialang.org/t/modelingtoolkit-9-39-is-broken-9-40-1-works-well/119670)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [September 21, 2024, 2:40pm UTC](https://discourse.julialang.org/t/modelingtoolkit-9-39-is-broken-9-40-1-works-well/119670 "2024-09-21T14:40:03Z")

</div>

Steps to reproduce: git clone https://github.com/ufechner7/Tethers.jl/ cd Tethers.jl git checkout broken julia --project and then in Julia using Pkg Pkg.update() include("src/Tether\_01.jl") This gives the following …

---

## [MTK - struggling with initialization](https://discourse.julialang.org/t/mtk-struggling-with-initialization/119643)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 5\
**Last updated:** [September 21, 2024, 10:38am UTC](https://discourse.julialang.org/t/mtk-struggling-with-initialization/119643 "2024-09-21T10:38:11Z")

</div>

I’m converting a model from Modelica to ModelingToolkit \[MTK\]. The Modelica-version works fine using OpenModelica, but the ModelingToolkit has problems wrt. initialization. Here is the Julia+MTK code that is equivalent …

---

## [ModelingToolkit -- possible to do "numeric" linearization?](https://discourse.julialang.org/t/modelingtoolkit-possible-to-do-numeric-linearization/118933)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 6\
**Last updated:** [September 2, 2024, 12:00pm UTC](https://discourse.julialang.org/t/modelingtoolkit-possible-to-do-numeric-linearization/118933 "2024-09-02T12:00:22Z")

</div>

I’ve had problems doing linearization with ModelingToolkit \[MTK\] for “complicated” models since May (due to bugs?). I’m wondering whether it is possible to “massage” the MTK model into a form that allows for “old-fashion…

---

## [How to determine distribution of real-world data and then apply same distribution to model with Agents.jl](https://discourse.julialang.org/t/how-to-determine-distribution-of-real-world-data-and-then-apply-same-distribution-to-model-with-agents-jl/119617)

<div class="topic-metadata">

**Author:** [@tfranks](https://discourse.julialang.org/u/tfranks)\
**Replies:** 6\
**Last updated:** [September 20, 2024, 12:28pm UTC](https://discourse.julialang.org/t/how-to-determine-distribution-of-real-world-data-and-then-apply-same-distribution-to-model-with-agents-jl/119617 "2024-09-20T12:28:20Z")

</div>

Hello, Goal: trying to determine distribution from 4Q22 data set and apply the same distribution to a network model using Agents.jl. See 4Q22 data on xy-grid. Background: I had an earlier post on Discourse where …

---

## [Help needed for a simple static sum](https://discourse.julialang.org/t/help-needed-for-a-simple-static-sum/99744)

<div class="topic-metadata">

**Author:** [@francis-gagnon](https://discourse.julialang.org/u/francis-gagnon)\
**Replies:** 6\
**Last updated:** [September 20, 2024, 7:52am UTC](https://discourse.julialang.org/t/help-needed-for-a-simple-static-sum/99744 "2024-09-20T07:52:02Z")

</div>

Hi, I’m learning ModelingToolkit.jl and it’s my first experience with acausal modeling. I’m working on modeling a mining circuit. My flow variable is a mass flowrate in t/h (tonnage). I’m starting with a simple example,…

---

## [An easy way to view system-state when a differential equation solver encounters a warning](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944)

<div class="topic-metadata">

**Author:** [@VBtheHun](https://discourse.julialang.org/u/VBtheHun)\
**Replies:** 4\
**Last updated:** [September 19, 2024, 3:47pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944 "2024-09-19T15:47:16Z")

</div>

I am trying to solve a system of differential equations where I run into a larger Maxiters needed warning. I suspect that my model has been ill-specified as this appears only for certain parameter values. To figure this …

---

## [ModelingToolkit -- limits to parameter blocks, etc.?](https://discourse.julialang.org/t/modelingtoolkit-limits-to-parameter-blocks-etc/119608)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 0\
**Last updated:** [September 19, 2024, 2:36pm UTC](https://discourse.julialang.org/t/modelingtoolkit-limits-to-parameter-blocks-etc/119608 "2024-09-19T14:36:39Z")

</div>

Assume I create a ModelingToolkit “instantiator”, say: @mtkmodel Tank begin @structural\_parameters case = :std @parameters begin ... end @variables begin ... end @equations begin ... end end Questions: …

---

## [MTK simulation allocation free?](https://discourse.julialang.org/t/mtk-simulation-allocation-free/119581)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 1\
**Last updated:** [September 19, 2024, 4:22am UTC](https://discourse.julialang.org/t/mtk-simulation-allocation-free/119581 "2024-09-19T04:22:20Z")

</div>

Is it possible to simulate an MTK model allocation-free? The task is to run a simulation in a control loop with 1ms update interval in real-time.

---

## [When is strip\_solution useful?](https://discourse.julialang.org/t/when-is-strip-solution-useful/119517)

<div class="topic-metadata">

**Author:** [@pulk\_jain](https://discourse.julialang.org/u/pulk_jain)\
**Replies:** 6\
**Last updated:** [September 18, 2024, 2:21pm UTC](https://discourse.julialang.org/t/when-is-strip-solution-useful/119517 "2024-09-18T14:21:38Z")

</div>

I was just curious about the use case for strip\_solution. I noticed that my files were too big when saving whole ode solutions using jld2 and whenever I loaded back the file using jldopen, the REPL was riddled with reco…

[Previous page](https://discourse.julialang.org/c/domain/models/21.md?page=15)

[Next page](https://discourse.julialang.org/c/domain/models/21.md?page=17)
