{
  "openapi": "3.1.1",
  "info": {
    "title": "Gas Law Calculator: Ideal, van der Waals \u0026 Combined API",
    "version": "1.0.0",
    "summary": "Solve the ideal or van der Waals gas law for p, V, n or T with units, plus the combined gas law.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://prooflinegaslaw.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Solve the ideal or van der Waals gas law for p, V, n or T with units, plus the combined gas law.",
        "description": "Type three of pressure, volume, amount and temperature with any units (bar, atm, kPa, mmHg; L, mL, m³; mol or grams; K, °C, °F) and get the fourth from the ideal gas law or the van der Waals equation. The real-gas mode shows the compressibility factor Z, how far the ideal gas is off, the critical point and the isotherm, and lists the liquid and gas solutions below the critical temperature. Ten preset gases take their van der Waals constants from their measured critical point; the combined gas law solves p₁V₁/T₁ = p₂V₂/T₂. Part of the Proofline math notebook.\n\nMethodology:\n- Quantities are read with their units (Proofline’s chemistry engine) and converted to Pa, m³, mol and K. Ideal gas: p·V = n·R·T with the exact R = 8.314462618 J/(mol·K).\n- van der Waals: (p + a·n²/V²)(V − n·b) = n·R·T. Pressure and temperature follow directly; volume and amount are roots of a cubic, found with Proofline’s bracketing root finder (Brent) on a logarithmic grid above V = n·b, so all real solutions are listed.\n- Preset gases: a = 27R²Tc²/(64pc) and b = R·Tc/(8pc) from the critical temperature and pressure of NIST’s reference equations of state. Z = pV/(nRT); Tc = 8a/(27Rb), pc = a/(27b²), Vc = 3b.\n- Verified: 1 mol at 0 °C and 1 atm occupies 22.414 L; CO₂ at 500 K and 100 atm (a = 3.592 L²·atm/mol², b = 0.04267 L/mol) has a molar volume of 0.366 L/mol, as in Atkins’ worked example; the preset constants reproduce the critical temperatures exactly.\n\nThe van der Waals equation is a qualitative real-gas model: near the critical point and in the liquid it can be off by tens of percent, and no Maxwell construction is applied. Compressed-gas work needs proper equations of state and safety rules. Nothing here is advice on handling chemicals or radioactive material safely.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "proofline_gas_law",
        "x-owner-app": "proofline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProoflineGasLawInput"
              },
              "examples": {
                "example1": {
                  "summary": "Molar volume of an ideal gas at 0 °C and 1 atm",
                  "value": {
                    "mode": "ideal",
                    "pressure": "1 atm",
                    "temperature": "0 °C",
                    "amount": "1 mol"
                  }
                },
                "example2": {
                  "summary": "CO₂ at 500 K and 100 atm as a van der Waals gas (Atkins)",
                  "value": {
                    "mode": "vdw",
                    "gas": "custom",
                    "a": 3.6395,
                    "b": 0.04267,
                    "formula": "CO2",
                    "pressure": "100 atm",
                    "temperature": "500 K",
                    "amount": "1 mol"
                  }
                },
                "example3": {
                  "summary": "Pressure of 1 mol of CO₂ in 1 L at 300 K",
                  "value": {
                    "mode": "vdw",
                    "gas": "co2",
                    "volume": "1 L",
                    "amount": "1 mol",
                    "temperature": "300 K"
                  }
                },
                "example4": {
                  "summary": "Nitrogen cylinder: 50 L at 200 bar and 20 °C — how much gas?",
                  "value": {
                    "mode": "vdw",
                    "gas": "n2",
                    "pressure": "200 bar",
                    "volume": "50 L",
                    "temperature": "20 °C"
                  }
                },
                "example5": {
                  "summary": "Combined gas law: a heated, compressed balloon",
                  "value": {
                    "mode": "combined",
                    "p1": "1 atm",
                    "v1": "2 L",
                    "t1": "20 °C",
                    "p2": "3 atm",
                    "t2": "80 °C"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProoflineGasLawResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ProoflineGasLawInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Gas law",
            "type": "string",
            "enum": [
              "ideal",
              "vdw",
              "combined"
            ],
            "default": "ideal"
          },
          "gas": {
            "title": "Gas (van der Waals)",
            "type": "string",
            "enum": [
              "custom",
              "he",
              "h2",
              "n2",
              "o2",
              "ar",
              "co",
              "co2",
              "ch4",
              "nh3",
              "h2o"
            ],
            "default": "co2"
          },
          "a": {
            "title": "a (L²·bar/mol², own gas)",
            "type": "number",
            "minimum": 0
          },
          "b": {
            "title": "b (L/mol, own gas)",
            "type": "number",
            "minimum": 0
          },
          "formula": {
            "title": "Formula (optional)",
            "description": "Gives the molar mass, so the amount can be a mass and the result shows the mass and density.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "pressure": {
            "title": "Pressure",
            "description": "Leave exactly one of pressure, volume, amount and temperature empty: that one is calculated.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "volume": {
            "title": "Volume",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "amount": {
            "title": "Amount of gas",
            "description": "mol, or a mass in g with a formula or preset gas.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "temperature": {
            "title": "Temperature",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "p1": {
            "title": "p₁",
            "description": "Combined gas law: leave exactly one of the six values empty.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "v1": {
            "title": "V₁",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "t1": {
            "title": "T₁",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "p2": {
            "title": "p₂",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "v2": {
            "title": "V₂",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "t2": {
            "title": "T₂",
            "type": "string",
            "maxLength": 60,
            "default": ""
          }
        },
        "required": []
      },
      "ProoflineGasLawResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mode",
              "solved",
              "pressurePa",
              "volumeL",
              "moles",
              "temperatureK",
              "molarVolumeL",
              "Z",
              "idealValue",
              "roots",
              "massG",
              "vdw",
              "combined"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "ideal",
                  "vdw",
                  "combined"
                ]
              },
              "solved": {
                "type": "string"
              },
              "pressurePa": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "volumeL": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "moles": {
                "type": "number"
              },
              "temperatureK": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "molarVolumeL": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "Z": {
                "type": "number"
              },
              "idealValue": {
                "type": "number"
              },
              "roots": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "massG": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "vdw": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "combined": {
                "type": [
                  "object",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}