coupled differential equation and Matlab ode45
Thu, 03/04/2021 - 12:26 pm
I am solving 2 coupled ode's:
P, Q, K0, G0 are constants.
I am using the following functions:
SetScale/P x 0,0.0001,DEMout
DEMout[%K] = kk
DEMout[%G] = kk
IntegrateODE/M=0/u=1000 Berryman, KK, DEMout
function Berryman(pw, tt, yw, dydt)
variable theta, fn, nu, r, a, b, Pa, Qa
// lots of calculations to get P and Q
a=pw/pw-1 // pw = 0 so it is always true that a=-1
b=(1/3)*(pw/pw-pw/pw) // pw = 0 so it is always true that b=(1/3)*(pw/pw)
// also, when pw = 0 (b = 0) there is virtually no discrepancy
variable f9a=a*((r-1)*fn-r*theta) + b*theta*(3-4*r)
Pa = f1a/f2a
Qa = 1/5*(2/f3a+1/f4a+(f4a*f5a+f6a*f7a-f8a*f9a)/f2a/f4a)
// the differential equation:
dydt = (pw-yw)/(1-tt)*Pa
dydt = (pw-yw)/(1-tt)*Qa
It seems to be working fine, but when I compare the output with results from Matlab (its original environment) there is a discrepancy. This issue only seems to arise for certain cases (when 'asp' is small AND pw is nonzero), which really should only affect the calculate values of P and Q, but otherwise not change how the function operates.
Is there any known difference between ODE solvers? Both Igor and Matlab are supposedly using Runge-Kutta (plus, I get the same result from Igor using other algorithms).