Skip to content

Commit f9f5257

Browse files
author
fchen121
committed
Created FDE to ODE for one equation with alpha < 1
1 parent c09883e commit f9f5257

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/systems/diffeqs/basic_transformations.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,46 @@ function change_of_variables(
184184
return new_sys
185185
end
186186

187+
function FDE_to_ODE(eqs, alpha, epsilon, T; initial=0)
188+
@independent_variables t
189+
@variables x(t)
190+
D = Differential(t)
191+
δ = (gamma(alpha+1) * epsilon)^(1/alpha)
192+
193+
a = pi/2*(1-(1-alpha)/((2-alpha) * log(epsilon^-1)))
194+
h = 2*pi*a / log(1 + (2/epsilon * (cos(a))^(alpha - 1)))
195+
196+
x_sub = (gamma(2-alpha) * epsilon)^(1/(1-alpha))
197+
x_sup = -log(gamma(1-alpha) * epsilon)
198+
M = floor(Int, log(x_sub / T) / h)
199+
N = ceil(Int, log(x_sup / δ) / h)
200+
201+
function c_i(index)
202+
h * sin(pi * alpha) / pi * exp((1-alpha)*h*index)
203+
end
204+
205+
function γ_i(index)
206+
exp(h * index)
207+
end
208+
209+
new_eqs = Equation[]
210+
rhs = initial
211+
def = Pair{Num, Int64}[]
212+
213+
for index in range(M, N-1; step=1)
214+
new_z = Symbol(:z, :_, index-M)
215+
new_z = ModelingToolkit.unwrap(only(@variables $new_z(t)))
216+
new_eq = D(new_z) ~ eqs - γ_i(index)*new_z
217+
push!(new_eqs, new_eq)
218+
push!(def, new_z=>0)
219+
rhs += c_i(index)*new_z
220+
end
221+
eq = x ~ rhs
222+
push!(new_eqs, eq)
223+
@mtkcompile sys = System(new_eqs, t; defaults=def)
224+
return sys
225+
end
226+
187227
"""
188228
change_independent_variable(
189229
sys::System, iv, eqs = [];

0 commit comments

Comments
 (0)