Hi,
I have been trying to use a SplitODEProblem
to solve the equations of motion of a pulse propagating along a transmission line but I get the following message:
ERROR: LoadError: type GMRESIterable has no field reltol
I am using DifferentialEquation v6.16.0.
Here’s a code snippet that reproduces the issue:
using DifferentialEquations
struct TL2
L::Float64
C::Float64
Rl::Float64
N::Int
end
struct Drive2{F}
Rd::Float64
waveform::F
end
struct GaussianPulse2
amp::Float64
t0::Float64
width::Float64
end
V(s::GaussianPulse2, t) = s.amp*exp.( -(t-s.t0)^2/(2*s.width) )/sqrt(2π*s.width)
(s::GaussianPulse2)(t) = V(s, t)
struct Circuit2{F}
tl::TL2
drive::Drive2{F}
end
function matrix_tl(tl::TL2)
L = tl.L
C = tl.C
N = tl.N
Rl = tl.Rl
A = zeros(2*(N+1)+2, 2*(N+1)+2)
A[1,3] = 1.0
A[N+3, N+2] = 1.0/Rl/C
A[N+3, N+3] = -1.0/Rl/C
for i in 3:N+2
A[i,(N+1)+ i] = 1.0/L
A[i,(N+1)+ i+1] = -1.0/L
A[(N+1)+ i + 1, i ] = 1.0/C
A[(N+1)+ i + 1, i+1] = -1.0/C
end
return DiffEqArrayOperator(A)
end
matrix_tl(circuit::Circuit2) = matrix_tl(circuit.tl)
function drive_tl(dy, y, circuit::Circuit2, t)
Vd_dot = gradient(circuit.drive.waveform, t)[1]
Rd = circuit.drive.Rd
N = circuit.tl.N
dy[2 + (N+1) + 1] = Vd_dot - Rd*dy[3] - dy[2]
end
g = GaussianPulse2(0.3, 1.0, 1e-3)
drive = Drive2(50.0, g)
tl = TL2(0.02, 0.005, 0.008, 51)
circuit = Circuit2(tl, drive)
y0 = zeros(2*(tl.N+1)+2)
prob = SplitODEProblem(matrix_tl(circuit), drive_tl, y0, (0.0, 5.0), circuit)
sol = solve(prob, tstops=(1.0))
Thanks for letting me know if you how how to fix this error.
P.S. Any comments that would help speedup the code is also highly appreciated