The basics are in the code below; I'll post more details and some examples on my blog in the next few days:
Code:
' Dimension an array for the results
ReDim YA2(0 To M - 1, 0 To N - 1)
' Set up the "State" object to transfer data between the AlgLib code and your code to evealuate the differential equations
' See AlgLib code comments or manual for more details
Call ODESolverRKCK(YA(), N, XA2, M, Eps, Step, State)
' Loop through ODESolver and evaluation of DE until all steps have converged
Rtn = True
Do While Rtn = True
Rtn = ODESolverIteration(State)
' Either hard code evaluation of the Diff Equn(s) or call a VBA function with the name specefied in FuncName as shown below
State.DY = Application.Run(FuncName, State.X, State.Y, CoeffA)
Loop
' Extract the results array from the State function
Call ODESolverResults(State, M, XA2, YA2, Rep)
ODE = YA2
A typical simple function to evaluate the Dif Equn is shown below:
Code:
Function ODEFunc1(X As Double, Y As Variant, CoeffA As Variant) As Variant
Dim ResA(0 To 0) As Double
ResA(0) = CoeffA(1, 1) * Y(0)
ODEFunc1 = ResA
End Function
To call that function insert the line:
FuncName = "ODEFunc1"
Note that Y, CoeffA and the function return value are dimensioned as variants because they may contain 1 or more values.