# 求反应网络的化学平衡

 In[1]:= Xvars = {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[ x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]};

 In[2]:= Xconservation = {Subscript[x, 2] + 2 Subscript[x, 6] + Subscript[x, 9] + 2 Subscript[x, 10] == Subscript[T, H], Subscript[x, 3] + Subscript[x, 8] == Subscript[T, CO], Subscript[x, 1] + Subscript[x, 3] + 2 Subscript[x, 5] + 2 Subscript[x, 8] + Subscript[x, 9] + Subscript[x, 10] == Subscript[T, O], Subscript[x, 4] + 2 Subscript[x, 7] == Subscript[T, N]};

 In[3]:= Xequilibrium = {Subscript[x, 5] == Subscript[R, 1] Subscript[x, 1]^2, Subscript[x, 6] == Subscript[R, 2] Subscript[x, 2]^2, Subscript[x, 7] == Subscript[R, 3] Subscript[x, 4]^2, Subscript[x, 8] == Subscript[R, 4] Subscript[x, 1] Subscript[x, 3], Subscript[x, 9] == Subscript[R, 5] Subscript[x, 1] Subscript[x, 2], Subscript[x, 10] == Subscript[R, 6] Subscript[x, 1] Subscript[x, 2]^2};

 In[4]:= Xpars = {Subscript[T, O] -> 5 10^-5, Subscript[T, CO] -> 3 10^-5, Subscript[T, H] -> 1 10^-5, Subscript[T, N] -> 1 10^-5, Subscript[R, 1] -> 24.528, Subscript[R, 2] -> 22.206, Subscript[R, 3] -> 47.970, Subscript[R, 4] -> 24.942, Subscript[R, 5] -> 22.120, Subscript[R, 6] -> 46.989};

 In[5]:= Xrsols = NSolve[Join[conservation, equilibrium] /. pars, vars, Reals];
 In[6]:= XThread[vars -> SelectFirst[vars /. rsols, VectorQ[#, NonNegative] &]]
 Out[6]=

 In[7]:= Xrsols = NSolve[ SetPrecision[Join[conservation, equilibrium] /. pars, 20], vars, Reals, WorkingPrecision -> 20];
 In[8]:= XThread[vars -> SelectFirst[vars /. rsols, VectorQ[#, NonNegative] &]]
 Out[8]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »