forum.alglib.nethttp://forum.alglib.net/ odesolverhttp://forum.alglib.net/viewtopic.php?f=2&t=24 Page 1 of 1

 Author: ChemE [ Fri Jun 11, 2010 7:44 pm ] Post subject: odesolver Can U please tell me how to run odesolver in VBA from Excel?Thanks!

 Author: Doug Jenkins [ Sun Jun 13, 2010 11:55 am ] Post subject: Re: odesolver 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 resultsReDim 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 detailsCall ODESolverRKCK(YA(), N, XA2, M, Eps, Step, State)' Loop through ODESolver and evaluation of DE until all steps have convergedRtn = TrueDo 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 belowState.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 = YA2A typical simple function to evaluate the Dif Equn is shown below:Code:Function ODEFunc1(X As Double, Y As Variant, CoeffA As Variant) As VariantDim ResA(0 To 0) As DoubleResA(0) = CoeffA(1, 1) * Y(0)ODEFunc1 = ResAEnd FunctionTo 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.

 Author: ChemE [ Sun Jun 13, 2010 12:19 pm ] Post subject: Re: odesolver Thanks!By the way, nice blog.

 Author: Doug Jenkins [ Fri Jun 18, 2010 3:02 am ] Post subject: Re: odesolver I have now posted details of running the AlgLib ODE solver routine via an Excel UDF here:http://newtonexcelbach.wordpress.com/20 ... ith-excel/The post includes a link to a download file, including all the necessary code and the five examples shown.

 Author: marcof [ Wed Jun 30, 2010 8:46 am ] Post subject: Re: odesolver Hi,Great code!Can I solve systems of differential equations with this code?I have a system with 9 differential equations that I solve usually with matlab (ode45), but I would love to solve it with an excel base software.Is it possible?Best regardsMF

 Author: Doug Jenkins [ Wed Jun 30, 2010 10:11 am ] Post subject: Re: odesolver Marco - I imagine that it is possible, but I'd have to look into it and I don't have time at the moment.Maybe Sergey can give some guidance!

 Author: Sergey.Bochkanov [ Thu Jul 01, 2010 8:11 am ] Post subject: Re: odesolver marcof wrote:Can I solve systems of differential equations with this code?I have a system with 9 differential equations that I solve usually with matlab (ode45), but I would love to solve it with an excel base software.If you talk about something likeCode:dy0/dx = f0(y0, ..., y8, x)dy1/dx = f1(y0, ..., y8, x)...dy8/dx = f8(y0, ..., y8, x)then - yes, you can do it. ODESolverState structure has Y and DY fields which are vectors. You can read y0..y8 and x from State.Y[0:8] and State.X and write f0...f8 to State.DY[0:8] every time you return from ODESolverIteration function.

 Author: marcof [ Wed Jul 07, 2010 5:45 pm ] Post subject: Re: odesolver Brilliant!Many thanks for your code. I will use it for sure in the near future!!MF

 Page 1 of 1 All times are UTC Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/