CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Could someone suggest simple (nonlinear) solver (https://www.cfd-online.com/Forums/main/16309-could-someone-suggest-simple-nonlinear-solver.html)

Bren February 4, 2009 08:26

Could someone suggest simple (nonlinear) solver
 
Hi Guys, I'm trying to solve a single equation (of one variable) which is nonlinear. It's quite a nasty equation containing a log(x) and an exp(1/x) term as well as some polynomial terms.

Could someone please suggest a numerical scheme I could use to solve such an equation? I want something that will calculate the answer very quickly.

Basically I'm trying to avoid an iterative procedure and have managed to write all my equations in terms of one unknown - this final equation is nonlinear and once I've solved it I can solve all the others. If the solution of the nonlinear eqn takes longer than the iterative procedure then the whole thing will be rather pointless.

I'd be very grateful for any help you guys could provide. Bren

ag February 4, 2009 12:01

Re: Could someone suggest simple (nonlinear) solve
 
As far as I am aware, there is no general "non-iterative" solver for non-linear equations. You may be able to find a solution technique for a particular equation, but that's what makes non-linear equations so tough - there are no general methods for coming up with exact solutions. Unless the equation presents itself in a form that allows an exact solution I don't think you'll find a non-iterative numerical technique. The only idea that comes to mind right off the bat is to see if you can implement a variable transformation that would result in an equation form that can be readily solved in an exact sense, i.e. one that would turn the existing equation into a simple polynomial form for which the roots are known.

A Newton-Raphson iterative solver is not particularly slow, unless you have an equation with a set of badly placed roots or you have no idea what to use as a starting guess.

Jed February 4, 2009 13:51

Re: Could someone suggest simple (nonlinear) solve
 
Bren, I'd like to point out that division, roots, and all the transcendental functions are implemented using iterative methods (the first two usually use Newton's method). Ignoring these iterations, it is not possible to find the roots of a general fifth (or higher) degree polynomial without iteration. In practice, the polynomial rootfinding problem is often transformed into an eigenvalue problem, but this does not work for non-polynomial functions. Due to this duality, there is no non-iterative eigenvalue procedure.

Also, it's not necessarily beneficial to eliminate as many variables as possible. That is, it's possible that the behavior of the function becomes more nasty as you eliminate variables.

If you want to speed up your solver, the initial guess is where you can gain the most time. Depending on the number of independent parameters, you might benefit from a small lookup table. Or perhaps there is a heuristic to get close, or the root of the last set of equations is close because of spatial correlation.

Ahmed February 4, 2009 15:38

Re: Could someone suggest simple (nonlinear) solve
 
Bren, I have used maxima (an open source programme that is available on most linux distributions) to solve such equations, try it

fluent-user February 4, 2009 21:36

Re: Could someone suggest simple (nonlinear) solve
 
many people have already commented that it might not be possible to find direct solution to your problem.

If i were you I would be trying to look of a equation whose direct solution is available and solution closely resembles the equation you have in your hand. I would use this initial guess with iterative procedure and quickly come out of it.

Anyway this is only a suggestion actual implementation may even not be possible though. So consider this just as a suggestion. My 2 cents (in this recession).

Bren February 5, 2009 04:24

Many thanks
 
Thank you very much everyone - your responses have been very helpful.

I think I will give the Newton-Raphson method a whirl as I've had some luck with it in the past. I have to be able to code up the method myself (using fortran) so, unfortunately, using commercially available software isn't an option.

Many thanks, Bren


andy2o February 5, 2009 13:31

Re: Many thanks
 
Bren,

You don't necessarily have to start from scratch with your code!

There are plenty of sources of free public domain code numerical routines around (www.netlib.org takes a bit of getting used to but has good Fortran / C codes, most (but not all) of which are public domain). A web search will find many other sources (of mixed quality of course, like anything on the internet, so be careful and test, test, test....).

Certainly look at the advice in the "Numerical Recipes" books too (in most libraries have copies or free access to the older editions is available on line at http://www.nr.com/oldverswitcher.html ). They should be a good starting point....

What language will you be using? If you're lucky someone might know of a code in your language!

Regards, Andy2o

momentum_waves February 5, 2009 21:23

Re: Could someone suggest simple (nonlinear) solve
 
It's dead easy. Write an Excel spreadsheet, & iterate into solution.

Be careful to approach the solution carefully by hand until the changes slow, then turn on automatic iteration.

Have fun. mw...

Momentum waves <www.adthermtech.com/wordpress3>


Ahmed February 6, 2009 21:02

Re: due correction
 
Bren On planet Earth, poeple know that the Linux OS and all the projects related to it are free open source codes including maxima (wxmaxima with the gui), you have your reasons to start from scratch, I do not enter here, but please do not tell us that "maxima" is a commercial code, there is even a windows installer. Good Luck to all living on Orion

Bren February 8, 2009 17:36

Re: due correction
 
I didn't mean to suggest that maxima was a commercial code Ahmed. I appologise for not being clear enough - I need to adapt an existing fortran code to include a nonlinear solver. That is why I need to code the method myself rather than rely on software produced by someone else, whether it be commercial or open source. I thought that my position was clear in my post: "able to code up the method myself" was a strong hint.

Here on Orion it's considered good manners to respond to a polite statement (such as my "Many Thanks" post) with a polite response, being a sarcastic tool is actually considered quite rude here! You should visit some time - though I would advise that you adopt a less hostile attitude.

Bren


ztdep March 7, 2009 06:36

Re: Could someone suggest simple (nonlinear) solve
 
try matlab or maple



All times are GMT -4. The time now is 07:41.