TransWikia.com

Making boundary condition a variable in ParametricNDSolve

Mathematica Asked on July 31, 2021

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.

One Answer

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}]

Answered by bbgodfrey on July 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP