|
[Sponsors] |
May 19, 2015, 02:43 |
Assigning time dependent heat Source terms
|
#1 |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Hi all;
Maybe, my question is a frequent question in OpenFoam forums, however I haven't still found a definite answer for it: How can we assign a time-dependent (transient) heat source term at OpenFoam.2.3.1 (for example by fvOptions) ? An example for heat source (S(h)): S(h)=2*physical_time/(1+physical_time); (h is the symbol of enthalpy.) Thx in advance for any attention and help. M.Asghari Last edited by Asghari_M; May 19, 2015 at 15:38. |
|
July 28, 2015, 14:16 |
fvOption for time dependent momentum source
|
#2 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
I was wondering if the modification can be done for the pressureGradientExplicitSource ,, I'm trying to solve pressure gradient source for time dependent icoFoam solver??
|
|
July 29, 2015, 13:15 |
|
#3 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Did you try codedSource?
https://github.com/OpenFOAM/OpenFOAM.../CodedSource.H |
|
July 29, 2015, 13:27 |
|
#4 | |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
Quote:
Thanks for the reply, but am not sure what you mean? |
||
July 29, 2015, 14:59 |
|
#5 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Sorry my response wasn't clear. I posted it using CFD-onlne app which it isn't very efficient. Actually, it is the second time to write this post because the first one wasn't posted for some reason, anyway . . .
The codedSource fvOption is general way to implement any source term on the run, on the other hand you could modify and existing fvOption to match your needs. Instead if you are planing to use only one solver you could implement it directly in the desired solver. Regarding the heat source problem, I think this relation cannot be write because it is function in time only and dimensionless. It isn't consistent. About the pressureGradientExplicitSource, for some reason OpenFOAM dropped it in OpenFOAM-dev, so I expect it will not be available in the next version or a new alternative will be introduced soon. Anyway, your question isn't clear, how do you want the pressure gradient to varies with time? The current implementation in OpenFOAM-2.4 calculates it based on average velocity and direction only both are constants and they are not like fixedTemperatureConstraint which has an option for that. I think both problems need to be more clear, so the forum users could really help you with constrictive comments. |
|
July 29, 2015, 16:50 |
|
#6 |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
S(h) has W/m3 unit. Heat source term presented by me isn't a physical relation. Dimensions are hidden in the coefficient number 2.0 as follows:
S(h)=2.0*t/(1+t); Assume , the coefficient number 2.0 (specified at above by red color) has W/m3 unit. And also the source term type is specific and not absolute. Last edited by Asghari_M; July 31, 2015 at 14:42. |
|
July 29, 2015, 17:27 |
|
#7 | |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Quote:
Your formula could be implemented like that; Code:
const Time& time = mesh().time(); // cells volumes const scalarField& V = mesh_.V(); scalarField& heSource = eqn.source(); //reference to the source term // your equation scalar hs = (2.0*time.value())/(1+time.value()); // adding to source term heSource += scalarField(V.size(), hs); // heSource += ((2.0*time.value())/(1+time.value()))*V; // in case you need it as absolute value Last edited by hk318i; July 29, 2015 at 19:47. Reason: Comments added to the code and link to cfd.direct post |
||
July 30, 2015, 09:41 |
|
#8 | |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
Quote:
Thanks for your Reply, yes the app is not that good, you can use it just for browsing stuff,,, anyway.. 1st of all I tried to use the (fvOption) and it works very good with the simpleFoam solver for the pressureGradientExplicitSource, but for some reason it didn't work with IcoFoam, the solver escape the file. So I modifaied the solver according to that post (http://www.cfd-online.com/Forums/ope...urce-term.html) and it work fine for single source value. What you said with pressureGradientExplicitSource, is exactly my problem, you can define single value for the U Bar with a direction, what am looking for is instead of this single value, I would like to define a list of values which will vary in time .. its like the same idea of time dependent velocity inlet but in the source term. Can you help with this problem ? I appreciate your response and sorry for not being very clear.. Mahmoud |
||
July 30, 2015, 12:22 |
|
#9 | |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Quote:
1-Is your suggested code same scalarCodedSource as source term type called in the fvOptions dictionary file? I presented scalarCodedSource as follows and also I have marked my questions with red colour in it: Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // energySource { type scalarCodedSource;//question.1// active true; selectionMode all; //Is following command applicable for defining specific or absolute mode correct in scalarCodedSource? question .2 volumeMode specific;// scalarCodedSourceCoeffs { fieldNames (h); redirectType sourceTime; codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ const Time& time = mesh().time(); const scalarField& V = mesh_.V(); const vectorField& C = mesh_.C(); scalarField& heSource = eqn.source(); scalar hs = (2.0*time.value())/(1+time.value()); heSource += scalarField(V.size(), hs) // should user use either this expression or following relation? heSource += 2*time.value()/(1+time.value()); question.3&4// Pout << "***codeAddSup***" << endl; #}; codeSetValue #{ Pout<< "**codeSetValue**" << endl; #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } sourceTimeCoeffs { // Dummy entry } 3- Suppose there is an energy source term in a simple solid conduction problem according to the above source term expression. As we know, the meaning of heSource += scalarField(V.size(), hs) relation is equal with the relation as follows: heSource = heSource+scalarField(V.size(), hs) or heSource_new= heSource_old + scalarField(V.size(), hs). What's old value of heSource? Whether this term is related to the previous time step? since the case is a simple solid thermal conduction, can user use the relation as follows?: heSource = scalarField(V.size(), hs) (instead of += sign); What's ur view? 4-Can user use heSource += hs instead of heSource = scalarField(V.size(), hs)? In this manner how should user specify absolute or specific source term? Also I have some questions & ambiguities that I prefer ask them in my next post in this thread. Also, I'd appreciated if you consult the following thread? http://www.cfd-online.com/Forums/ope...dedsource.html Thanks for ur kind attention. Last edited by Asghari_M; July 30, 2015 at 13:50. |
||
July 30, 2015, 12:58 |
|
#10 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
@Mahmoud
You are right icoFoam doesn't support fvOptions but it could be enabled. Tomislav Maric wrote a post on his blog about how to enable fvOption in an OF solver, if you still interested, [LINK 1]. About a time-varying pressureGradientExplicitSource for Ubar, it think it shouldn't be a big problem (maybe I'm too optimistic ). My idea is to use the DataEntry class [LINK 2] in a new modified time-varying pressureGradientExplicitSource, so the user can specify Ubar as any time-varying BC in OpenFOAM. I will have a deeper look and see how we could do it, hopefully this idea will work. Best wishes, Hassan |
|
July 30, 2015, 13:07 |
|
#11 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
Dear Hassan,
Thanks for your help, I will try your idea. Hopfully it works. Thanks again Mahmoud |
|
July 30, 2015, 13:57 |
|
#12 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
@Asghari
Best Wishes, Hassan |
|
July 31, 2015, 04:40 |
|
#13 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
||
July 31, 2015, 07:00 |
|
#14 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
||
July 31, 2015, 08:16 |
|
#15 | |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Quote:
I made some modifications on the original code and upladed it to github, you can download it as follows Code:
git clone https://github.com/HIKassem/varingPressureGradientExplicitSource.git Best wishes, Hassan PS. I just noticed right now that your surname looks familiar to me! |
||
July 31, 2015, 09:00 |
|
#16 | ||
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
@Hassan
I assigned heat source term as follows: Code:
scalar hs = (2.0*time.value())/(1+time.value()); heSource += scalarField(V.size(), hs); How is this interpretable?!! Is it a bug?! Also, I have two other questions about your last helpful replies: Quote:
(Excuse me if my questions are easy. I'm almost biginner in OF) Quote:
Meanwhile, I use OF2.3.1. Thanks again for ur kind attention. Last edited by Asghari_M; July 31, 2015 at 10:08. |
|||
July 31, 2015, 10:22 |
|
#17 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Sorry my answer was very concise in the previous post.
Regarding the results, it is really hard to comment on it because I don't know the physics of you problem and your case study. I think hs value is really small specially at the beginning of your simulation, isn't it? |
|
July 31, 2015, 13:42 |
|
#18 | |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Quote:
Also, I have another question as follows: Which expression in scalarCodedSource is suitable for this specific heat source term definition (I've indicited expressions in following code by red colour)? Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // energySource { type scalarCodedSource; active true; selectionMode all; scalarCodedSourceCoeffs { fieldNames (h); redirectType sourceTime; codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ const Time& time = mesh().time(); const scalarField& V = mesh_.V(); const vectorField& C = mesh_.C(); scalarField& heSource = eqn.source(); scalar hs = (2.0*time.value())/(1+time.value()); // Which following expression is suitable for mentioned specific source term ? heSource += hs .OR. heSource += hs*V;// Pout << "***codeAddSup***" << endl; #}; codeSetValue #{ Pout<< "**codeSetValue**" << endl; #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } sourceTimeCoeffs { // Dummy entry } |
||
August 1, 2015, 08:57 |
|
#19 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
First, because you are using [selectionMode all;] option, your source is applied every where in your domain.
I am not sure about if scalarCodedSource should be W/m3 or should be multiplied by V. Usually the source term is specified as w/m3 but I am not sure about that using this code. I am confused because in the description of the class, the give example is multiplied by V. I believe more investigations are required to confirm this issue. |
|
August 1, 2015, 10:24 |
|
#20 | |
Senior Member
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16 |
Quote:
In both my questions, I think it's better to refer source code. What's ur idea? Sincerely; |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transient spacial dependent heat source | Kumudu | OpenFOAM Running, Solving & CFD | 0 | October 28, 2013 12:02 |
same geometry,structured and unstructured mesh,different behaviour. | sharonyue | OpenFOAM Running, Solving & CFD | 13 | January 2, 2013 23:40 |
plot over time | fferroni | OpenFOAM Post-Processing | 7 | June 8, 2012 08:56 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |