| MATLAB Central > MATLAB Newsreader > Newton Raphson method for chemical equilibrium sys... |
|
|
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 3 Aug, 2010 23:38:07 Message: 1 of 26 |
|
I am trying to solve a system of equations relating to a chemical equilibrium problem in the form or A*x = B, five equations and five unknowns. The A-matrix is 5x5 as is the Jacobian. I have no problem solving the current system; however, when I try to solve for a larger system I start running into problems. I was wondering if anyone could provide some suggestions on how to use this method for a larger system of equations, thus solving for more unknowns. My function for the Newton Raphson method is shown below. Please let me know how I could improve the code. It currently works well even with bad initial guesses for the 5x5 system, but fails when the system is larger than 5x5. When I run the problem for a 6x6 system, it converges but gives a warning that the matrix is close to singular or badly scaled. How can I fix this? I've read that incorporating a damping method with Newton |
|
Subject: Newton Raphson method for chemical equilibrium system From: TideMan Date: 3 Aug, 2010 23:58:19 Message: 2 of 26 |
|
On Aug 4, 11:38 am, "Gavin " <wigg...@gmail.com> wrote: |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 4 Aug, 2010 03:28:04 Message: 3 of 26 |
|
TideMan <mulgor@gmail.com> wrote in message <ec2acf45-eb15-4a32-bc4d-4199af5dbbab@n19g2000prf.googlegroups.com>... |
|
Subject: Newton Raphson method for chemical equilibrium system From: TideMan Date: 4 Aug, 2010 03:46:39 Message: 4 of 26 |
|
On Aug 4, 3:28 pm, "Gavin " <wigg...@gmail.com> wrote: |
|
Subject: Newton Raphson method for chemical equilibrium system From: Roger Stafford Date: 4 Aug, 2010 04:28:04 Message: 5 of 26 |
|
TideMan <mulgor@gmail.com> wrote in message <126edaf0-e1e5-4760-a737-6d680d5f9dfb@m17g2000prl.googlegroups.com>... |
|
Subject: Newton Raphson method for chemical equilibrium system From: TideMan Date: 4 Aug, 2010 04:50:02 Message: 6 of 26 |
|
On Aug 4, 4:28 pm, "Roger Stafford" |
|
Subject: Newton Raphson method for chemical equilibrium system From: Steve Amphlett Date: 4 Aug, 2010 07:58:06 Message: 7 of 26 |
|
"Gavin " <wigging@gmail.com> wrote in message <i3a98v$lck$1@fred.mathworks.com>... |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 4 Aug, 2010 14:00:11 Message: 8 of 26 |
|
|
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 4 Aug, 2010 14:55:44 Message: 9 of 26 |
|
> |
|
Subject: Newton Raphson method for chemical equilibrium system From: Maxx Chatsko Date: 4 Aug, 2010 15:05:26 Message: 10 of 26 |
|
"Gavin " <wigging@gmail.com> |
|
Subject: Newton Raphson method for chemical equilibrium system From: Maxx Chatsko Date: 4 Aug, 2010 15:19:05 Message: 11 of 26 |
|
"Maxx Chatsko" <chatskom@chemimage.com> |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 4 Aug, 2010 23:40:23 Message: 12 of 26 |
|
"Maxx Chatsko" <chatskom@chemimage.com> wrote in message <i3c0d8$1o4$1@fred.mathworks.com>... |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 5 Aug, 2010 03:03:05 Message: 13 of 26 |
|
> The first thing I'd do is to substitute N(i) = N~(i)^2 |
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 5 Aug, 2010 06:26:14 Message: 14 of 26 |
|
> > The first thing I'd do is to substitute N(i) = |
|
Subject: Newton Raphson method for chemical equilibrium system From: Darren Rowland Date: 5 Aug, 2010 07:39:22 Message: 15 of 26 |
|
Torsten makes a good point about the need for updating the Jacobian. |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 6 Aug, 2010 04:06:04 Message: 16 of 26 |
|
> > Gavin |
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 6 Aug, 2010 09:12:44 Message: 17 of 26 |
|
> > > Gavin |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 6 Aug, 2010 23:42:05 Message: 18 of 26 |
|
> In every expression in the function F, you will have |
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 7 Aug, 2010 10:15:30 Message: 19 of 26 |
|
I did not check your equations in detail, just |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 9 Aug, 2010 01:44:06 Message: 20 of 26 |
|
> % outputs of system, moles and total moles |
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 9 Aug, 2010 06:44:55 Message: 21 of 26 |
|
%%%%%%%%%%%%%% MAIN FUNCTION using Newton Raphson method %%%%%%%%%%%%%%%% |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 9 Aug, 2010 09:28:06 Message: 22 of 26 |
|
> % outputs of system, moles and total moles |
|
Subject: Newton Raphson method for chemical equilibrium system From: Torsten Hennig Date: 9 Aug, 2010 09:55:23 Message: 23 of 26 |
|
> > % outputs of system, moles and total moles |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 9 Aug, 2010 12:47:04 Message: 24 of 26 |
|
I have tried using fsolve but ended up with incorrect results. Feel free to try with my system of equations and let me know if you get it to work correctly. I found that the newton raphson method gave more consistent answers and was easier to fix if problems arose. |
|
Subject: Newton Raphson method for chemical equilibrium system From: Gavin Date: 10 Aug, 2010 13:57:04 Message: 25 of 26 |
|
> > Gavin |
|
Subject: Newton Raphson method for chemical equilibrium system From: Zaki Date: 23 May, 2012 10:05:09 Message: 26 of 26 |
|
Dear Gavin, |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| newton raphson | Gavin | 3 Aug, 2010 19:39:31 |
| chemical equilibri... | Gavin | 3 Aug, 2010 19:39:31 |
| system of equation... | Gavin | 3 Aug, 2010 19:39:31 |
