# Modelling & Simulations

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

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

**Page:** 25

---

## [Discretization problem using MOL](https://discourse.julialang.org/t/discretization-problem-using-mol/105514)

<div class="topic-metadata">

**Author:** [@Johan\_Ekberg](https://discourse.julialang.org/u/Johan_Ekberg)\
**Replies:** 2\
**Last updated:** [April 6, 2024, 9:50pm UTC](https://discourse.julialang.org/t/discretization-problem-using-mol/105514 "2024-04-06T21:50:00Z")

</div>

Hi im trying to solve a 4th order PDE using the MethodOfLines package but im getting the following error messege when trying to discretize my system in space. Could the problem be caused by the mixed derivative? The PDES…

---

## [Enzyme Reverse Diff rules for complex sqrt](https://discourse.julialang.org/t/enzyme-reverse-diff-rules-for-complex-sqrt/111489)

<div class="topic-metadata">

**Author:** [@dchang10](https://discourse.julialang.org/u/dchang10)\
**Replies:** 6\
**Last updated:** [April 6, 2024, 4:32pm UTC](https://discourse.julialang.org/t/enzyme-reverse-diff-rules-for-complex-sqrt/111489 "2024-04-06T16:32:36Z")

</div>

I have a function that I’m trying to reverse mode diff through that at some point needs to calculate the square root of a complex number. I have been able to define custom rules for the Forward mode autodiff in the follo…

---

## [Memory issues for large computational graph](https://discourse.julialang.org/t/memory-issues-for-large-computational-graph/112606)

<div class="topic-metadata">

**Author:** [@Arijit\_Bhattacharya](https://discourse.julialang.org/u/Arijit_Bhattacharya)\
**Replies:** 3\
**Last updated:** [April 6, 2024, 3:11pm UTC](https://discourse.julialang.org/t/memory-issues-for-large-computational-graph/112606 "2024-04-06T15:11:56Z")

</div>

I’m working on developing a differentiable CFD solver incorporating the immersed boundary method for solving the Navier-Stokes equations. I plan on using Enzyme.jl .My goal is to compute gradients of a parametric geometr…

---

## [Help to formulate an ODE problem to use OrdinaryDiffEq](https://discourse.julialang.org/t/help-to-formulate-an-ode-problem-to-use-ordinarydiffeq/112494)

<div class="topic-metadata">

**Author:** [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Replies:** 4\
**Last updated:** [April 5, 2024, 8:31am UTC](https://discourse.julialang.org/t/help-to-formulate-an-ode-problem-to-use-ordinarydiffeq/112494 "2024-04-05T08:31:24Z")

</div>

Hi everyone, For one of my problem, I need to solve this ODE backwards: \\frac{dX}{dt} = a(X(t),t), \\\\ X(t^{n+1}) = X\_g where X is the position of a marker (could be 1d, 2d or 3d), a(X(t),t) is a velocity vector and X…

---

## [Differentiability of functions that have integer outputs](https://discourse.julialang.org/t/differentiability-of-functions-that-have-integer-outputs/112520)

<div class="topic-metadata">

**Author:** [@Arijit\_Bhattacharya](https://discourse.julialang.org/u/Arijit_Bhattacharya)\
**Replies:** 6\
**Last updated:** [April 5, 2024, 6:55am UTC](https://discourse.julialang.org/t/differentiability-of-functions-that-have-integer-outputs/112520 "2024-04-05T06:55:00Z")

</div>

Question: I’m currently implementing an Immersed Boundary Method (IBM) in Julia, and I’ve written a function to compute interpolation weights for IBM forcing. I want my IBM code to be differentiable for which I will be u…

---

## [Monte Carlo simulation and probabilistic programming packages](https://discourse.julialang.org/t/monte-carlo-simulation-and-probabilistic-programming-packages/111408)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 3\
**Last updated:** [April 5, 2024, 6:12am UTC](https://discourse.julialang.org/t/monte-carlo-simulation-and-probabilistic-programming-packages/111408 "2024-04-05T06:12:11Z")

</div>

I’m trying to find Julia packages to perform (financial) quantitative analysis under uncertainty, typicaly by Monte Carlo simulation. Somewhat similar to Oracle Crystal Ball or Palisade @RISK. Found MCHammer.jl that seem…

---

## [Loaded v1.10.2; receiving LoadError: MethodError: no method matching var"@agent](https://discourse.julialang.org/t/loaded-v1-10-2-receiving-loaderror-methoderror-no-method-matching-var-agent/112549)

<div class="topic-metadata">

**Author:** [@tfranks](https://discourse.julialang.org/u/tfranks)\
**Replies:** 7\
**Last updated:** [April 5, 2024, 3:34am UTC](https://discourse.julialang.org/t/loaded-v1-10-2-receiving-loaderror-methoderror-no-method-matching-var-agent/112549 "2024-04-05T03:34:38Z")

</div>

Hello, I’ve installed the latest version 1.10.2 and using the predator-prey example. When I run my code (shown below) and the predator-prey code, both get the same error message: LoadError: MethodError: no method matc…

---

## [Gradient-based parameter estimation for Catalyst.jl models](https://discourse.julialang.org/t/gradient-based-parameter-estimation-for-catalyst-jl-models/112542)

<div class="topic-metadata">

**Author:** [@dhowsmon](https://discourse.julialang.org/u/dhowsmon)\
**Replies:** 1\
**Last updated:** [April 5, 2024, 3:03am UTC](https://discourse.julialang.org/t/gradient-based-parameter-estimation-for-catalyst-jl-models/112542 "2024-04-05T03:03:48Z")

</div>

Hi, I am trying to estimate parameters/initial conditions in an ODE system built with Catalyst.jl. I first find the steady-state using a callback, and then in a separate simulation I add some input to get my actual desir…

---

## [IDA is allocating a lot](https://discourse.julialang.org/t/ida-is-allocating-a-lot/112383)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 28\
**Last updated:** [April 4, 2024, 10:06am UTC](https://discourse.julialang.org/t/ida-is-allocating-a-lot/112383 "2024-04-04T10:06:24Z")

</div>

I am using the IDA solver from Sundials.jl to solve a system of DAEs. It works fine, but each time step needs a lot of allocations, even though my callback function does not allocate at all. MWE: using KiteModels kps4…

---

## [ModelingToolkit.jl for material flow analyis (MFA)](https://discourse.julialang.org/t/modelingtoolkit-jl-for-material-flow-analyis-mfa/112454)

<div class="topic-metadata">

**Author:** [@gvdeynde](https://discourse.julialang.org/u/gvdeynde)\
**Replies:** 1\
**Last updated:** [April 4, 2024, 8:18am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-for-material-flow-analyis-mfa/112454 "2024-04-04T08:18:33Z")

</div>

I was wondering if there are any people working on material flow analysis problems using ModelingToolkit.jl? And has developed/is working on extensions like the ones in ModelingToolkitStandardLibrary.jl? MFA tracks mate…

---

## [Problem when assessing parameter identifiability using ODE system built with @mtkbuild](https://discourse.julialang.org/t/problem-when-assessing-parameter-identifiability-using-ode-system-built-with-mtkbuild/112418)

<div class="topic-metadata">

**Author:** [@giro](https://discourse.julialang.org/u/giro)\
**Replies:** 2\
**Last updated:** [April 2, 2024, 3:32pm UTC](https://discourse.julialang.org/t/problem-when-assessing-parameter-identifiability-using-ode-system-built-with-mtkbuild/112418 "2024-04-02T15:32:46Z")

</div>

Hello, I have built several models of protein dynamics with ModelingToolkit.jl (using @mtkmodel and @mtkbuild) and I would like to perform a parameter identifiability assessement with StructuralIdentifiability.jl. But …

---

## [Error while running a PDE model using ModelingToolkit and MethodOfLines!](https://discourse.julialang.org/t/error-while-running-a-pde-model-using-modelingtoolkit-and-methodoflines/112160)

<div class="topic-metadata">

**Author:** [@aelmokadem](https://discourse.julialang.org/u/aelmokadem)\
**Replies:** 1\
**Last updated:** [April 1, 2024, 2:00am UTC](https://discourse.julialang.org/t/error-while-running-a-pde-model-using-modelingtoolkit-and-methodoflines/112160 "2024-04-01T02:00:17Z")

</div>

Hi, I am trying to solve this PDE system and getting the error below. Any ideas what I am missing here?! Thank you. Modeling code: using DifferentialEquations, ModelingToolkit, MethodOfLines, DomainSets @parameters …

---

## [Can RuntimeGeneratedFunctions.jl cause memory leak issue?](https://discourse.julialang.org/t/can-runtimegeneratedfunctions-jl-cause-memory-leak-issue/112261)

<div class="topic-metadata">

**Author:** [@VPBML](https://discourse.julialang.org/u/VPBML)\
**Replies:** 1\
**Last updated:** [March 31, 2024, 4:33pm UTC](https://discourse.julialang.org/t/can-runtimegeneratedfunctions-jl-cause-memory-leak-issue/112261 "2024-03-31T16:33:34Z")

</div>

Hi, I am writing a Genetic Programming-styled code to search for solutions to specific problems. The solutions are in the form of functions. Thus, I use RuntimeGeneratedFunctions.jl to generate functions in runtime in o…

---

## [How to catch a instability in an ODE using Julia?](https://discourse.julialang.org/t/how-to-catch-a-instability-in-an-ode-using-julia/112324)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 2\
**Last updated:** [March 30, 2024, 12:56pm UTC](https://discourse.julialang.org/t/how-to-catch-a-instability-in-an-ode-using-julia/112324 "2024-03-30T12:56:43Z")

</div>

I am modeling the interaction between bacteria and phages with DifferentialEquations and making an interactive plot with GLMakie. The plot works, but is it possible to catch instability in the ODEs so that I can run a l…

---

## [Agent-based small-economy modeling](https://discourse.julialang.org/t/agent-based-small-economy-modeling/112309)

<div class="topic-metadata">

**Author:** [@Chuck\_Harrison](https://discourse.julialang.org/u/Chuck_Harrison)\
**Replies:** 1\
**Last updated:** [March 30, 2024, 9:42am UTC](https://discourse.julialang.org/t/agent-based-small-economy-modeling/112309 "2024-03-30T09:42:45Z")

</div>

I am starting a project to model local economies using complementary currencies. I expect to start with Stef Kuyper’s EconoSim.jl framework(GitHub - HapponomyOrg/EconoSim.jl: Economic simulation tools). I am inexperience…

---

## [Make variable available on all workers](https://discourse.julialang.org/t/make-variable-available-on-all-workers/112302)

<div class="topic-metadata">

**Author:** [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)\
**Replies:** 0\
**Last updated:** [March 29, 2024, 4:31pm UTC](https://discourse.julialang.org/t/make-variable-available-on-all-workers/112302 "2024-03-29T16:31:43Z")

</div>

Hi all, I’d like to run an evolutionary algorithm which starts with a population of agents and then lets that evolve for a number of generations. To make this not too slow, parts of the algorithm are parallelized. If I …

---

## [Callback function to set negative values to zero](https://discourse.julialang.org/t/callback-function-to-set-negative-values-to-zero/111902)

<div class="topic-metadata">

**Author:** [@Nick1](https://discourse.julialang.org/u/Nick1)\
**Replies:** 8\
**Last updated:** [March 26, 2024, 11:52pm UTC](https://discourse.julialang.org/t/callback-function-to-set-negative-values-to-zero/111902 "2024-03-26T23:52:33Z")

</div>

I have an ODE system of 60 equations and run multiple simulations with different sets of parameters. I want to prevent the outputs from taking any negative values since it is not physically plausible. I currently use som…

---

## [AD of Neural ODEs with \`SplitODEProblem\` using Zygote or Enzyme](https://discourse.julialang.org/t/ad-of-neural-odes-with-splitodeproblem-using-zygote-or-enzyme/112114)

<div class="topic-metadata">

**Author:** [@xkykai](https://discourse.julialang.org/u/xkykai)\
**Replies:** 1\
**Last updated:** [March 26, 2024, 2:29pm UTC](https://discourse.julialang.org/t/ad-of-neural-odes-with-splitodeproblem-using-zygote-or-enzyme/112114 "2024-03-26T14:29:53Z")

</div>

Hello, I am trying to perform AD in the Neural ODE setup using a SplitODEProblem as it is a PDE discretization of the diffusion equation which is rather stiff when using explicit timesteppers. The neural network appears …

---

## [Set seed GLMNet.jl](https://discourse.julialang.org/t/set-seed-glmnet-jl/112071)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 0\
**Last updated:** [March 25, 2024, 9:22am UTC](https://discourse.julialang.org/t/set-seed-glmnet-jl/112071 "2024-03-25T09:22:41Z")

</div>

Hello! I’m using GLMNet.jl to obtain a logistic regression model. How can I set a seed so that every time I run function glmnetcv with the same parameters I get the same result? Thank you!

---

## [Features coefficients - GLMNet.jl](https://discourse.julialang.org/t/features-coefficients-glmnet-jl/112053)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 0\
**Last updated:** [March 24, 2024, 9:53pm UTC](https://discourse.julialang.org/t/features-coefficients-glmnet-jl/112053 "2024-03-24T21:53:37Z")

</div>

Hello! I’m using GLMNet.jl to obtain a logistic regression model. My database contains 17 features. After training the model, how can I obtain the coefficients associated to each of these features, so it is possible to…

---

## [How is division by a singular matrix performed in Julia even it is theoretically looks invalid?](https://discourse.julialang.org/t/how-is-division-by-a-singular-matrix-performed-in-julia-even-it-is-theoretically-looks-invalid/111961)

<div class="topic-metadata">

**Author:** [@shubh\_b](https://discourse.julialang.org/u/shubh_b)\
**Replies:** 3\
**Last updated:** [March 22, 2024, 12:43pm UTC](https://discourse.julialang.org/t/how-is-division-by-a-singular-matrix-performed-in-julia-even-it-is-theoretically-looks-invalid/111961 "2024-03-22T12:43:48Z")

</div>

These are two matrices A1 and A2: julia\> A1 = \[2 4 6; 5 8 3; 2 1 8; 7 6 3\] 4×3 Matrix{Int64}: 2 4 6 5 8 3 2 1 8 7 6 3 julia\> A2 = reshape(collect(11:19), (3, 3)) 3×3 Matrix{Int64}: 11 14 17 12 15 18 1…

---

## [Naming of states, inputs and outputs in \`ControlSystemsMTK\`](https://discourse.julialang.org/t/naming-of-states-inputs-and-outputs-in-controlsystemsmtk/111783)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 12\
**Last updated:** [March 21, 2024, 10:27am UTC](https://discourse.julialang.org/t/naming-of-states-inputs-and-outputs-in-controlsystemsmtk/111783 "2024-03-21T10:27:57Z")

</div>

Hi, I just tested naming states, inputs and outputs while passing a state-space model to ODESystem. It seems the optional names are ignored, am I doing something wrong here ? using ControlSystemsBase, ControlSystemsMTK…

---

## [ModelingToolkit stepping through simulation manually](https://discourse.julialang.org/t/modelingtoolkit-stepping-through-simulation-manually/111736)

<div class="topic-metadata">

**Author:** [@rg2](https://discourse.julialang.org/u/rg2)\
**Replies:** 3\
**Last updated:** [March 19, 2024, 2:19am UTC](https://discourse.julialang.org/t/modelingtoolkit-stepping-through-simulation-manually/111736 "2024-03-19T02:19:55Z")

</div>

Hi! I created a system with modelingtoolkit, which I’m now trying to expose to python through PythonCall.jl in order to simulate the system and learn a controller using reinforcement learning. For that to work as I imag…

---

## [Implementing Laplacian operator acting on a 2D array](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615)

<div class="topic-metadata">

**Author:** [@matt1](https://discourse.julialang.org/u/matt1)\
**Replies:** 6\
**Last updated:** [March 18, 2024, 5:41pm UTC](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615 "2024-03-18T17:41:03Z")

</div>

Hello, I’m interested in implementing the laplacian operator \\nabla^2=\\partial\_x^2+\\partial\_y^2, such that I can apply it to a matrix A\_{ij} and obtain the corresponding matrix: B\_{ij}=(\\nabla^2A)\_{i,j}. For example, th…

---

## [How to handle floating point observable to keep rounding at two digits?](https://discourse.julialang.org/t/how-to-handle-floating-point-observable-to-keep-rounding-at-two-digits/111764)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 0\
**Last updated:** [March 18, 2024, 11:14am UTC](https://discourse.julialang.org/t/how-to-handle-floating-point-observable-to-keep-rounding-at-two-digits/111764 "2024-03-18T11:14:46Z")

</div>

I am trying to draw an interactive plot of a SIV model with GLMakie. I have added the sliders and forced the values associated to these sliders to two decimal digits. While the sliders for the parameters mu and omega wor…

---

## [Unstablities when solving initial value problem with Julia DifferentialEquations.jl](https://discourse.julialang.org/t/unstablities-when-solving-initial-value-problem-with-julia-differentialequations-jl/110910)

<div class="topic-metadata">

**Author:** [@paho](https://discourse.julialang.org/u/paho)\
**Replies:** 3\
**Last updated:** [March 18, 2024, 12:05am UTC](https://discourse.julialang.org/t/unstablities-when-solving-initial-value-problem-with-julia-differentialequations-jl/110910 "2024-03-18T00:05:23Z")

</div>

I’m trying to numerically determine the stationary solution of Fokker-Plank equations \\frac{\\partial P}{\\partial t}(x,t) = -\\frac{\\partial }{\\partial x}\\left\[A(x,t) P(x,t)\\right\]+\\frac{1}{2}\\frac{\\partial^2}{\\partial^2 x…

---

## [Callbacks causing wrong solution mixed ODE and Linear system](https://discourse.julialang.org/t/callbacks-causing-wrong-solution-mixed-ode-and-linear-system/111648)

<div class="topic-metadata">

**Author:** [@Lode](https://discourse.julialang.org/u/Lode)\
**Replies:** 3\
**Last updated:** [March 17, 2024, 12:47pm UTC](https://discourse.julialang.org/t/callbacks-causing-wrong-solution-mixed-ode-and-linear-system/111648 "2024-03-17T12:47:15Z")

</div>

Hello, I am new in Julia and tried to model a system with a discrete stepping feedback controller. The system was modelled using ‘ModelingToolkit’ and thereafter converter to an ‘ODEProblem’. The discrete feedback con…

---

## [Understanding the use of \`SDEFunction\`](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559)

<div class="topic-metadata">

**Author:** [@james](https://discourse.julialang.org/u/james)\
**Replies:** 2\
**Last updated:** [March 16, 2024, 12:33pm UTC](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559 "2024-03-16T12:33:38Z")

</div>

I am learning how to work with SDEs in julia and am a bit confused: In the documentation, both of SDEProblem’s constructors take two functions f,g as their first two arguments, where f should be the drift and g the nois…

---

## [How to copy Mathematica expression into a Julia function](https://discourse.julialang.org/t/how-to-copy-mathematica-expression-into-a-julia-function/97670)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 7\
**Last updated:** [March 16, 2024, 6:03am UTC](https://discourse.julialang.org/t/how-to-copy-mathematica-expression-into-a-julia-function/97670 "2024-03-16T06:03:13Z")

</div>

Very similar questions were asked before in the discourse (see e.g. this, this, and this). Answers point to MathLink where one can plug an expression like this using MathLink sqx = W\`Sqrt\[x\]\` and then evaluate this fun…

---

## [Incidence matrix from ModelingToolkit.jl](https://discourse.julialang.org/t/incidence-matrix-from-modelingtoolkit-jl/111626)

<div class="topic-metadata">

**Author:** [@hhindley](https://discourse.julialang.org/u/hhindley)\
**Replies:** 0\
**Last updated:** [March 14, 2024, 3:56pm UTC](https://discourse.julialang.org/t/incidence-matrix-from-modelingtoolkit-jl/111626 "2024-03-14T15:56:35Z")

</div>

Hi, I’ve just started using ModelingToolkit properly and am looking at doing some hybrid stochastic modelling. For my framework I need the stoichiometric matrix and reaction propensities. In the @mtkbuild output there is…

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

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