0
$\begingroup$

I want to calculate the density of CO2 using a cubic equation of state in order to plot the P-v diagram. From theory I know that I get one real root when the substance is in single-phase region and two when it is in two-phase region. In the latter case the smaller volume is associated to liquid while the other to vapor. I'm using Matlab to solve the cubic eos, incrementing the pressure and the temperature at fixed intervals. How can I merge the two solutions to represent the actual Pv plot?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Set temperature as constant, make P change and find V solutions (if V(P,T) which according to what he is saying it is what he is doing...)

You HAVE to set one constant, since you want to plot PV you need to set T as constant.

In case it is P(V,T) you change the Volume and calculate the Pressure.

... I would recommend you do a loop to print out all the values then plot them in either Origin, Excel, by hand or whatever you want to use.

In case you don't know how to use loops (completely OK with that this is a place to learn) https://www.mathworks.com/help/matlab/ref/for.html

My recommendation? Use Fortran because Matlab takes AGES to solve but that is just personal preferrence.

$\endgroup$
1
  • $\begingroup$ For a cubic equation with real coefficients, the number of real roots is one or three (though two could be repeated). Source: high school advanced algebra or college pre-calculus algebra. Don't count on two real roots. $\endgroup$
    – W H G
    Nov 28, 2022 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.