Skip to main content
14-Alexandrite
July 21, 2023
Solved

Problem with Odesolve variable undefined

  • July 21, 2023
  • 2 replies
  • 3222 views

I am trying to solve a simulation of blowdown of a pressure vessel and have defined the ODE's but there is a glitch I cannot resolve with a variable undefined error. I am sure it is a trivial error but if anyone can assist I would appreciate it. Mathcad 15 sheet attached.

Thanks Ross

 

Best answer by Werner_E

With a noisy signal like the one you show, the numerical derivative sure is useless. If you know which kind of function type you expect, you may try a fit using genfit() or a solve block with minerr.
Otherwise smoothing sure might be an option. Be sure to also look at the functions available in the Data Analysis Extension Pack (Help->E-Books).

2 replies

ttokoro
21-Topaz I
21-Topaz I
July 21, 2023

Prime 9 show this.

image.png

t.t.
25-Diamond I
July 21, 2023

@ttokoro wrote:

Prime 9 show this.

 


Real Mathcad (15) shows the very same. The problem is below in the solve block.

The sheet can't be simply converted to Prime as Prime won't allow to symbolically evaluate the result of a solve block.

25-Diamond I
July 21, 2023

Look at the parentheses around P and P.tank. They denote 1x1 matrices! Why did you do that??

Werner_E_0-1689931511991.png

If you fix this you still get a "variable not defined" error. This error stems from the numeric engine because it misses a guess value for P.tank and could be ignored if the result is evaluated and used only for symbolic calculations.

Main problem is the fact that P.tank is not a simple variable but rather a function. "Find" will only solve for variables and you seem to try to solve an integral equation, which Mathcad is not capable to do.

You might try to turn the equation into a differential equation if possible and then try your luck using the numeric odesolve.

As you tried to symbolically evaluate P after the solve I guess that you expected to see a symbolic solution for your integral equation. You won't get a symbolic solution even if the above suggestion may work because Mathcad can't solve integral equations and will solve (some) differential equations only numerically - you will never see a symbolic function equation when you use odesolve.

 

Looking further in your sheet I guess you already solved the ODE for P.tank and the subsequent failing solve block wih the integral equation was introduced because you wanted to see a symbolic function definition of the derived solution, right?
This must fail because Odesolve is a numeric method only - it basically returns just a function which interpolated discrete values which were found using a numerical approximation algorithm like Euler's.

Prime just started to be able to solve some very basic ODEs also symbolically but I doubt that it will be able to give you the result you are looking for. As @ttokoro seems to already have converted the sheet he may be able to give it a try and tell us, if Prime 9 would be able to symbolically solve the ODE for P.tank.

remslie14-AlexandriteAuthor
14-Alexandrite
July 21, 2023

Werner,

My humble apologies I appended the wrong MathCad sheet. The one I sent was a past version where I was trying a few things and seeing it I could obtain a closed form solution using symbolic notation. The sheet I meant to send is attached. Sorry again for wasting your time. If you could assist with the attached I would be grateful.

Regards,

Ross

25-Diamond I
July 21, 2023

The error in the new sheet is not "variable undefined" as you initially wrote, but rather "too few initial conditions"!??

Some things I  noticed:

You sure should put

Werner_E_0-1689939543762.png
in before solve block and don't let the solve block solve for P.BP

You have only a first order ODE so you can't use P.QA(0)=... and P.QA'(0)=... as IC. Delete the latter.

There is no IC for neither DP.QA and DP.BP.  And there is no ODE for both of them , too - guess odesolve does not like this?

 

Anyway, I guess all you have is just one first oder ODE for P.QA and I thought hat the approach shown in the picture should do it.
But I get a rather meaningless error message and don't know what the problem may be.

I also noticed that when I just omit the one highlighted P.BP(t) (replaced it by 1), the solve block seems to work OK.

Werner_E_2-1689941543130.png

Have no clue how to fix that at the moment but I attach the modified sheet anyway