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

ODE & PDE model

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 3, 2016, 12:19
Default ODE & PDE model
  #1
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Dear members,

I am writing a 3D solver that has one ODE and one PDE.

dC/dt = -a*X, with C(0)=1
dX/dt = laplacian(DX, X) + k*X, with no slip boundary condition everywhere and X(0) = 0.05 at the bottom

I am confused how to setup this model specially ODE and need help. So far I can think as follows:


Code:
while (simple.loop())
{                 
    Info<< "Time = " << runTime.timeName() << nl << endl;         
    solve(fvm::ddt(C) == -a*X);           
    solve(fvm::ddt(X) == fvm::laplacian(DX, X) + k*X); 

    runTime.write();      
}
Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0";
    object      C;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField   uniform 1;

boundaryField
{
    AllWalls
    {
        ??????? //I don't have boundary conditions
    }
    
}
My questions are:
(1) is my setup correct?
(2) I don't have boundary conditions for ODE, what should I do in above code?
(3) I don't want to use simple.loop() in while condition, what are other options to iterate through time-steps?

(4)Plz suggest, how can I improve this setup?

Thanks for reading.
cute is offline   Reply With Quote

Old   August 4, 2016, 19:49
Default
  #2
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Anyone has any suggestion.
cute is offline   Reply With Quote

Old   August 11, 2016, 09:48
Default
  #3
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Hello everyone,

Any comment or suggestion in my case?

Thanks.
cute is offline   Reply With Quote

Old   August 11, 2016, 10:31
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
I don't think finiteVolume is set up for ODEs. OpenFOAM has an ODE solver library, src/ode. Have a look at applications/test/ODE to see how one is set up.

If you take an example from the chemistry solvers, ODEs are solved by first looping through all the cells in the mesh, then solving the ODE. That is:

Code:
// given that rho is a volScalarField
// given that C is a PtrList<volScalarField> of your ODE variables
forAll(rho, cellI)
{
    scalarField y(nEqns); // number of variables in your ODE
    forAll(y, varI)
    {
        y[varI] = C[varI][cellI];
       // solve ODE here, see Test-ODE for example
    }
}
But you should also consider the fact that you are solving a complex numerical system in two uncoupled steps. You might need to do something to couple them. I describe this in section 2.1.8 here http://mspace.lib.umanitoba.ca/handle/1993/22096
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   August 12, 2016, 08:24
Default
  #5
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Thanks marupio. I am not sure how to implement this. I am using OpenFoam for the last three months and still learning.

If I setup ODE using FVM, will it be wrong? I think that it should produce the same result, but less efficient.

I need to know, how we can make it more efficient?

Thanks.
cute is offline   Reply With Quote

Old   August 12, 2016, 10:07
Default
  #6
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
But you should also consider the fact that you are solving a complex numerical system in two uncoupled steps.
This is in fact something you should take into account but to be honest. We are always solving complex stuff uncoupled. Even the momentum equation is segregated and the pressure - momentum coupling is also not coupled (only if you have the explicit coupled solver that we are not using normally).

I solved something similar -> the Gray-Scott-Model <- Both equations are coupled but I also solved it segregated and without any problems. Even your equations above should be an easy task to implement.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   August 12, 2016, 10:19
Default
  #7
Member
 
anonymous
Join Date: Mar 2016
Location: Canada
Posts: 93
Rep Power: 10
cute is on a distinguished road
Thanks Tobi, I will look into it.
cute 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
kklOmega omega boundary condition at the wall - OF3.0 Artur OpenFOAM Running, Solving & CFD 1 June 17, 2016 15:42
Turbulence model choice dave13 CFX 3 December 22, 2015 07:12
problem with solving lagrange reaction cloud Polli OpenFOAM Running, Solving & CFD 0 April 30, 2014 07:53
manualInjection model in sprayFoam Mentalo OpenFOAM Running, Solving & CFD 1 April 2, 2014 09:29
Problems bout CFD model of biomass gasification, Downdraft gasifier wanglong FLUENT 2 November 25, 2009 23:27


All times are GMT -4. The time now is 05:31.