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

Chemistry Source Term RR()

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By zhangyan
  • 1 Post By ebringley

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2017, 11:39
Default Chemistry Source Term RR()
  #1
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
Hey all,

at the moment I am checking how FOAM is calculating the source terms for different species. For that purpose I checked the chemFoam. Here we will find the header file where we calculate the species i, named YEqn.H. In that file we see that we call a function from the chemistry object named RR(label).
Code:
{                                                                               
    forAll(Y, specieI)                                                          
    {                                                                           
        volScalarField& Yi = Y[specieI];                                        
                                                                                
        solve                                                                   
        (                                                                       
            fvm::ddt(rho, Yi) - chemistry.RR(specieI),                          
            mesh.solver("Yi")                                                   
        );                                                                      
    }                                                                           
}
Howver If I make a source code search for a function of type RR(const label i), I find the function in thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C

However, it seems that this function just returns zero, right?
Code:
const Foam::DimensionedField<Foam::scalar, Foam::volMesh>&                      
Foam::basicSolidChemistryModel::RR(const label i) const                         
{                                                                               
    NotImplemented;                                                             
    return (DimensionedField<scalar, volMesh>::null());                         
}                                                                               
                                                                                
                                                                                
Foam::DimensionedField<Foam::scalar, Foam::volMesh>&                            
Foam::basicSolidChemistryModel::RR(const label i)                               
{                                                                               
    NotImplemented;                                                             
                                                                                
    return dynamic_cast<DimensionedField<scalar, volMesh>&>                     
    (                                                                           
        const_cast<DimensionedField<scalar, volMesh>& >                         
        (                                                                       
            DimensionedField<scalar, volMesh>::null()                           
        )                                                                       
    );                                                                          
}

I am confused :P
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 23, 2017, 05:15
Default
  #2
Member
 
hekseli
Join Date: Mar 2013
Posts: 49
Rep Power: 13
heksel8i is on a distinguished road
Quick post:

Apparently the access function is in basicChemistryModel.H and then in the constructor of chemistryModel.C one creates new fields RR_ pointing to the original RR and the RR_ are updated in the end of the solve() routine in chemistryModel.C.
heksel8i is offline   Reply With Quote

Old   July 25, 2018, 11:59
Default Seeing chemistry source term during runtime
  #3
New Member
 
Eric Bringley
Join Date: Nov 2016
Posts: 14
Rep Power: 9
ebringley is on a distinguished road
Hi Tobias,

Were you able figure out how to access the source term? I'm using reactingFoam for a laminar combustion simulation but cannot figure out how to access the RR_ field updated in the reaction->correct(); routine to see the value at runtime.

Thanks,
Eric
ebringley is offline   Reply With Quote

Old   July 25, 2018, 15:35
Default
  #4
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
Yes I was able. Check the source and you will get it.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   July 26, 2018, 04:43
Default Combustion vs Chemistry Model
  #5
New Member
 
Eric Bringley
Join Date: Nov 2016
Posts: 14
Rep Power: 9
ebringley is on a distinguished road
Hi Tobias,

I think I may be incorrect to have asked my question here. We are trying to do the same thing, but using different methods: You are looking at chemFoam which uses a psiChemistryModel and the source term is called through the chemistry.RR(label specI) method. I am looking at this from reactingFoam which uses a combustionModels:: psiCombustionModel and calls the source term reaction->R(Yi) which returns an fvMatrix. This R(Yi) member function of a combustion model accesses the protected chemistryPtr_ to access the a-fore-mentioned RR function. To my knowledge, I cannot access the chemistry pointer from a combustionModel. I was wondering if there was some C++ knowledge I am missing here to access this pointer to the chemistry.

Some of my questions are as follows:
1. How can I access, from a psiCombustionModel, the chemistry source term? I'd like to print to screen, or ideally, write to file to compare different chemistry methods. It may be that I should switch to chemFoam for this...
2. in the reaction->R(Yi) method, it returns a fvMatrix with units dimMass/dimTime, by adding the RR_[i] of the chemistryModel (kg/m3/s) (accessed through the RR(label i) inline chemistryModel method). What is the reason for this? Why do the units change?
3. Is there any specific references I should look at regarding the way the chemistry models / combustion models / solvers are programmed? I'd like to be able to know whats the best place to find stuff like this on my own.


PS. I am using OpenFOAM v5. There are changes in v6 that may cause some confusion, such as the chemistryModel class is renamed in v6.

Last edited by ebringley; July 26, 2018 at 04:46. Reason: fix accidental smile
ebringley is offline   Reply With Quote

Old   July 26, 2018, 08:06
Default
  #6
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
fvMatrix.C:
Code:
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
(
    const fvMatrix<Type>& A,
    const DimensionedField<Type, volMesh>& su
)
{
    checkMethod(A, su, "+");
    tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
    tC.ref().source() -= su.mesh().V()*su.field();
    return tC;
}
Rochi likes this.
__________________
https://openfoam.top
zhangyan is offline   Reply With Quote

Old   July 26, 2018, 08:40
Default
  #7
New Member
 
Eric Bringley
Join Date: Nov 2016
Posts: 14
Rep Power: 9
ebringley is on a distinguished road
Thank you. I didn't realise the + operator took volume into account.
Zhiheng Wang likes this.
ebringley is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Source Term due to evaporation in energy transport equation styleworker OpenFOAM Programming & Development 3 September 7, 2022 03:09
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 17:34
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 15:14
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


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