Leumas Physics

Bring your own equations

A formula pack is a JSON file of relations from your own field. Drop one into the explorer and it joins the same graph the built-in formulas live in โ€” the solver chains them together, the derivation shows them, and the dimensional check applies to them exactly as it does to ours.

The format

A pack is an object with a name and a list of formulas. Each formula has an id, an expression written as a single equation with one symbol on the left, the list of inputs it takes, and a symbols map giving each symbol a label, an optional unit and โ€” this is the one worth filling in โ€” a dimension over the base dimensions M, L, T, I, Th, N and J.

A pack ships an expression, never code

Your formulas are parsed, not executed. The expression is read into a syntax tree and refused unless every part of it is a constant, a symbol, an arithmetic operator or a call to one of a fixed list of mathematical functions. That is why a pack can be dropped in by anyone, with no account, and still be safe to run on our servers.

What is refused, and why

An expression containing an assignment, a property access, a function definition or a function outside the allowed list. A formula with no inputs at all, because such a formula would run on every derivation whether you wanted it or not and would overwrite that symbol for the built-in formulas too. A symbol name beginning with a double underscore, which is reserved. And a pack where any single formula fails: a partly-accepted pack would be missing exactly the relations you came to use, with nothing on screen to say which.

Your ids cannot collide with ours

Every formula in a pack is filed under a namespaced id, so a pack containing its own kinetic-energy sits beside the built-in one rather than replacing it. Without that, a derivation using your version would still print the name a reader expected.

A complete example

Save this as aero.json and drop it into the explorer.

{
  "name": "aero",
  "formulas": [
    {
      "id": "drag",
      "name": "Drag force",
      "domain": "aerodynamics",
      "expression": "F_d = 0.5 * rho * v^2 * C_d * A",
      "inputs": ["rho", "v", "C_d", "A"],
      "symbols": {
        "F_d": { "label": "Drag force",   "unit": "N",      "dimension": "M L T^-2" },
        "rho": { "label": "Air density",  "unit": "kg/m3",  "dimension": "M L^-3" },
        "v":   { "label": "Airspeed",     "unit": "m/s",    "dimension": "L T^-1" },
        "C_d": { "label": "Drag coefficient",               "dimension": "1" },
        "A":   { "label": "Frontal area", "unit": "m2",     "dimension": "L^2" }
      }
    }
  ]
}

Questions

Do I need an account to use a pack?
No. Dropping a pack into the explorer is free and needs no account โ€” it lives for as long as your page is open. Saving one so it is there next time is what requires a membership.
How big can a pack be?
Up to 200 formulas and 256KB. Each expression is capped at 500 characters and 24 symbols.