My goal is to use the Newton Raphson root finding method with the Ideal Gas Law, Van der Waal equation and Beattie-Bridgeman equation to solve for the Specific Volume over a process of constant Temperature but variant Pressure.
I was able to get the Van der Waal equation, assuming the code should work for the other equations, applied them. However, as I manually worked out the Root Finding Method for the first few iterations for all equation, I know what is expected I'm not getting the same results for the Ideal Gas Law nor the Beattie-Bridgeman Equation. In fact I'm getting very odd results with some errors and I suspect it must have to do with what starting number I choose for the FindMinimum function.
This is my code Beattie-Bridgeman:
R = 8.314;
A = 507.28;
B = 0.10476;
a = 0.07132;
b = 0.07235;
c = 660000;
T = 333;
iter = 60;
FX = (R*T/v^2) (1 - c/(v*T^3)) (v + B (1 - b/v)) - (A (1 - a/v))/v^2 - P;
FXX = (1/(T^2*v^5)) ((-a*T^2*v*A (1 - a/v)) + 2*T^2*v^2*A (1 - a/v) + R (b*B (3*T^3*v - 4 c)) + (v*((3*B*c) - (2*B*T^3 v) + (2*c*v + T^3)*(-(v^3)))));
FXXX = v - FX/FXX;
nn = Table[FXXX, {P, 400, 6000, iter}];
Ps = Table[P, {P, 400, 6000, iter}];
vs = Table[
] v /. Last@FindMinimum[nn[[i]], {v, 7 i^(-.5) - 0.5}], {i, Length@nn}]
ListPlot[Thread[{Ps, vs}], Joined -> True, PlotRange -> {0, 7}]
Output:
{6.83167, 8.25229, 9.92447, 11.6632, 13.3806, 15.0489, 16.6622, \
]18.2218, 19.7311, 21.1941, 1.61453, 1.61453, 1.61453, 1.61453, \
1.61453, 1.61453, 1.61453, 1.14992, 1.61453, 1.61453, 35.0641, \
1.33489, 1.18791, 1.08221, 0.996586, 0.923465, 0.859006, 0.800873, \
0.747449, 0.697476, 0.649823, 0.603252, 0.555946, 0.503696, -1.76313, \
-1.76313, 0.306443, -1.76313, -1.76313, -1.76313, 0.196067, -1.76313, \
-1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313, 0.246203, -1.76313, -1.76313, -1.76313, \
-1.76313, -1.76313, -1.76313}
and
Errors:
FindMinimum::lstol: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>
General::stop: Further output of FindMinimum::nrnum will be suppressed during this calculation. >>
Power::infy: Infinite expression 1/0. encountered. >>
General::stop: Further output of FindMinimum::nrnum will be suppressed during this calculation. >>
Any help would be greatly appreciated. Thanks!