The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
Hello,
I'm trying to solve an ode in Mathcad Prime 3.0 using odesolve. I know the analytical solution (which I used to calculate the "initial" condition since the actual problem has a Neumann BC @ x=0 and I believe that for second order ode's we cannot use a Neumann bc as the "initial" condition).
The problem I'm having is that Mathcad says that the units are not compatible. However, I have triple checked the units and they are correct.
Please take a look at the worksheet attached and let me know your thoughts/comments/suggestions.
Thanks!
Solved! Go to Solution.
I think the odesolve is not for a boundary problem. Try pls solve a Coushy problem and than the boundary problem with shot method for example.
See pls the attsch.
I think the odesolve is not for a boundary problem. Try pls solve a Coushy problem and than the boundary problem with shot method for example.
See pls the attsch.
Hello Valery,
Thank you so much for your help!
What is interesting is that if I remove the units, odesolve solves the equation with any combination of boundary conditions. For example, I can specify the Neumann BC @ x=0 and the prescribed temperature @ the right (or left) boundary. Likewise, I can specify the prescribed temperatures at the left and right boundary and odesolve still works. It is only when I introduce the units that I get into trouble.
As you indicate, it looks like in order to use odesolve with units, we need to specify the initial values for n-1 unknown functions. For instance, in this case we are solving a second order ODE (n=order +1=3), thus we need to specify the "initial" conditions for the the function and its derivative at x=0. It is important to note that we are actually transforming the boundary problem into an initial value problem. Also, we already had the analytical solution so we could use that to determine the value of the function at x=0. However, when this is not readily known, we use the built-in function sbval to find the initial value using the known boundary condition at a location other than x=0.
Thanks again!
Regards,
Josué
P.S. See the attched file in which I'm using sbval to determine the intial condition.
Message was edited by: Josue Adorno Nunez
Does sbval work with units?
Hello Valery,
Sbval does work with units associated to its arguments. However, the result is a non-dimensional vector. If you want to use the output from sbval as the initial condition for a Solve block using units, you need to manually add the units.
If you look at the last file I included in my reply to your post, I call the sbval output to the solve block, but I'm attaching the units when I declare the initial condition in the solve block.
Again, note that I'm assigning Kelvin as the units of the initial value I calculated using sbval when I declare the initial condition for odesolve in the solve block.
Hope this helps!
Best,
Josué
Valery,
Josue's second worksheet makes it appear that sbval works with units, but note that the unit K gets left off of the final result for the initial temperature. Josue had to add it before using it in the odesolve block. That is probably where the error occurred when odesolve called sbval on its own.
Edit: I see Josue just replied with the same answer.
Odesolve is supposed to work with units, but unfortunately some of the methods that it can call do not yet work with units, so you get an error when it calls one of those methods. You have demonstrated that odesolve won't work with units when calling sbval. The documentation doesn't indicate this restriction, so it is a bug. Also, some of the ode methods work with units, but all of the dependent variables must have the same dimension. See here. http://communities.ptc.com/message/243553#243553
Thanks for demonstrating this bug. Until odesolve can work with units with all of its methods, I will continue to make the problem dimensionless for the odesolve block.
Hi Harvey,
Ok, I see now what you meant in your response to Valery when you said that sbval does not work with units.
As you mention, the bug is that when odesolve calls sbval, for example, to convert a boundary condition problem to an initial value problem, odesolve won't work because the internal result it gets from sbval is dimensionless, That explains perfectly why I was getting "These unit are not compatible" from odesolve when using boundary conditions, but not when I use the initial conditions!
Thanks for your input, much appreciated indeed.
Regards,
Josué
The rkfixed+shot method on Mathcad Server:
http://twt.mpei.ac.ru/MCS/Worksheets/Books/Mathcad-14/5_11_Epid_Shot.xmcd