DotNumerics

DotNumerics - Initial-value problem for nonstiff and stiff ordinary differential equations ODEs - Messages

#1 Posted: 7/13/2013 3:50:08 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

DotNumerics

SMath Studio compatibility SMath Viewer compatibility mono compatibility Extension page Sources


Functions list:

Show Spoiler



Differential Equations. Initial-value problem for nonstiff and stiff ordinary differential equations ODEs (explicit Runge-Kutta, implicit Runge-Kutta, Gear’s BDF and Adams-Moulton).

Solvers for Non-Stiff Systems:

dn_AdamsMoulton(init, x1, x2, intvls, D) solves an initial-value problem for nonstiff ordinary differential equations using the Adams-Moulton method.

dn_ExplicitRK45(init, x1, x2, intvls, D) solves an initial-value problem for nonstiff ordinary differential equations using the explicit Runge-Kutta method of order (4)5.


Solvers for Stiff Systems:

dn_ImplicitRK5(init, x1, x2, intvls, D) solves an initial-value problem for stiff ordinary differential equations using the implicit Runge-Kutta method of order 5.

dn_GearsBDF(init, x1, x2, intvls, D) solves an initial-value problem for stiff ordinary differential equations using the Gear’s BDF method.


Arguments:

- init is either a vector of n real initial values, where n is the number of unknowns (or a single scalar initial value, in the case of a single ODE).
- x1 and x2 are real, scalar endpoints of the interval over which the solution to the ODE(s) is evaluated. Initial values in init are the values of the ODE function(s) evaluated at x1.
- intvls is the integer number of discretization intervals used to interpolate the solution function. The number of solution points is the number of intervals + 1.
- D is a vector function of the form D(x,y) specifying the right-hand side of the system

Options:

- AbsTol - absolute tolerance parameter, default value 10⁻⁷.
- RelTol - relative tolerance parameter, default value 10⁻⁴.



Links:

1. DotNumerics is a website dedicated to numerical computing for .NET. DotNumerics includes a Numerical Library for .NET. The library is written in pure C# and has more than 100,000 lines of code with the most advanced algorithms for Linear Algebra, Differential Equations and Optimization problems. The Linear Algebra library includes CSLapack, CSBlas and CSEispack, these libraries are the translation from Fortran to C# of LAPACK, BLAS and EISPACK, respectively.

2. Arenstorf orbit. Numerical Analysis: Theory and Applications. Proseminar, 28.03.2011, UIBK [pdf].

3. How to find spatial periodic orbits around the Moon in the TBP.

Books:

1. Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems.

[albumimg]237[/albumimg]

Examples:

[albumimg]232[/albumimg] [albumimg]241[/albumimg] [albumimg]242[/albumimg] [albumimg]243[/albumimg]

[albumimg]1564[/albumimg] [albumimg]1579[/albumimg] [albumimg]1580[/albumimg] [albumimg]1567[/albumimg] [albumimg]1566[/albumimg] [albumimg]1565[/albumimg]

dn.ode.kinetic1.sm (8 KiB) downloaded 109 time(s).
dn.ode.kinetic2.sm (12 KiB) downloaded 82 time(s).
dn.ode.kinetic3.sm (12 KiB) downloaded 81 time(s).
dn.ode.test1.sm (19 KiB) downloaded 89 time(s).
dn.ode.test2.sm (18 KiB) downloaded 87 time(s).
dn.ode.Amplitude detector.sm (20 KiB) downloaded 93 time(s).

dn.ode.kinetic1.pdf (77 KiB) downloaded 94 time(s).
dn.ode.kinetic2.pdf (93 KiB) downloaded 74 time(s).
dn.ode.kinetic3.pdf (91 KiB) downloaded 69 time(s).
dn.ode.test1.pdf (115 KiB) downloaded 72 time(s).
dn.ode.test2.pdf (120 KiB) downloaded 72 time(s).
dn.ode.Amplitude detector.pdf (148 KiB) downloaded 72 time(s).

See also:

● [topic=726]Mathcad Toolbox[/topic]
● [topic=13809]SADEL[/topic]
● [topic=1970]Matlab C++ Math Library[/topic]
● [topic=17063]OSLO[/topic]
● [topic=17067]lsoda[/topic]
● [topic=1997]GNU Scientific Library (GSL)[/topic]
DorNumerics. ODE. Arenstorf orbit.sm (91 KiB) downloaded 124 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
4 users liked this post
Davide Carpi 7/14/2013 9:00:00 AM, ioan92 7/13/2013 6:54:00 AM, Radovan Omorjan 7/13/2013 7:01:00 AM, IVR 7/13/2013 5:01:00 AM
#2 Posted: 7/14/2013 3:15:34 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Thank you uni,

dn_GearsBDF might be the ODE solver of choice for SMath. I would not mind some more solvers as well

Regards,
Radovan



Updated. dn_AdamsMoulton(), dn_ExplicitRK45(), dn_ImplicitRK5() added.

In Russia we say: получите, распишитесь.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Radovan Omorjan 7/14/2013 5:28:00 AM
#3 Posted: 7/14/2013 5:41:33 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

uni,

If you are by any chance here on Thassos-Greece (I am here with my family on the vacation) just let me know and come for a beer

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 users liked this post
#4 Posted: 7/14/2013 8:55:08 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

You're a lucky man, on Greek island with beer and I'm in Siberia with the bears
Russia ☭ forever, Viacheslav N. Mezentsev
#5 Posted: 7/14/2013 8:56:35 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

By the way uni,

I am just curious how is the numerical accuracy controlled in all your solvers? There is no any additional parameter about this, or I was wrong about it?.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#6 Posted: 7/14/2013 8:59:20 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

You're a lucky man, on Greek island with beer and I'm in Siberia with the bears



If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 7/14/2013 9:04:02 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

By the way uni,

I am just curious how is the numerical accuracy controlled in all your solvers? There is no any additional parameter about this, or I was wrong about it?.

Regards,
Radovan



For all methods the following values​​:

RelTol = 1.0E-4,
AbsTol = 1.0E-7

I will add the ability to change it. I think, using variables in the document: RelTol and AbsTol.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Radovan Omorjan 7/14/2013 9:09:00 AM
#8 Posted: 7/14/2013 9:08:34 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote

Wrote

You're a lucky man, on Greek island with beer and I'm in Siberia with the bears





Just imagine how different we are?. My "Lord of the ring" bring us here - me and our children, and I am most interested to "chat" here with you about the ODE solvers . Someone will say that I am crazy - my wife a.k.a "Lord of the Ring" would be the first one .

Regards,
Radovan

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 users liked this post
Davide Carpi 7/14/2013 9:29:00 AM
#9 Posted: 7/14/2013 9:30:28 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote

Wrote

By the way uni,

I am just curious how is the numerical accuracy controlled in all your solvers? There is no any additional parameter about this, or I was wrong about it?.

Regards,
Radovan



For all methods the following values​​:

RelTol = 1.0E-4,
AbsTol = 1.0E-7

I will add the ability to change it. I think, using variables in the document: RelTol and AbsTol.


I must be annoying now , but could you try please try to reduce this numbers just a bit and try my "famous" example with bioreactions. I used recently some ODE stiff solvers from a package inside R. They gave the same results with negative concentration. Then, I reduced the default values for the accuracy and it worked a bit longer, but gave me the expected zero concentration.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#10 Posted: 7/14/2013 2:52:57 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Wrote

Wrote

By the way uni,

I am just curious how is the numerical accuracy controlled in all your solvers? There is no any additional parameter about this, or I was wrong about it?.

Regards,
Radovan



For all methods the following values​​:

RelTol = 1.0E-4,
AbsTol = 1.0E-7

I will add the ability to change it. I think, using variables in the document: RelTol and AbsTol.


I must be annoying now , but could you try please try to reduce this numbers just a bit and try my "famous" example with bioreactions. I used recently some ODE stiff solvers from a package inside R. They gave the same results with negative concentration. Then, I reduced the default values for the accuracy and it worked a bit longer, but gave me the expected zero concentration.

Regards,
Radovan



Updated. I've added support for accuracy (not completely). The library allows to set accuracy for each equation separately. Now for all the equations will be the same accuracy.

[albumimg]245[/albumimg]
Russia ☭ forever, Viacheslav N. Mezentsev
#11 Posted: 7/14/2013 3:57:40 PM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote

Wrote

Wrote

Wrote

By the way uni,

I am just curious how is the numerical accuracy controlled in all your solvers? There is no any additional parameter about this, or I was wrong about it?.

Regards,
Radovan



For all methods the following values​​:

RelTol = 1.0E-4,
AbsTol = 1.0E-7

I will add the ability to change it. I think, using variables in the document: RelTol and AbsTol.


I must be annoying now , but could you try please try to reduce this numbers just a bit and try my "famous" example with bioreactions. I used recently some ODE stiff solvers from a package inside R. They gave the same results with negative concentration. Then, I reduced the default values for the accuracy and it worked a bit longer, but gave me the expected zero concentration.

Regards,
Radovan



Updated. I've added support for accuracy (not completely). The library allows to set accuracy for each equation separately. Now for all the equations will be the same accuracy.

[albumimg]245[/albumimg]



Yes ... This was simply great and a celebration for my eyes and soul .
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#12 Posted: 7/14/2013 7:34:48 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Amplitude detector.

[albumimg]246[/albumimg]
Amplitude detector.sm (14 KiB) downloaded 75 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
Radovan Omorjan 7/15/2013 1:29:00 AM, Davide Carpi 7/16/2013 11:17:00 AM
#13 Posted: 7/16/2013 4:26:31 AM
Fridel Selitsky

Fridel Selitsky

520 likes in 451 posts.

Group: User

Animation of one example of Uni


UniAnimac.sm (14 KiB) downloaded 85 time(s).
3 users liked this post
Davide Carpi 7/16/2013 4:35:00 AM, Вячеслав Мезенцев 7/16/2013 8:09:00 AM, ioan92 7/16/2013 4:43:00 PM
#14 Posted: 7/16/2013 11:03:00 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Hi Uni,



I've seen you can play the magician and make people's dreams to come true.

I have such a modest dream – ta have available in SMath some others modules from DOTNUMERICS, particularly the EISPACK one.

If my gentle request is not too abusive, please let me know how to address this package.


Please accept my wishes for an agreeable summer.

The same greetings for all the forum members and particularly to Andrey!



Ioan


Well, if that's possible, I'll do it. Thank you.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
ioan92 7/16/2013 5:23:00 PM
#15 Posted: 7/18/2013 5:44:14 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated.

[+]: dn_LinAlgSolve(), dn_LinAlgLLS_COF(), dn_LinAlgLLS_QRorLQ(), dn_LinAlgLLS_SVD(), dn_LinAlgSVD(), dn_LinAlgEigenvalues(), dn_LinAlgEigenvectors(), dn_MatrixInverse().

Quote

I have such a modest dream – ta have available in SMath some others modules from DOTNUMERICS, particularly the EISPACK one.


What kind of functions do you need?

I'm not sure that dn_LinAlgEigenvalues() works correctly.
DotNumerics. Linear Algebra. Example 1.sm (28 KiB) downloaded 103 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
ioan92 7/19/2013 1:23:00 PM, Radovan Omorjan 7/19/2013 1:25:00 AM
#16 Posted: 7/19/2013 1:40:19 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello uni,

I played a bit with your example. It seems to me that eigenvalues and eigenvectors are correct for both matrices A and F. For the matrice F you gave the vector of eigenvalues which should be correct ("must be" vector). It seems that both vectors of eigenvalues - this one and the one found by dn_LinAlgEigenvalues() correspond to the eigenvectors fond by dn_LinAlgEigenvectors(). I am not sure this should be all right then or some numerical "glitch" is involved here. For some simpler matrices it works Ok and we can get the desired result by simple transformations of eigenvectors. I do not know how the AlgLib works and which kind of transformtion uses in order to give one of the many possible solutions for eigenvectors. I might be wrong about all of this, of course.

This time again eval() must be used as well to get the result. Moreover, again the well known annoying thing that sometimes the results with and without eval() are slightly different. See the attached file please.

Regards,
Radovan
DotNumerics_LinearAlgebra_Example-corr.sm (106 KiB) downloaded 86 time(s).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
2 users liked this post
Вячеслав Мезенцев 7/19/2013 3:16:00 AM, ioan92 7/19/2013 1:23:00 PM
#17 Posted: 7/19/2013 4:02:29 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Yes, this is interesting. And I'm doing it this way.

[albumimg]250[/albumimg]
DotNumerics. Linear Algebra. Example 2.sm (11 KiB) downloaded 101 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
ioan92 7/19/2013 1:23:00 PM, Radovan Omorjan 7/19/2013 9:41:00 AM
#18 Posted: 7/19/2013 3:17:59 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated. Source code refactoring. Source code added.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
ioan92 7/19/2013 5:46:00 PM
#19 Posted: 7/20/2013 1:39:05 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Wrote

Yes, this is interesting. And I'm doing it this way.

[albumimg]250[/albumimg]



Hmm...If you use eigenvals() instead of Eigenvals(), you will get the roots as on the graph. I do not know what is the difference?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#20 Posted: 8/1/2018 12:22:44 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

dn_AdamsMoulton simple test 1.

[albumimg]1498[/albumimg]

dn_AdamsMoulton.test1.sm (11 KiB) downloaded 69 time(s).
dn_AdamsMoulton.test1.pdf (48 KiB) downloaded 60 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Radovan Omorjan 8/2/2018 3:04:00 AM
  • New Posts New Posts
  • No New Posts No New Posts