Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica: 2nd order PDE, variable coefficients

  1. Oct 3, 2010 #1
    [tex]a\text{''}[t]+B[t]*a'[t]-A[t]*a[t]==0[/tex]

    a[0] = 10^-9
    a'[0] = 0
    a[t] = ?

    The coefficients A and B are variable over time. I HAVE solved (experimental and theoretical values) for the values of A and B over the time interval of interest!

    I attempted to solve for a[t] using NDSolve as one normally would when coefficients are not variable over time. No luck.

    Any help would be greatly appreciated!
     
  2. jcsd
  3. Oct 4, 2010 #2
  4. Oct 4, 2010 #3

    phyzguy

    User Avatar
    Science Advisor

    I agree that NDSolve should work for this. Just for the record, this is an ODE, not a PDE.
     
  5. Oct 4, 2010 #4
    Oh geez, yeah, I meant ODE... it was a little late at night.

    So, here is code. SolutionA, SolutionB and SolutionC are for R(t), R'(t), and R''(t).


    For coefficients A and B:
    [tex]A[\text{t$\_$}] = \text{constants}*\frac{R\text{''}[t]}{R[t]}-\frac{\text{constants}}{\rho *(R[t])^3}+\frac{R'[t]}{(R[t])^3}*\left(\text{constants}*\frac{1}{1+2*\psi /R[t]}\right);[/tex]
    [tex]\text{AA}= \text{Evaluate}[A[t]\text{/.}\text{SolutionA}\text{/.}\text{SolutionB}\text{/.}\text{SolutionC}] [/tex]


    [tex] B[\text{t$\_$}] =3 \frac{R'[t]}{R[t]}+\frac{\text{constants}}{(R[t])^2}*\left(\frac{\text{constants}}{\text{constants}*R[t]}\right); [/tex]
    [tex] BB = Evaluate[B[t] /. SolutionA /. SolutionB /. SolutionC]; [/tex]



    Attempt at using NDSolve (for SolutionD):

    [tex]SolutionD =
    NDSolve[{a''[t] + BB*a'[t] - AA*a[t] == 0, a[0] == 10^-9,
    a'[0] == 0}, a[t], {t, 0, tmax}]; [/tex]


    I've tried making AA and BB into tables, I've tried using DSolve, and so on.

    Thanks a million for the help.
     
    Last edited: Oct 4, 2010
  6. Oct 4, 2010 #5
    Although that's a lot of detail (and it's probably best to use a code block, rather than latex) it's still hard to tell what could be causing the problem.
    One small thing (which is probably a problem with you're copy/pasting) is that the you should bracket {t,0,tmax}.
    Can you:
    1) Supply the error message that NDSolve is giving
    2) Give the form of Solution* (and are \psi and \rho numerical?)
    3) Provide a copy of the notebook (preferably with any extraneous stuff removed)

    I'm guessing that R[t] must be some numerical/interpolated function. Here's a simple example showing the use of an interpolated function and NDSolve. Note that the interpolation becomes bad at around x=4.
    Code (Text):
    data=Table[{x,Cos[Exp[x]]},{x,0,5,.05}];
    AA=Interpolation[data];
    Code (Text):
    Plot[{Cos[Exp[x]],AA[x]},{x,0,5}]
    Code (Text):
    sol1=NDSolve[{y'[x]+Cos[Exp[x]] y[x]==0,y[0]==1},y,{x,0,5}];
    sol2=NDSolve[{y'[x]+AA[x] y[x]==0,y[0]==1},y,{x,0,5}];
    Code (Text):
    Plot[Evaluate[Flatten[y[x]/.{sol1,sol2}]],{x,0,5}]
     
  7. Oct 4, 2010 #6
    This is very difficult to me, because i am a new user here.
    ==================================
    http://www.bestbankrates.net" [Broken]
     
    Last edited by a moderator: May 5, 2017
  8. Oct 4, 2010 #7
    phyzguy and Simon_Tyler, thanks for the help.

    I found the issue: it wasn't with my finding a[t] directly, it was solving for R[t], R'[t], and R''[t] (I wasn't getting real values). Also, I was reaching my maximum number of steps when using NDSolve to find a[t].

    Also, I am still new and learning (mathematica and forums), I didn't realize there was a code block, so for what it is worth, this worked beautifully:

    Code (Text):
    SolutionD =
      NDSolve[{a''[t] + BB*a'[t] - AA*a[t] == 0, a[0] == 10^-9,
        a'[0] == 0}, a[t], {t, 0, tmax}, MaxSteps -> 700000000];

    CC = Evaluate[a[t] /. SolutionD];
     
  9. Oct 5, 2010 #8
    Glad you got it sorted!
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook