Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
My last take on this problem only included h as a function of time h(t). I have concluded that this is incorrect in that the height of the water in the tank also effects the flow in the discharge pipe. Thus Q is a nested function of both h and V i.e. Q(h(t),V) , as Werner had pointed out my previous version may not be physically correct because V was not taken into account. Although, the previous version solve blocked worked I have concluded that Werner was correct and that the answer is incorrect due to not taking into account the change in velocity with height. I therefore redone the worksheet to include V in the solve block and change the weir equation with a more physically accurate version. Now unfortunately the solve block is complaining about scalars. I think I have tried every ODE combination of vaiable but all to no avail. Can anyone spot the problem?
Thanking you in advance
Mark
Solved! Go to Solution.
Werner;
The method that you have presented in my humble opinion is far too complicated. The answer is so simple its almost embarrassing. I had some lunch recharged my brain and then it occurred to me. The answer as I always suspected is to do with the velocity. All I needed to do was relate h the height of the water to the velocity of discharge i.e. V(h) and then the rest is trivial. The answer was starring me and you right in the face but I could not see it and you were far too busy fixing my sloppy math to probably pick up this fundamental error. One of the problems, I believe, is that MathCad presents error messages that tend to lead one to look in all the wrong places. I have attached the final version for your and others inspection. If you think I have overlooked something please let me know.
Kind regards, Mark
PS
Thank you for all you help I have learned so more about MathCad in the process and this was my secondary aim, in doing this exercise so I am satisfied.
You still confuse others and I guess yourself with using the same name for completely different things. before we enter the solve block h and V are vectors. Then you try to derive a function h. You have to decide what V should be. If its dependent on time you have to make it a function of time.
Werner;
I cannot understand why t instead of V. I agree V is a vector because its value changes with the depth of water hw which is the parameter feed to the Qout function above the solve block. Qout isin fact a function of hw and V because hw i.e the total depth i.e. head of water above the base of the tank which drives the velocity in the outlet pipe. I agree that h is a function of t as in h(t) because that is the function of the ODE one is trying to find i.e. the depth of water in the tank from one time step to the next. How then h(t),t what is the second t for I agree I left the units out of the inital condition as you say I should have h(0s)=0m as you point out but why t instead of V because as you can see the plot above the solve plot is plotting the function correctly and it uses hw and V but not t? Maybe I missing some subtle point, my math certainly needs a good refresher but that said it seems illogical that you would need Qout(h(t),t) when V itself is dh/dt or as I see it the rate at which water is draining or filling the tank at least that is intuitivly correct i.e. maps to the reality of the situation in my view. Please show me what you mean because I made the changes you suggested and it still dosn't work. As you said previously it not just making the solve block happy it must be solving real world things.
Kind regards, Mark
I cannot understand why t instead of V
The goal of your ODESolve block is to get the function h(t) - at least thats how it is setup. But I was wrong about the t as the syntax for odesolve is a bit different compared to Mathcad (15 and below) which I use and am used to. odesolve(h(t),3600s) would be correct, without specifying the independent variable as this is already seen in h(t).
The origin of all your calculation is a set of discrete datapoints und you are about to do various calculations with it. You could have chosen to stay discrete throughout which I suppose could be possible. Of course you would not have integrals then but sums and no derivatives but ratios of differences. And so formulas out of reference books would have to be "retranslated".
You have chosen to work with continuous functions from the very beginning (your first question here was how to turn your data into a godd fitting function) and I can not decide if that decision was good or if it even was necessary.
But what I see now is that you are mixing continous (functions like h(t)) and discrete (Vectors like V) and this is calling for troubles.
it seems illogical that you would need Qout(h(t),t) when V itself is dh/dt or
That wasn't what I tried to say. Assuming your function Q.out is setup correctly it requires a length as first and a velocity as second parameter. So t would not work as second argument. I had something like Q.out(h(t),V(t)) in mind. If V is really simply the derivative of h wrt t, why don't you write it that way? Or the other way round - if V is the derivative of h and you already know V (at as a vector of points), you could turn it into a function again and integrate.
You may make your ode solveblock solve for both h() and V() as I think Mathcad will not be happy if you feed dh(t)/dt into Q.out instead of V. That way solving a system of ODEs.
Your problem looks to me like some kind of two compartment model and I wonder why you do not end up with a DE of second order or a system of two ODEs of first order. But then I may be wrong, of course.
I should state again that I don't know about the things you are trying to calculate and am looking at it from a more abstract point of view. But I somehow get the impression you want to drill some holes in a wall and have already turned on a drill machine you are not acquainted with but still don't know where and at what diameter you want your holes exactly. Sorry for the comparison, but I have the impression that it would be a good idea to go back again to the drawing board sorting out the problem and to refine your mathematical model. I would guess that its not necessary to reinvent the wheel anyway and that working models are already available in the literature.
I attach a sheet where I have used your specification (V(t)=dh(t)/dt) and solved the system of ODEs, but the results obviously are not valid.
Werner;
The method that you have presented in my humble opinion is far too complicated. The answer is so simple its almost embarrassing. I had some lunch recharged my brain and then it occurred to me. The answer as I always suspected is to do with the velocity. All I needed to do was relate h the height of the water to the velocity of discharge i.e. V(h) and then the rest is trivial. The answer was starring me and you right in the face but I could not see it and you were far too busy fixing my sloppy math to probably pick up this fundamental error. One of the problems, I believe, is that MathCad presents error messages that tend to lead one to look in all the wrong places. I have attached the final version for your and others inspection. If you think I have overlooked something please let me know.
Kind regards, Mark
PS
Thank you for all you help I have learned so more about MathCad in the process and this was my secondary aim, in doing this exercise so I am satisfied.
Glad you found a suitable math model for your problem. The error messages Mathcad throws if there is an error in a solve block seldom are use- or helpful. But in this case you can't blame Mathad for not telling you how you should have modelled your problem. Thats something a math program can't do.
Find attached an annotated file. I got rid of the adding of 10^-10m which was only added by you to avoid a divison by zero for h=0.
Also I am suspicous about the definition of Q.out and its triple step at that sepcific point. You may want to look over it again.
Werner;
Thank you for your great comments. I have revised the weir and orifice section of the sheet as I found more accurate empirical formulations. As for the weir equation there appears to be no closed form solution for this, other than using elliptic integrals which are impractical and cannot be calculated by MathCad's symbolic engine, anyway. Mathematica gave me a solution but it was 2 pages of indecipherable math, at least to me.
Good working with you. I have some ideas for other challegers but that is enough for now.
Kind regards, Mark
Your calculations just rely on a dozen of data points. You won't need a symbolic "exact" solution for those ellptic integrals. You may set them up as normal definite integrals (which they are anyway) and evaluate them numerically or use them in a solve block, whatever may be applicable. If you are interested I am sure you will find some examples in this forum, most/all of them in "real" Mathcad format (MC15 and below) "only", though. I vaguely remember a quite comprehensice sheet by Alvaro Díaz but wasn't able to find it with a quick search.
Anyway, if your empiric formulas give satisfactory results (at least a somewhat continuous Q.out()), you may as good stay with them, I guess.