I’m trying to solve the following DAE:
The solution obtained from a simulator is:
Nevertheless, we want to solve the model with
DifferentialEquations.jl, and I’ve tried with the following code:
using DifferentialEquations, Plots f = 10E3 ω = 2*π*f n = 1 C = 0.01E-6 VT = 25E-3 IS = 1E-6 A = 1.0 R = 10E3 function func(out, du, u, p, t) V0, IR = u dV0, _ = du out = C*dV0 - IR out = (A*sin(ω*t) - V0 - n*VT*log(1+IR/IS)) - R*IR end B = A*ω/R/(1+n*VT/R/IS) u₀ = [0, 0.0] # V0, IR du₀ = [0, B] # dV0, dIR dvars = [true, false] tspan = (0, 2E-3) prob = DAEProblem(func, du₀, u₀, tspan, differential_vars=dvars);
It gives the following error:
sol = solve(prob) DomainError with -0.33407903800223493: log will only return a complex result if called with a complex argument. Try log(Complex(x)).
What do you suggest to tackle this problem?