# Gas Laws Calculator

> Solves the one unknown final pressure, volume or temperature of a fixed amount of gas from its initial state using Boyle's law (P1V1 = P2V2), Charles's law (V1/T1 = V2/T2), Gay-Lussac's law (P1/T1 = P2/T2) or the combined gas law (P1V1/T1 = P2V2/T2).

- Calculator id: `gas-laws` · Category: Chemistry (`chemistry`) · Tool name: `solve_gas_laws`
- Canonical page: https://tttkmbb.com/chemistry/gas-laws · This document: https://tttkmbb.com/chemistry/gas-laws.md · JSON definition: https://tttkmbb.com/chemistry/gas-laws.json

## Purpose

Solves the one unknown final pressure, volume or temperature of a fixed amount of gas from its initial state using Boyle's law (P1V1 = P2V2), Charles's law (V1/T1 = V2/T2), Gay-Lussac's law (P1/T1 = P2/T2) or the combined gas law (P1V1/T1 = P2V2/T2).

**Use when:** A closed gas sample changes pressure, volume or temperature and you need the missing final quantity; temperatures may be entered in °C or K and pressures in atm, kPa, bar, mmHg or psi.

**Do not use when:** The amount of gas is unknown or changes, or you need moles or molar volume (use ideal-gas-law with PV = nRT); the gas is near condensation or above roughly 10 atm where ideal behaviour fails.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `law` | enum: boyle \| charles \| gay_lussac \| combined |  | optional, default "combined" | Which relation to apply; the combined law needs all three initial quantities and two of the final ones. |
| `initial_pressure` | number |  | optional | Initial pressure in pressure_unit (not needed for Charles's law). (> 0) |
| `initial_volume` | number |  | optional | Initial volume in any unit shared with final_volume (not needed for Gay-Lussac's law). (> 0) |
| `initial_temperature` | number |  | optional | Initial temperature in temperature_unit (not needed for Boyle's law). |
| `final_pressure` | number |  | optional | Final pressure in pressure_unit. Leave empty to solve for it. (> 0) |
| `final_volume` | number |  | optional | Final volume, same unit as initial_volume. Leave empty to solve for it. (> 0) |
| `final_temperature` | number |  | optional | Final temperature in temperature_unit. Leave empty to solve for it. |
| `pressure_unit` | enum: atm \| kpa \| bar \| mmhg \| psi |  | optional, default "atm" | Unit of the pressure inputs (1 atm = 101.325 kPa = 1.01325 bar = 760 mmHg = 14.696 psi). |
| `temperature_unit` | enum: celsius \| kelvin |  | optional, default "celsius" | Unit of the temperature inputs; the calculation uses kelvin (K = °C + 273.15). |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `solved_for` | string |  | final_pressure, final_volume or final_temperature. |
| `law_used` | string |  | Name and form of the relation applied. |
| `final_pressure` | number |  | P2 in the chosen pressure unit (pressure laws only). |
| `final_pressure_atm` | number | atm | P2 in standard atmospheres. |
| `final_pressure_kpa` | number | kPa | P2 in kilopascals. |
| `final_volume` | number |  | V2 in the unit of initial_volume (volume laws only). |
| `final_temperature_k` | number | K | T2 in kelvin (temperature laws only). |
| `final_temperature_c` | number | °C | T2 in degrees Celsius. |
| `initial_temperature_k` | number | K | T1 in kelvin, as used in the ratio. |
| `change_factor` | number |  | Solved final value divided by its initial value. |

## Formula

`P1 × V1 / T1 = P2 × V2 / T2 with T in kelvin; Boyle drops T, Charles drops P, Gay-Lussac drops V. Solve: P2 = P1V1T2/(V2T1), V2 = P1V1T2/(P2T1), T2 = T1P2V2/(P1V1)`

Ratios are unit-independent, so pressure and volume come out in the units entered; temperatures must be absolute, which is why °C inputs are converted to kelvin before dividing. Amount of gas is assumed constant and the gas ideal.

## Data Sources

- OpenStax Chemistry 2e – 9.2 Relating Pressure, Volume, Amount, and Temperature: The Ideal Gas Law — https://openstax.org/books/chemistry-2e/pages/9-2-relating-pressure-volume-amount-and-temperature-the-ideal-gas-law (textbook, retrieved 2026-09-24)
- Wikipedia – Combined gas law — https://en.wikipedia.org/wiki/Combined_gas_law (reference, retrieved 2026-09-24)
- Wikipedia – Boyle's law — https://en.wikipedia.org/wiki/Boyle%27s_law (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/gas-laws?`
- `POST https://tttkmbb.com/api/v1/calculate/gas-laws` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/gas-laws · OpenAPI operationId `solve_gas_laws` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "gas-laws", "inputs": {…}}`

## Example

- Boyle: 2.0 L at 760 mmHg compressed to 0.5 L: inputs `{"law":"boyle","initial_pressure":760,"initial_volume":2,"final_volume":0.5,"pressure_unit":"mmhg"}` → `{"solved_for":"final_pressure","final_pressure":3040,"final_pressure_atm":4,"final_pressure_kpa":405.3,"change_factor":4}`
- Combined: 10 L at 1 atm, 25 °C to 2 atm, 100 °C: inputs `{"law":"combined","initial_pressure":1,"initial_volume":10,"initial_temperature":25,"final_pressure":2,"final_temperature":100}` → `{"solved_for":"final_volume","final_volume":6.2578,"final_temperature_k":373.15,"initial_temperature_k":298.15,"change_factor":0.62578}`

```
GET https://tttkmbb.com/api/v1/calculate/gas-laws?law=boyle&initial_pressure=760&initial_volume=2&final_volume=0.5&pressure_unit=mmhg
```

## Limitations

The amount of gas is unknown or changes, or you need moles or molar volume (use ideal-gas-law with PV = nRT); the gas is near condensation or above roughly 10 atm where ideal behaviour fails. Ratios are unit-independent, so pressure and volume come out in the units entered; temperatures must be absolute, which is why °C inputs are converted to kelvin before dividing. Amount of gas is assumed constant and the gas ideal. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why must temperature be in kelvin?**

The gas laws are proportionalities to absolute temperature: doubling 25 °C to 50 °C raises T only from 298 K to 323 K (8%), not 100%. Enter °C and the calculator converts, or set temperature_unit=kelvin.

**Which inputs does each law need?**

Boyle: P1, V1 and one of P2/V2. Charles: V1, T1 and one of V2/T2. Gay-Lussac: P1, T1 and one of P2/T2. Combined: P1, V1, T1 and two of P2/V2/T2. Inputs irrelevant to the chosen law are ignored.

## Related

- [Ideal Gas Law Calculator](https://tttkmbb.com/chemistry/ideal-gas-law.md) — Solve PV = nRT when the amount of gas is involved.
- [Pressure Converter](https://tttkmbb.com/conversion/pressure.md) — Convert pressures between Pa, bar, psi, atm and mmHg.
- [Temperature Converter](https://tttkmbb.com/conversion/temperature.md) — Convert between Celsius, Fahrenheit and kelvin.
