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!

Sometimes the units get in the way

Status
Not open for further replies.

PNachtwey

Electrical
Oct 9, 2004
776
I would like to use units but Mathcad is not very good at handling them.

For instance, I am trying to calculate the change in pressure when a volume of oil is compressed. The formula is

delta Pressure = Bulk Modulus of Oil * delta volume / volume. If I make this continuous it is dp/dv=-B/v. I can solve for delta p = B*(ln(a)-ln(b)) where
delta p is the change pressure
B is the bulk modulus of oil
a is the initial volume of oil
b is the compressed volume of oil

The problem is that I have units for a and b and Mathcad will not take the natural log unless a and b are unit less. Does anybody know how to temporarily strip the units from a variable and only within an equation?

I want to keep the units for normal dimensional analysis.

Peter Nachtwey
 
Replies continue below

Recommended for you

Mathcad has the unitsof() function, but there are operational context issues with that.

Seems to me that the simplest solution, assuming that what you wrote is mathematically correct, is to use B*ln(a/b). Your first equation doesn't seem to be consistent with that, but that's neither here nor there.

Since your equation doesn't appear to be one of those "empirical" equations, there should always be a formulation which has unitless arguments for ln and exp.

TTFN

FAQ731-376
 
I agree ln(a/b) would work for my example but I have had this problem with other functions. What I will try tomorrow is dividing a/unitsof(a) to remove the units. Hopefully, I can use units with other functions.
 
Be forewarned that UnitsOf is finicky; most Collab members recommend not using it.

TTFN

FAQ731-376
 
You can just divide by the units and add them to the outside of the equation so that you get the correct units in your answer.

As an example, if I need the shear strength of concrete in units of psi but my equation is 2*(f'c)^0.5 where f'c is in psi, I either have to have strange units on the coefficient of 2, or divide the units out of what's under the radical and put them back in outside the radical: 2*psi*(f'c/psi)^0.5.

It may not be the most elegant solution but it works for me. In your case I would try dividing out the units and adjusting your equation accordingly.
 
If you are using MC13 or 14, you should use SIUnitsOf(), UnitsOf is being depreciated.

Peter
 
This is something that I regularly do since so many of the Oil & Gas equations are empirical. The beauty of this is that if you divide by the units it converts. For example:

Len:= 10,560 ft
Width:=6 km

cumquats:=(len/mi)^2.5 * ln(width/mi)
in this case the equation really equals
cumquats:=(2)^2.5 * ln(3.728)

Pretty cool. It really helps in equations like the AGA fluid-flow equation where length must be in miles, diameter in inches, etc. I can define a diameter in mm, a length in ft, etc. and the equation has an explicit conversion.

Instead of having to remember the units (sometimes years later), you only have to remember that each term must have units and it is pretty self documenting.

David

David Simpson, PE
MuleShoe Engineering
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.

The harder I work, the luckier I seem
 
I think that UcfSE's suggestion is the easiest but it is still a pain doing the divide and then the mulitply by the units. At least it is automatic.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor