p-V diagram work, IMEP and power calculator
The area inside a p-V loop is the indicated work per cycle. For the demo cycle below (a 0.5 L cylinder, compression ratio 10), the closed-loop trapezoid gives 412.2 J. That is an IMEP of 8.25 bar, 5.15 kW at 1500 rpm for a four-stroke (N/120, not N/60) and an ISFC of 218 g/kWh. Paste your own engine data, such as a CONVERGE engine output file or any two-column p and V table, to get the same numbers, the common slips and a Python script. Free, runs in your browser.
Heywood's definitions as taught at Rose-Hulman, NIT Srinagar and MIT 2.61 · NumPy 2.x and SciPy 1.14 release notes · synthetic demo cycle, not course data · checked against an independent solution (1,731 checks at build) · Updated 23 Nov 2026
Used by every tab. The data is taken as one cylinder's cycle; power is multiplied by the cylinders. LHV 44 MJ/kg is the petrol value in MIT's 2.61 notes.
Is my file readable (the compatibility check), what columns does it have, and what does any column look like against any other?
Demo cycle inputs (synthetic single-zone four-stroke)
The fuel per cycle and LHV come from the engine settings above. Firing TDC is at 0°; the file runs from −360° to 360°: intake at the intake pressure, compression, Wiebe heat release (a = 5, m = 2 are the usual petrol values) and expansion with constant γ and no wall heat loss, blowdown to the exhaust pressure at bottom dead centre (two rows at 180°), then exhaust. Temperature is the trapped charge's pV/(mR). It is a teaching cycle, not engine data.
- Load the demo or paste data.
Units are read from the header's units line when it has one; change them if your file has none.
What is the work per cycle, and the IMEP, indicated power and specific fuel consumption that follow from it?
| Quantity | Value | How |
|---|---|---|
| Trapezoid along the data | 412.188 J | numpy.trapezoid(p, V) |
| + closing line | 0.000 J | last point back to the first |
| Polygon (shoelace) | 412.188 J | same as the closed trapezoid |
| Simpson, stroke by stroke | 412.219 J | 4 monotonic runs |
What would the common mistakes give on this data? Each line is computed from the loaded data and the engine settings.
| Slip | You would report | Right | Why |
|---|---|---|---|
| N/60 for a four-stroke | 10.3 kW, 109.2 g/kWh if SFC is fuel rate / power | 5.152 kW (N/120: one cycle every two revolutions) | Power doubles and any SFC worked from fuel flow and power halves. W N/60 is right only for a two-stroke. |
| 2πN/60 × work (work treated as torque) | 64.75 kW | 5.152 kW | P = 2πNT/60 needs torque in N·m. Work per cycle in J is not torque: for a four-stroke the mean torque is W/(4π). |
| MPa × m³ printed as J | 4.122e-4 "J" | 412.2 J | The data's pressure is in MPa; the integral is in MPa·m³ until you multiply by 10⁶. MPa × m³ = MJ, so 0.0005 MJ is 500 J. |
| m³ data converted as if it were cm³ | 4.122e-4 J | 412.2 J | 1 m³ = 10⁶ cm³. A 0.5 L cylinder is 5 × 10⁻⁴ m³ or 500 cm³: check the data's Vd against the bore and stroke before converting. |
| Expansion stroke only | 592.8 J | 417.2 J gross, 412.2 J net | Integrating only the power stroke leaves out the work spent compressing the charge, so the work is too high. |
| Loop not closed | 412.2 J | 412.2 J | Your data ends at the volume it started at, so the closing line adds no area here; with a cut-off record it would. |
| µg and mg mixed up | 218300 g/kWh or 0.2183 g/kWh | 218.3 g/kWh | 1 mg = 1000 µg = 10⁻⁶ kg; 1 µg = 10⁻⁹ kg. A 1000 times error in the fuel is a 1000 times error in SFC. |
| Fuel per cycle used as fuel per second | 17.47 g/kWh | 218.3 g/kWh | Multiply the fuel per cycle by 12.5 cycles per second (N/120) before dividing by power, or use ISFC = m_f / W directly. |
- Fuel energy check: 25 mg × 44 MJ/kg = 1,100 J of fuel for 412.2 J of work, an efficiency of 37.5 %. With the task's 20 µg per cycle and 500.6 J the same check gives 56,885 %: the SFC arithmetic is right, the engine is impossible.
A short script that does the whole task: compatibility check, columns and units from the header, any-column plot with automatic labels, work, IMEP, power and ISFC.
"""p-V data analysis for a CONVERGE-style engine output file (Skill-Lync free tool: /tools/pv-diagram-work-calculator).
Usage:
python pv_work.py engine_data.out # compatibility check, work, IMEP, power, ISFC
python pv_work.py engine_data.out 1 2 # also plot column 2 against column 1, labels from the header
Set RPM, STROKES and FUEL_PER_CYCLE_KG for your engine (the defaults reproduce the tool's demo cycle).
"""
import sys
import numpy as np
RPM = 1500
STROKES = 4 # 4: one cycle every 2 revolutions (N/120); 2: every revolution (N/60)
FUEL_PER_CYCLE_KG = 25e-6 # 25 mg. 20 micrograms would be 20e-9 kg (1 ug = 1e-9 kg)
P_SCALE = {"(MPa)": 1e6, "(kPa)": 1e3, "(bar)": 1e5, "(Pa)": 1.0}
V_SCALE = {"(m^3)": 1.0, "(m3)": 1.0, "(cm^3)": 1e-6, "(L)": 1e-3}
# numpy.trapz was deprecated in NumPy 2.0 in favour of numpy.trapezoid
trapezoid = getattr(np, "trapezoid", None) or np.trapz
def read_converge(path):
"""Compatibility check + parsing: '#' header with 'column 1 2 ...', a names line and a units line."""
try:
lines = open(path).read().splitlines()
except FileNotFoundError:
sys.exit(f"File not found: {path}")
header = [ln[ln.index("#") + 1:].split() for ln in lines if ln.strip().startswith("#")]
col = next((i for i, h in enumerate(header) if h and h[0].lower() == "column"), None)
if col is None or col + 1 >= len(header):
sys.exit("Not a CONVERGE output file: no '#' line with column numbers followed by column names.")
names = header[col + 1]
units = header[col + 2] if col + 2 < len(header) else [""] * len(names)
rows = []
for k, ln in enumerate(lines, start=1):
s = ln.strip()
if not s or s.startswith("#"):
continue
parts = s.split()
if len(parts) != len(names):
sys.exit(f"Line {k}: {len(parts)} values for {len(names)} columns. Not a valid CONVERGE file.")
try:
rows.append([float(x) for x in parts])
except ValueError:
sys.exit(f"Line {k}: non-numeric value. Not a valid CONVERGE file.")
return names, units, np.array(rows)
def find(names, word):
for i, n in enumerate(names):
if n.lower() == word:
return i
return next(i for i, n in enumerate(names) if word in n.lower())
def main():
path = sys.argv[1] if len(sys.argv) > 1 else "engine_data.out"
names, units, data = read_converge(path)
print(f"compatible: {len(names)} columns, {len(data)} rows")
for i, (n, u) in enumerate(zip(names, units), start=1):
print(f" {i:2d} {n} {u}")
if len(sys.argv) > 3: # plot any two columns, labels from the header
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
x, y = int(sys.argv[2]) - 1, int(sys.argv[3]) - 1
plt.plot(data[:, x], data[:, y])
plt.xlabel(f"{names[x]} {units[x]}")
plt.ylabel(f"{names[y]} {units[y]}")
plt.savefig(f"{names[y]}_vs_{names[x]}.png", dpi=150)
ip, iv = find(names, "pressure"), find(names, "volume")
p = data[:, ip] * P_SCALE[units[ip]] # Pa
V = data[:, iv] * V_SCALE[units[iv]] # m^3
# closed-loop work: trapezoid along the data, plus the straight line back to the first point
work = trapezoid(p, V) + 0.5 * (p[-1] + p[0]) * (V[0] - V[-1]) # J per cycle
vd = V.max() - V.min()
cycles_per_s = RPM / 60 / (2 if STROKES == 4 else 1)
power = work * cycles_per_s # W
isfc = FUEL_PER_CYCLE_KG * 1e3 / (work / 3.6e6) # g/kWh = fuel per cycle / work per cycle
print(f"work_J = {float(work)!r}")
print(f"imep_Pa = {float(work / vd)!r}")
print(f"power_W = {float(power)!r}")
print(f"isfc_g_per_kWh = {float(isfc)!r}")
if __name__ == "__main__":
main()
Run on the demo file (Load demo cycle, then copy the text area into engine_data.out) with NumPy 2.0.2, it prints work_J = 412.1875836, imep_Pa = 825105.86, power_W = 5152.3448 and isfc_g_per_kWh = 218.34719: the tool's numbers to 8 digits (the file stores 10). Our verifier runs this exact script at every update. It calls numpy.trapezoid because NumPy 2.4 removed np.trapz; the fallback keeps it working on NumPy 1.x. For Simpson, scipy.integrate.simpson replaces simps, which SciPy 1.14 removed, and simpson's even= argument is gone too.
Type what your report states. The work is checked against the loaded data; power and SFC are recomputed from your work and the engine settings above, and a slip that explains the gap is named.
- Type at least one number, or fill the example.
How do you calculate work done from a p-V diagram?
The indicated work per cycle is the area the loop encloses. Rose-Hulman's engine notes put it as "the area enclosed by the path", and NIT Srinagar's (from Heywood) as "integrating around the curve". With sampled data, use the trapezoidal rule in the order the samples were recorded:
Three things decide whether the number is right. Use pascals and cubic metres, since MPa × m³ is MJ. Keep the data in time order, because numpy.trapezoid "is not sorted", as its documentation puts it. And close the loop. A clockwise loop (V across, p up) gives positive work. Adding the straight line from the last point back to the first gives exactly the polygon (shoelace) area, which tab 2 shows as a check.
For the demo cycle the closed trapezoid gives 412.188 J. Simpson stroke by stroke gives 412.219 J, a difference of 0.01 %. Both use 1° samples. On the ideal Otto version of the same cycle, the closed form Q(1 − r1−γ) = 438.955 J against 439.006 J from the trapezoid and 438.955 J from Simpson. Halving the step cuts the trapezoid's error about four times; the verifier checks this.
What is gross and net indicated work, and the pumping loop?
NIT Srinagar's notes define gross indicated work as "work delivered to the piston over the compression and expansion strokes only". Net work adds the intake and exhaust strokes, the pumping loop. Rose-Hulman gives the pumping work for flat intake and exhaust pressures as Wp = (pi − pe)(V1 − V2):
The demo has intake at 0.095 MPa and exhaust at 0.105 MPa, so Wpump = −0.01 × 106 × 499.56 × 10−6 = -4.996 J. The tool finds the firing stroke from the peak pressure and splits the record at the bottom dead centres on either side. It reports a pumping loop only when the data covers all 720°. A file that holds only the closed part, from intake valve closing to exhaust valve opening, gives gross work only. Say which one you report.
How do you calculate IMEP from pressure data?
IMEP is the work per cycle divided by the displaced volume. Rose-Hulman's lecture: "We divide the work per cycle by the cylinder volume displaced". It turns the loop into one pressure that compares engines of any size:
The tool takes Vd from the data, the largest volume minus the smallest. For the demo's 86 mm bore and 86 mm stroke that is 499.6 cm³, and the net IMEP is 8.25 bar (0.825 MPa). If your data does not cover a full stroke, work Vd out from the bore and stroke instead.
Indicated power for a four-stroke engine: why N/120?
Power is work per cycle times cycles per second. A four-stroke cylinder completes a cycle every two revolutions, nR = 2 (Heywood's symbol, used in all three sets of notes):
All the demo's numbers:
Two slips account for most wrong powers in reports. N/60 doubles the power (10.30 kW here). 2πN/60 × W treats the work per cycle as a torque and gives 4π times the right power (64.75 kW). The torque behind a four-stroke's indicated power is W/(4π), not W.
What is the specific fuel consumption formula?
Specific fuel consumption is "the fuel flow rate per unit power output of the engine" (NIT Srinagar). Per cycle, engine speed cancels: the fuel per cycle divided by the work per cycle. The same quantities give the fuel conversion efficiency:
The task in the reports gives 1500 rpm and "20 micrograms of fuel (per 1 stroke cycle)". With the 500.59 J that many public reports compute (for example this one):
So the arithmetic answer is 0.144 g/kWh, but no real engine can do that. At 44 MJ/kg (MIT's petrol LHV), 20 µg of fuel holds 0.88 J. The loop delivers 500.6 J, about 569 times the fuel's energy. Heywood's typical best brake value for SI engines is about 270 g/kWh (75 µg/J), which at 44 MJ/kg is an efficiency of about 30 %. Against that, 0.14 g/kWh is about 1,877 times too low. Even 20 mg (880 J of fuel energy) would mean an indicated efficiency of 57 %, which is high. Report the number the task asks for, then add the efficiency check, which tab 2 runs live on any data. The demo burns 25 mg for 412 J, an efficiency of 37.5 %.
np.trapz, numpy.trapezoid or scipy simpson?
numpy.trapezoid is the current name. The NumPy 2.0 release notes say "np.trapz has been deprecated", and NumPy 2.4 lists numpy.trapz among the "long-deprecated APIs" it removed. In SciPy, "scipy.integrate.{simps,trapz,cumtrapz} have been removed" as of 1.14.0, in favour of simpson, trapezoid and cumulative_trapezoid. As of 23 Nov 2026, 238 of 369 reports with readable code call trapz, 121 call simps and 5 call trapezoid. Their scripts will not run on a current NumPy or SciPy without a one-word change.
Simpson's rule needs care on a loop. It fits p as a parabola in V through three samples. Near top or bottom dead centre the three volumes are not in order, and with symmetric sampling two of them are equal, so the parabola is undefined. The tool, like a careful script, splits the data wherever V changes direction and applies Simpson within each stroke. An odd interval left over at the end of a stroke gets the trapezoid.
How do you parse a CONVERGE engine output file in Python?
Students' public reports show the layout: '#' lines at the top, one with the word column and the column numbers, then a line of names (Crank, Pressure, …, Volume, …) and a line of units ((DEG), (MPa), (m^3) …), then rows of numbers. A good compatibility check reads that structure instead of trusting the file name. Read the names and units from the header, check that every row has as many numbers as there are names, and report the first line that breaks the rule. Tab 1 does exactly that, and the script in tab 4 does the same in 50 lines. Reading pressure and volume by name, with their units from the header, also removes the hard-coded "column 2 and column 8" and the MPa conversion slip.
How is the demo cycle made?
The demo is a synthetic single-zone four-stroke cycle, generated in your browser from the inputs under "Demo cycle inputs", so you can test a script without the course's file. Cylinder volume follows the slider-crank (a = S/2 the crank radius, l the rod length):
Heat is released along a Wiebe curve. The University of Kansas paper gives a = 5 and m = 2 as the frequently used values for petrol. With constant γ and no wall heat loss, the first-law heat release equation (Heywood's, as in the Rose-Hulman and University of Malta notes) becomes a rule for p Vγ:
The tool integrates that with Simpson's rule in 0.05° steps. The defaults are an 86 × 86 mm cylinder with a 143.5 mm rod and r = 10, γ = 1.3, 25 mg of fuel at 44 MJ/kg with 80 % released as heat (880 J), intake at 0.095 MPa and 330 K, and exhaust at 0.105 MPa. They give a peak of 4.06 MPa at 17° after top dead centre. Choose "Instant at TDC" to get the ideal Otto cycle with the same heat. No wall heat loss and a constant γ make the work higher than a real engine's; it is a test cycle, not a prediction.
What 374 public data analysis reports do (as of 23 Nov 2026)
We read the 374 public Skill-Lync reports titled "Week 6 - Data analysis", "Data analysis using Python" and similar, all on the same CONVERGE engine file task, as of 23 Nov 2026, n = 374. 3 are images with almost no text. Counts are of what the text shows; a row's "of" is the number of reports where the item could be read. The links are examples.
- 160 / 374Power uses the four-stroke factor (N/120, N/(2*60), cycles per second = rps/2). report 1report 2
- 85 / 374Power uses N/60 (work x revolutions per second, no halving). report 1report 2
- 109 / 374Power treats work as torque (2 pi N/60, or area x 1e6 x rpm/9550). report 1report 2
- 238 / 369Integrates with np.trapz / trapz (deprecated in NumPy 2.0). report 1report 2
- 121 / 369Integrates with scipy simps (removed in SciPy 1.14). report 1report 2
- 5 / 369Integrates with np.trapezoid. report 1report 2
- 230 / 369Multiplies pressure or area by 1e6 (MPa to Pa). report 1report 2
- 210 / 374Types fuel as 20 x 1e-6 (20e-6, pow(10,-6)), unit left to the formula. report 1report 2
- 12 / 374Types fuel as 20 x 1e-9 (kg). report 1report 2
- 20 / 79Work printed as 0.0005 (MPa x m3) with no unit or "units". report 1report 2
- 18 / 86SFC digits match 0.1438 g/kWh (= 20 ug / 500.6 J) in some unit. report 1report 2
- 9 / 86SFC correct with the unit written (0.1438 g/kWh or 1.438e-4 kg/kWh). report 1report 2
- 90 / 369Compatibility check compares the file name with engine_data.out. report 1report 2
- 66 / 369Compatibility check looks for the string CONVERGE in the file. report 1report 2
- 75 / 369Column names typed as a Python list. report 1report 2
What stands out: only 160 of 374 use the four-stroke factor for power, while 85 use N/60 and 109 treat the work as a torque. 20 of the 79 reports whose work we can read print the raw 0.0005 (MPa × m³) with no unit or as "units". Only 9 of 86 print an SFC with the right digits and a matching unit. These are first-party counts, a starting point rather than a measure of ability.
How we checked the calculator
An independent Python script, scripts/verify/pvwork.py, rebuilds the numbers with its own code. This page refuses to build if the browser code differs from it in any of 1,731 numbers, indices or verdicts (68 more assertions run inside the script, 117 cases). The script works the cylinder volume in Heywood's dimensionless form and integrates the heat release with 20-point Gauss-Legendre (its own nodes), where the tool uses Simpson. It cross-checks the result against a Runge-Kutta solution of the first-law equation. It also tests rectangles, triangles and regular polygons, convergence to the Otto closed form, the exact pumping work, 16 files for the parser, and the report values 6.2573 kW and 0.00014383 kg/kWh. It runs the tab 4 script on its own demo file. Two deliberate bugs (nR = 1 for a four-stroke, and dropping γ − 1 from the heat release) each make the build fail.
What this calculator does not cover
- Brake values. Everything here is indicated (from cylinder pressure). Brake power, BMEP and BSFC need friction or a dynamometer: use the engine performance calculator.
- Several cylinders in one file. The data is read as one cylinder's cycle; the cylinder count only multiplies power and fuel flow.
- Pressure referencing and noise. Measured traces need pegging and phasing (TDC location) before integration; a 1° phasing error moves IMEP noticeably. CONVERGE output has neither problem.
- Heat release analysis of your data. The Wiebe model only generates the demo; it is not fitted to pasted data.
File parsing and engine data analysis are a week of Skill-Lync's Python course for mechanical engineers, also taught inside the CFD program, before the projects where CONVERGE output files become real engine studies.
Frequently asked questions
How do you calculate work done from a p-V diagram?
Integrate pressure over volume around the closed loop: W = ∮ p dV. With sampled data, add up (p_i + p_i+1)/2 × (V_i+1 − V_i) in time order, which is what numpy.trapezoid(p, V) does. Use pascals and cubic metres to get joules. A clockwise loop, with V across and p up, gives positive work.
How do you calculate indicated power from a p-V diagram?
Multiply the work per cycle by the number of cycles per second: P = W N / (60 n_R). A four-stroke engine needs two revolutions per cycle, so n_R = 2. At 1500 rpm that is 12.5 cycles per second. Multiply by the number of cylinders if the work is for one cylinder.
Why divide by 120 for a four-stroke engine?
Each cylinder of a four-stroke engine fires once every two crankshaft revolutions. N/60 is revolutions per second, so cycles per second is N/120. Using N/60 doubles the power and halves any specific fuel consumption worked out from it. N/60 is right only for a two-stroke engine, which fires every revolution.
How do you calculate IMEP from pressure data?
Find the work per cycle from the p-V loop, then divide it by the displaced volume: IMEP = W / Vd, with Vd = π/4 × bore² × stroke. Joules over cubic metres gives pascals; divide by 100,000 for bar. Say whether you used gross work or net work, which includes the pumping loop.
What is the specific fuel consumption formula?
Specific fuel consumption is fuel mass flow divided by power. Per cycle this simplifies to fuel mass per cycle divided by work per cycle, so engine speed cancels out. In g/kWh: grams of fuel per cycle × 3.6 million ÷ joules per cycle. Heywood gives about 270 g/kWh as a good brake value for SI engines.
Should I use np.trapz or numpy.trapezoid?
Use numpy.trapezoid. NumPy 2.0 deprecated np.trapz and NumPy 2.4 removed it, so old scripts that call np.trapz now fail. Both apply the same trapezoidal rule, and trapezoid(y, x) integrates in data order without sorting x. That matters for a p-V loop, where volume goes up and then back down.
Can I use Simpson's rule on a p-V loop?
Yes, one stroke at a time. Simpson's rule fits a parabola p(V) through three samples, and that breaks down where V turns around at top or bottom dead centre. Split the data where V changes direction and apply Simpson to each stroke. SciPy 1.14 removed simps; the function is now scipy.integrate.simpson.
What is the difference between gross and net indicated work?
Gross indicated work counts only the compression and expansion strokes. Net work covers the whole four-stroke cycle, so it also includes the pumping loop of the intake and exhaust strokes. That loop is negative when exhaust pressure is above intake pressure, as in a throttled engine, so net work is then the smaller of the two.
Related on Skill-Lync
- Otto and Diesel cycle calculator (air-standard p-v and T-s diagrams, efficiency and MEP)
- IC engine performance calculator (brake power, torque, BMEP, BSFC and efficiencies)
- Combustion phasing calculator (CA10, CA50, CA90 and mass fraction burned from the same pressure data, combustion efficiency)
- Curve fitting calculator (the Python course's other data week: polyfit and curve_fit)
- NASA polynomial calculator (the other file parsing project: THERMO.dat)
- Throttle body calculator (a CONVERGE engine case)
- All free engineering tools
Sources
- Rose-Hulman ME 410 Internal Combustion Engines (Heywood as text), lecture notes Day 3, 4, 21 and 27: work as the enclosed area, nR = 2 for a four-stroke, Wp = (pi − pe)(V1 − V2), gross indicated work, imep = W/Vd, slider-crank volume, Wiebe a = 5, the single-zone dP/dθ equation, QLHV = 44,000 kJ/kg.
- NIT Srinagar MSD 302 Advanced Engine Design (from Heywood), Engine Design and Operating Parameters (22 Apr 2020 and 29 Sep 2020): gross and net indicated work, nR, sfc definition, "about 75 µg/J = 270 g/KW.h" for SI engines, fuel conversion efficiency.
- MIT OpenCourseWare 2.61 Internal Combustion Engines (Spring 2017), lectures 2, 3 and 15: nR, ideal Otto efficiency, LHV 44 MJ/kg (SI fuel). UNC Charlotte MEGR 3210 equation sheet: imep = indicated net work / Vd.
- Alam et al., University of Kansas, Fuel 303 (2021) 121218: Wiebe function, "frequently used values of aw and mw for petroleum gasoline are 5 and 2". Saliba and Farrugia, University of Malta, Energies 19 (2026) 1657, eq. 1: Heywood's first-law apparent heat release.
- NumPy documentation, numpy.trapezoid ("New in version 2.0.0"), NumPy 2.0.0 and 2.4.0 release notes (trapz deprecated, then removed). SciPy 1.14.0 release notes (simps, trapz, cumtrapz removed; simpson's even argument removed) and the scipy.integrate.simpson page.
- Skill-Lync, the 374 public data analysis reports, read 23 Nov 2026.