Questions tagged [event-detection]

Questions on events in differential equations, which may arise from WhenEvent or discontinuous coefficients in the commands NDSolve and DSolve.

Filter by
Sorted by
Tagged with
1 vote
1 answer
70 views

Discrete number does not work well in DSolve

The code below works fine. ...
metroidman's user avatar
0 votes
1 answer
74 views

Which condition is better for WhenEvent?

I'm solving a non-linear system with NDSolve. See my previous post In the WhenEvent, which one is better for ODE solving ...
metroidman's user avatar
3 votes
2 answers
198 views

Is there a way to improve the speed of the NDSolve in my code?

I want to tell the background before raising the question of details. My boss and I are designing synthersizer in a millimeter-wave chip. He analyzes the transient behavior with Julia. His code is ...
metroidman's user avatar
2 votes
1 answer
54 views

Event control in delay differential equations

A delay-differential system for variables {y[t],z[t]} is defined by time-lag w {y'[t] == (r (1 - y[t] - z[t]) - 1) y[t], z'[t] == (y[t] - y[t - w])}; The ...
DavidG's user avatar
  • 53
1 vote
1 answer
82 views

Dynamically generate system to use with NDSolve

I have a d-dimensional differential equation that I want to solve that takes the following form: When d = 1: ...
Max Kanwal's user avatar
0 votes
0 answers
38 views

How can I resolve the error in using WhenEvent to solve the cooling of liquid, where the cooling coefficient changes for some time?

I am trying to solve the cooling of liquid in which the cooling coefficient changes for some time. I attempted to solve it using WhenEvent, but it is showing an error. ...
Gopal Verma's user avatar
  • 1,055
1 vote
0 answers
60 views

Multiple function definition inside a whenevent [closed]

I am trying to implement a whenevent inside a NdSolve such that when a particle reaches within earths radius its position becomes a constant <0,0,0>. When I set one function x[t]-> 0 it works....
mdansfo's user avatar
  • 21
5 votes
4 answers
209 views

Detecting existence of period orbit

I wish to detect the existence of a periodic orbit (limit cycle). For example, the test should return FALSE (i.e. it should fail) for the left (m = 0.35) and ...
user12734's user avatar
  • 349
0 votes
0 answers
99 views

Problem with bifurcation diagram for driven damped pendulum

I am using the following equation of motion for a driven damped pendulum: $$\frac{d^2\theta}{dt^2} = -\frac{g}{l}\sin \theta -\gamma \frac{d\theta}{dt} + A\sin(\omega_d t)$$ where $\theta$ is the ...
codebpr's user avatar
  • 899
0 votes
0 answers
29 views

Issues while using WhenEvent and HeavisideTheta inside NDSolve

What I am doing? Integrating a piece-wise ODE using NDSolve. The piece-wise part is governed by HeavisideTheta. Objective? The goal is to update numerical values when an event is detected. This is ...
Rohit Chawla's user avatar
1 vote
1 answer
82 views

Code involves WhenEvent and DiscreteVariables no longer works [duplicate]

Bug introduced after 10.0, in or before 10.3, persisting through 13.2.1 The exact problem I am dealing with has already been asked and answered here. Unfortunately the solution no longer seems to ...
pip's user avatar
  • 11
2 votes
0 answers
37 views

Why doesn't ParametricNDSolve execute the action of WhenEvent, except the first occurrence?

I'm trying to create a ParametricFunction object using ParametricNDSolve targeting a system of equations that involves WhenEvent and DiscreteVariables. For some reason I fail to discover, the ...
adibognar's user avatar
2 votes
1 answer
160 views

How to change NDSolve equations at every Event detection?

According to this tutorial on Event Actions for NDSolve, if $x'[t]=f(t,x(t))$: it is not possible to set the derivatives x'[t], since those are determined explicitly from the function. In my case, I ...
Max Kanwal's user avatar
2 votes
1 answer
126 views

WhenEvent with multiple actions

I have a 'WhenEvent' where I want two actions to be performed. I thought the actions should be in a list but this does not seem to work. Here is an example there are two actions in the 'WhenEvent'. <...
Hugh's user avatar
  • 16.1k
1 vote
1 answer
58 views

Nminimize output of ParametricNDSolveValue

I want to minimize the time a family of ODEs vanishes. To do so, I'm using WhenEvent to extract the vanishing time and put the result inside Nminimize: ...
Einav Brin's user avatar
4 votes
1 answer
78 views

Discontinuous ODE results in NDSolve::ndinid warning, initial condition is not in the range specified by the discrete variable (internal variable)

The equations and code are below. The short version is: I know the error is because NDSolve is doing something in the background to handle the discontinuous ODE. ...
Nolan King's user avatar
3 votes
1 answer
94 views

Using WhenEvent in ParametricNDSolveValue

I want to solve an ODE and find the time the function y(t) vanishes. ...
Einav Brin's user avatar
4 votes
1 answer
467 views

Bifurcation diagram for Lorenz attractor

As I was following a similar question I came across a beautiful answer here. However, in that code, he used InternalBag[] which heavily depends on ram that I can't ...
user84456's user avatar
  • 1,554
8 votes
2 answers
254 views

Detect an event in NDSolve that is initially true

I want to check at what time the derivative of a function converges to zero. If the function starts far from equilibrium, the event is detected correctly at ...
István Zachar's user avatar
0 votes
1 answer
212 views

Sticky Collisions (perfectly inelastic)

There is an awesome simulation https://mathematica.stackexchange.com/a/124926/87086 which shows N particles bouncing in a box (with elastic collisions), made by @Feyre https://mathematica....
Zach's user avatar
  • 373
1 vote
0 answers
41 views

WhenEvent to resolve NDSolve Singularity

I'm trying to use NDSolve to solve the following ODE: ...
j.foobles's user avatar
3 votes
1 answer
79 views

Using WhenEvent to stop N objects at a boundary

I am attempting to implement an event into my simulation which makes any moving particle in an electric field completely stop at the instant they pass some specified threshold. I was trying to utilize ...
Zach's user avatar
  • 373
2 votes
0 answers
151 views

Problem with a DAE and DiscreteVariables (II)

I continue with a DAE problem similar to another one posted here some days ago. @bbgodfrey offered a solution for the DiscreteVariables problem but now I have a ...
art's user avatar
  • 145
8 votes
2 answers
237 views

Problem with a DAE and DiscreteVariables

Cross-posted in Wolfram Community. I am solving an DAE problem with NDSolve. It is a physical problem related to friction forces: one mass on the X axis and ...
art's user avatar
  • 145
9 votes
3 answers
521 views

How to make all the balls move until they stop by NBodySimulation

...
yode's user avatar
  • 26.3k
2 votes
1 answer
84 views

WhenEvent for equation defined outside NDSolve

Say i want to use WhenEvent to specify a value of R[s] when my function Dsonic[s]==-3. For some reason i get an error message. Seems that mathematica cannot read my function. Here is my code. Thank ...
Agaph's user avatar
  • 101
1 vote
2 answers
305 views

How to reset an event counter to zero after every nth evaluation while using Experimental`ValueFunction to observe for value changes in counter

Synopsis Below serves as a skeleton for a function that will track number of occurrences of a particular notebook event. The nth event will trigger a function call. After which the counter symbol must ...
Jules Manson's user avatar
  • 2,407
1 vote
0 answers
44 views

"StopIntegration" inside the "EventAction" is not working in the given instance

...
Souraj Ghosh's user avatar
1 vote
0 answers
85 views

Driving along a Beziercurve with given velocity

In this model I try to describe the kinematics of a point moving along a beziercurve b[u] (bezier parameter 0<u<1) with prescribed velocity ...
Ulrich Neumann's user avatar
0 votes
2 answers
127 views

Using NDsolve with WhenEvent is not working

I am trying to use WhenEvent in this nonlinear equation system: $\ddot r-\dot\phi^2r+9.8(\sin\phi-0.7\cos\phi)=0$ $1.2(1+20(r^2+2^2+4r\sin\phi)^2)\ddot\phi+\dot\phi+...
Jagoba Barata's user avatar
6 votes
1 answer
167 views

Plot3D + WhenEvent + NDSolve

Given: $\begin{cases} \dot{x}=-x-By^2 \\ \dot{y}=Ax-y^3 \end{cases}$ where $x,y$ - variables; $A=[2;4],B=[0.2;2]$ - positive parameters; My task is to find the time $t_n$ of the first intersection of ...
dtn's user avatar
  • 2,374
0 votes
0 answers
87 views

How to use WhenEvent?

I am trying to locate the time when $R=1,T=0,P=0$ in my system of equations, but I get the following errors: here is the code: ...
mattiav27's user avatar
  • 6,607
1 vote
1 answer
173 views

WhenEvent how to handle events at the same time and detection order

I need to use WhenEvent inside NDSolve in which events happen simultaneously. I show simple code to better explain my question: ...
PeaceEverybody's user avatar
1 vote
1 answer
186 views

WhenEvent disabled in NDsolve

I try to simulate particle motion in electric field. Ex and Ey is the intensity of electric field in X axis and y axis resepectively, which is related to the position of particle. ...
Yue Yu's user avatar
  • 55
4 votes
1 answer
251 views

problem when using WhenEvent "StopIntegration" in NDSolve

I am trying to solve some system of nonlinear differential equations by using NDSolve. I am looking for a particular shape of the solution which definitely excludes ...
Jovan Markov's user avatar
1 vote
1 answer
160 views

Solving the Stefan Problem with WhenEvent

The formulation of the problem: I tried to solve it with MOL and the method of V.R. Voller: The script: ...
Ymir's user avatar
  • 58
0 votes
0 answers
67 views

Using WhenEvent to change initial conditions of a system of Ode

i want to solve a system of two differential equations and apply two conditions. The first one is to stop the integration when the first condition (D1[s]==0,N1[s]==0) (in my code) is met.Lets say this ...
Agaph's user avatar
  • 101
2 votes
2 answers
172 views

ParametricNDSolve for a system of two differentia equations

Is there a way to plot the system of the code below? How can I get the value of s for WhenEvent happens for each parameter? <...
Agaph's user avatar
  • 101
1 vote
0 answers
282 views

If condition in differential equation

I need to plot the Integrate the Fire model of neuron. The differential equation is $\frac{dV}{dt} + \frac{V}{\tau} = \frac{I}{C}$. The initial condition is $V(0) = 0$. And there is this condition if ...
A Q's user avatar
  • 141
1 vote
1 answer
153 views

Problem with ParametricNDSolveValue & WhenEvent

I have a set of coupled differential equations, which I am trying to integrate parametrically. Rast is the parameter that is being varied. My code is as follows: <...
testing09's user avatar
  • 115
0 votes
2 answers
142 views

Finding the solution for argument of interpolating function for known functional value

Suppose I want to numerically determine the location of an object falling vertically in a gravitational field from an arbitrary height h. I know that I can use <...
honeste_vivere's user avatar
1 vote
0 answers
91 views

"If" not working when solving piecewise differential equation

This is a part 2 to my previous question: Solving Piecewise Differential Equation I am embarking on a physics project and this is the simulation that I would like to do. More information is included ...
bob the legend's user avatar
1 vote
1 answer
93 views

Doing something when a condition is met

I am attempting to solve a set of coupled differential equations using ParametricDSolveValue. I want a point, where a condition is met, to be marked on the corresponding plot. The condition I want the ...
testing09's user avatar
  • 115
1 vote
0 answers
100 views

`NDSolve & WhenEvent` return interpolation function with duplicate points ! How to avoid?

In a simple example I switch the ode depending on two events. ...
Ulrich Neumann's user avatar
0 votes
1 answer
120 views

WhenEvent doesn't work as expected when the condition is satisfied in the first step

I have noticed strange behavior of WhenEvent in the case where the body of WhenEvent is satisfied in the first step. For example, ...
Thela Hun Ginjeet's user avatar
9 votes
3 answers
297 views

Solving a Nonlinear Complementary Problem (plasticity)

I would like to solve the following: given $t\mapsto\sigma(t)$ and $E>0$, $\sigma_y>0$, find $\epsilon$ such that: $$\left\lbrace\begin{array}{l}g(t,\epsilon)\geq 0,\\ \phi(t,\epsilon,\epsilon')\...
anderstood's user avatar
  • 14.2k
0 votes
0 answers
65 views

Giving variable inside WhenEvent a value

I am defining ParametricNDSolveValue in one cell and then using this in another one to find the parameter value using bisection. For clarity, I have simplified my differential equation. In order to ...
Thela Hun Ginjeet's user avatar
4 votes
1 answer
141 views

How to increase the speed of NDsolve when using WhenEvent

I am trying to solve a set of ODE's with switching. I implemented using WhenEvents. ...
kosa's user avatar
  • 485
4 votes
1 answer
157 views

WhenEvent in Stochastic Differential Equation

Is there a way to add events with WhenEvent or similar when using ItoProcess? Minimal example of my problem would be to change ...
Radost's user avatar
  • 211
4 votes
1 answer
123 views

How to count the number of collisions in real time?

I want to show in real time the number of times a blue object hits a red object or wall (=y axis). ...
Hoony's user avatar
  • 1,520