Problem with FindRootProblem with FindRoot applied to functionsFindRoot with GradFindRoot with NIntegrate giving errorsProblem with FindRoot + NDSolve + InterpolatingFunctionDomainProblem using ConstantArray in FindRootProblem with FindRoot outputError to converge NIntegrate with FindRootA difficult problem about the “FindRoot”A problem with FindRootProblem with FindRoot, NIntegrate, and ImplicitRegion
Simplify an interface for flexibly applying rules to periods of time
How to explain that I do not want to visit a country due to personal safety concern?
Fastest way to pop N items from a large dict
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
Welcoming 2019 Pi day: How to draw the letter π?
Why does a Star of David appear at a rally with Francisco Franco?
Violin - Can double stops be played when the strings are not next to each other?
Why is the President allowed to veto a cancellation of emergency powers?
Describing a chess game in a novel
PTIJ: Who should I vote for? (21st Knesset Edition)
Adventure Game (text based) in C++
Why won't this compile? Argument of h has an extra {
A diagram about partial derivatives of f(x,y)
Shortcut for setting origin to vertex
Problem with FindRoot
How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?
Did Ender ever learn that he killed Stilson and/or Bonzo?
Knife as defense against stray dogs
Numerical Minimization of Large Expression
What is the adequate fee for a reveal operation?
Employee lack of ownership
Pauli exclusion principle
Is it normal that my co-workers at a fitness company criticize my food choices?
Problem with FindRoot
Problem with FindRoot applied to functionsFindRoot with GradFindRoot with NIntegrate giving errorsProblem with FindRoot + NDSolve + InterpolatingFunctionDomainProblem using ConstantArray in FindRootProblem with FindRoot outputError to converge NIntegrate with FindRootA difficult problem about the “FindRoot”A problem with FindRootProblem with FindRoot, NIntegrate, and ImplicitRegion
$begingroup$
Maxwell Construction is just integral of area and finding root to find vapor pressure.
This must be exactly the same where Gibbs energy graph cross at a point i found it p = 0.81.
The problem my areadifferential doesn't work properly to return a value p=0.81;
What mistake i have done in coding!?
t = 0.95;
p[v_] := (8*t)/(3*v - 1) - 3/v^2;
Plot[p[v], v, 0.5, 3, PlotRange -> 0, 3, 0.6, 1, AxesLabel -> V/Vc, P/Pc]
g[v_] := (-t)*Log[3*v - 1] + 0.95/(3*v - 1) - 9/(4*v);
ParametricPlot[p[v],g[v],v,.65,2.25,AxesLabel->P/Pc,G/NKT,
PlotLabel->"Gibbs Free Energy Vs. P/Pc"]
That's Return pressure p=P/Pc=0.81 in plot which is correct
This is the error Maxwell Construction "area differential" Part
pint[v_] := (8/3)*t*Log[3*v - 1] + 3/v;
areadifferential[p0_, v1guess_, v2guess_] :=
(v1 = FindRoot[p[v] == p0, v, v1guess][[1,2]];
v2 = FindRoot[p[v] == p0, v, v2guess][[1,2]];
pint[v2] - pint[v1] - p0*(v2 - v1))
FindRoot[areadifferential[p0, 0.7, 2] == 0, p0, 0.8, 0.82]
equation-solving numerical-integration differentials
New contributor
$endgroup$
add a comment |
$begingroup$
Maxwell Construction is just integral of area and finding root to find vapor pressure.
This must be exactly the same where Gibbs energy graph cross at a point i found it p = 0.81.
The problem my areadifferential doesn't work properly to return a value p=0.81;
What mistake i have done in coding!?
t = 0.95;
p[v_] := (8*t)/(3*v - 1) - 3/v^2;
Plot[p[v], v, 0.5, 3, PlotRange -> 0, 3, 0.6, 1, AxesLabel -> V/Vc, P/Pc]
g[v_] := (-t)*Log[3*v - 1] + 0.95/(3*v - 1) - 9/(4*v);
ParametricPlot[p[v],g[v],v,.65,2.25,AxesLabel->P/Pc,G/NKT,
PlotLabel->"Gibbs Free Energy Vs. P/Pc"]
That's Return pressure p=P/Pc=0.81 in plot which is correct
This is the error Maxwell Construction "area differential" Part
pint[v_] := (8/3)*t*Log[3*v - 1] + 3/v;
areadifferential[p0_, v1guess_, v2guess_] :=
(v1 = FindRoot[p[v] == p0, v, v1guess][[1,2]];
v2 = FindRoot[p[v] == p0, v, v2guess][[1,2]];
pint[v2] - pint[v1] - p0*(v2 - v1))
FindRoot[areadifferential[p0, 0.7, 2] == 0, p0, 0.8, 0.82]
equation-solving numerical-integration differentials
New contributor
$endgroup$
add a comment |
$begingroup$
Maxwell Construction is just integral of area and finding root to find vapor pressure.
This must be exactly the same where Gibbs energy graph cross at a point i found it p = 0.81.
The problem my areadifferential doesn't work properly to return a value p=0.81;
What mistake i have done in coding!?
t = 0.95;
p[v_] := (8*t)/(3*v - 1) - 3/v^2;
Plot[p[v], v, 0.5, 3, PlotRange -> 0, 3, 0.6, 1, AxesLabel -> V/Vc, P/Pc]
g[v_] := (-t)*Log[3*v - 1] + 0.95/(3*v - 1) - 9/(4*v);
ParametricPlot[p[v],g[v],v,.65,2.25,AxesLabel->P/Pc,G/NKT,
PlotLabel->"Gibbs Free Energy Vs. P/Pc"]
That's Return pressure p=P/Pc=0.81 in plot which is correct
This is the error Maxwell Construction "area differential" Part
pint[v_] := (8/3)*t*Log[3*v - 1] + 3/v;
areadifferential[p0_, v1guess_, v2guess_] :=
(v1 = FindRoot[p[v] == p0, v, v1guess][[1,2]];
v2 = FindRoot[p[v] == p0, v, v2guess][[1,2]];
pint[v2] - pint[v1] - p0*(v2 - v1))
FindRoot[areadifferential[p0, 0.7, 2] == 0, p0, 0.8, 0.82]
equation-solving numerical-integration differentials
New contributor
$endgroup$
Maxwell Construction is just integral of area and finding root to find vapor pressure.
This must be exactly the same where Gibbs energy graph cross at a point i found it p = 0.81.
The problem my areadifferential doesn't work properly to return a value p=0.81;
What mistake i have done in coding!?
t = 0.95;
p[v_] := (8*t)/(3*v - 1) - 3/v^2;
Plot[p[v], v, 0.5, 3, PlotRange -> 0, 3, 0.6, 1, AxesLabel -> V/Vc, P/Pc]
g[v_] := (-t)*Log[3*v - 1] + 0.95/(3*v - 1) - 9/(4*v);
ParametricPlot[p[v],g[v],v,.65,2.25,AxesLabel->P/Pc,G/NKT,
PlotLabel->"Gibbs Free Energy Vs. P/Pc"]
That's Return pressure p=P/Pc=0.81 in plot which is correct
This is the error Maxwell Construction "area differential" Part
pint[v_] := (8/3)*t*Log[3*v - 1] + 3/v;
areadifferential[p0_, v1guess_, v2guess_] :=
(v1 = FindRoot[p[v] == p0, v, v1guess][[1,2]];
v2 = FindRoot[p[v] == p0, v, v2guess][[1,2]];
pint[v2] - pint[v1] - p0*(v2 - v1))
FindRoot[areadifferential[p0, 0.7, 2] == 0, p0, 0.8, 0.82]
equation-solving numerical-integration differentials
equation-solving numerical-integration differentials
New contributor
New contributor
edited 3 hours ago
user64494
3,51811021
3,51811021
New contributor
asked 4 hours ago
AlrubaieAlrubaie
438
438
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Good job on describing your problem.
Copying your definitions from your question
p[v_] := (8 t)/(3 v - 1) - 3/v^2
g[v_] := t/(3 v - 1) - t Log[-1 + 3 v] - 9/(4 v)
pint[v_] := 8/3 t Log[-1 + 3 v] + 3/v
t = 0.95
I found the value 0.81188 to be the value that minimized your areadifferential
function (shown at the bottom).
Look at the plot of P/Pc vs V/Vc and note the three points corresponding to three different V/Vc values resulting in p[v] = 0.8118
.
Module[
v1 = v /. FindRoot[p[v] == 0.8118, v, 0.5],
p1,
v2 = v /. FindRoot[p[v] == 0.8118, v, 1],
p2,
v3 = v /. FindRoot[p[v] == 0.8118, v, 2],
p3
,
p1 = p[v1];
p2 = p[v2];
p3 = p[v3];
Show[
Plot[p[v], v, 0.65, 2.25, PlotRange -> 0, 3, 0.6, 1,
AxesLabel -> "V/Vc", "P/Pc"],
Graphics[
PointSize[0.03],
Red,
Point[v1, p1],
Green,
Point[v2, p2],
Black,
Point[v3, p3]
]
]
]
The problem that you are experiencing is because the value of 0.7 for v1guess
is just to the right of the valley so it converges on the wrong point (i.e., the green point).
Change v1guess
to 0.5 and you will be fine, it will converge on the red point. Using v2guess
of 2.0 works fine causing convergence on the black point.
I slightly modified the areadifferential
function to use Module
rather than parenthesis. One needs to constrain the input arguments to be numeric so FindRoot
doesn't complain (FindFoot
first tries to work with symbolic arguments which doesn't work with your problem).
areadifferential[
p0_?NumericQ,
v1guess_?NumericQ,
v2guess_?NumericQ] := Module[
v1 = FindRoot[p[v] == p0, v, v1guess][[1, 2]],
v2 = FindRoot[p[v] == p0, v, v2guess][[1, 2]]
,
pint[v2] - pint[v1] - p0*(v2 - v1)
]
and then
FindRoot[areadifferential[p0, 0.5, 2] == 0, p0, 0.8, 0.82]
(* p0 -> 0.811879 *)
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Alrubaie is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193383%2fproblem-with-findroot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Good job on describing your problem.
Copying your definitions from your question
p[v_] := (8 t)/(3 v - 1) - 3/v^2
g[v_] := t/(3 v - 1) - t Log[-1 + 3 v] - 9/(4 v)
pint[v_] := 8/3 t Log[-1 + 3 v] + 3/v
t = 0.95
I found the value 0.81188 to be the value that minimized your areadifferential
function (shown at the bottom).
Look at the plot of P/Pc vs V/Vc and note the three points corresponding to three different V/Vc values resulting in p[v] = 0.8118
.
Module[
v1 = v /. FindRoot[p[v] == 0.8118, v, 0.5],
p1,
v2 = v /. FindRoot[p[v] == 0.8118, v, 1],
p2,
v3 = v /. FindRoot[p[v] == 0.8118, v, 2],
p3
,
p1 = p[v1];
p2 = p[v2];
p3 = p[v3];
Show[
Plot[p[v], v, 0.65, 2.25, PlotRange -> 0, 3, 0.6, 1,
AxesLabel -> "V/Vc", "P/Pc"],
Graphics[
PointSize[0.03],
Red,
Point[v1, p1],
Green,
Point[v2, p2],
Black,
Point[v3, p3]
]
]
]
The problem that you are experiencing is because the value of 0.7 for v1guess
is just to the right of the valley so it converges on the wrong point (i.e., the green point).
Change v1guess
to 0.5 and you will be fine, it will converge on the red point. Using v2guess
of 2.0 works fine causing convergence on the black point.
I slightly modified the areadifferential
function to use Module
rather than parenthesis. One needs to constrain the input arguments to be numeric so FindRoot
doesn't complain (FindFoot
first tries to work with symbolic arguments which doesn't work with your problem).
areadifferential[
p0_?NumericQ,
v1guess_?NumericQ,
v2guess_?NumericQ] := Module[
v1 = FindRoot[p[v] == p0, v, v1guess][[1, 2]],
v2 = FindRoot[p[v] == p0, v, v2guess][[1, 2]]
,
pint[v2] - pint[v1] - p0*(v2 - v1)
]
and then
FindRoot[areadifferential[p0, 0.5, 2] == 0, p0, 0.8, 0.82]
(* p0 -> 0.811879 *)
$endgroup$
add a comment |
$begingroup$
Good job on describing your problem.
Copying your definitions from your question
p[v_] := (8 t)/(3 v - 1) - 3/v^2
g[v_] := t/(3 v - 1) - t Log[-1 + 3 v] - 9/(4 v)
pint[v_] := 8/3 t Log[-1 + 3 v] + 3/v
t = 0.95
I found the value 0.81188 to be the value that minimized your areadifferential
function (shown at the bottom).
Look at the plot of P/Pc vs V/Vc and note the three points corresponding to three different V/Vc values resulting in p[v] = 0.8118
.
Module[
v1 = v /. FindRoot[p[v] == 0.8118, v, 0.5],
p1,
v2 = v /. FindRoot[p[v] == 0.8118, v, 1],
p2,
v3 = v /. FindRoot[p[v] == 0.8118, v, 2],
p3
,
p1 = p[v1];
p2 = p[v2];
p3 = p[v3];
Show[
Plot[p[v], v, 0.65, 2.25, PlotRange -> 0, 3, 0.6, 1,
AxesLabel -> "V/Vc", "P/Pc"],
Graphics[
PointSize[0.03],
Red,
Point[v1, p1],
Green,
Point[v2, p2],
Black,
Point[v3, p3]
]
]
]
The problem that you are experiencing is because the value of 0.7 for v1guess
is just to the right of the valley so it converges on the wrong point (i.e., the green point).
Change v1guess
to 0.5 and you will be fine, it will converge on the red point. Using v2guess
of 2.0 works fine causing convergence on the black point.
I slightly modified the areadifferential
function to use Module
rather than parenthesis. One needs to constrain the input arguments to be numeric so FindRoot
doesn't complain (FindFoot
first tries to work with symbolic arguments which doesn't work with your problem).
areadifferential[
p0_?NumericQ,
v1guess_?NumericQ,
v2guess_?NumericQ] := Module[
v1 = FindRoot[p[v] == p0, v, v1guess][[1, 2]],
v2 = FindRoot[p[v] == p0, v, v2guess][[1, 2]]
,
pint[v2] - pint[v1] - p0*(v2 - v1)
]
and then
FindRoot[areadifferential[p0, 0.5, 2] == 0, p0, 0.8, 0.82]
(* p0 -> 0.811879 *)
$endgroup$
add a comment |
$begingroup$
Good job on describing your problem.
Copying your definitions from your question
p[v_] := (8 t)/(3 v - 1) - 3/v^2
g[v_] := t/(3 v - 1) - t Log[-1 + 3 v] - 9/(4 v)
pint[v_] := 8/3 t Log[-1 + 3 v] + 3/v
t = 0.95
I found the value 0.81188 to be the value that minimized your areadifferential
function (shown at the bottom).
Look at the plot of P/Pc vs V/Vc and note the three points corresponding to three different V/Vc values resulting in p[v] = 0.8118
.
Module[
v1 = v /. FindRoot[p[v] == 0.8118, v, 0.5],
p1,
v2 = v /. FindRoot[p[v] == 0.8118, v, 1],
p2,
v3 = v /. FindRoot[p[v] == 0.8118, v, 2],
p3
,
p1 = p[v1];
p2 = p[v2];
p3 = p[v3];
Show[
Plot[p[v], v, 0.65, 2.25, PlotRange -> 0, 3, 0.6, 1,
AxesLabel -> "V/Vc", "P/Pc"],
Graphics[
PointSize[0.03],
Red,
Point[v1, p1],
Green,
Point[v2, p2],
Black,
Point[v3, p3]
]
]
]
The problem that you are experiencing is because the value of 0.7 for v1guess
is just to the right of the valley so it converges on the wrong point (i.e., the green point).
Change v1guess
to 0.5 and you will be fine, it will converge on the red point. Using v2guess
of 2.0 works fine causing convergence on the black point.
I slightly modified the areadifferential
function to use Module
rather than parenthesis. One needs to constrain the input arguments to be numeric so FindRoot
doesn't complain (FindFoot
first tries to work with symbolic arguments which doesn't work with your problem).
areadifferential[
p0_?NumericQ,
v1guess_?NumericQ,
v2guess_?NumericQ] := Module[
v1 = FindRoot[p[v] == p0, v, v1guess][[1, 2]],
v2 = FindRoot[p[v] == p0, v, v2guess][[1, 2]]
,
pint[v2] - pint[v1] - p0*(v2 - v1)
]
and then
FindRoot[areadifferential[p0, 0.5, 2] == 0, p0, 0.8, 0.82]
(* p0 -> 0.811879 *)
$endgroup$
Good job on describing your problem.
Copying your definitions from your question
p[v_] := (8 t)/(3 v - 1) - 3/v^2
g[v_] := t/(3 v - 1) - t Log[-1 + 3 v] - 9/(4 v)
pint[v_] := 8/3 t Log[-1 + 3 v] + 3/v
t = 0.95
I found the value 0.81188 to be the value that minimized your areadifferential
function (shown at the bottom).
Look at the plot of P/Pc vs V/Vc and note the three points corresponding to three different V/Vc values resulting in p[v] = 0.8118
.
Module[
v1 = v /. FindRoot[p[v] == 0.8118, v, 0.5],
p1,
v2 = v /. FindRoot[p[v] == 0.8118, v, 1],
p2,
v3 = v /. FindRoot[p[v] == 0.8118, v, 2],
p3
,
p1 = p[v1];
p2 = p[v2];
p3 = p[v3];
Show[
Plot[p[v], v, 0.65, 2.25, PlotRange -> 0, 3, 0.6, 1,
AxesLabel -> "V/Vc", "P/Pc"],
Graphics[
PointSize[0.03],
Red,
Point[v1, p1],
Green,
Point[v2, p2],
Black,
Point[v3, p3]
]
]
]
The problem that you are experiencing is because the value of 0.7 for v1guess
is just to the right of the valley so it converges on the wrong point (i.e., the green point).
Change v1guess
to 0.5 and you will be fine, it will converge on the red point. Using v2guess
of 2.0 works fine causing convergence on the black point.
I slightly modified the areadifferential
function to use Module
rather than parenthesis. One needs to constrain the input arguments to be numeric so FindRoot
doesn't complain (FindFoot
first tries to work with symbolic arguments which doesn't work with your problem).
areadifferential[
p0_?NumericQ,
v1guess_?NumericQ,
v2guess_?NumericQ] := Module[
v1 = FindRoot[p[v] == p0, v, v1guess][[1, 2]],
v2 = FindRoot[p[v] == p0, v, v2guess][[1, 2]]
,
pint[v2] - pint[v1] - p0*(v2 - v1)
]
and then
FindRoot[areadifferential[p0, 0.5, 2] == 0, p0, 0.8, 0.82]
(* p0 -> 0.811879 *)
answered 2 hours ago
Jack LaVigneJack LaVigne
11.9k21632
11.9k21632
add a comment |
add a comment |
Alrubaie is a new contributor. Be nice, and check out our Code of Conduct.
Alrubaie is a new contributor. Be nice, and check out our Code of Conduct.
Alrubaie is a new contributor. Be nice, and check out our Code of Conduct.
Alrubaie is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193383%2fproblem-with-findroot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown