georgeip1
(George Ip)
October 20, 2024, 12:59pm
1
Good morning,
I am trying to solve a homework problem but could not get Mathematica to get an answer. Any suggestion?
Clear["Global`*"]
R = 8.314 ;(*J/mol/K*)
N1Ai = 0.5;
N1Bi = 1;
N2A = 0.75;
N2B = 0.5;
V = 5;(*Liters*)
Teq = 272.7; (*K*)
Uf = 9353.25;(*J*)
dSdN1A =
D[(N1A + N2A)*A + (N1A + N2A)*R*
Log[UA^(3/2)*V/((N1A + N2A)^(5/2))] -
N1A*R*Log[N1A/(N1A + N2A)] - N2A*R*Log[N2A/(N1A + N2A)], N1A];
UA = ((3/2)*(N1A + N2A)*R*Teq);
dSdN1B =
D[(N1B + N2B)*A + (N1B + N2B)*R*
Log[UB^(3/2)*V/((N1B + N2B)^(5/2))] -
N1B*R*Log[N1B/(N1B + N2B)] - N2B*R*Log[N2B/(N1B + N2B)], N1B];
UB = ((3/2)*(N1B + N2B)*R*Teq);
dSdN1A
dSdN1B
Solve[dSdN1A == dSdN1B && N1A + N1B == N1Ai + N1Bi, {N1A, N1B}]
Here are the outputs
dSdN1A=
-20.785 + A + 6.2355/(0.75 + N1A) -
8.314 (0.75 + N1A) (-(N1A/(0.75 + N1A)^2) + 1/(0.75 + N1A)) +
8.314 Log[991630./(0.75 + N1A)] - 8.314 Log[N1A/(0.75 + N1A)]
dSdN1B=
-20.785 + A + 4.157/(0.5 + N1B) -
8.314 (0.5 + N1B) (-(N1B/(0.5 + N1B)^2) + 1/(0.5 + N1B)) +
8.314 Log[991630./(0.5 + N1B)] - 8.314 Log[N1B/(0.5 + N1B)]
Solve::svars: Equations may not give solutions for all "solve" variables.
{{N1B -> 1.5 - 1. N1A}}
2_8_1_a.nb (9.32 KB)
You forgot the multiplication star in N1BRLog and N1ARLog . A part from that, I get different output.
georgeip1
(George Ip)
October 20, 2024, 2:37pm
3
Can you share your output?
I made sure the multiplication stars are there but it still gives me the same output.
I think when I make this post it took out some of the stars. See my attached code.
Clear["Global`*"]
R = 8.314 ;(*J/mol/K*)
N1Ai = 0.5;
N1Bi = 1;
N2A = 0.75;
N2B = 0.5;
V = 5;(*Liters*)
Teq = 272.7; (*K*)
Uf = 9353.25;(*J*)
dSdN1A =
D[(N1A + N2A)*A + (N1A + N2A)*R*
Log[UA^(3/2)*V/((N1A + N2A)^(5/2))] -
N1A*R*Log[N1A/(N1A + N2A)] - N2A*R*Log[N2A/(N1A + N2A)], N1A];
UA = ((3/2)*(N1A + N2A)*R*Teq);
dSdN1B =
D[(N1B + N2B)*A + (N1B + N2B)*R*
Log[UB^(3/2)*V/((N1B + N2B)^(5/2))] -
N1B*R*Log[N1B/(N1B + N2B)] - N2B*R*Log[N2B/(N1B + N2B)], N1B];
UB = ((3/2)*(N1B + N2B)*R*Teq);
Solve[dSdN1A == dSdN1B && N1A + N1B == N1Ai + N1Bi, {N1A, N1B}]
2_8_1_a.nb (9.65 KB)
Mathematica ignores your first equation, I wonder why. However, a plot suggests that your first equation is simpler than it may appear from the formula:
ContourPlot[{dSdN1A == dSdN1B, N1A + N1B == N1Ai + N1Bi},
{N1A, -1, 2}, {N1B, -1, 2}]
I would simplify your equations first:
dSdN1A == dSdN1B;
Rationalize[%, 0]
FullSimplify[%, N1A > 0 && N1B > 0]
eq1New = ApplySides[Exp, %]
and
N1A + N1B == N1Ai + N1Bi;
eq2New = Rationalize[%]
and finally
Solve[{eq1New, eq2New}]
dontdont9
(Bill Nelson)
October 20, 2024, 4:13pm
5
Changing Solve to Reduce and no other changes
Reduce[dSdN1inA==dSdN1inB&&N1A+N1B==N1Ai+N1Bi, {N1A,N1B}]
returns a warning that can be ignored
Reduce: Reduce was unable to solve the system with inexact coefficients.
The answer was obtained by solving a corresponding exact system and numericizing the result.
and then
N1A==0.75&&N1B==0.75
georgeip1
(George Ip)
October 20, 2024, 6:05pm
6
I used your method and plug the answers back into the equations for both dSdN1A and dSdN1B. They do equal to each other!