TransWikia.com

Error with ParametricNDSolveValue

Mathematica Asked on July 1, 2021

Consider the following code:

ClearAll["Global`*"]
s0 = ParametricNDSolveValue[{A''[t] - [Omega]^2 A[t] == 1, A[0] == 0,
    A[1] == 0}, A, {t, 0, 1}, {[Omega]}]
A1[[Omega]_?NumericQ][t] := s0[[Omega]][t];

s1 = ParametricNDSolveValue[{B''[t] - [Omega]^2 B[t] == 
    D[A1[[Omega]][t], t], B[0] == 0, B[1] == 0}, 
  B, {t, 0, 1}, {[Omega]}]
B1[[Omega]_?NumericQ][t] := s1[[Omega]][t];

Plot[B1[1][t], {t, 0, 1}]

I get the error "Dependent variables {B,A1[[Omega]]} cannot depend on parameters { [Omega]}".

How do I get rid of this error? In the second equation A1 should be a known function, not a dependent one.

One Answer

Try this:

s0 = ParametricNDSolveValue[{A''[t] - [Omega]^2 A[t] == 1, A[0] == 0,
     A[1] == 0}, A, {t, 0, 1}, {[Omega]}];
s1 = ParametricNDSolveValue[{B''[t] - [Omega]^2 B[t] == 
     D[s0[[Omega]][t], t], B[0] == 0, B[1] == 0}, 
   B, {t, 0, 1}, {[Omega]}];

Plot[s1[1][t], {t, 0, 1}]

enter image description here

Have fun!

Correct answer by Alexei Boulbitch on July 1, 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