differential equation solving when changing the coefficients with time [message #89936] |
Mon, 05 January 2015 06:04  |
idlforum2424
Messages: 2 Registered: January 2015
|
Junior Member |
|
|
Hi all,
I'd like to solve a differential equation in IDL using a Runge Kutta 4th order procedure. However the coefficients of my differential equation evolve with time. How can we pass the coefficients into the function that defines the differential equation or do you have any other way to manage that?
Typically my diff equation is something like Y'=aY+b with a and b two functions of time and I want to solve that for all timesteps I have.
Thanks.
|
|
|
Re: differential equation solving when changing the coefficients with time [message #89941 is a reply to message #89936] |
Mon, 05 January 2015 11:15   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Monday, January 5, 2015 9:05:00 AM UTC-5, idlfor...@gmail.com wrote:
> Hi all,
> I'd like to solve a differential equation in IDL using a Runge Kutta 4th order procedure. However the coefficients of my differential equation evolve with time. How can we pass the coefficients into the function that defines the differential equation or do you have any other way to manage that?
> Typically my diff equation is something like Y'=aY+b with a and b two functions of time and I want to solve that for all timesteps I have.
IDL's RK4 passes "X" to your differential function. For you, X is time, so you can use this X variable to calculate Y' as you please.
EXAMPLE:
function differential, x, y
a = (0.4*x + 10)
b = (-7.2*x - 0.01*x^2)
return, a*y + b
exit
Craig
|
|
|
Re: differential equation solving when changing the coefficients with time [message #89943 is a reply to message #89941] |
Tue, 06 January 2015 08:12  |
idlforum2424
Messages: 2 Registered: January 2015
|
Junior Member |
|
|
On Monday, January 5, 2015 8:15:39 PM UTC+1, Craig Markwardt wrote:
> On Monday, January 5, 2015 9:05:00 AM UTC-5, idlfor...@gmail.com wrote:
>> Hi all,
>> I'd like to solve a differential equation in IDL using a Runge Kutta 4th order procedure. However the coefficients of my differential equation evolve with time. How can we pass the coefficients into the function that defines the differential equation or do you have any other way to manage that?
>> Typically my diff equation is something like Y'=aY+b with a and b two functions of time and I want to solve that for all timesteps I have.
>
> IDL's RK4 passes "X" to your differential function. For you, X is time, so you can use this X variable to calculate Y' as you please.
>
> EXAMPLE:
> function differential, x, y
> a = (0.4*x + 10)
> b = (-7.2*x - 0.01*x^2)
> return, a*y + b
> exit
>
> Craig
thanks !
|
|
|