1
$\begingroup$

I would like to make where my ODE is evaluated at (not the boundary condition itself but rather the "x" value of the boundary condition) to be a variable in my code. I find that Mathematica complains that it cannot find a starting value for ParametricNDSolve. My code is as follows:

    a321 = {-7, -(19/6), 41/10};


    b321 =  {
        {-26, 9/2, 11/10},
       {12, 35/6, 9/10},
        {44/5, 27/10, 199/50}
       } ;

    ainv3221[u_] = {1/v4[u], 1/v3[u], 1/v2[u], 1/v1[u]};

    
   sol = ParametricNDSolve[{
        v4'[u] - 
          1/u Part[-(a3221/(2 \[Pi])) - 
             1/(8 \[Pi]^2) b3221 .ainv3221[u], 1] == 0,
         v3'[u] - 
          1/u Part[-(a3221/(2 \[Pi])) - 
             1/(8 \[Pi]^2) b3221 .ainv3221[u], 2] == 0,
        v2'[u] - 
          1/u Part[-(a3221/(2 \[Pi])) - 
             1/(8 \[Pi]^2) b3221 . ainv3221[u], 3] == 0,
        v1'[u] - 
          1/u Part[-(a3221/(2 \[Pi])) - 
             1/(8 \[Pi]^2) b3221 . ainv3221[u], 4] == 0,
        v4[t] == b1,
        v3[t] == b2,
        v2[t] == b3, 
        v1[t] == b4},
     {v1, v2, v3, v4}, {u, 10^1, 10^17}, {t, b1, b2, b3, 
        b4}];
    v1sol[t_, b1_, b2_, b3_, b4_] := v1[t, b1, b2, b3, b4][u] /. sol;
    v2sol[t_, b1_, b2_, b3_, b4_] := v2[t, b1, b2, b3, b4][u] /. sol;
     v3sol[t_, b1_, b2_, b3_, b4_] := v3[t, b1, b2, b3, b4][u] /. sol;
    v4sol[t_, b1_, b2_, b3_, b4_] := v4[t, b1, b2, b3, b4][u] /. sol;

I would like to get v1sol, v2sol, v3sol and v4sol such that I can vary where the boundary condition are satisfied. Varying the boundary condition itself (say b1 = 34, b2 = 45, b3 = 55, b4 = 65) is not a problem but varying "t" is.

Any help is appreciated.

$\endgroup$
4
  • $\begingroup$ Try sol[t_, b1_, b2_, b3_, b4_] := NDSolve[.... $\endgroup$
    – bbgodfrey
    Mar 31 at 1:08
  • $\begingroup$ I did but that also don't allow you to make the boundary condition (or where the boundary is evaluated) a variable $\endgroup$
    – SAMCRO
    Mar 31 at 6:23
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Mar 31 at 20:57
  • $\begingroup$ By the way, a3221 and b3221 are undefined, and a321 and b321have a different dimension than ainv3221. $\endgroup$
    – bbgodfrey
    Apr 1 at 1:09
1
$\begingroup$

Here is a simple implementation of the suggestion I made in my comment last night.

s[x0_] := NDSolveValue[{y'[x] == 1, y[x0] == 0}, y[x], {x, 0, 5}]
Table[s[n], {n, 0, 5}];
Plot[%, {x, 0, 5}]

enter image description here

If you wish to vary both the value and location of the boundary condition, use

s[x0_, y0_] := NDSolveValue[{y'[x] == 1, y[x0] == y0}, y[x], {x, 0, 5}]
$\endgroup$
1
  • $\begingroup$ Thank you, I will give that a shot! $\endgroup$
    – SAMCRO
    Apr 2 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.