2
$\begingroup$

How to summon Acceleration due to Gravity in Mathematica 11?

enter image description here

seems like a simple thing but the documentation is no help.

$\endgroup$
  • 4
    $\begingroup$ It's Quantity["StandardAccelerationOfGravity"], plain "AccelerationOfGravity" isn't universal. $\endgroup$ – b3m2a1 Nov 10 '17 at 21:56
  • $\begingroup$ Or to see the numeric value: Quantity["StandardAccelerationOfGravity"] // UnitConvert $\endgroup$ – Bob Hanlon Nov 10 '17 at 22:07
  • 3
    $\begingroup$ You can also use GeogravityModelData[GeoPosition[{40, -90}], "Magnitude"] to get the value at a given location. Or even at a given elevation in meters with GeogravityModelData[GeoPosition[{40, -90, 100000}], "Magnitude"]. $\endgroup$ – jose Nov 11 '17 at 1:30
2
$\begingroup$

Are you trying to get the numeric value in MKS units? That can be done as follows.

g = SemanticInterpretation @ "acceleration of qravity" // UnitConvert

Quantity[196133/20000, ("Meters")/("Seconds")^2]

To get the numeric value you could do

QuantityMagnitude[1. g]

or make use of how the Quantity is structured

N @ g[[1]]

Both give

9.80665

The above does require internet access. To get by with only one such access, you can make the quantity persist in a local symbol stored in your local file system. Just evaluate

LocalSymbol["g"] = g

You can retrieve the value at any time in any Mathematica session by evaluating

LocalSymbol["g"]

You can of course use any string you like in place of "g".

$\endgroup$
10
$\begingroup$

Rightly or wrongly, if the unit specification is unknown, then WA is used behind the scenes to decide if it could be interpreted as a standard unit. You can see this with the error message provided:

Quantity["AccelerationOfGravity"]

Quantity::unkunit: Unable to interpret unit specification AccelerationOfGravity.

Quantity["AccelerationOfGravity"]

So, you can make use of this discovery mechanism by trying to use standard English instead of some random camel-cased string. For example:

Quantity["acceleration due to gravity"] //InputForm

Quantity[1, "StandardAccelerationOfGravity"]

$\endgroup$
  • 2
    $\begingroup$ I like the use of W|A here, but it also means that when W|A is down (like it seems to have been periodically recently) anything with a slightly funky Quantity causes the system to hang until a ::timeout message can be emitted. Would be nice to have a quicker timeout on things like this. $\endgroup$ – b3m2a1 Nov 10 '17 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.