# Modelling & Simulations

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

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

**Page:** 56

---

## [Mutation of integrator](https://discourse.julialang.org/t/mutation-of-integrator/60545)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 1\
**Last updated:** [May 5, 2021, 6:33am UTC](https://discourse.julialang.org/t/mutation-of-integrator/60545 "2021-05-05T06:33:19Z")

</div>

Suppose that I use an explicit scheme with fixed time-stepping to integrate an ODE, and I am not interested in interpolations of any sort. Is it ok to change directly the right-hand-side function f, the state u and the …

---

## [Better way to solve jacobian dependent differential equation](https://discourse.julialang.org/t/better-way-to-solve-jacobian-dependent-differential-equation/60259)

<div class="topic-metadata">

**Author:** [@willian](https://discourse.julialang.org/u/willian)\
**Replies:** 4\
**Last updated:** [May 2, 2021, 3:18pm UTC](https://discourse.julialang.org/t/better-way-to-solve-jacobian-dependent-differential-equation/60259 "2021-05-02T15:18:47Z")

</div>

What is the best way to solve the following differential equations ? I mean, I could solve the first equation x(t) alone and use the solutions to run the solver again and find P(t). I would like to know if there is a…

---

## [EnsembleThreads slower than EnsembleSerial or EnsembleDistributed](https://discourse.julialang.org/t/ensemblethreads-slower-than-ensembleserial-or-ensembledistributed/59511)

<div class="topic-metadata">

**Author:** [@ograsdijk](https://discourse.julialang.org/u/ograsdijk)\
**Replies:** 3\
**Last updated:** [April 29, 2021, 3:09pm UTC](https://discourse.julialang.org/t/ensemblethreads-slower-than-ensembleserial-or-ensembledistributed/59511 "2021-04-29T15:09:43Z")

</div>

For my ode system EnsembleThreads (6 threads) is slower than either EnsembleSerial or EnsembleDistributed (6 processes). My specs are Windows 10 and a 6 core i8700k with 32Gb ram and running Julia V1.6. I’m running opti…

---

## [Adaptive step-size algorithm for stiff SDE solvers in StochasticDiffEq.jl](https://discourse.julialang.org/t/adaptive-step-size-algorithm-for-stiff-sde-solvers-in-stochasticdiffeq-jl/59785)

<div class="topic-metadata">

**Author:** [@alvestad10](https://discourse.julialang.org/u/alvestad10)\
**Replies:** 2\
**Last updated:** [April 29, 2021, 1:57pm UTC](https://discourse.julialang.org/t/adaptive-step-size-algorithm-for-stiff-sde-solvers-in-stochasticdiffeq-jl/59785 "2021-04-29T13:57:56Z")

</div>

Could someone point me in the direction of where to find info on how the time-stepping method for stiff SDE solvers is implemented? I am mainly interested in how the ImplicitEM solver does the adaptive stepsize control, …

---

## [ModelingToolkit.jl ODESystems with a forcing function: how to autodiff?](https://discourse.julialang.org/t/modelingtoolkit-jl-odesystems-with-a-forcing-function-how-to-autodiff/58823)

<div class="topic-metadata">

**Author:** [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Replies:** 2\
**Last updated:** [April 28, 2021, 3:54pm UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-odesystems-with-a-forcing-function-how-to-autodiff/58823 "2021-04-28T15:54:08Z")

</div>

Hi! Lots of differential equations models incorporate an external input function (e.g. a control system doing reference tracking). When I build models of this form in ModelingToolkit.jl, they don’t seem to be differenti…

---

## [Error in PDE Example](https://discourse.julialang.org/t/error-in-pde-example/60040)

<div class="topic-metadata">

**Author:** [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Replies:** 4\
**Last updated:** [April 27, 2021, 1:31pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040 "2021-04-27T13:31:21Z")

</div>

I’m trying to follow the example for solving the heat equation PDE from the DiffEqOperators page, but I am running into an error in the discretization step. The code is using OrdinaryDiffEq, ModelingToolkit, DiffEqOpera…

---

## [Using DynamicHMC to calculate paths of Quantum Simple Harmonic Oscillator](https://discourse.julialang.org/t/using-dynamichmc-to-calculate-paths-of-quantum-simple-harmonic-oscillator/60009)

<div class="topic-metadata">

**Author:** [@jdhooghe](https://discourse.julialang.org/u/jdhooghe)\
**Replies:** 2\
**Last updated:** [April 26, 2021, 11:54am UTC](https://discourse.julialang.org/t/using-dynamichmc-to-calculate-paths-of-quantum-simple-harmonic-oscillator/60009 "2021-04-26T11:54:33Z")

</div>

Hello, I need some help getting sampling to work using DynamicHMC. The model thus far is: using LogDensityProblems using Statistics using Distributions using UnPack using TransformVariables using DynamicHMC using MCMCDi…

---

## [\[DifferentialEquations.jl\] Can't brodcast time gradients into dualcache](https://discourse.julialang.org/t/differentialequations-jl-cant-brodcast-time-gradients-into-dualcache/60007)

<div class="topic-metadata">

**Author:** [@MatFi](https://discourse.julialang.org/u/MatFi)\
**Replies:** 4\
**Last updated:** [April 25, 2021, 10:05pm UTC](https://discourse.julialang.org/t/differentialequations-jl-cant-brodcast-time-gradients-into-dualcache/60007 "2021-04-25T22:05:38Z")

</div>

I need to cache some data during the evaluation of an ODE. However the time gradients make it a bit difficult to me and cuse a MethodError. MWE using DiffEqBase, OrdinaryDiffEq struct rb{T} B::T end rb(n::Integer)…

---

## [Problems with stiff solvers for MTK model](https://discourse.julialang.org/t/problems-with-stiff-solvers-for-mtk-model/59658)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 4\
**Last updated:** [April 25, 2021, 8:14am UTC](https://discourse.julialang.org/t/problems-with-stiff-solvers-for-mtk-model/59658 "2021-04-25T08:14:57Z")

</div>

I have a MTK model (copy paste from docs): using ModelingToolkit, Plots, DifferentialEquations @parameters t function Pin(;name) @variables v(t) i(t) ODESystem(Equation\[\], t, \[v, i\], \[\], name=name, defaults=\[v…

---

## [Acausal modeling with ModelingToolkit.jl: Why does structural\_simplify not eliminate one more variable?](https://discourse.julialang.org/t/acausal-modeling-with-modelingtoolkit-jl-why-does-structural-simplify-not-eliminate-one-more-variable/59474)

<div class="topic-metadata">

**Author:** [@frnkcg](https://discourse.julialang.org/u/frnkcg)\
**Replies:** 10\
**Last updated:** [April 25, 2021, 5:28am UTC](https://discourse.julialang.org/t/acausal-modeling-with-modelingtoolkit-jl-why-does-structural-simplify-not-eliminate-one-more-variable/59474 "2021-04-25T05:28:07Z")

</div>

I know a little bit of Modelica so when I recently encountered ModelingToolkit.jl, I was excited to try it out. But I ran into some unexpected problems even for a very simple model. I created an acausal model of a simpl…

---

## [PDE Errors](https://discourse.julialang.org/t/pde-errors/59707)

<div class="topic-metadata">

**Author:** [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Replies:** 6\
**Last updated:** [April 22, 2021, 4:36pm UTC](https://discourse.julialang.org/t/pde-errors/59707 "2021-04-22T16:36:34Z")

</div>

I am trying to reproduce this solution to a PDE (Mathematica code located beneath tweet). https://twitter.com/matthen2/status/1378820454589292550?s=21 This is my attempt thus far. Note that with my domains I actually h…

---

## [Nested vector variables in ODE problem definitions](https://discourse.julialang.org/t/nested-vector-variables-in-ode-problem-definitions/33417)

<div class="topic-metadata">

**Author:** [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Replies:** 6\
**Last updated:** [April 22, 2021, 1:05pm UTC](https://discourse.julialang.org/t/nested-vector-variables-in-ode-problem-definitions/33417 "2021-04-22T13:05:32Z")

</div>

I am trying to define an ODE in which the state variables are nested in arrays. Here is a toy example: using DifferentialEquations function f!(du, u, p, t) du\[1\] = u\[1\] - u\[2\]\[1\] du\[2\] .= -5 \* u\[2\] return n…

---

## [Periodic boundary conditions for PDE system using ModellingToolkit and DiffEqBase](https://discourse.julialang.org/t/periodic-boundary-conditions-for-pde-system-using-modellingtoolkit-and-diffeqbase/51827)

<div class="topic-metadata">

**Author:** [@archermarx](https://discourse.julialang.org/u/archermarx)\
**Replies:** 6\
**Last updated:** [April 22, 2021, 5:56am UTC](https://discourse.julialang.org/t/periodic-boundary-conditions-for-pde-system-using-modellingtoolkit-and-diffeqbase/51827 "2021-04-22T05:56:28Z")

</div>

I’m working with ModellingToolkit and DiffEqOperators to solve a set of PDEs, and I wanted to test out a simpler problem before I jumped into a more complicated problem. I followed the heat equation example and that work…

---

## [OrdinaryDiffEq: unexpected results in DEDataArray](https://discourse.julialang.org/t/ordinarydiffeq-unexpected-results-in-dedataarray/59282)

<div class="topic-metadata">

**Author:** [@AlexS12](https://discourse.julialang.org/u/AlexS12)\
**Replies:** 10\
**Last updated:** [April 21, 2021, 2:29pm UTC](https://discourse.julialang.org/t/ordinarydiffeq-unexpected-results-in-dedataarray/59282 "2021-04-21T14:29:26Z")

</div>

I am trying to solve a ODE using a DEDataVector to pass and store parameters that come from evaluating functions taking the state vector as argument. After reading the documentation I expected to obtain the value of the …

---

## [White noise for 'SDEs with diagonal noise'](https://discourse.julialang.org/t/white-noise-for-sdes-with-diagonal-noise/59695)

<div class="topic-metadata">

**Author:** [@Frederic\_Gilt](https://discourse.julialang.org/u/Frederic_Gilt)\
**Replies:** 10\
**Last updated:** [April 21, 2021, 12:55pm UTC](https://discourse.julialang.org/t/white-noise-for-sdes-with-diagonal-noise/59695 "2021-04-21T12:55:02Z")

</div>

dear all, I have a SDEs with a stochastic part as a white noise k\*N(0,1). Time step is ‘dt’ Following explanations here I don’t get why the white noise is N(0,dt) and not N(0,1/dt), which seems consitent with my resul…

---

## [Solve a routine economics PDE from an HJB w/ ModelingToolkit](https://discourse.julialang.org/t/solve-a-routine-economics-pde-from-an-hjb-w-modelingtoolkit/49718)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 33\
**Last updated:** [April 21, 2021, 5:29am UTC](https://discourse.julialang.org/t/solve-a-routine-economics-pde-from-an-hjb-w-modelingtoolkit/49718 "2021-04-21T05:29:10Z")

</div>

Consider a routine continuous time optimization problem from economics: V(t,a\_{t}) := \\max \\int\_{\\tau=t}^{\\tau = T} e^{-\\rho (\\tau -t)} u(c\_{\\tau})d\\tau \\text{ s.t. } \\dot{a}\_{t} = y + ra\_{t} - c\_{t}, a\_{0} \\text…

---

## [How to (properly) use the solution of a simulation in ModelingToolkit](https://discourse.julialang.org/t/how-to-properly-use-the-solution-of-a-simulation-in-modelingtoolkit/59686)

<div class="topic-metadata">

**Author:** [@CodeLenz](https://discourse.julialang.org/u/CodeLenz)\
**Replies:** 4\
**Last updated:** [April 20, 2021, 8:16pm UTC](https://discourse.julialang.org/t/how-to-properly-use-the-solution-of-a-simulation-in-modelingtoolkit/59686 "2021-04-20T20:16:02Z")

</div>

Hi there. I am starting to use the amazing ModellingToolkit, but I am afraid I am missing something important. So I apologize if my questions is silly. Suppose I have a model consisting of two differential equations, t…

---

## [Solving for the steady-state of a large nonlinear ODE in SciML](https://discourse.julialang.org/t/solving-for-the-steady-state-of-a-large-nonlinear-ode-in-sciml/50613)

<div class="topic-metadata">

**Author:** [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Replies:** 32\
**Last updated:** [April 19, 2021, 10:01am UTC](https://discourse.julialang.org/t/solving-for-the-steady-state-of-a-large-nonlinear-ode-in-sciml/50613 "2021-04-19T10:01:05Z")

</div>

I have a few questions: What is the difference in scope between NonlinearSolve.jl and NLSolvers.jl/NLsolve.jl? What are the pros/cons of NonlinearSolve.jl vs NLSolvers.jl/NLsolve.jl? Are there any plans to include the …

---

## [Same ODEProblem has differente results when variable is Float64 and Vector{Float64}](https://discourse.julialang.org/t/same-odeproblem-has-differente-results-when-variable-is-float64-and-vector-float64/59477)

<div class="topic-metadata">

**Author:** [@Rafael\_FC](https://discourse.julialang.org/u/Rafael_FC)\
**Replies:** 2\
**Last updated:** [April 17, 2021, 8:08pm UTC](https://discourse.julialang.org/t/same-odeproblem-has-differente-results-when-variable-is-float64-and-vector-float64/59477 "2021-04-17T20:08:12Z")

</div>

Hello! I’m having trouble with the following code. As of now it’s working fine, but if I change y0 (Float64) to y0\[1\] (Vector{Float64}) and dy to dy\[1\], it returns a wrong result. Since it’s a simple problem I must be …

---

## [Makie mouse\_in\_scene gives pixel positions](https://discourse.julialang.org/t/makie-mouse-in-scene-gives-pixel-positions/58864)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 2\
**Last updated:** [April 8, 2021, 9:19pm UTC](https://discourse.julialang.org/t/makie-mouse-in-scene-gives-pixel-positions/58864 "2021-04-08T21:19:30Z")

</div>

Hi, I don’t understand why the following code doesn’t work. (maybe I an just blind) using AbstractPlotting X = Node( rand(Point2f0, 10) ) fig = Figure(resolution = (1200, 900)) scatter(fig\[1,1\], X) scene = fig.scen…

---

## [Stochastic simulation error](https://discourse.julialang.org/t/stochastic-simulation-error/58692)

<div class="topic-metadata">

**Author:** [@jailton](https://discourse.julialang.org/u/jailton)\
**Replies:** 1\
**Last updated:** [April 6, 2021, 4:32pm UTC](https://discourse.julialang.org/t/stochastic-simulation-error/58692 "2021-04-06T16:32:47Z")

</div>

Hello, I am newbie in Julia, trying to run a MCMC algorithm, but I getting some complaints about the parameters of the gamma distribution (which are supposed to be \> 0), but they are, so I don’t understand this complain…

---

## [Making a PD Controller Component in ModelingToolkit.jl](https://discourse.julialang.org/t/making-a-pd-controller-component-in-modelingtoolkit-jl/58509)

<div class="topic-metadata">

**Author:** [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Replies:** 28\
**Last updated:** [April 6, 2021, 10:10am UTC](https://discourse.julialang.org/t/making-a-pd-controller-component-in-modelingtoolkit-jl/58509 "2021-04-06T10:10:32Z")

</div>

If I were to make a PD controller component, I’d probably do something like this: using ModelingToolkit function PD\_controller(Pgain, Dgain, num\_inputs; name=:pd) @parameters t D = Differential(t) @variables…

---

## [Combining ContinuousCallback and DiscreteCallback in solving ODEProblem (DifferentialEquations)](https://discourse.julialang.org/t/combining-continuouscallback-and-discretecallback-in-solving-odeproblem-differentialequations/58608)

<div class="topic-metadata">

**Author:** [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Replies:** 1\
**Last updated:** [April 5, 2021, 12:15pm UTC](https://discourse.julialang.org/t/combining-continuouscallback-and-discretecallback-in-solving-odeproblem-differentialequations/58608 "2021-04-05T12:15:56Z")

</div>

Is it possible to combine ContinuousCallback and DiscreteCallback while solving ODEProblem? While the former checks if some real quantity attains a zero value, checking a simultaneous satisfaction of some additional logi…

---

## [What is the "interface" necessary for DifferentialEquations.jl if your data type does not subclass AbstractArray?](https://discourse.julialang.org/t/what-is-the-interface-necessary-for-differentialequations-jl-if-your-data-type-does-not-subclass-abstractarray/58480)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 5\
**Last updated:** [April 5, 2021, 10:26am UTC](https://discourse.julialang.org/t/what-is-the-interface-necessary-for-differentialequations-jl-if-your-data-type-does-not-subclass-abstractarray/58480 "2021-04-05T10:26:38Z")

</div>

There are a few similar conversation from previous years in this forum (e.g. JuliaDiffEq with custom types - #24 by mzilhao), but I was not able to find official documentation on the topic, and I am uncertain how much of…

---

## [Taking gradients of large differential equations](https://discourse.julialang.org/t/taking-gradients-of-large-differential-equations/57788)

<div class="topic-metadata">

**Author:** [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Replies:** 4\
**Last updated:** [April 3, 2021, 4:39pm UTC](https://discourse.julialang.org/t/taking-gradients-of-large-differential-equations/57788 "2021-04-03T16:39:49Z")

</div>

Hi all, I have a rather large reaction network I want to fit to data. I imported it from an .xml file so it is in the form of ModelingToolkit.ODESystem. It has 228 states and 470 parameters. It’s not particularly sti…

---

## [Build\_function from differential equation](https://discourse.julialang.org/t/build-function-from-differential-equation/58276)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 2\
**Last updated:** [April 1, 2021, 8:19pm UTC](https://discourse.julialang.org/t/build-function-from-differential-equation/58276 "2021-04-01T20:19:15Z")

</div>

I tried the example from Symbolics.jl but ran into a problem: using Symbolics function lotka\_volterra!(du, u, p, t) x, y = u α, β, δ, γ = p du\[1\] = dx = α\*x - β\*x\*y du\[2\] = dy = -δ\*y + γ\*x\*y end @variables t du\[…

---

## [Log every evaluation of ODE solver](https://discourse.julialang.org/t/log-every-evaluation-of-ode-solver/58107)

<div class="topic-metadata">

**Author:** [@carlisto1250](https://discourse.julialang.org/u/carlisto1250)\
**Replies:** 5\
**Last updated:** [March 30, 2021, 5:37pm UTC](https://discourse.julialang.org/t/log-every-evaluation-of-ode-solver/58107 "2021-03-30T17:37:39Z")

</div>

So, Im getting a lot of warnings (and consequently errors) about NaN and Instability problems while trying to solve my ODE system, like: Warning: NaN dt detected. Likely a NaN value in the state, parameters, or derivati…

---

## [Modeling Toolkit crash](https://discourse.julialang.org/t/modeling-toolkit-crash/58056)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 4\
**Last updated:** [March 27, 2021, 10:19am UTC](https://discourse.julialang.org/t/modeling-toolkit-crash/58056 "2021-03-27T10:19:17Z")

</div>

The following causes a crash in Julia v 1.6 using ModelingToolkit, NonlinearSolve, Plots @variables c, ℓ, L, K, Y, Π, v, r, w @parameters αK, αL, γ, EH, EK F(K,L,αK, αL) = (K^αK)\*(L^αL) FK(K,L,αK,αL) = αK\*(K^(αK-1…

---

## [ModelingToolkit's structural\_simplify fails on LI-cutset simplification](https://discourse.julialang.org/t/modelingtoolkits-structural-simplify-fails-on-li-cutset-simplification/57852)

<div class="topic-metadata">

**Author:** [@owiecc](https://discourse.julialang.org/u/owiecc)\
**Replies:** 2\
**Last updated:** [March 24, 2021, 8:42pm UTC](https://discourse.julialang.org/t/modelingtoolkits-structural-simplify-fails-on-li-cutset-simplification/57852 "2021-03-24T20:42:42Z")

</div>

I modified the example on acausal component modelling from ModelingToolkit and I get internal tearing error. In my modification I have a series connected V+R+L+L circuit. The series connection of inductors/current sourc…

---

## [New to Julia, using it for dynamic systems simulations](https://discourse.julialang.org/t/new-to-julia-using-it-for-dynamic-systems-simulations/55285)

<div class="topic-metadata">

**Author:** [@Babou](https://discourse.julialang.org/u/Babou)\
**Replies:** 14\
**Last updated:** [March 24, 2021, 5:09pm UTC](https://discourse.julialang.org/t/new-to-julia-using-it-for-dynamic-systems-simulations/55285 "2021-03-24T17:09:02Z")

</div>

Hi all, I am a new Julia user. I am going to be using it to run some toy simulations of biologically realistic neural networks. If you aren’t familiar with this topic have a peak here.I saw DifferentialEquations.jl an…

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

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