CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to write a solver for nonlinear equations

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 6, 2019, 20:59
Default How to write a solver for nonlinear equations
  #1
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
Hello,


I am trying to solve the emden-fowler equation: T*laplace(T)=x by writing an openfoam solver (I only care about the 1D problem, so I am taking T as a scalar). I have some code that can solve div(T)=x using fvOptions - that part is not hard. However, when I add in multiplication by T, it complies, but the solver crashes. I am not sure what is wrong:


Code:
                fvScalarMatrix TEqn
                (

                       T*fvm::laplacian(DT, T) == correctDim*fvOptions(T)
                );

                fvOptions.constrain(TEqn);
                TEqn.solve();
                fvOptions.correct(T);

or if the solver is actually the problem. When I remove the fvOptions forcing term, the solver will run, but produce incorrect results. For example, if I specify dirichlet 1 boundaries on either side, the solution is f(x) = 0 with kinked boundaries, but should be f(x)=1.


Any ideas? I was thinking maybe I am not treating the T*laplace(T) term correctly?


Thanks
KTG is offline   Reply With Quote

Old   November 7, 2019, 15:20
Default
  #2
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
So here is a little update: It looks like I was actually crashing the matrix solver. So I think I am solving the correct equation, but now I am getting a singular matrix. I am solving:


Code:
                fvScalarMatrix TEqn
                (

                       T* (fvm::laplacian(DT, T)) == -2*correctDim*fvOptions(T)
                );

                fvOptions.constrain(TEqn);
                TEqn.solve();
                fvOptions.correct(T);

with x in [.2 1], fvOptions is coded to be just the spatial values of x, and the left boundary is zerogradient while the right is fixedvalue 0. Its tempting to say that its probably a boundary condition issue, but I know this specific problem to have a published power series solution... Anyone have any ideas? ANY ideas... Like is there a way to print the matrix problem from the solver so I can manually check it for problems? Given how simple the problem is I probably could have written in house code for this by now (which is not to say that would work)...



Thanks
KTG is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to develop my OWN solver for Navier-Stokes equations Abderahmane Main CFD Forum 1 September 7, 2017 12:26
New Free Solver -- FlowEDG: A DG solver for the compressible Euler and NS equations mavguy Main CFD Forum 11 May 29, 2015 17:52
thobois class engineTopoChangerMesh error Peter_600 OpenFOAM 4 August 2, 2014 09:52
Adding two Energy Equations to Porous Solver Filankes OpenFOAM Programming & Development 2 December 3, 2013 05:20
free " ordinary differential equations solver" ztdep Main CFD Forum 2 March 21, 2006 01:58


All times are GMT -4. The time now is 01:57.