Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

5 Pages<12345>
Options
Go to last post Go to first unread
Offline mkraska  
#41 Posted : 05 August 2013 21:19:02(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,685
Germany

Was thanked: 928 time(s) in 586 post(s)
I played around a bit with the examples by Radovan.

My observations:
- using stack() or not is irrelevant in the single first order equation case.
- D and initial condition may be scalar or vector-valued.
- if() and Max() and eval() work, if D is defined inline (in the solver argument list), they do not work, if D is defined outside.
- the different behaviour of Rkadapt is due to poor convergence of the adaptivity algorithm.
- if rkfixed (and possibly the other solvers as well) fails, then you can evaluate the expression using = and get an error
- if rkfixed succeeds, there is no way to evaluate it using = (key is ignored), you have to use assignment instead

Edited by user 05 August 2013 21:29:55(UTC)  | Reason: Not specified

File Attachment(s):
if-max-eval.sm (13kb) downloaded 54 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 05/08/2013(UTC)
Offline uni  
#42 Posted : 05 August 2013 21:37:42(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,155
Man
Russian Federation

Was thanked: 1005 time(s) in 582 post(s)
Updated. Source code refactoring.

The problem here is not the solvers, the problem is in the values ​​of the function parameters.



Russia ☭ forever
Viacheslav N. Mezentsev
💰 Support me for plugins development: https://yoomoney.ru/to/410013245578758
thanks 1 user thanked uni for this useful post.
on 05/08/2013(UTC)
Offline uni  
#43 Posted : 05 August 2013 21:57:23(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,155
Man
Russian Federation

Was thanked: 1005 time(s) in 582 post(s)
Originally Posted by: mkraska Go to Quoted Post
I played around a bit with the examples by Radovan.

My observations:
- using stack() or not is irrelevant in the single first order equation case.
- D and initial condition may be scalar or vector-valued.
...

Do not recommend using scalars. The point is that the ode functions in SMath Studio are described as follows:
Quote:

new ArgumentInfo[] {
new ArgumentInfo( ArgumentSections.ColumnVector ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.Function )
}
);

For now there is no strict monitoring parameter types, but it can occur in the future. I can make support for scalar parameters, but then for every function I need to write it analog with different set of types of parameters.
Russia ☭ forever
Viacheslav N. Mezentsev
💰 Support me for plugins development: https://yoomoney.ru/to/410013245578758
thanks 1 user thanked uni for this useful post.
on 05/08/2013(UTC)
Offline mkraska  
#44 Posted : 05 August 2013 22:41:23(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,685
Germany

Was thanked: 928 time(s) in 586 post(s)
Originally Posted by: uni Go to Quoted Post

Do not recommend using scalars. The point is that the ode functions in SMath Studio are described as follows:
Quote:

new ArgumentInfo[] {
new ArgumentInfo( ArgumentSections.ColumnVector ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.RealNumber ),
new ArgumentInfo( ArgumentSections.Function )
}
);

For now there is no strict monitoring parameter types, but it can occur in the future. I can make support for scalar parameters, but then for every function I need to write it analog with different set of types of parameters.

Ok, I see. How about a generic ODESolve(method, y0, t0, t1, n, D), where method is some optional string indicating the numerical procedure. Then, whatever convenience UI stuff you add goes to all solvers.

Similar to the FindRoot function you might adopt the embedded assignment option, e.g. by specifying the initial conditions and iniial value of the independent variable in equation form like

ODESolve(mat(v≡1,s≡0,2,3,1),t≡0,1,10,D(t,y))

That would create vectors v, s and t, ready for plotting or further processing. In case of two requested vectors you might augment them into something like v_s which would immediately be good for plotting.

Edited by user 05 August 2013 22:45:24(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
Offline ignasi  
#45 Posted : 06 August 2013 11:53:41(UTC)
ignasi

Rank: Newbie

Groups: Registered
Joined: 04/07/2013(UTC)
Posts: 6
Man
Sweden
Location: Stockholm

Was thanked: 7 time(s) in 3 post(s)
Dear uni and omorr

I can not express in words how thankful I am and my admiration for your work. SMath studio will be my preferred tool from now on.

To help others I have the intention of making a “stirred tank reactor” example with microorganisms growing and consuming a substrate; I already have such an example in Mathcad from the time I was teaching. There is already a similar example posted in http://smath.info/wiki/Examples.ashx, but an example with the new plugin functions would be useful I believe.

Thanks again!
thanks 2 users thanked ignasi for this useful post.
on 06/08/2013(UTC),  on 07/08/2013(UTC)
Offline omorr  
#46 Posted : 06 August 2013 12:28:59(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
You are welcome and thank you Good
I am looking forward to your examples.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#47 Posted : 07 August 2013 01:40:12(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,685
Germany

Was thanked: 928 time(s) in 586 post(s)
I tried to summarize the results of the recent discussions as to how to use the ODE solvers. Up to now I assume that everything might work with any of the solvers but that is not tested thoroughly. It would be desirable to have some sort of benchmark problems and to compare the performance of the individual solvers. That might result in sort of usage recommendations, if not in a generic solver just like FindRoot.

Feel free to challenge and correct the statements in the attached handbook pages.

Edit: Minor corrections in the introduction (example description had a sign error) and in the requirements for D (there was a spurious result display for an expression with embedded :=, which I could not reproduce)

Edited by user 07 August 2013 12:52:16(UTC)  | Reason: Not specified

File Attachment(s):
section math ode.zip (67kb) downloaded 67 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 3 users thanked mkraska for this useful post.
on 07/08/2013(UTC),  on 07/08/2013(UTC),  on 07/08/2013(UTC)
Offline omorr  
#48 Posted : 07 August 2013 08:49:07(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Martin,

Once more, all my respect to you for having a good will and patience to extract all these things and put them together. I have to admit that sometimes I envy you for that Good

Regards,
Radovan

Edited by user 07 August 2013 14:42:25(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 07/08/2013(UTC)
Offline uni  
#49 Posted : 14 August 2013 05:51:32(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,155
Man
Russian Federation

Was thanked: 1005 time(s) in 582 post(s)
Updated. Added functions from the Intel® Ordinary Differential Equations Solver Library: rkm9st(), mk52lfn(), mk52lfa(), rkm9mkn(), rkm9mka().

mk52lfa() not finished yet.

Edited by user 14 August 2013 05:57:35(UTC)  | Reason: Not specified

File Attachment(s):
ODE_manual.pdf (240kb) downloaded 77 time(s).
ODESolvers. Van der Pol oscillator.sm (11kb) downloaded 69 time(s).
Russia ☭ forever
Viacheslav N. Mezentsev
💰 Support me for plugins development: https://yoomoney.ru/to/410013245578758
thanks 2 users thanked uni for this useful post.
on 14/08/2013(UTC),  on 14/08/2013(UTC)
Offline omorr  
#50 Posted : 14 August 2013 11:16:00(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Shok Thank you

I have never imagined that so many ODE solvers would be available in SMath. I wish you to stay inspired because you are keeping our positive spirit high Good
Many thanks for that.

By the way, are you going to to introduce some additional parameters like RelTol,AbsTol in DotNumerics. As I could see from the Reference Manuel for these solvers, among many other parameters (I suppose you set them by default values) there are parameters like ep, tr for absolute and relative tolerance.

Regards,
Radovan

Edited by user 14 August 2013 11:30:48(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 14/08/2013(UTC)
Offline uni  
#51 Posted : 14 August 2013 11:52:10(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,155
Man
Russian Federation

Was thanked: 1005 time(s) in 582 post(s)
Originally Posted by: omorr Go to Quoted Post
Shok Thank you

I have never imagined that so many ODE solvers would be available in SMath. I wish you to stay inspired because you are keeping our positive spirit high Good
Many thanks for that.

By the way, are you going to to introduce some additional parameters like RelTol,AbsTol in DotNumerics. As I could see from the Reference Manuel for these solvers, among many other parameters (I suppose you set them by default values) there are parameters like ep, tr for absolute and relative tolerance.

Regards,
Radovan

You can use RelTol and AbsTol in the same way. I included them in to the plugin. This code is running in the unmanaged space. Therefore, it is platform-specific. During loading the plugin from its resources on disk is copied library for specific platform (iode.dll). I'm wondering to know does it work in 64-bit system?

Now I can use any function that is written in C/C++ or other languages.
Russia ☭ forever
Viacheslav N. Mezentsev
💰 Support me for plugins development: https://yoomoney.ru/to/410013245578758
Offline Davide Carpi  
#52 Posted : 14 August 2013 12:37:41(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,393
Man
Italy
Location: Italy

Was thanked: 1195 time(s) in 787 post(s)
Works on x64 systems (at least on my notebook), except for the mk52lfa(Y,t0,tmax,n,D(t,y,4)) (Y not defined)


best regards,

Davide
If you like my plugins please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 14/08/2013(UTC)
Offline uni  
#53 Posted : 14 August 2013 12:46:46(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,155
Man
Russian Federation

Was thanked: 1005 time(s) in 582 post(s)
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
Works on x64 systems (at least on my notebook), except for the mk52lfa(Y,t0,tmax,n,D(t,y,4)) (Y not defined)

best regards,

Davide

Thank you, Davide. Unfortunately, this function requires the Jacobian. It must be specified explicitly. Some other functions also require it, but it can be omitted. I'll have to change the number of parameters to a function call.
Russia ☭ forever
Viacheslav N. Mezentsev
💰 Support me for plugins development: https://yoomoney.ru/to/410013245578758
Offline omorr  
#54 Posted : 14 August 2013 14:35:37(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: uni Go to Quoted Post
You can use RelTol and AbsTol in the same way. I included them in to the plugin. This code is running in the unmanaged space. Therefore, it is platform-specific. During loading the plugin from its resources on disk is copied library for specific platform (iode.dll). I'm wondering to know does it work in 64-bit system?

You are right. RelTol and AbsTol worked with these functions as well Good . I tried it and can confirm that mk52lfn() and rkm9mkn() are quite fast and worked as expected with Abstol=Reltol=10^-7 OK . There is no secret which one of the examples i tried Wink . This worked on my 64-bit laptop. I also could see the iode.dll in the plugins folder. I used few SMath SMath versions (including few ones by Martin) and am not sure if 32-bit is enabled or not. Anyway, I think it is not so important at the moment Good

Originally Posted by: uni Go to Quoted Post
Now I can use any function that is written in C/C++ or other languages.

All my respect for that Good . I hope that you will find a nice "candy store" now and allow us to taste it as well Wink

Regards,
Radovan

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#55 Posted : 14 August 2013 17:42:48(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,685
Germany

Was thanked: 928 time(s) in 586 post(s)
Here is a nice little toy for exploring precision control. Have fun!

Edited by user 14 August 2013 17:52:58(UTC)  | Reason: Not specified

File Attachment(s):
Section Math ODE precision.sm (18kb) downloaded 73 time(s).
mkraska attached the following image(s):
ode.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 15/08/2013(UTC),  on 15/08/2013(UTC)
Offline mkraska  
#56 Posted : 15 August 2013 09:44:08(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,685
Germany

Was thanked: 928 time(s) in 586 post(s)
Originally Posted by: uni Go to Quoted Post
Unfortunately, this function requires the Jacobian. It must be specified explicitly. Some other functions also require it, but it can be omitted. I'll have to change the number of parameters to a function call.

Does that mean that currently, the routines use an internal approximation of the Jacobi matrix, whenever they need it? Could the matrix be generated analytically or numerically by the functions from Davide's Nonlinear Solvers? Would that require user input?
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
Offline ignasi  
#57 Posted : 21 August 2013 09:54:08(UTC)
ignasi

Rank: Newbie

Groups: Registered
Joined: 04/07/2013(UTC)
Posts: 6
Man
Sweden
Location: Stockholm

Was thanked: 7 time(s) in 3 post(s)
Dear colleagues
I made an example on how SMath ODE solvers may be used.
Comments and improvements are welcome
If you thing it would be useful, feel free to post it or use it wherever it is best suited.
I am not sure of what would be appropriate.
File Attachment(s):
Box_models.sm (109kb) downloaded 88 time(s).
thanks 4 users thanked ignasi for this useful post.
on 21/08/2013(UTC),  on 21/08/2013(UTC),  on 21/08/2013(UTC),  on 21/08/2013(UTC)
Offline omorr  
#58 Posted : 21 August 2013 15:19:26(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Nice example Good

As a chemical engineer I am quite "attached" to chemical, biochemical reactors Good. That is one of the reason I was nagging before about ode solvers (at the moment we have many of them - thanking to uni Thank you .
Quite a chance that this model will fail with some nonstiff solvers. Fortunately, and thanking to uni, there are three plugins (at the moment) with ode solvers (OdeSolvers, DotNumerics and Mathlab C++ Math library). You can try all of them.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline madan26  
#59 Posted : 15 May 2015 11:36:35(UTC)
madan26

Rank: Newbie

Groups: Registered
Joined: 15/05/2015(UTC)
Posts: 2

I have solved one equation in sage math but not able understand how to solve in smath anybody can guide me on this. below is my equation


exercise1

r = var('r'Wink
PI = pi.n()
rc = 281
rw = 262
Bc = 36/180*PI
F = (r^2-rw^2)*sqrt(rc^2-r^2*sin(Bc)^2)/sqrt((rc^2-rw^2)^2*rc^2*cos(Bc)^2-(r^2-rw^2)^2*(rc^2-r^2*sin(Bc)^2))
F.show()




z = function('z',r)
d = desolve_rk4(diff(z,r)-F,z,ics=[rc,0],end_points=255,step=-0.01)
list_plot(d,plotjoined=True, aspect_ratio=1)


madan26 attached the following image(s):
exercise10001.jpg
exercise10002.jpg
Online Jean Giraud  
#60 Posted : 08 October 2015 06:11:23(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 5,498
Canada

Was thanked: 846 time(s) in 676 post(s)
From the start, you are all right and all wrong !

1. You have to understand what you are doing and how it can be done numerically.
2. No need for all these Moulton gadget, Fhelberg ... etc. For instance: Fhelberg
extends the RK domain where it has no meaning [Trust my years old testing].
3. All those librairies, proven ? only few of them [NAG, ACM... OK ? !]
4. My Smath version came with Maxima plugins: some work some don't. On that, Smath
is not an integrated version. Your clients will be soon fed up of shoping for zillions
of unproven plugins and eventual incompatibility between versions.
5. On the other hand, as long as Smath is 32 bits it is not really a CAS.
6. Too much automation in solvers may exclude finding a solution. What can be done
with little manual pushing may take days to de-automate. In Mathcad 11, Levenberg-Marquardt
works generally well but many fits have to start manually, then Newton, then CG, refined LM.
6. All those 3D plots from "Uni" make me envious, but why should I scratch my right ear with
my left hand or ask someone else to do it [unless paralysed]. The GNUplot works, but that's
the only one. Martin couldn't put color in my famous "Breather".

Very interesting.

Cheers, Jean
Users browsing this topic
Similar Topics
Double Integration using ode solvers (Samples)
by Razonar 04/06/2020 07:40:08(UTC)
Informative ODE Solvers RK5/Laplace - ODE Solvers RK5/Laplace (Samples)
by mac service 14/06/2019 13:14:16(UTC)
ODE Solvers RK5/Laplace (Samples)
by Jean Giraud 29/12/2018 20:50:46(UTC)
ODE Solvers [Viktor-Valery] (Samples)
by Jean Giraud 28/12/2018 04:47:01(UTC)
Ode solvers implementation (Questions)
by Razonar 30/11/2018 01:09:04(UTC)
ODE solvers? (Feature Requests)
by omorr 20/11/2011 12:44:21(UTC)
5 Pages<12345>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.