{
  "id": "tank-volume",
  "version": "803bdfd2e5a1",
  "status": "published",
  "name": "Tank Volume Calculator",
  "question": "What is my tank volume?",
  "summary": "Finds the capacity of a horizontal or vertical cylinder, rectangular, capsule, or oval tank in gallons or litres, and the volume of liquid at a fill height.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/tank-volume-calculator",
  "markdown": "https://www.acalculator.org/math/tank-volume-calculator.md",
  "kind": "function",
  "method": "Capacity from the tank shape (πr²L for a cylinder, l × w × h for a box, plus 4/3 πr³ for capsule ends); a part-full round tank uses the circular segment area r²(θ − sin θ) ÷ 2.",
  "assumptions": [
    "Dimensions are inside measurements, and the tank is level.",
    "A capsule has half-sphere ends as wide as its diameter; its length is the straight part only.",
    "Volumes show in US gallons (231 in³), or litres in Metric."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "shape": {
        "title": "Tank shape",
        "description": "The shape of the tank and which way it lies.",
        "type": "string",
        "enum": [
          "hcyl",
          "vcyl",
          "rect",
          "hcap",
          "vcap",
          "hoval"
        ]
      },
      "d": {
        "title": "Diameter",
        "description": "The inside diameter of the round tank.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "exclusiveMinimum": 0
      },
      "length": {
        "title": "Length",
        "description": "The inside length of the tank; for a capsule, the straight part only.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "exclusiveMinimum": 0
      },
      "w": {
        "title": "Width",
        "description": "The inside width of the tank.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "exclusiveMinimum": 0
      },
      "h": {
        "title": "Height",
        "description": "The inside height of the tank.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "exclusiveMinimum": 0
      },
      "fill": {
        "title": "Fill height",
        "description": "The depth of the liquid, measured from the bottom of the tank. Leave it empty for the capacity only.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "minimum": 0
      }
    }
  },
  "outputs": {
    "total": {
      "label": "Tank capacity",
      "description": "The volume of the whole tank when full.",
      "format": "quantity",
      "unit": "gal"
    },
    "filled": {
      "label": "Filled volume",
      "description": "The volume of liquid at the fill height.",
      "format": "quantity",
      "unit": "gal"
    },
    "empty": {
      "label": "Space left",
      "description": "The capacity minus the filled volume.",
      "format": "quantity",
      "unit": "gal"
    },
    "percent": {
      "label": "Percent full",
      "description": "The filled volume as a percent of the capacity.",
      "format": "percent"
    },
    "percentEmpty": {
      "label": "Percent empty",
      "description": "The space left as a percent of the capacity: 100% minus the percent full.",
      "format": "percent"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "shape": "hcyl",
      "d": 1.2191999999999998,
      "length": 3.048,
      "w": 0.9144,
      "h": 1.524,
      "fill": 0.9144
    },
    "outputs": {
      "total": 3.5583998890502544,
      "filled": 2.862728762774946,
      "empty": 0.6956711262753081,
      "percent": 80.44988905221147,
      "percentEmpty": 19.550110947788514
    },
    "text": "The tank holds 940.03 gal when full, and 756.25 gal at a fill height of 36 in."
  },
  "examples": [
    {
      "given": {
        "shape": "hcyl",
        "d": 1.2191999999999998,
        "length": 3.048,
        "fill": 0.9144
      },
      "expect": {
        "total": 3.5583998890502544,
        "filled": 2.862728762774946,
        "percent": 80.44988905221147
      },
      "source": "NIST Handbook 44, Appendix C, 1 US gallon = 231 in³ (https://www.nist.gov/pml/owm/nist-handbook-44-current-edition); Weisstein, MathWorld, circular segment area (https://mathworld.wolfram.com/CircularSegment.html); hand calculation in content.mdx: V = πr²L with r = 24 in; filled = [r² acos((r − f)/r) − (r − f)√(2rf − f²)] × L, 940.03 gal and 756.25 gal; Python 3 with math.acos (progress log)"
    },
    {
      "given": {
        "shape": "vcyl",
        "d": 1,
        "h": 2,
        "fill": 1.5
      },
      "expect": {
        "total": 1.5707963267948966,
        "filled": 1.1780972450961724,
        "percent": 75
      },
      "source": "hand calculation in content.mdx: π × 0.5² × 2 = π/2 m³; π × 0.25 × 1.5 = 3π/8 m³"
    },
    {
      "given": {
        "shape": "rect",
        "length": 2,
        "w": 1,
        "h": 1.5,
        "fill": 0.75
      },
      "expect": {
        "total": 3,
        "filled": 1.5,
        "empty": 1.5,
        "percent": 50
      },
      "source": "hand calculation in content.mdx: 2 × 1 × 1.5 = 3 m³, 2 × 1 × 0.75 = 1.5 m³"
    },
    {
      "given": {
        "shape": "hcap",
        "d": 2,
        "length": 3,
        "fill": 1
      },
      "expect": {
        "total": 13.61356816555577,
        "filled": 6.806784082777885,
        "percent": 50
      },
      "source": "hand calculation in content.mdx: π × 1 × 3 + 4/3 π = 13π/3 m³, half full at the middle"
    },
    {
      "given": {
        "shape": "vcap",
        "d": 2,
        "length": 3,
        "fill": 4
      },
      "expect": {
        "total": 13.61356816555577,
        "filled": 11.519173063162574
      },
      "source": "hand calculation in content.mdx: full minus a cap of height 1: 13π/3 − π × 1 × (3 − 1)/3 = 13π/3 − 2π/3 = 11π/3"
    },
    {
      "given": {
        "shape": "hoval",
        "w": 2,
        "h": 1,
        "length": 4,
        "fill": 0.5
      },
      "expect": {
        "total": 6.283185307179586,
        "filled": 3.141592653589793,
        "percent": 50
      },
      "source": "hand calculation in content.mdx: π × 1 × 0.5 × 4 = 2π m³, half at the middle"
    },
    {
      "given": {
        "shape": "hcyl",
        "d": 1,
        "length": 1
      },
      "expect": {
        "total": 0.7853981633974483
      },
      "source": "hand calculation in content.mdx: π × 0.5² × 1 = π/4 m³; no fill height, so capacity only"
    }
  ],
  "sources": [
    "NIST Handbook 44 (2024), Appendix C, General Tables of Units of Measurement (1 US gallon = 231 in³ = 3.785411784 L). https://www.nist.gov/pml/owm/nist-handbook-44-current-edition",
    "NIST Digital Library of Mathematical Functions, §4.23 Inverse Trigonometric Functions (arcsin, arccos). https://dlmf.nist.gov/4.23",
    "OpenStax, Calculus Volume 1, §6.2 Determining Volumes by Slicing (cross-section area times length; sphere volume). https://openstax.org/books/calculus-volume-1/pages/6-2-determining-volumes-by-slicing",
    "Weisstein, Eric W. \"Circular Segment\" and \"Spherical Cap\", MathWorld (segment area r²(θ − sin θ)/2, cap volume πh²(3r − h)/3). https://mathworld.wolfram.com/CircularSegment.html"
  ],
  "related": [
    "cylinder-volume",
    "volume",
    "pool-volume",
    "cubic-feet"
  ],
  "changelog": []
}
