Skip to main content

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
4 votes
1 answer
140 views

How can I use WhenEvent to make one object (follower) follow another obect (mover) with a gap between them?

My problem I'm trying to implement a program in Mathematica where a "follower" moves with a "mover." Both the mover and the follower move up and down. Specifically: 1. There is a ...
xinxin guo's user avatar
  • 1,467
8 votes
1 answer
234 views

Why can't I use logic operator Or to specify multiple events with WhenEvent?

I want to use logic operator Or to specify multiple events. After reading these very helpful posts here and here, it seems to be better to use a function to inlude ...
xinxin guo's user avatar
  • 1,467
1 vote
0 answers
69 views

Why does WhenEvent not work with DiscontinuitySignature and the Brent location method?

Why is it not possible to use "LocationMethod" -> "Brent" to locate an event when the action is ...
Escall's user avatar
  • 31
2 votes
1 answer
95 views

Why doesn't the action in my code using WhenEvent option of NDSolve work?

I'm trying to solve two ODEs, and I want to restrict the variables y1[t] and y2[t] from being less than the constant ...
xinxin guo's user avatar
  • 1,467
2 votes
0 answers
80 views

NDSolve with integrated event, discrete variable and arbitrary-precision arithmetic gives error

I'm trying to solve an ODE numerically with NDSolve but get an unexpected error message (Experimental`NumericalFunction::nlnum1),...
Escall's user avatar
  • 31
0 votes
0 answers
97 views

Mod[] does not work correctly in WhenEvent

From the expression we know Mod[t,1]==0 and Sin[2 [Pi] t] > 0 are equivalent in WhenEvent. This can be seen from the results below. ...
metroidman's user avatar
  • 1,005
2 votes
1 answer
80 views

Discrete number does not work well in DSolve

The code below works fine. ...
metroidman's user avatar
  • 1,005
2 votes
1 answer
148 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
  • 1,005
3 votes
2 answers
250 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
  • 1,005
2 votes
1 answer
66 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
84 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
40 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,065
1 vote
0 answers
69 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
254 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
1 vote
1 answer
96 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
39 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
174 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
3 votes
1 answer
200 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.6k
1 vote
1 answer
66 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
108 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
97 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
548 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 ...
user444's user avatar
  • 2,688
8 votes
2 answers
288 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
228 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
49 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
86 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
3 votes
0 answers
157 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
  • 165
8 votes
2 answers
253 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
  • 165
9 votes
3 answers
536 views

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

...
yode's user avatar
  • 27k
2 votes
1 answer
88 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
337 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,467
1 vote
0 answers
48 views

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

...
Souraj Ghosh's user avatar
1 vote
0 answers
89 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
145 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
173 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 ...
ayr's user avatar
  • 2,464
0 votes
0 answers
96 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,777
1 vote
1 answer
202 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
197 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
326 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
193 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
76 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
183 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
336 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
  • 161
1 vote
1 answer
160 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
  • 125
0 votes
2 answers
203 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
92 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
106 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
  • 125
1 vote
0 answers
106 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
164 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
317 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.4k