Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [event-detection]

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

0
votes
0answers
56 views

WhenEvent not setting discrete variables in If clause

The following example shows two functionally identical versions of the same WhenEvent. The two versions rely on two conditions Condition A and Condition B being satisfied and differ only in the order ...
2
votes
1answer
85 views

Having trouble using WhenEvent with NDSolve

First of all, this is my first time on this forum. Please be patient with me because if I make some mistakes in this post. I'm not used to doing this! I'm trying to modify a parameter during ...
0
votes
1answer
32 views

Changing the integration equation in NDSolve upon an event

I'm trying to implement the solution to the following ODE dx/dt = -x for x < 0 dx/dt = x for x > 0 Using NDSolve and ...
2
votes
2answers
130 views

Using WhenEvent to limit the derivative

In the system below, would like to keep z[t] between 0 and 1. The intent of the code below is to use WhenEvent to detect when z[t] reaches the limit of 1, and then only allow negative values of the ...
2
votes
2answers
241 views

Solve PDE with complicated coefficient non-linearity [closed]

I wish to solve is the heat equation with solution-dependent coefficient. The equation along with BC's and IC's are as follows: $\begin{equation} \frac{\partial P[x,t]}{\partial t}-\alpha[x,t]\frac{\...
1
vote
1answer
71 views

WhenEvent detects only the first event

My code is based on the suggestion in this discussion by Michael E2 And when I'm using the same definitions the WhenEvent function locates only the first time the ...
-1
votes
1answer
94 views

Why doesn't WhenEvent work in this case?

yb[a_?NumericQ] := a^2; eqns = {x'[s] == -yb[s], WhenEvent[x'[s] > 0, {yb[s] -> - yb[s]}], x'[0] == 0} NDSolve[eqns, x[s], {s, -50, 50}] The ...
3
votes
1answer
52 views

How to trigger WhenEvent for NDSolve in parallel?

Say I have a system of differential equations that I need to solve for different initial conditions and say the process is sufficiently expensive and I have sufficiently many that I am calculating in ...
1
vote
1answer
46 views

Solution dependent variable -how to use WhenEvent

I'm having trouble using WhenEvent function in two-dimensional functions: My goal is to change the value of a diffusion coefficient $\alpha[x, t]$ as a function of ...
2
votes
1answer
66 views

Understanding WhenEvent option: “DiscontinuitySignature”

Trying to understand WhenEvent I modified a simple Example (Help WhenEevent) ...
1
vote
0answers
63 views

stick-slip oscillator: Missed WhenEvent

Using Mathematica I try to modell the stick slip effect as recommended in the documentation (WhenEvent). The initial condition starts from a state ...
3
votes
2answers
112 views

Issues With WhenEvent in PDEs

I am trying to solve the PDE below: ...
0
votes
2answers
95 views

Using WhenEvent to calculate the period of an orbit

I'm having trouble trying to have Mathematica tell me when the period of the orbit of my system is. Namely, I'm trying to use Mathematica to find the orbital period of the Earth around the Sun. Here's ...
3
votes
1answer
75 views

WhenEvent - energy conservation not valid [closed]

I would like to simulate the following conservative system, with purely elastic impacts (coefficient of restitution is 1). Applying the WhenEvents the energy of the system is not conserved. How can I ...
0
votes
3answers
135 views

Using WhenEvent to Change the Sign of a Constant

I am attempting to change the sign of a constant when a certain condition is met during a numerical integration. Here is the code: ...
3
votes
2answers
162 views

Increase Performance of WhenEvent in NDSolve

I'm trying to reset the value of functions $u_{i}$ when they reach a threshold $θ$. Below the threshold, they evolve according to a simple differential equation. The $r_{i}$ resets the derivative to ...
2
votes
1answer
87 views

Event Trigger Ode's

I am trying to simulate a Hybrid system using the WhenEvent function in Mathematica. I have asked this question earlier. It was not an MWE. Now I tried to make an ...
5
votes
1answer
77 views

How to reflect from an ellipse while solving a system of differential equations?

While solving a system of differential equations to plot trajectories, we can use NDSolve and WhenEvent like shown here. I am trying to solve this for a system of equations (Hamiltons Equations) for ...
1
vote
1answer
104 views

WhenEvent, Storing Sow data, Loops

My problem is essentially to do with manipulating and storing Sow data in a nested loop structure. I have a set of differential equations describing time-evolution of a bunch of variables. ...
5
votes
1answer
145 views

WhenEvent not triggering

I have a PDE describing a bending beam which I want to solve numerically. ...
1
vote
0answers
37 views
0
votes
1answer
72 views

Exclude evaluation of a function at certain points

I run an experiment when I put some nutrients every day in week days but not in weekends. So I have a system of differential equations where I use the WhenEvent function to define the periodic pulses ...
1
vote
1answer
148 views

ParametricNDSolve with Event

Using ParametricNDSolve ...
5
votes
1answer
96 views

Using WhenEvent with DSolve (not NDSolve)

The documentation says WhenEvent expressions can be used in NDSolve, NDSolveValue, ParametricNDSolve, ParametricNDSolveValue, DSolve, and DSolveValue. But when I try this toy case ...
3
votes
1answer
129 views

NDSolve message: Step size changed sign at t == 65.380000

I wanted to solve a nonlinear DDE until a given condition. I got the following error message: NDSolve::ndssc: Step size changed sign at t == 65.380000. Does anyone know the solution?
3
votes
2answers
152 views

Sow in WhenEvent can't extract parameter value of ParametricNDSolve

This is a problem I noticed when trying to answer this question. Just consider the following toy example: ...
1
vote
2answers
214 views

Using NDSolve with Manipulate when singularity or stiffness detected

I want to solve a little bit complicated system of ODEs, where I have to vary initial conditions. My attempt to solution is like this (similar to what I found here Using ndsolve within manipulate): <...
1
vote
0answers
82 views

Adding a perturbation to a dynamic 3-tier food chain model

I have a predator prey food chain model set up as follows, with x representing the resource, y the consumer, and z the predator: ...
7
votes
1answer
99 views

Weird behaviour in `WhenEvent`

Consider the following code (taken from question 158857): ...
1
vote
1answer
140 views

Parameter which is updated in NDSolve equation

I have an NDSolve problem which is easy to solve numerically, given by $$m y''(x)+\Xi(y(x)) = -mg, \quad y(0)=y_0, \quad y'(0)=v_0$$ where $\Xi(y(x))$ may be some ...
9
votes
0answers
293 views

Spurious Error Messages from NDSolve when Using WhenEvent with Time Delays

Bug introduced between versions 10.1 and 10.4, and resolved in 11.3. Using either 11.2 or 10.4 on Windows 10 (64 bit), I am unable to reproduce the answer by March to question 99576. Specifically, ...
1
vote
1answer
93 views

speed of WhenEvent in NDSolve with many events

Is there a way to speed up NDSolve with WhenEvent in this example (many state variables and many events)? ...
1
vote
1answer
31 views

Modifying this GoL implementation to make it sensible to clicks on the corner of the array

I'm interested in modifying this interactive implementation of the Game of Life http://demonstrations.wolfram.com/RealTimeSimulationOfTheGameOfLife/ to make it sensible to click events on the ...
2
votes
1answer
82 views

Issue with `WhenEvent` with dependence in a parameter

Here I define the equations: ...
4
votes
1answer
182 views

Options of WhenEvent

I'm using NDSolve and WhenEvent to simulate building heating systems and their discontinuous operation. Here is a simplified example. The idea is quite simple. I have the following WhenEvents: <...
4
votes
1answer
217 views

Pendulum, pulleys and friction

Considering the following physical situation: and writing the following code: ...
1
vote
1answer
474 views

Harmonic oscillator with damping attrition

Considering the following physical situation: and writing the following code: ...
2
votes
1answer
90 views

Detecting crossing events of jumps with NDSolve

Backgroud: I'm simulating temporal data of soil moisture $s(t)$ at a daily time scale by generating a random function with a compound Poisson process. ...
3
votes
1answer
86 views

Reap output sequence depends upon inputs— How do I specify the order of reap output?

I am simulating two groups of interacting oscillators, swings and metronomes. When I perform the NDSolve, I also extract the peaks of the swings and the metronomes. This was going fine until I changed ...
23
votes
3answers
2k views

Ball Bouncing on Hilly Terrain

There is a maple code for the bouncing ball on the given curve. I tried to make this animation by using Mathematica Why does the following code not work? ...
0
votes
0answers
48 views

How do I detect two sets of events with WhenEvent? [duplicate]

I have a system of two kinds of interacting oscillators. I represent these oscillator types with phi and theta. I want to extract, using Reap and WhenEvent, the times and values of the maxima of these ...
5
votes
2answers
290 views

Force NDSolve to choose given branch at a critical point

I am trying to find the solution of f[x,y]==0 by integrating along the curve starting from a point (vars1): ...
4
votes
2answers
320 views

Calculating the current through coil with a flyback diode using NDSolve

I plan to simulate the current through a coil with flyback (or freewheel) diode for an arbitrary voltage signal (square or PWM modulated signal is possible). You can find the circuit diagram over ...
2
votes
1answer
186 views

Problem with WhenEvent in solving a PDE with NDSolveValue

I have problem with my PDE. The problem is as bellow: I used "WhenEvent" operator to solve it. The code is: ...
0
votes
0answers
73 views

Custom FrontEndToken calls

So I've been playing with FrontEndTokens recently and discovered that there are some of them that don't seem to have a standard-usage way of being called. For ...
4
votes
2answers
224 views

WhenEvent does not detect event

I'm having some trouble stopping NDSolve when the solutions gets outside of a given domain. There are five unknowns, and NDSolve ...
1
vote
1answer
178 views

Why does NDSolve return the stiff system error in this case?

I was playing with the WhenEvent method of NDSolve and was simulating the dynamics of a spring-mass system with two degrees-of-...
1
vote
1answer
75 views

Integrate function in segments of defined area (and get borders)

I have to integrate a function and need to split the area under the function in segments of equal area. Of all the areas I get, I need the values of the borders on the x axis. I found an approach ...
1
vote
1answer
126 views

Several WhenEvents within NDSolve[] - loss of events

I need to solve a differential equation numerically wherein two "events" must trigger independently and one of the WhenEvent[] "actions" changes it's own "...
3
votes
2answers
229 views

Using EventLocator to detect periodic solutions in NDSolve

I loop over some systems of DAEs with NDSolve; some solutions are periodic, some are not. When integrating with NDSolve, I ...