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

fvOptions() Options and SemiImplicit Source Term - Units

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

Like Tree6Likes
  • 1 Post By Tobi
  • 1 Post By clapointe
  • 1 Post By clapointe
  • 3 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2020, 18:44
Default fvOptions() Options and SemiImplicit Source Term - Units
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,679
Blog Entries: 6
Rep Power: 49
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
Hi everybody,

at the moment I am investigating into the energy equation and the fvOptions possibilities. Therefore, I have a few questions that arises.

1. The unit of the energy (he) is in m^2/s^2. That's due to it is the energy per unit mass. Correct?


2. The units of the matrix of the energy equation is given as kg m^2/s^3. Here again, as it is per unit mass


3. The units for fvOptions(he) is equal to m^5 / s^3


4. The units for fvOptions(rho, he) is equal to kgm^2/s^3. This is clear to point 3.


Thus, for point 3. we do have the volumetric fluxes which lead to the units of the energy again (m/s) and for point 4 we do have the mass related fluxes which lead to the same units.


Therefore, as he is equal to m/s, I guess the absolute value in the semiImplicitSource has the same units. So the units are actually J/kg.



Maybe I am a bit tired right now but I am wondering how to set a energy sink of e.g., 100 W.
fnovo likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 9, 2020, 21:42
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 13
clapointe is on a distinguished road
You should be able to use fvOptions with a negative source term value. See fore example the file from a cht tutorial :

https://github.com/OpenFOAM/OpenFOAM...ater/fvOptions.

Units of the source should be W/m^3 for specific, W for absolute source.

Caelan
clapointe is offline   Reply With Quote

Old   January 10, 2020, 05:20
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,679
Blog Entries: 6
Rep Power: 49
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:
Originally Posted by clapointe View Post
You should be able to use fvOptions with a negative source term value. See fore example the file from a cht tutorial :

https://github.com/OpenFOAM/OpenFOAM...ater/fvOptions.

Units of the source should be W/m^3 for specific, W for absolute source.

Caelan
Dear Caelan, thank you for your feedback. Sure, you can set a negative value. That is obvious. For me, it is more interesting why you think that the unit we apply here is in [W] rather than [J/kg], I guess it is due to the fact that Henry set the comment, right? As the fvOptions() term is inside the matrix construction, and we are solving for the energy field (he) that has the units of [J/kg], I expect that the unit of the semiImplicitSource does have to have the same units as the field, thus [J/kg]. I guess I have to check the implementation of the fv:: options class to get the answer.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 10, 2020, 10:41
Default
  #4
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 13
clapointe is on a distinguished road
If we are to assume that the comment is correct, then yes. Checking the scalarSemiImplicit source code (https://github.com/OpenFOAM/OpenFOAM...plicitSource.C), we see that the units of the addition are equation units/m^3 and that the absolute/volumetric option is just worked in through division. Presuming that the comment is still correct, we also need the same units (W/m^3) on the LHS of the equation. Thinking about the temporal derivative term, we have a temporal derivative of rho*h. As you've pointed out, h is units of m^2/s^2. This is multiplied by density and 1/s for the derivative, for units of J/m^3*s. For the energy source this appears to be consistent. To solve for h itself division by density would be necessary -- making the source term be units of quantity/kg as you've shown. This is a bit circular (and I've not had my coffee yet) but this is how I rationalized the addition in W or W/m^3.

Caelan
altinel likes this.
clapointe is offline   Reply With Quote

Old   January 10, 2020, 13:49
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,679
Blog Entries: 6
Rep Power: 49
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
Hi,

Just as an hint, as you said correlates to my point #4. However, I was expecting, that the value we set is actually multiplied by the density if we have FvOptions(rho, he). I agree about what you said and will investigate into the code in more depth. But sure, it should be fine and the unit should be in Watt.

Thanks
Tobi
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 10, 2020, 14:53
Default
  #6
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 13
clapointe is on a distinguished road
Perhaps I missed a rho term in the code -- I looked again and did not see anything obvious, so will be interested to learn what you figure out. One observation I made is that there is a member function that takes rho as an argument (presumably for compressible, with fvOptions(rho,he)) but appears to use the version that does not take rho as an argument (for fvOptions(he) or generality) :

Code:
template<class Type>
void Foam::fv::SemiImplicitSource<Type>::addSup
(
    const volScalarField& rho,
    fvMatrix<Type>& eqn,
    const label fieldi
)
{
    return this->addSup(eqn, fieldi);
}
If we look at a different function object, e.g. the buoyancyForce one, the "compressible" member function taking rho as an argument does multiply by rho (in contrast to the "incompressible" function that does not) :

Code:
void Foam::fv::buoyancyForce::addSup
(
    const volScalarField& rho,
    fvMatrix<vector>& eqn,
    const label fieldi
)
{
    eqn += rho*g_;
}
vs.

Code:
void Foam::fv::buoyancyForce::addSup
(
    fvMatrix<vector>& eqn,
    const label fieldi
)
{
    eqn += g_;
}
So perhaps we implicitly multiply by rho by giving the value in Watts for use in a compressible solver, and if we wanted to use in an incompressible sense for fvOptions(he) we would need to divide our source in Watts by a representative rho? This is not to say that we would have a heat source in an incompressible solver, but just thinking out loud. What do you think?

Caelan
Tobi likes this.
clapointe is offline   Reply With Quote

Old   January 10, 2020, 18:07
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,679
Blog Entries: 6
Rep Power: 49
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
Exactly that function I came across yesterday. I mean the SuSp that takes the rho and redirects to the SuSp without rho. I will investigate into that.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 11, 2020, 12:21
Default
  #8
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 13
simrego is on a distinguished road
Hi!


If you check the energy equation (chtMultiRegionFoam or buoyantSImple foam), you find the buoyant energy term as rho*(U&g) which is kg/(m*s^3), right? This is just J/(m^3 * s), which is W/m^3. So the equation must be in W/m^3. For me it seems correct, since in the semiImplicitSource you should add the source in W or W/m^3. (Actually this source is always divide with the volume, but if you are using with "absolute", you divide with 1. Kinda efficient...)
So let's assume you are correct and he is in m^2/s^2. You have a term: ddt(rho, he) which would give you kg/(m*s^3). This is W/m^3 again, so we are done.


In incompressible case, you divide everything with rho. So I think that's why that multiplication with rho is missing in that function.



So finally if i'm correct:
The energy equation is in W/m^3, not J/m^3.
You can add the source in W/m^3.


I hope it was clear.
simrego is offline   Reply With Quote

Old   January 11, 2020, 13:22
Default
  #9
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,679
Blog Entries: 6
Rep Power: 49
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 made a mistake in my point 2) ... forgot to divide by m. Therefore, yes, the equation has the unit of W/m. Nevertheless, as we can see in the semiImplicit, the units are given as:
Code:
                                                                                
    Valid options for the \c volumeMode entry include:                          
    - absolute: values are given as \<quantity\>                                
    - specific: values are given as \<quantity\>/m3
The quantity is (he) and this takes the units of m/s. Well, in any case, I guess W or W/m are the units here.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 12, 2020, 04:04
Default
  #10
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 13
simrego is on a distinguished road
Yap, but to be honest I don't trust the comments 100%
And just came to my mind. If the units would be in J/kg, then how could you add a 1W heat source for example in a steady state simulation? I think it would be impossible.
simrego is offline   Reply With Quote

Old   September 30, 2020, 11:24
Default
  #11
New Member
 
Join Date: Jun 2020
Posts: 5
Rep Power: 4
fnovo is on a distinguished road
Hey!


I just made a post regarding a similar question (Units in addSups fvOption).
Maybe someone of you can help me out. A brief description of my problem:


I am writing a source class for battery heating. I used to add my heatSource in W to fvMatrix<scalar>& eqn in addSupp.
Code:
 scalarField& heSource = eqn.source(); Info<<"eqn dimension "<<eqn.dimensions()<<nl; Info<<"heatFlow dimension "<<heatFlow.dimensions()<<nl; heSource-=heatSource;
According to the log file, the eqn term also has the dimension W, so it simulates without any dimension errors.
Today I changed this part of my code to:
Code:
 scalarField& heSource = eqn.source(); Info<<"eqn dimension "<<eqn.dimensions()<<nl; Info<<"heatFlow dimension "<<heatFlow.dimensions()<<nl; eqn-=heatSource;
Now instead of using eqn.source(), I am substracting my source term directly from eqn. This leads to the following error:
Code:
 --> FOAM FATAL ERROR:       [h[1 -1 -3 0 0 0 0] ] -= [heatSource[1 2 -3 0 0 0 0] ]      From function void Foam::checkMethod(const Foam::fvMatrix<Type>&, const Foam::DimensionedField<Type, Foam::volMesh>&, const char*) [with Type = double]     in file /home/student-ift/OpenFOAM/OpenFOAM-5.x/src/finiteVolume/lnInclude/fvMatrix.C at line 1304.
When changing the code again by dividing each value of heatSource by the corrosponding cell volume, to make it volume specific (W/m^3), my model is simulating. Even though, the results seem to be wrong, as the temperature is decreasing instead of increasing.
Is there a difference in using eqn.source() or just eqn for the calculation regarding the dimensions? And am I even allowed to use heatSource with the unit W?


Hope you can help me out, since this post is pretty similar
Kind regards
Frederik

Last edited by fnovo; September 30, 2020 at 11:24. Reason: just spelling mistakes
fnovo is offline   Reply With Quote

Old   February 18, 2021, 10:13
Default
  #12
Member
 
UOCFD
Join Date: Oct 2020
Posts: 40
Rep Power: 4
uosilos is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Yes, I made a mistake in my point 2) ... forgot to divide by m. Therefore, yes, the equation has the unit of W/m. Nevertheless, as we can see in the semiImplicit, the units are given as:
Code:
                                                                                
    Valid options for the \c volumeMode entry include:                          
    - absolute: values are given as \<quantity\>                                
    - specific: values are given as \<quantity\>/m3
The quantity is (he) and this takes the units of m/s. Well, in any case, I guess W or W/m are the units here.

So let's suppose I want to simulate the effect of a 10kJ ignitor with this Energy Source.

How can I change my value to W??
How do "timeStart" and "duration" parameters affect the source??


This is for coalChemistryFoam so this should be something like this:


Code:
sources
        {
            h
            {
                explicit 1e4; //10kJ
                implicit 0;
            }
        }
Thanks!!
uosilos 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



All times are GMT -4. The time now is 12:09.