Re: simultaneous equations for chemical speciation
- To: mathgroup at smc.vnet.net
- Subject: [mg100198] Re: [mg100186] simultaneous equations for chemical speciation
- From: sean k <sean_incali at yahoo.com>
- Date: Thu, 28 May 2009 04:26:27 -0400 (EDT)
- Reply-to: sean_incali at yahoo.com
You have 13 unknowns but only 8 equation. I presume you want to derive an expression for g? Remove["Global`*"] 1. Your systems is chem = {a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}; 2. Solving the 6th eqn gives an idea as to what g should look like, gsol = Solve[chem[[6]], g] gives the following. g-> f j / m 3. Let's replace f, j and m in above by solving the appropriate equations in your system. Solving the eqn 2 for f and replace into the system (giving the replaced system a new name chem2) fsol = Solve[chem[[2]], f] chem2 = chem /. fsol // Flatten 4. Repeat for m. msol = Solve[chem2[[7]], m] chem3 = chem2 /. msol // Flatten 5. Now note j expression is really ugly. Let's use i and h equations to simplify. chem4 = chem3 /. {i -> d/(c g), h -> c/(b g)} 6. Solve for b and replace. bsol = Solve[chem4[[1]], b] chem5 = chem4 /. bsol // Flatten 7. Solve for l and replace. lsol = Solve[chem5[[6]], l] chem6 = chem5 /. lsol // Cancel // Flatten 8. Finally solve for g and you will get a huge expression. gsol = Solve[chem6[[8]], g] %//length You can now do parameter lumping to see if you can further simplify the expressions for g. There are 3 roots. I don't know if you need all 3. Since it's chem, you will need positive ones. People in here will be able to tell you how to simplify this further. If you want to do everything in one cell, copy and paste the following. Remove["Global`*"] chem = {a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}; gsol = Solve[chem[[6]], g] fsol = Solve[chem[[2]], f] chem2 = chem /. fsol // Flatten msol = Solve[chem2[[7]], m] chem3 = chem2 /. msol // Flatten chem4 = chem3 /. {i -> d/(c g), h -> c/(b g)} bsol = Solve[chem4[[1]], b] chem5 = chem4 /. bsol // Flatten lsol = Solve[chem5[[6]], l] chem6 = chem5 /. lsol // Cancel // Flatten gsol = Solve[chem6[[8]], g] % // Length --- On Wed, 5/27/09, Jem & Tracy <jemandtracy at bigpond.com> wrote: > From: Jem & Tracy <jemandtracy at bigpond.com> > Subject: [mg100186] simultaneous equations for chemical speciation > To: mathgroup at smc.vnet.net > Date: Wednesday, May 27, 2009, 1:09 AM > Hi, I am a postgrad student and > completely new to mathematica, I am just > starting to realise the possibilities. > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the > equilibria, > mass balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able > to solve for > the remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > Basically, I can solve for the variable I want, but I am > having trouble > eliminating the ones I don't want (ie. I am getting an > answer that is in > terms of the wrong variables) > Sofar my formula looks like: > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == > l*m, > n + m + b + c == g + l}, {g}] > > If I use a similar formula for the "Eliminate" function, I > get error > mesages. > > I have been in the help files for ages, and don't really > understand how > to do this. > I would really appreciate some pointers!! > Thanks > >