# Modelling & Simulations

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

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

**Page:** 28

---

## [Optimizating computational time of gradient on big linear UDEs](https://discourse.julialang.org/t/optimizating-computational-time-of-gradient-on-big-linear-udes/108645)

<div class="topic-metadata">

**Author:** [@jarroyoe](https://discourse.julialang.org/u/jarroyoe)\
**Replies:** 11\
**Last updated:** [January 11, 2024, 10:28pm UTC](https://discourse.julialang.org/t/optimizating-computational-time-of-gradient-on-big-linear-udes/108645 "2024-01-11T22:28:25Z")

</div>

I have an high-dimensional UDE model that includes a linear model. A MWE of the linear component of the model is: using ForwardDiff, DifferentialEquations, SciMLSensitivity trainingData = rand(100,4) p0 = rand(100,100)…

---

## [How to change specific parameter in DifferentialEquations CallbackSet?](https://discourse.julialang.org/t/how-to-change-specific-parameter-in-differentialequations-callbackset/108378)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 7\
**Last updated:** [January 11, 2024, 11:02am UTC](https://discourse.julialang.org/t/how-to-change-specific-parameter-in-differentialequations-callbackset/108378 "2024-01-11T11:02:05Z")

</div>

Hello, I am trying to run a simulation of a bacterial population with Julia. I set a function that takes one parameter (growth rate, mu) that should change at a specific time point (t\_in). I set the CallbackSet for the…

---

## [Angle of complex numbers: how to get continuous plot?](https://discourse.julialang.org/t/angle-of-complex-numbers-how-to-get-continuous-plot/108624)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 7\
**Last updated:** [January 10, 2024, 8:18pm UTC](https://discourse.julialang.org/t/angle-of-complex-numbers-how-to-get-continuous-plot/108624 "2024-01-10T20:18:03Z")

</div>

I’m trying to plot the phase of a complex transfer function (as in control engineering) using the angle function. So essentially, if I have a transfer function g(s), I compute the angle (with rad2deg conversion) of g(j\\…

---

## [Provenance of data in scientific packages](https://discourse.julialang.org/t/provenance-of-data-in-scientific-packages/108625)

<div class="topic-metadata">

**Author:** [@NicholasWMRitchie](https://discourse.julialang.org/u/NicholasWMRitchie)\
**Replies:** 4\
**Last updated:** [January 10, 2024, 5:11pm UTC](https://discourse.julialang.org/t/provenance-of-data-in-scientific-packages/108625 "2024-01-10T17:11:01Z")

</div>

I’m not sure how pervasive it is but I’ve noticed this issue a couple of times. The issue is this: The provenance of data used to implement basic “scientific packages” is ambiguous. This could mean the source of the d…

---

## [Cannot access MTK's observed variables in steady-state solutions (NonlinearSolution)](https://discourse.julialang.org/t/cannot-access-mtks-observed-variables-in-steady-state-solutions-nonlinearsolution/108524)

<div class="topic-metadata">

**Author:** [@Wen-Wei\_Tseng](https://discourse.julialang.org/u/Wen-Wei_Tseng)\
**Replies:** 3\
**Last updated:** [January 10, 2024, 8:42am UTC](https://discourse.julialang.org/t/cannot-access-mtks-observed-variables-in-steady-state-solutions-nonlinearsolution/108524 "2024-01-10T08:42:20Z")

</div>

MWE: using DifferentialEquations using ModelingToolkit @variables t x(t) RHS(t) @parameters τ D = Differential(t) eqs = \[ RHS ~ (1 - x) / τ D(x) ~ RHS \] @named sys = ODESystem(eqs, defaults=\[x=\>0.0, τ=\>3.0\]) …

---

## [How to use discrete events with an affect](https://discourse.julialang.org/t/how-to-use-discrete-events-with-an-affect/108503)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 1\
**Last updated:** [January 8, 2024, 10:40am UTC](https://discourse.julialang.org/t/how-to-use-discrete-events-with-an-affect/108503 "2024-01-08T10:40:53Z")

</div>

I am trying to add an affect function to a discrete event. Not working: function bb\_affect!(integ, u, p, ctx) println(integ.u) end discrete\_events = \[\[1.0, 4.0\] =\> bb\_affect!\] @named sys = ODESystem(eqs…

---

## [UDEs & ModelingToolkit](https://discourse.julialang.org/t/udes-modelingtoolkit/108543)

<div class="topic-metadata">

**Author:** [@armansa](https://discourse.julialang.org/u/armansa)\
**Replies:** 1\
**Last updated:** [January 9, 2024, 3:48am UTC](https://discourse.julialang.org/t/udes-modelingtoolkit/108543 "2024-01-09T03:48:30Z")

</div>

Hi everyone, I’m using the UDE example here but trying to make it work for the case that my ODE system is not in defined in vector form (as it usually is for UODE examples I’ve seen), but in symbolic form using MTK. I h…

---

## [How to catch integrator problems](https://discourse.julialang.org/t/how-to-catch-integrator-problems/108512)

<div class="topic-metadata">

**Author:** [@Niall](https://discourse.julialang.org/u/Niall)\
**Replies:** 6\
**Last updated:** [January 8, 2024, 5:45pm UTC](https://discourse.julialang.org/t/how-to-catch-integrator-problems/108512 "2024-01-08T17:45:59Z")

</div>

I am using a CoupledODEs as a test for the results of a genetic algorithm. In other words, the parameter values (here 0.5 and 1.8) are chosen at random by the GA, then tested by solving the ODEs. This means that occasion…

---

## [Differential Equations running out of GPU memory](https://discourse.julialang.org/t/differential-equations-running-out-of-gpu-memory/101048)

<div class="topic-metadata">

**Author:** [@Tommy\_Fischer](https://discourse.julialang.org/u/Tommy_Fischer)\
**Replies:** 16\
**Last updated:** [January 7, 2024, 2:53pm UTC](https://discourse.julialang.org/t/differential-equations-running-out-of-gpu-memory/101048 "2024-01-07T14:53:11Z")

</div>

Hi all, I posted earlier about minimising memory usage on gpu modelling a system here. Since then I’ve tidied up my code a bit and have managed to reduce memory usage, but it still runs out of memory when I try to scan o…

---

## [In DataDrivenDiffEq, how to get SINDy results as an array of numeric coefficients?](https://discourse.julialang.org/t/in-datadrivendiffeq-how-to-get-sindy-results-as-an-array-of-numeric-coefficients/108449)

<div class="topic-metadata">

**Author:** [@kmd](https://discourse.julialang.org/u/kmd)\
**Replies:** 1\
**Last updated:** [January 7, 2024, 1:56pm UTC](https://discourse.julialang.org/t/in-datadrivendiffeq-how-to-get-sindy-results-as-an-array-of-numeric-coefficients/108449 "2024-01-07T13:56:08Z")

</div>

Hi, I would like to obtain the result of a SINDy model fitting as an array of coefficients I can convert to Float64. I can do this in PySINDy with the function \`\`model.coefficients()‘’, which will return the weights in…

---

## [Checkpointing and adjoints for custom kernels](https://discourse.julialang.org/t/checkpointing-and-adjoints-for-custom-kernels/108281)

<div class="topic-metadata">

**Author:** [@smartalecH](https://discourse.julialang.org/u/smartalecH)\
**Replies:** 2\
**Last updated:** [January 6, 2024, 12:32am UTC](https://discourse.julialang.org/t/checkpointing-and-adjoints-for-custom-kernels/108281 "2024-01-06T00:32:52Z")

</div>

I’ve written a PDE finite-difference solver that uses KernelAbstractions.jl to update my stencil each time step. In my previous life, when I’d write this stuff in C/C++, I’d roll my own adjoints, and then hook them up t…

---

## [ABM - Scheduler.bytype just for 1 agent function](https://discourse.julialang.org/t/abm-scheduler-bytype-just-for-1-agent-function/107611)

<div class="topic-metadata">

**Author:** [@elisadonati23](https://discourse.julialang.org/u/elisadonati23)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 5:25pm UTC](https://discourse.julialang.org/t/abm-scheduler-bytype-just-for-1-agent-function/107611 "2024-01-04T17:25:25Z")

</div>

Dear all, I am running an ABM model with NoSpaceAgent representing sardines populations over time with three lifestages identified by the field type::Symbol and with 2 sexes (sex::Symbol). Adults can spawn in a period …

---

## [ModelingToolkit model with structural\_simplify error: How to initialize variables correctly?](https://discourse.julialang.org/t/modelingtoolkit-model-with-structural-simplify-error-how-to-initialize-variables-correctly/108110)

<div class="topic-metadata">

**Author:** [@juanmvenegas](https://discourse.julialang.org/u/juanmvenegas)\
**Replies:** 5\
**Last updated:** [January 4, 2024, 2:49pm UTC](https://discourse.julialang.org/t/modelingtoolkit-model-with-structural-simplify-error-how-to-initialize-variables-correctly/108110 "2024-01-04T14:49:41Z")

</div>

Hello everybody, I am currently developing a ModelingToolkit.jl model to simulate axial flow in a tubular pipe with a chemical reaction, including axial diffusion. This system is currently an initial value problem, and …

---

## [Calculate Equilibrium points for continuous system DynamicalSystems.jl](https://discourse.julialang.org/t/calculate-equilibrium-points-for-continuous-system-dynamicalsystems-jl/85247)

<div class="topic-metadata">

**Author:** [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Replies:** 9\
**Last updated:** [January 4, 2024, 4:50am UTC](https://discourse.julialang.org/t/calculate-equilibrium-points-for-continuous-system-dynamicalsystems-jl/85247 "2024-01-04T04:50:49Z")

</div>

I need calculate all equilibrium points for dynamical system Hindmarsh Rose (HR). Code for system: function HR!(du, u, p, t) function sigma(x) return 1.0 / ( 1.0 + exp( -10.0 \* ( x - ( - 0.25 ) ) )…

---

## [Access variables of another subsystem in a callback](https://discourse.julialang.org/t/access-variables-of-another-subsystem-in-a-callback/108248)

<div class="topic-metadata">

**Author:** [@HKruenaegel](https://discourse.julialang.org/u/HKruenaegel)\
**Replies:** 1\
**Last updated:** [January 2, 2024, 8:23am UTC](https://discourse.julialang.org/t/access-variables-of-another-subsystem-in-a-callback/108248 "2024-01-02T08:23:13Z")

</div>

Is it possible to read a variable of another subsystem in a callback? For example if I want tu use decay2.u in a callback defined in decay1 in the following example code: using ModelingToolkit function affect!(integ,u,p…

---

## [Monte Carlo ray tracing flow chart algorithm pseudocode: A @goto-implementation and a recursion based implementation, any ideas for a more modern implementation?](https://discourse.julialang.org/t/monte-carlo-ray-tracing-flow-chart-algorithm-pseudocode-a-goto-implementation-and-a-recursion-based-implementation-any-ideas-for-a-more-modern-implementation/108089)

<div class="topic-metadata">

**Author:** [@NikoBiele](https://discourse.julialang.org/u/NikoBiele)\
**Replies:** 3\
**Last updated:** [December 29, 2023, 11:59pm UTC](https://discourse.julialang.org/t/monte-carlo-ray-tracing-flow-chart-algorithm-pseudocode-a-goto-implementation-and-a-recursion-based-implementation-any-ideas-for-a-more-modern-implementation/108089 "2023-12-29T23:59:58Z")

</div>

Hi Julia-people :slight\_smile: I am working with heat transfer, more specifically simulating thermal radiation heat transfer in participating media through Monte Carlo ray tracing. I am currently working with a 2D algor…

---

## [Can I rely on consecutive state positions of a variable in discretized problem with MOL?](https://discourse.julialang.org/t/can-i-rely-on-consecutive-state-positions-of-a-variable-in-discretized-problem-with-mol/108126)

<div class="topic-metadata">

**Author:** [@progtw1](https://discourse.julialang.org/u/progtw1)\
**Replies:** 1\
**Last updated:** [December 28, 2023, 12:22pm UTC](https://discourse.julialang.org/t/can-i-rely-on-consecutive-state-positions-of-a-variable-in-discretized-problem-with-mol/108126 "2023-12-28T12:22:06Z")

</div>

MethodOfLines creates a symbolic array variable indexed over discretized spaces. After structurally simplifying the system (currently done automatically in the discretization) there are several corresponding variables i…

---

## [Change to MTK plotting?](https://discourse.julialang.org/t/change-to-mtk-plotting/108109)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 4\
**Last updated:** [December 28, 2023, 9:15am UTC](https://discourse.julialang.org/t/change-to-mtk-plotting/108109 "2023-12-28T09:15:56Z")

</div>

I just updated Julia to v1.10, and now plotting results from MTK models do not work as before. Consider a solution structure sol from an MTK model: julia\> sol(0.5, idxs=\[r2m.Vd\_v, r2m.Dp\_p\]) 2-element Vector{Float64}: …

---

## [MTK & \`@mtkmodel\` & \`@mtkbuild\`](https://discourse.julialang.org/t/mtk-mtkmodel-mtkbuild/104793)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 16\
**Last updated:** [December 20, 2023, 5:01pm UTC](https://discourse.julialang.org/t/mtk-mtkmodel-mtkbuild/104793 "2023-12-20T17:01:56Z")

</div>

Great to see the latest update of the ModelingToolkit.jl documentation! The “new way” of doing things with @mtkmodel makes sense to me! There are a few things that I don’t understand in the transition from the “old” way…

---

## [2D arrays with ModelingToolkit](https://discourse.julialang.org/t/2d-arrays-with-modelingtoolkit/107448)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 22\
**Last updated:** [December 19, 2023, 8:25am UTC](https://discourse.julialang.org/t/2d-arrays-with-modelingtoolkit/107448 "2023-12-19T08:25:28Z")

</div>

I have the following code, representing a mass attached to a spring-damper element: using ModelingToolkit, OrdinaryDiffEq, LinearAlgebra G\_EARTH = Float64\[0.0, 0.0, -9.81\] # gravitational acceleration \[m/s…

---

## [Compatibility issue between ControlSystems and SeeToDee?](https://discourse.julialang.org/t/compatibility-issue-between-controlsystems-and-seetodee/107592)

<div class="topic-metadata">

**Author:** [@Fabrice\_Boquet](https://discourse.julialang.org/u/Fabrice_Boquet)\
**Replies:** 13\
**Last updated:** [December 18, 2023, 8:16pm UTC](https://discourse.julialang.org/t/compatibility-issue-between-controlsystems-and-seetodee/107592 "2023-12-18T20:16:10Z")

</div>

I tried to run a program which uses ControlSystems and SeeToDee at the same time but I never managed to make it work. I am using Julia in Visual Studio Code. I tried many many different things and none of them work. Here…

---

## [ArgumentError: u names not unique. Repeated names:](https://discourse.julialang.org/t/argumenterror-u-names-not-unique-repeated-names/107386)

<div class="topic-metadata">

**Author:** [@maltee1](https://discourse.julialang.org/u/maltee1)\
**Replies:** 14\
**Last updated:** [December 18, 2023, 8:08pm UTC](https://discourse.julialang.org/t/argumenterror-u-names-not-unique-repeated-names/107386 "2023-12-18T20:08:36Z")

</div>

Hi, I’m getting this error when using connect. The error is pretty self-explanatory and the solution is workable. However, every time I’m getting that error, I actually have two inputs that have the same name because t…

---

## [Registering a time dependent function inside a function in ModelingToolkit.jl](https://discourse.julialang.org/t/registering-a-time-dependent-function-inside-a-function-in-modelingtoolkit-jl/100402)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 5\
**Last updated:** [December 18, 2023, 1:21pm UTC](https://discourse.julialang.org/t/registering-a-time-dependent-function-inside-a-function-in-modelingtoolkit-jl/100402 "2023-12-18T13:21:07Z")

</div>

Let’s say that I build my model using functions that, if need be create variables and parameters, and return equations. In the end of the code i put all equations together. Let’s say I have an example block such as usin…

---

## [High Memory Usage when using offline\_run from Agents.jl in for loops](https://discourse.julialang.org/t/high-memory-usage-when-using-offline-run-from-agents-jl-in-for-loops/107731)

<div class="topic-metadata">

**Author:** [@PaoloBova](https://discourse.julialang.org/u/PaoloBova)\
**Replies:** 3\
**Last updated:** [December 18, 2023, 1:19pm UTC](https://discourse.julialang.org/t/high-memory-usage-when-using-offline-run-from-agents-jl-in-for-loops/107731 "2023-12-18T13:19:35Z")

</div>

Hello Julia Community, I’m currently working with the Agents.jl package, specifically using the offline\_run function. I’ve encountered an issue where my program seems to be consuming a significant amount of memory when …

---

## [How can I simplify this code](https://discourse.julialang.org/t/how-can-i-simplify-this-code/107757)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 0\
**Last updated:** [December 18, 2023, 8:02am UTC](https://discourse.julialang.org/t/how-can-i-simplify-this-code/107757 "2023-12-18T08:02:18Z")

</div>

How can I simplify the creation of a system of equations in a loop: using ModelingToolkit, OrdinaryDiffEq, LinearAlgebra G\_EARTH = Float64\[0.0, 0.0, -9.81\] # gravitational acceleration \[m/s²\] L0::Float…

---

## [What is the @named macro needed for?](https://discourse.julialang.org/t/what-is-the-named-macro-needed-for/107647)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [December 15, 2023, 8:48am UTC](https://discourse.julialang.org/t/what-is-the-named-macro-needed-for/107647 "2023-12-15T08:48:05Z")

</div>

Why is the @named macro needed here: @named sys = ODESystem(eqs, t) I am NOT giving a name to the ODE system… But I get an error if I leave it out.

---

## [Number of solvers available for DifferentialEquations.jl?](https://discourse.julialang.org/t/number-of-solvers-available-for-differentialequations-jl/107607)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 8\
**Last updated:** [December 14, 2023, 10:14pm UTC](https://discourse.julialang.org/t/number-of-solvers-available-for-differentialequations-jl/107607 "2023-12-14T22:14:23Z")

</div>

I am preparing a talk. I would like to know: How many different solvers are available when you use the package DifferentialEquations.jl? I don’t need the exact number, just an estimate…

---

## [Tracking dynamical increments du and accompanying variables during a DynamicalSystems run](https://discourse.julialang.org/t/tracking-dynamical-increments-du-and-accompanying-variables-during-a-dynamicalsystems-run/107558)

<div class="topic-metadata">

**Author:** [@Niall](https://discourse.julialang.org/u/Niall)\
**Replies:** 2\
**Last updated:** [December 14, 2023, 8:32am UTC](https://discourse.julialang.org/t/tracking-dynamical-increments-du-and-accompanying-variables-during-a-dynamicalsystems-run/107558 "2023-12-14T08:32:56Z")

</div>

Hi. I have two things that I want from DynamicalSystems, and I’m not sure how to get them: Is there some way of retrieving the dynamical increment values du during the running of a DynamicalSystem? It would be useful …

---

## [How does ModelingToolkit use bounds metadata?](https://discourse.julialang.org/t/how-does-modelingtoolkit-use-bounds-metadata/81487)

<div class="topic-metadata">

**Author:** [@jedforrest](https://discourse.julialang.org/u/jedforrest)\
**Replies:** 17\
**Last updated:** [December 13, 2023, 5:18pm UTC](https://discourse.julialang.org/t/how-does-modelingtoolkit-use-bounds-metadata/81487 "2023-12-13T17:18:24Z")

</div>

Hi all, What is the purpose of the bounds symbolic metadata in ModelingToolkit? When I add bounds to x in the following code, I would at first expect the solution for x to be limited between 0 and 2, but this doesn’t s…

---

## [Direct Forward Sensitivity Analysis of ODEs in ModelingToolkit.jl for a Subset of Parameters](https://discourse.julialang.org/t/direct-forward-sensitivity-analysis-of-odes-in-modelingtoolkit-jl-for-a-subset-of-parameters/104903)

<div class="topic-metadata">

**Author:** [@Can\_Bozdogan](https://discourse.julialang.org/u/Can_Bozdogan)\
**Replies:** 4\
**Last updated:** [December 12, 2023, 10:00pm UTC](https://discourse.julialang.org/t/direct-forward-sensitivity-analysis-of-odes-in-modelingtoolkit-jl-for-a-subset-of-parameters/104903 "2023-12-12T22:00:49Z")

</div>

Hello, I am working on a project that involves setting up and solving an ODE system. I’ve defined my ODE system using ModelingToolkit.jl and not as a function. My ODE system has many parameters, and I’m interested in pe…

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

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