How to use 'colloc'?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use 'colloc'?

Søren Hauberg
Hi All

I need to solve a system of 2nd order ODE's with two-point boundary conditions, and I'd figure I'd try to use the 'colloc' function for this (I've tried a few different routines, but there all kinda slow). The documentation for this function is a bit lacking for a newbie like myself, so I was wondering if anybody has a link to some tutorial on how to use the function? Specifically, I can't figure out how to have general boundary  conditions u(0) = u_0 and u (1) = u_1.

Thanks
Søren

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

How to use 'colloc'?

John W. Eaton
Administrator
On  2-Jul-2012, Søren Hauberg wrote:

| I need to solve a system of 2nd order ODE's with two-point boundary
| conditions, and I'd figure I'd try to use the 'colloc' function for
| this (I've tried a few different routines, but there all kinda
| slow). The documentation for this function is a bit lacking for a
| newbie like myself, so I was wondering if anybody has a link to some
| tutorial on how to use the function? Specifically, I can't figure
| out how to have general boundary  conditions u(0) = u_0 and u (1) =
| u_1.

Take a look at section A.5 from the following and let me know if it
helps.

  http://jbrwww.che.wisc.edu/home/jbraw/chemreacfun/web-appendix.pdf

jwe
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

c.-2
In reply to this post by Søren Hauberg

Il giorno 02/lug/2012, alle ore 19.52, Søren Hauberg ha scritto:

> Hi All
>
> I need to solve a system of 2nd order ODE's with two-point boundary conditions, and I'd figure I'd try to use the 'colloc' function for this (I've tried a few different routines, but there all kinda slow). The documentation for this function is a bit lacking for a newbie like myself, so I was wondering if anybody has a link to some tutorial on how to use the function? Specifically, I can't figure out how to have general boundary  conditions u(0) = u_0 and u (1) = u_1.
>
> Thanks
> Søren

Søren,

for this kind of problem you could also use bim.
attached is an example script to solve a particular system
of 2 semilinear 2nd order ODEs with two-point boundary conditions.
If you can provide more info about your specific problem I can help
you adapt the script to your needs.


HTH,
c.

P.S. this example was written quite quickly I'm sure it DOES contain bugs ;)


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave

fitzhughnagumo1d.m (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

Søren Hauberg
In reply to this post by John W. Eaton

On Jul 4, 2012, at 4:04 PM, John W. Eaton wrote:

> On  2-Jul-2012, Søren Hauberg wrote:
>
> | I need to solve a system of 2nd order ODE's with two-point boundary
> | conditions, and I'd figure I'd try to use the 'colloc' function for
> | this (I've tried a few different routines, but there all kinda
> | slow). The documentation for this function is a bit lacking for a
> | newbie like myself, so I was wondering if anybody has a link to some
> | tutorial on how to use the function? Specifically, I can't figure
> | out how to have general boundary  conditions u(0) = u_0 and u (1) =
> | u_1.
>
> Take a look at section A.5 from the following and let me know if it
> helps.
>
>  http://jbrwww.che.wisc.edu/home/jbraw/chemreacfun/web-appendix.pdf

Thanks John, that actually helped quite a bit. I still can't follow the code in the Octave documentation, but I've been able to solve some toy problems now.

I don't know much about ODE's (neither the analytical stuff nor the closed-form stuff), so how do I go about solving systems of ODE's this way? I can only figure out how to solve 1D problems so far…

Thanks
Søren
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

Søren Hauberg
In reply to this post by c.-2

On Jul 4, 2012, at 7:57 PM, c. wrote:
> for this kind of problem you could also use bim.
> attached is an example script to solve a particular system
> of 2 semilinear 2nd order ODEs with two-point boundary conditions.
> If you can provide more info about your specific problem I can help
> you adapt the script to your needs.

Sounds nice! I've been using 'bvp4c' so far, which has worked out nicely, but it is kinda slow (I need to solve a system of ODE's to compute the geodesic between points on a specific manifold; as I am doing statistics on manifolds at the moment, so I usually need to compute many thousands of geodesics, so speed is kinda important). I'm looking into collocation as it seems to be rather fast (at the moment speed is more important than accuracy).

Is the BIM package able to give me rough solutions fast? Or do you have any thoughts on which approaches would be most suitable when speed is more important than accuracy? I can provide more details on the systems in question, but only off-line as this is still not published.

Thanks
Søren
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

c.-2

Il giorno 05/lug/2012, alle ore 11.56, Søren Hauberg ha scritto:

>
> On Jul 4, 2012, at 7:57 PM, c. wrote:
>> for this kind of problem you could also use bim.
>> attached is an example script to solve a particular system
>> of 2 semilinear 2nd order ODEs with two-point boundary conditions.
>> If you can provide more info about your specific problem I can help
>> you adapt the script to your needs.
>
> Sounds nice! I've been using 'bvp4c' so far, which has worked out nicely, but it is kinda slow (I need to solve a system of ODE's to compute the geodesic between points on a specific manifold; as I am doing statistics on manifolds at the moment, so I usually need to compute many thousands of geodesics, so speed is kinda important). I'm looking into collocation as it seems to be rather fast (at the moment speed is more important than accuracy).
>
> Is the BIM package able to give me rough solutions fast?
Yes, I think so. Is your problem linear or non-linear?

If the problem is linear the solution time is limited only by the linear system solution, the size of the system depends
on the number of grid points you choose which is up to you.

If it is a nonlinear problem the solution time depends more on the nonlinear solver (in the example I used fsolve) rather than on the discretization algorithm.
But anyway the algorithm implemented in BIM (piecewise-linear Finite Elements with Exponential Fitting stabilization and Mass Lumping) guarantees that the Jacobian
of the nonlinear system will have good properties that often ensure stability and convergence of the nonlinear iteration.


> Or do you have any thoughts on which approaches would be most suitable when speed is more important than accuracy? I can provide more details on the systems in question, but only off-line as this is still not published.
feel free to send me details off-line. I'll be glad to help if I can.

> Thanks
> Søren
c.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

Søren Hauberg

On Jul 5, 2012, at 4:34 PM, c. wrote:

>
> Il giorno 05/lug/2012, alle ore 11.56, Søren Hauberg ha scritto:
>
>>
>> On Jul 4, 2012, at 7:57 PM, c. wrote:
>>> for this kind of problem you could also use bim.
>>> attached is an example script to solve a particular system
>>> of 2 semilinear 2nd order ODEs with two-point boundary conditions.
>>> If you can provide more info about your specific problem I can help
>>> you adapt the script to your needs.
>>
>> Sounds nice! I've been using 'bvp4c' so far, which has worked out nicely, but it is kinda slow (I need to solve a system of ODE's to compute the geodesic between points on a specific manifold; as I am doing statistics on manifolds at the moment, so I usually need to compute many thousands of geodesics, so speed is kinda important). I'm looking into collocation as it seems to be rather fast (at the moment speed is more important than accuracy).
>>
>> Is the BIM package able to give me rough solutions fast?
> Yes, I think so. Is your problem linear or non-linear?

It's non-linear :-(

> If it is a nonlinear problem the solution time depends more on the nonlinear solver (in the example I used fsolve) rather than on the discretization algorithm.
> But anyway the algorithm implemented in BIM (piecewise-linear Finite Elements with Exponential Fitting stabilization and Mass Lumping) guarantees that the Jacobian
> of the nonlinear system will have good properties that often ensure stability and convergence of the nonlinear iteration.

Okay, I'll try to port my current code to the BIM package and try a couple of different optimizers.

Thanks
Søren
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to use 'colloc'?

c.-2

Il giorno 05/lug/2012, alle ore 17.13, Søren Hauberg ha scritto:

> Okay, I'll try to port my current code to the BIM package and try a couple of different optimizers.

In this case the construction of a proper Jacobian is VERY important for the solution speed.
Given my experience, it is much easier and effective to first write the linearized system of differential equations
and then to discretize it than to  first discretize the nonlinear system and then linearize the resulting algebraic problem.
Note that the two approaches do not always produce the same Jacobian.

> Thanks
> Søren
c.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave