Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solving for Pressure at Depth 3

Status
Not open for further replies.

zdas04

Mechanical
Jun 25, 2002
10,274
I've got a series of a dozen equations (MathCad V11) that are needed to compute the pressure at the bottom of a column that has a mixture of gases and liquids. Of course the pressure at each point in the column is a function of the pressure at the next higher point and the pressure gradient (the gradient changes continiously and is not a linear function of depth).

I've gone through and written all the equations for each depth and it is just horrible to find where you are (calcs at every 100 ft down to 3,000 ft). Also, the file needs to be able change ultimate depth that is just too hard with this technique.

When I backed up and said this is just an array and I should be able to do this in one iteration with subscripts I had to define my pressure array first (since many of the equations need pressure and MathCad reads top to bottom) with arbitrary values. When I got through the 12th equation and had enough information to actually solve for pressure, it sorta worked (the arbitrary values were replaced with pressures calculated from the arbitraty values), but every cell had the calcs based on the arbitraty value and they all were the same.

Then I tried a solve block with all 12 equations defined in the "Given" section and then repeated all 12 equations(with CNTL =) in the "Guess" section. This gave me [2.32] in every element of the array (the square brakets are in the cells).

I'm sure that something this vanilla is simply operator error on my part, but I've gotten so close to it that I just can't see a way to solve it.

David
 
Replies continue below

Recommended for you

Is the result at 100 ft affected by the solution at 200 ft?

If so then you will need an iterative approach. I haven't used v11, and am not at all confident with the looping construct, but that would be one way to do it. Another would be to do it in Excel, which is quite happy with iterative solutions, if you switch it on.

I don't understand why your solve block is a bust, but can't say I'm especially surprised.

"When I backed up and said this is just an array and I should be able to do this in one iteration with subscripts"

This is an approach that is very likely to work

" I had to define my pressure array first (since many of the equations need pressure and MathCad reads top to bottom) with arbitrary values. When I got through the 12th equation and had enough information to actually solve for pressure, it sorta worked (the arbitrary values were replaced with pressures calculated from the arbitraty values), but every cell had the calcs based on the arbitraty value and they all were the same.
"

Sadly you need to be a bit cleverer than that. If you think about it Mathcad solves each vector in turn, so if you have 12 equations it'll solve eqn 1 for all depths, then equn 2, then equn 3.

You need to turn this on its head, either by using the loop, which will let you solve all 12 equations for each depth in turn or, and this is very horrible indeed, only use 1 vector to store all your data.

i:0;11
depth:0;30
bigvector[depth*12+i:0
depth:0
bigvector[depth*12+i:if(i=0,equn1,if(i=1,eqn2......))
"set up your surface conditions here
depth:1;30
bigvector[depth*12+i:if(i=0,equn1,if(i=1,eqn2......))

where eqn 1 etc are defined in terms of bigvector[(depth-1)*12+i-whatever as variables

like I said, horrible.

I'd use a loop



Cheers

Greg Locock
 
Thanks Greg,
The pressure at 100 ft doesn't know (there I go anthropormorphising again) about what is happening below it, but the pressure at 200 is a function of the pressure at 100 ft and the pressure gradient between the two points.

I'm a pretty old dog to be learning new tricks. I learned Fortran (actually WatFOR) in school (yes, with punch cards), so I was thinking of the problem in a Loop construct already, but I didn't think MathCad had that construct (and therefore I didn't look). I just tried the loop construct and got exactly the answer I was looking for.

David
 
not much as changed w.r.t. loops and solve blocks for this type.

Your result is simlpy telling you that each array element contains a 2x32 array, for whatever reason...

A loop is one way to do it, another is to make the solve block a function of depth and then run an array of depths at it, something like:

given
blah, blah
func(d):find(pressure)

depth[i:=i*100

func(depth)


Not sure which is easier, but since you've already gotten the equations into a solve-block...

btw... you can also get help in the Mathcad Collab:


plus, you can post your file, if you're willing...

If you do, it would help to have a sample of the correct answers as well.

TTFN
 
IRstuff,
There was slightly more to the problem than I posted. I wanted to solve the entire mess for two different surface pressures for the 32 points (which is why it was 2X32).

My solve block looked much like yours, but for some reason I got the sub-matrixes.

I go to the MathCad Collab on occasion, but I don't feel like I have much to add there so I'm reluctant to ask for help there (here I can sometimes help in fluids).

The Loop idea worked very well and ran much faster than the solve block.

Thanks for the ideas.

David
 
OK, I got it now. Mathcad doesn't much like 3-D matrices.

You could try the expand nested matrices option in the Format|Results|Display Options tab. It'll be messy, but should all display.



TTFN
 
How about this, with all subscripts using [

step s:=0;32
depth d0:=0
ds+1:=ds+100
pressure p0:=p0
ps+1:=function(ps,ds+1)
 
jghrist,
This doesn't work if you step forward. The pressure gradiant at 200 ft is dependent on the pressure and density at 100 ft not the pressure and density at 300 ft.

David
 
I'm not sure why it wouldn't work.

d1=100
d2=200
p2=function(p1,d2)
or pressure at 200' = function of pressure at 100' and the depth (200')

Let's say the function is something simple like

ps+1=ps+2·ds+1
and p0=100

Then I get the following array using a simple iterative formula in Mathcad:

p=100,300,700,1300,2100,...,99300,105700

 
I see it now, I was trying to use "s" and "s-1" instead of "s+1" and "s" (trying to look at the last itteration instead of the next). Pretty clever, thanks for perservering.

The loop method is still VERY susinct and worked really well for this mess.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor