Hi everybody,
I’m now to Julia and trying to translate a simple slider-block model from Python. The code is modelling earthquake cycles. It consists mainly of a set of 3 differential equations. In Python, I use from scipy.intergrate the function solve_ivp which solves the differential equations with many different solvers reliably. I figured out that the solver ‘lsoda’ is fasted for what I need.
However, on my translated code in Julia, where I use ‘solve’ also with ‘lsoda’, the equations are not solved correctly. Essentially the solver misses the earthquake cycles, which are very short. I expect a behaviour like in the attached plot. However, Julia does not replicate, what I would expect.
Here is a minimal code example. I’m happy for any help!
using DifferentialEquations
using LSODA
#set parameters here
a = 1.899e-2        # material property
b = 2.959e-2        # material property
mu = 5e-02          # steady-state friction (no steady state at mu=0)
sigma = 1.5e5       # Pa normal stress
k = 1e8             # N/m spring constant
vload = 1.6e-7      # m/s starting velocity
v0 = 2.2e-6         # m/s reference velocity 
L = 9.0e-6 ;        # m characterisitc slip distance
# set of differential equations
function sb_funcs(dY,Y,pars,t)
    a,b,mu,sigma,k,vload,v0,L = pars
    tau = Y[2]   # shear stress
    theta = Y[3] # state variable
    eps = 1e6    # small perturbation
    sdot = exp(-mu/a)*v0 * (v0*theta/L)^(-b/a) * exp(tau/a/sigma-1) # velocity
    taudot = k * (vload - sdot)                                     # shear stress
    thetadot = 1 - (sdot * (theta - eps) / L)                       # state evolution
    dY = [sdot, taudot, thetadot]
    return dY
end
#run the model
tspan = (0.0,7200)                     # time span
pars_in = (a,b,mu,sigma,k,vload,v0,L)  # input parameters
y0 = [0., 1e-6, 1e-6]                  # starting values
#define the ODE Problem
prob = ODEProblem(sb_funcs,y0,tspan,pars_in)
#solve differential equations
sol = solve(prob, lsoda(), abstol=1e-9, reltol=1e-9, save_everystep=true)
The solver returns:
retcode: Success
Interpolation: 1st order linear
t: 7-element Vector{Float64}:
    0.0
    0.22768399153212332
    0.45536798306424664
 2277.2952833042973
 4554.13519862553
 6830.9751139467635
 7200.0
u: 7-element Vector{Vector{Float64}}:
 [0.0, 1.0e-6, 1.0e-6]
 [0.0, 1.0e-6, 1.0e-6]
 [-1.1281505e-317, 1.0e-6, 1.0e-6]
 [-1.2854371873e-314, 1.0e-6, 1.0e-6]
 [1.2845366769083356e-306, 1.0e-6, 1.0e-6]
 [2.927253055270818e-303, 1.0e-6, 1.0e-6]
 [2.1337310042281397e-302, 1.0e-6, 1.0e-6]
            

