# Using Julia to solving ODE switched systems?

**URL:** https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678
**Category:** New to Julia
**Created:** [April 8, 2024, 11:51am UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678 "2024-04-08T11:51:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tridane](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tridane](https://discourse.julialang.org/u/tridane)
#### Post date: [April 8, 2024, 11:51am UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678/1 "2024-04-08T11:51:48Z")

</div>

Hi All,  
I am new to Julia. I was wondering if there is any effort in solving ODE switched systems?

Thank You.

A. Tridane

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 8, 2024, 12:44pm UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678/2 "2024-04-08T12:44:34Z")

</div>

> [@tridane](#):
>
> I am new to Julia. I was wondering if there is any effort in solving ODE switched systems?

How do you define such systems?

---

<div class="post-metadata">

### Author: ![tridane](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tridane](https://discourse.julialang.org/u/tridane)
#### Post date: [April 9, 2024, 11:50am UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678/3 "2024-04-09T11:50:18Z")

</div>

Thank you for the reply  
For example this type of system  
x’(t) = -ax(t)(y(t)+z(t))  
y’(t)= a x(t) (y(t)+z(t))- (g(t)+b)y(t)  
z’(t)= g(t)y(t)-cz(t)  
w’(t)= by(t)+cz(t)

with g(t) = g1 for t \< tau  
g(t)= g2 for t \> tau

The parameters of the system are constant except g(t). This is an example of only two modes switches. We can have more then two switches, but finite number of course!  
Thank you.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 9, 2024, 11:53am UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678/4 "2024-04-09T11:53:24Z")

</div>

That’s just a system with callbacks. See for example

> **[Event Handling and Callback Functions · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/#PresetTimeCallback)**
>
> Documentation for DifferentialEquations.jl.

Just switch a parameter.

---

<div class="post-metadata">

### Author: ![tridane](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tridane](https://discourse.julialang.org/u/tridane)
#### Post date: [April 12, 2024, 3:24pm UTC](https://discourse.julialang.org/t/using-julia-to-solving-ode-switched-systems/112678/5 "2024-04-12T15:24:36Z")

</div>

Thank you! this is very helpful.
