Howto use scalarCodedSource in fvOptions
Hi,
currently I'm struggling with setting up a volumetric source. In my case I would like to add a volumetric heat source for a given cellSet and run the simulation with the buoyantBoussinesqSimpleFoam solver, later with the respective Pimple solver. I tried creating a fvOptions file but unfortunately I don't really know what to put where... I adapted the below code from the CodedSource.H and now my question is where can I put the source term and in which form? Code:
mySource Does anybody have any suggestions? Thanks a lot Hannes |
Hi Hanness,
I'm interesting in your case, do you finally work out how to tackle your problem? (i.e volumetric "heat source" in buoyantBoussinesqSimple/PimpleFoam) Why are you trying with a codedSource, an explicit or semi-implicit should be able to do the job, shouldn't it? I'm currently able to add a source of "temperature", (i.e I set a value with an explicitSource and the temperature raise up in my selected region) but I'm struggling to understand which amount of heat I'm setting in my model. Is it wrong to try to link it to a proper heat load? (as we are solving only temperature?) I'm currently trying the same basic "testing" than in this post: http://www.cfd-online.com/Forums/ope...implefoam.html And it doesn't make sense. (does the source's unit is really in K/s? --> seems ok for me regarding the equation i.e homogeneous with the dT/dt) Thanks for sharing any hints, R |
Hi R,
Eventually I got it working. I don't know whether it is the best approach but it works for me: Code:
heatSource Regards, Hannes |
volumetric heat source in TEqn, dimension understanding
1 Attachment(s)
Hi Hannes,
Many thanks for your reply, I use the same functionality as you to get it run (well), (i.e. semiimplicitsource) I've took the week end to sleep on it and reach the following: I like the idea of your: Q/(rho*cp) = Ts (1) It fits with the TEqn solved, which is, I think an energy equation divided by rho*cp, considered as constant. With: Ts : source of temperature (0.1 in your example). Q : heat source Is that correct with your notation, I try to avoid any confusion with your PHI'''. I’m still kind of struggle with the dimension of all of this. Based on the attached small test case (air flow in a duct with a heat source in the middle of the duct.), I get the relation: Ts = phi*DT With: phi : (openfoam calculated) flow (m3/s as we have an incompressible solver)??? DT variation of temperature along the duct (K) Coupled with the (1), it fits with the classic Q=phi*rho*cp*DT. I could stop there and be happy but 2 questions remained: - Which value are you using for your rho and cp, as in the transport property we don't set them explicitly but hidden under the Pr and nu. The solver probably don't use rho and cp at all, so I'm not confident with this step. (do you just use the value which fit the model environment, without any link with the model?) - This approach leads for the Ts a dimension in m3.K/s where I think K/s is more correct, regarding the TEqn. I guess somewhere the source module link it to the volume to reduce it in K/s. ??? (I’m aware of the absolute/specific functionality, and I’ve understand what is doing in the fact but I’ve not fully understand the code), and so can’t explain my dimension issue.. I hope my post is clear, I’m probably doing a mistake somewhere or missing something, certainly trivial… :( Thanks for any reply, Remi |
Hi Hannes,
Thanks for the comments first of all. It looks like "specific", instead of "absolute", is required for this to work properly. However, it is kind of confusing to me when it is named "specific" and "absolute". To me, it sounds more like "intensive" property versus "extensive" because when I calculated the source for T, I didn't really have a m^3 in the denominator. yanxiang |
Volumetric heat source (W/m³)
Hello everybody!
I'm aware that this thread is maybe dead by now but I have a quick question related to what it has been said here. I hope that someone can answer me. My case is that I have to define a volumetric heat source in chtMultiRegionSimpleFoam in a solid region defined as, say, heatSource. The approach I thought about is similar to what suggested hanness but I don't want to define a "source of temperature" (K) but a "source of heat" (W/m³). I have tried the following fvOptions settings to do so: Code:
heatSource Another question I have is if it's correct or not to use the h variable (enthalpy, if I am not wrong) to create a heat source in a solid region. I have also made some other attempts using T instead of h but I noticed that nothing happened, like if no source existed. But, according to what I read in this topic above, it shoud have been because I used absolute mode instead of specific. Am I right? Thanks in advance. Any suggestion or hint will be welcome! Alex |
Quote:
Code:
type compressible::turbulentHeatFluxTemperature; |
Quote:
Yes, I guess it should work at least this configuration of the fvOptions file makes sense to me. But my hesitation is about the values I have to set as Su-Sp coefficients (assuming the configuration is ok) to define the heat generation (for example, 50 W/m³) inside the region. Regards Alex |
Hi,Alex.
Did you figure out what X and Y stand for? I know that they basically describe a source as s=X+Yx where the small x is coordinate. Is that right? Thanks Zech |
Hi,
you can find an answer in the SemiImplicitSource.H: Code:
Description Code:
UIndirectList<Type>(Su, cells_) = injectionRate_[fieldI].first()/VDash_; |
yeah, thanks for answering. I have looked at that some time ago. But that doesn't really make sense to me. As I don't really know how to express my heat resource in an implicit and explicit form.
1. Any suggestions on where can I learn about that? 2. What I want to define is a volumetric heat generation rate that changes along x axis, rather than with a field (heat generation rate q"'=cos (x) where x is the system coordinate). Any idea on how to define that? 3. A more challenging question is: what if the source is not even a regular function. It is just a bunch of random numbers. Say a table like when x=1 q"'=4 when x=2 q"'=7 when x=3 q"'=1 ..... irregular (x is still system coordinate and as assume the q"' doesn't change along y and z direction. ) wishes Zech |
Hi,
1. Sources. Tutorial. Google. 2. Lots of. Usually at this point people suggest swak4Foam. Or you can modify solver. Or you can take SemiImplicitSource and modify it. 3. In fvOptions file. |
1. that means nothing. every body doing Foam knows.... :)
3. can you say something more? How? If you can do this, question 2 is not even question !!! |
Well,
If you need someone to Google for you, there is http://www.esi-cfd.com/content/blogcategory/99/128/, you know. For your case you can take a look at CodedSource. In this case you can just use C++ to extract coordinates from field and to calculate your source term. |
Thank again for your reply.
Yes,I'm looking at the codedSource. That is exactly what this thread start with discussing, isn't it? Do you have any examples of this? If you know how to use it can you post it here, which, I believe, will be helpful for a lot of people. I'm asking because I have exhausted the searching result from Google without finding some answers and could not understand what the source code is doing as many new comers to openFoam cannot. |
2 Attachment(s)
Guess, you're right. Google search leads to the first message of this thread. There were other links though with less information.
So here's an example of the codedSource: Code:
harmonic Also I've attached archive of the case (hotRoom case from buoyantBoussinesqSimpleFoam tutorial with removed gravitation (therefore no convection) and suppressed heat diffusivity) and a screen shot of temperature distribution. |
Thank you so much for sharing the example!
I haven't get a chance to run the case yet, but it might be helpful anyway to explain what kind of heat source you have defined here. what it depends on? I mean I see it depends on C[i], V[i] and x(). What are they? I roughly know C and V are values extract from mesh, but not quite sure what are they. And x() is not even defined in advance, is it recognised as the system coordinate by default? Comparing with the example in the codedSource.H file, you kept the codeCorrect and codeSetValue as they were. I assume their functions are irrelevant to the source your are defining here. If you happen to know, can you please say something on what they can be used to define? |
Well, at this point your answers for the questions are can be easily found in documentation (http://openfoam.org/docs/cpp/). I will answer some of them, the rest - it is up to you to look up.
You've deduced that V and C are properties of the mesh, so you enter mesh in search dialog in documentation (well, I will just enter fvMesh), click on fvMesh in drop-down menu and go to fvMesh documentation. There we'll find that V is a list of cell volumes, C is a list of cell centers (or centres if you prefer). Also from documentation you've learned that C is a list of vectors. Enter vector in search box, click on the link in the drop-down list, et voilà, x is a method of vector class and it returns x-component of the vector. As there's no convection, no diffusion, and no heat exchange with outer space, strange steady state with negative temperatures reached in 44 iterations. As it was just a test, I've taken mesh with sizes 2x1x1, and source term in T-equation that is proportional to sin(2*pi*x), so in x-direction we have 2 periods (and there are two periods on temperature field). As to other methods. Take a look at TEqn.H, relevant part is: Code:
... Code:
DILUPBiCG: Solving for Ux, Initial residual = 0, Final residual = 0, No Iterations 0 |
Thanks for your answer Alex. I have run your case and don't understand the flowing things:
1. You have set it to stop running after steady state is arrived (44s) somewhere? I wanted to see what happens as time goes, so I set it to run between 0-1000s in the controlDict. But it still runs from 0-44? What is the problem? 2. Because I cannot play with time, I played with the function in the codeAddSup part. I'm so sorry. Although you have told me so clear what V C x are, I'm still not quite sure about what how it defines the source. Quote:
b. V is the volume, then the quantity 10*sin(6.28*C[i].x()) gives should be q’’’/(rho*Cp). Is that right? 3. As I cannot figure out the previous questions. I thought that I at least know the example you gave defined a temperature source with a period of 1. So, I applied the source into one that I’m familiar with. That is the planeWall2D case. I changed the bottom air with a heat generation solid, and it worked fine as a constant source. I replaced the source with the 1-period source in your example. I changed the proportion to observe a more obvious phenomenon. But sadly, no period could be observed. I have the case uploaded here. |
1 Attachment(s)
Quote:
Quote:
Quote:
Concerning your case: maybe there's no period, I don't know. |
All times are GMT -4. The time now is 02:24. |