3
$\begingroup$

Unit Checking Demo

In order to throw a unit error,we run the code

FormulaData["NewtonsLawOfUniversalGravitation", {
  QuantityVariable["r","Distance"] -> Quantity[12, "Kilograms"], 
  QuantityVariable[Subscript["m", 1],"Mass"] -> Quantity[12, "Kilograms"], 
  QuantityVariable[Subscript["m", 2],"Mass"] -> Quantity[12, "Kilograms"]
}]

It will throw an error telling us The input for r has incorrect units for Distance.

Built-in FormulaData

Mathematica stores FormulaData in \the_path_to\Wolfram Research\Mathematica\10.3\AddOns\Applications\FormulaData\Kernel\downvalues.m

Formula Demo

I copy a formula which is in downvalues.m

HoldPattern[MathematicaFormula["NewtonsLawOfUniversalGravitation"]] :> 
   QuantityVariable["F", "Name" -> "gravitational force", 
     "PhysicalQuantity" -> "Force", "CanonicalUnit" -> {HoldForm["Newtons"]}, 
     "UnitDimensions" -> {{"LengthUnit", 1}, {"MassUnit", 1}, 
       {"TimeUnit", -2}}] == (Quantity[None, "GravitationalConstant"]*
      QuantityVariable[Subscript["m", 1], "Name" -> "primary mass", 
       "PhysicalQuantity" -> "Mass", "CanonicalUnit" -> 
        {HoldForm["Kilograms"]}, "UnitDimensions" -> {"MassUnit", 1}]*
      QuantityVariable[Subscript["m", 2], "Name" -> "secondary mass", 
       "PhysicalQuantity" -> "Mass", "CanonicalUnit" -> 
        {HoldForm["Kilograms"]}, "UnitDimensions" -> {"MassUnit", 1}])/
     QuantityVariable["r", "Name" -> "distance", "PhysicalQuantity" -> 
       "Distance", "CanonicalUnit" -> {HoldForm["Meters"]}, 
       "UnitDimensions" -> {"LengthUnit", 1}]^2, 

Question: How to insert a formula in FormulaData?

How to insert a self-defined formula in FormulaData so that we can apply it just like a built-in formula?

$\endgroup$
  • $\begingroup$ Look at Simpler input for the new unit support $\endgroup$ – user9660 Feb 20 '16 at 15:44
  • $\begingroup$ No, it has't unit-check feature in physical formula $\endgroup$ – xiang Feb 20 '16 at 16:01

Your Answer

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

Browse other questions tagged or ask your own question.