# PV-loop area

**URL:** https://discourse.julialang.org/t/pv-loop-area/137839
**Category:** General Usage
**Tags:** question
**Created:** [June 29, 2026, 10:32am UTC](https://discourse.julialang.org/t/pv-loop-area/137839 "2026-06-29T10:32:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![violabini](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/violabini/32/222225_2.png) [@violabini](https://discourse.julialang.org/u/violabini)
#### Post date: [June 29, 2026, 10:32am UTC](https://discourse.julialang.org/t/pv-loop-area/137839/1 "2026-06-29T10:32:43Z")

</div>

I am developing a 0D model for the cardiac circulation and I would like to compute the workload as the internal area of the Pressure Volume -loop. Do you know any method that allow me to do this even if my PV loop is extracted and defined just by the points (ventricular volume, ventricular pressure ) ?

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [June 29, 2026, 10:35am UTC](https://discourse.julialang.org/t/pv-loop-area/137839/2 "2026-06-29T10:35:44Z")

</div>

This is a julia programming forum, the general julia programmer will probably not know what PV, VLV or PLV refers to. You may want to introduce your problem a bit better for the audience expected to read it here.

---

<div class="post-metadata">

### Author: ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)
#### Post date: [June 29, 2026, 12:46pm UTC](https://discourse.julialang.org/t/pv-loop-area/137839/3 "2026-06-29T12:46:17Z")

</div>

I’d say you probably want to use the [area of a polygon](https://en.wikipedia.org/wiki/Polygon#Area).

---

<div class="post-metadata">

### Author: ![ducksoverip](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ducksoverip/32/31967_2.png) [@ducksoverip](https://discourse.julialang.org/u/ducksoverip)
#### Post date: [June 29, 2026, 5:02pm UTC](https://discourse.julialang.org/t/pv-loop-area/137839/4 "2026-06-29T17:02:40Z")

</div>

It’s very hard to tell what you’re asking for without more detail. Could you either edit your initial post or add a reply that explains what exactly you’re trying to compute (I’m assuming you mean W = \int P dV, but I’m not sure), along with what you have so far? In particular, if you have a PV diagram of this loop, that could be very helpful for understanding what you’re trying to accomplish.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [June 29, 2026, 5:14pm UTC](https://discourse.julialang.org/t/pv-loop-area/137839/5 "2026-06-29T17:14:26Z")

</div>

> [@violabini](#):
>
> I would like to compute the workload as the internal area of the Pressure–Volume loop. Do you know any method that allow me to do this even if my PV loop is extracted and defined just by the points

It sounds like you are trying to solve a numerical-integration problem, also called “quadrature”. There are lots of quadrature algorithms, but a key question is whether you can _choose_ the points. If you can, then you can get a _much_ more accurate result for the same number of points (e.g. by applying Gaussian quadrature to something like the Green’s theorem formulae below).

> [@tobydriscoll](#):
>
> I’d say you probably want to use the [area of a polygon](https://en.wikipedia.org/wiki/Polygon#Area).

This corresponds to numerical integration by the [trapezoidal rule](https://en.wikipedia.org/wiki/Trapezoidal_rule).

e.g. you could use the [shoelace formula](https://en.wikipedia.org/wiki/Shoelace_formula) for the polygon area, which is closely related to a trapezoidal rule applied to the [Green’s theorem](https://en.wikipedia.org/wiki/Green%27s_theorem) formulae \text{area} = \oint\_C x \, dy = - \oint\_C y\, dx.

---

<div class="post-metadata">

### Author: ![violabini](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/violabini/32/222225_2.png) [@violabini](https://discourse.julialang.org/u/violabini)
#### Post date: [June 30, 2026, 6:58am UTC](https://discourse.julialang.org/t/pv-loop-area/137839/6 "2026-06-30T06:58:21Z")

</div>

The problem is that my Pv loop is defined just through points, I compute the pressure and the volume separately and then match the pressure with the corresponding volume in time. So far I am just interested on its plot p3=plot(V\_LV\_vec[t\_vec.\>t\_end-5], PLV[t\_vec.\>t\_end-5].\*Pa2mmHg; label=“LV”, xlabel=“Volume [ml]”, ylabel=“Pressure [mmHg]”,color=lv\_color)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [June 30, 2026, 11:52am UTC](https://discourse.julialang.org/t/pv-loop-area/137839/7 "2026-06-30T11:52:05Z")

</div>

> [@violabini](#):
>
> The problem is that my Pv loop is defined just through points, I compute the pressure and the volume separately and then match the pressure with the corresponding volume in time.

You can still use the trapezoidal rule / polygon area, of course, for low-order accuracy.

If you can choose the time points, and you have the _time derivative_ of either the pressure or volume, you can still use a higher-order quadrature rule, since \oint\_C x dy = \int x\frac{dy}{dt} dt. (Here, x is pressure and y is volume or vice versa.)

**How are you computing pressure and volume as a function of time?** If it is an ODE solver like DifferentialEquations.jl (for your [0D cardiac model](https://en.wikipedia.org/wiki/Lumped_parameter_model_for_the_cardiovascular_system)), that will be able to (a) give you the time derivatives too and (b) compute the time when the loop closes to high-order accuracy using a [continuous callback](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/), and (c) let the ODE solver accumulate the area integral for you (so that you don’t need a separate quadrature rule, you just add another equation \frac{dA}{dt} = x \frac{dy}{dt}.
