Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.8K Views
|
10 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Add two constants with same units using UnitConvert?

Posted 7 years ago

Although the units are the same, the scalers will not add, what do I need to do to make this work?

atm = N[UnitConvert[Quantity[1, "Atmospheres"], "PSI"]]
gage = 8.7 lbf/in^2
atm + gage
POSTED BY: Raymond Low
10 Replies
Posted 7 years ago

Tim, I tried using "Cntrl+=" with Bernoulli Equation using the English system,but after two hours I still can't get it to work. Mathematica will not put the gravitational constant "32.2 lbm ft / (lbf s^2)" into units and any units described by "Cntrl+=" will not compute with 'variables' of the same names

zA = 0 Quantity[1, "Feet"]
prA = 10 Quantity[1, (("PoundsForce")/(("Inches")^2))]
velA = UnitConvert[
  Quantity[7.761668264705552`, ("Meters")/("Seconds")], "ft/s"]
\[Gamma]wtr = 62.4 Quantity[1, (("Pounds")/(("Feet")^3))]
g = UnitConvert[Quantity["StandardAccelerationOfGravity"], 
   "Ft/s^2"] // N
gc = 32.2  *(lb ft)/(lbf s^2)
energTA = prA/\[Gamma]wtr + velA^2/(2 gc) + zA/gc

enter image description here

zA = 0 Quantity[1, "Feet"]
prA = 10 Quantity[1, (("PoundsForce")/(("Inches")^2))]
velA = UnitConvert[
  Quantity[7.761668264705552`, ("Meters")/("Seconds")], "ft/s"]
\[Gamma]wtr = 62.4 Quantity[1, (("Pounds")/(("Feet")^3))]
g = UnitConvert[Quantity["StandardAccelerationOfGravity"], 
   "Ft/s^2"] // N
gc = 32.174 Quantity[1, "Pounds"]*
  Quantity[1, (("Feet")/("PoundsForce" ("Seconds")^2))]
energTA = prA/\[Gamma]wtr + velA^2/(2 gc) + zA/gc

My result

enter image description here

the result should be something close to 32.7 ft lbf / lbm

POSTED BY: Raymond Low
POSTED BY: Tim Laska
Posted 7 years ago

Tim, thank you kindly for all your work, I am slowly learning, didn't know that you could ignore the gravitational constant when using Quantity, does make life a little easier.

POSTED BY: Raymond Low
Posted 7 years ago

In your notebook take a look at the syntax coloring in the gage = expression. Both lbf and in are blue, which means they are interpreted as undefined symbols. Try

atm = UnitConvert[Quantity[1, "Atmospheres"], "lbf/in^2"] // N
gage = Quantity[8.7, "lbf/in^2"]
atm + gage
POSTED BY: Rohit Namjoshi
Posted 7 years ago

Thanks again, I tried..

atm = UnitConvert[Quantity[1, "Atmospheres"], "PSI"] // N
atmN = QuantityMagnitude@atm * QuantityUnit@atm
gage = 8.7 lbf/in^2
atmN + gage

I got

enter image description here

units in Quantity are different than the units in QuantityUnits and I still can not add them, Is here a possible work around????

POSTED BY: Raymond Low

Hi Raymond,

Have you tried the built-in unit discovery using ctrl+=? Mathematica understands units so you can focus on the relations such as force = pressure x area. At the end, you can use UnitConvert to convert to whatever is required. A screen capture is shown below where you could use almost any oddball English unit and easily convert to SI at the end.

enter image description here

POSTED BY: Tim Laska
Posted 7 years ago

Beautiful Tim -- didn't know about cntrl+= or understand it. thank for the demonstration, I think that is about as simple as I can get it, instead of using units like variables and confusing Mathematica in the process. I will work with what you suggested and see how well that works out.

POSTED BY: Raymond Low

You get the scalar by applying QuantityMagnitude at the result, e.g.:

ft = Quantity[1, "foot"]
(* output: 1 ft*)

QuantityMagnitude@ ft
(* output: 1*)
POSTED BY: Michael Gamer
Posted 7 years ago
POSTED BY: Raymond Low

Look at QuantityUnit@atm it is ("PoundsForce")/("Inches")^2. So if you define

gage=Quantity[2.4, ("PoundsForce")/("Inches")^2]

everything is fine.

POSTED BY: Michael Gamer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard