Question: Calculating the binodal curve for the van der Waals equation of state

I'm having trouble performing what I had supposed was a simple calculation. I'm trying to calculate pairs of values that lie on the binodal (liquid-gas coexistence) curve of the van der Waals phase diagram. I have an equation, that I need to solve for the two variables vg, and vl, based on two constraints. Unfortunately, while the code I have written returns answers, they are wrong, and do not even satisfy the constraints. My code is below - I'd be exceptionally greatful if someone could point out what I am doing wrong, or suggest a better way. > kbd := 1: > bd := 0.5: > ad:=2: > T:=0.9; > p_vdw := (v,T) -> ((1/v) * kbd * T )/(1-(1/v)*bd) - ad*(1/v)^2; > constraint_1 := Int(p_vdw(v,T),v=vl..vg)=(vl-vg)*p_vdw(vg,T); > constraint_2 := p_vdw(vg,T) = p_vdw(vl,T); > ans:= fsolve({constraint_1,constraint_2},{vl,vg});
Please Wait...