CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   transient source term (https://www.cfd-online.com/Forums/openfoam/86052-transient-source-term.html)

strakakl March 13, 2011 10:53

transient source term
 
hi foamers,

I wonder how to set a transient source term.
I want to simulate an electric heater band around a metal cylinder. Therefor i added a heat source to the chtMultiRegion solver and, in the first step, initalized it with a constant value. Results seems to be ok.
In the next step i want to use transient values for the heat source because I got set values for the heater band from an experiment which i want to use with the heat source term. But i don't know how to write them on the field of the heat source.

I tried to modify one of the timeVarying BCs in a way, that they also modify the internal field in the heater and not only the boundary field. By now, i had no sucess :mad:. I'm also not sure if this is the best way to do this.

Does anyone know how to impement this kind of transient source term?

Cheers, Klaus

robingilbert October 23, 2011 22:47

does anybody know how to do this?? transient source term?

kathrin_kissling October 24, 2011 02:40

Hi guys,

what are your exact plans?
Can you post an equation?
Do you want to have a real source term or a specific boundary condition?


Best

Kathrin

robingilbert October 24, 2011 16:42

Hi,

Thank you for your reply. This is what I want:
Code:

        fvm::div(phi, T)
      - fvm::Sp(fvc::div(phi), T)
      - fvm::laplacian(kappaEff, T)
    ==
    Q/(rho0*Cp0)

where Q is dependent on temperature at a particular point in the solution domain. I thought of using something like:

Code:

    if (T at (x1,y1,z1) > Tref)
    {
        Q=Qref1;
    }
  else
  {
  Q= Qref2
  }

where Tref, Qref1 and Qref2 are read by the solver in the beginning. But my question is how to extract temperature at the position (x1,y1,z1) ?

I have been trying to figure that out from the forum. It would be great help if you can answer this question or just give me some hints.

Thank you,

Robin

kathrin_kissling October 25, 2011 02:50

Hi Robin,

so you're searching for a spatial dependent source term.

To get you values: The easiest way is to grap them at the cell center:

Something like

Code:

dimensionedScalar Tref("Tref", dimensionSet(0,0,0,1,0,0,0), 350.);

dimensionedScalar Qref1("Qref1", dimensionSet(yourDimensionsHere), scalarValue1);
dimensionedScalar Qref2("Qref2", dimensionSet(yourDimensionsHere), scalarValue2);

forAll(T, cellI) //This loops over all cell centers
{
    if(T[cellI]>Tref)
    {
      Q = Qref1;
    }
    else
    {
        Q = Qref2;
    }
}

This at least will set your field Q;

Be aware that the convergence can be poor!

Best

Kathrin

boger October 25, 2011 10:10

Actually, I think this earlier post by Kathrin is the one that Robin needs, or the post from Su Junwei that immediately precedes it. Both show methods for returning the cell index for a specified (x,y,z) location. Otherwise, I think Robin's coding was essentially correct, where "T at (x1,y1,z1)" would become T[labelOfClosestCell] or T[nearestCellIndex] according to the referenced links.

kathrin_kissling October 25, 2011 10:20

Oh maybe I got something wrong. I thought that he would like to chance the complete Q field!

Robin: Do you want only one single position to determine you Q value, and that this Q value is then constant for the whole domain or do you want to have a field of different Q values each depending on the actual cell value?

Best

Kathrin

gschaider October 25, 2011 15:06

May I add a bit more entropy to the discussion? Yes? Thanks

Quote:

Originally Posted by boger (Post 329385)
Actually, I think this earlier post by Kathrin is the one that Robin needs, or the post from Su Junwei that immediately precedes it. Both show methods for returning the cell index for a specified (x,y,z) location. Otherwise, I think Robin's coding was essentially correct, where "T at (x1,y1,z1)" would become T[labelOfClosestCell] or T[nearestCellIndex] according to the referenced links.

But be warned that this only works reliable for serial runs. For parallel runs with N CPUs there is a (N-1):N chance that the cell in question is on another processor and therefor the value would have to be sent to the others

For your first implementation I wouldn't bother with that too much but be warned that parallel runs will most likely produce "funny" (depends on your sense of humor) results

robingilbert October 25, 2011 16:18

Quote:

Originally Posted by kathrin_kissling (Post 329388)
Robin: Do you want only one single position to determine you Q value, and that this Q value is then constant for the whole domain or do you want to have a field of different Q values each depending on the actual cell value?

Hi Kathrin, thank you for your reply. I want a single position to determine my Q value and this Q value is not for the whole domain but only for a small volume inside the domain. Now, the problem that I am facing is that I am not able to extract the temperature at that single position at run time. And for making it work in a small volume in the domain I thought of doing something like:
Code:

LHS= Q/(rho*Cp0)*N
where N is 1 in the required domain and 0 elsewhere (I can set that using setFields). Do you think that will work? or is it a messy solution?

I will go through the threads suggested by Boger and get back with results.

Quote:

Originally Posted by gschaider (Post 329425)
But be warned that this only works reliable for serial runs. For parallel runs with N CPUs there is a (N-1):N chance that the cell in question is on another processor and therefor the value would have to be sent to the others

For your first implementation I wouldn't bother with that too much but be warned that parallel runs will most likely produce "funny" (depends on your sense of humor) results

In that case I will initially start with serial runs before trying it out in parallel.

Thank you all for your replies.

Linse October 26, 2011 14:34

I do not know if it works, but an approach MIGHT be to use abovementioned forAll()-function first to know if it should switch any value. Then you could implement this either by way of changing the N or by adding another source term, again via the forAll() method.
I did something like that recently for testing something and will document this still this week, so look into this thread by the end of the week and you should find the link to some documentation. ;-)

robingilbert October 26, 2011 15:00

Hi Bernard,

Thank you so much. I will look into it when you post the documentation.

kathrin_kissling October 27, 2011 04:01

Hi Robin,

I thought about a little more Foam like solution and I came up with this.
Why just don't use the setFields functionality within your executable. The following piece of code is an example on how this could be done. It uses cellSets to define your desired box/circle or whatever

Code:


IOdictionary defineQPositionDict
(
    IOobject
    (
        "defineQPositionDict",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);

PtrList<entry> regions(defineQPositionDict.lookup("regions"));
Info << regions << endl;
forAll(regions, regionI)
{
  const entry& region = regions[regionI];
 
  autoPtr<topoSetSource> source = topoSetSource::New(region.keyword(), mesh, region.dict());
 

      cellSet selectedCellsSet
      (
        mesh,
    "cellSet",
    mesh.nCells()/10+1 //size estimate
      );
     
      source->applyToSet
      (
        topoSetSource::NEW,
    selectedCellsSet
      );
     
      labelList selection = selectedCellsSet.toc();
      forAll(selection, cellI)
      {
          alpha1[selection[cellI]] = 1.; //Replace this with your source term calculation
      }

}

Here it is coded to set an alpha value during runTime but you can perfectly put in your temperature dependent source term. Of course you need to define it somewhere in advance. You can put this snippet everywhere, either before the beginning of the time loop or within. Then you can even read the dictionary, if you modified it during your run. Just change the dictionary write option to
Code:

MUST_READ_IF_MODIFIED
. The dictionary is placed in constant and called
Code:

defineQPositionDict
it has the same entries like the setFieldsDict for the regions and you can use all the possibilities to set fields, which you can use with setFields
Code:

regions
(
    boxToCell
    {
        box (0.1 0.1 -1) (0.5 0.5 1);
    }
);

I tried to run it in parallel and it works for me. I can not say for certain it will for you.
@ Bernhard can you take some entropy out here? It would be so great, to know if this is a safer way to programm this!

Best

Kathrin

gschaider October 27, 2011 07:20

Quote:

Originally Posted by kathrin_kissling (Post 329651)
I tried to run it in parallel and it works for me. I can not say for certain it will for you.
@ Bernhard can you take some entropy out here? It would be so great, to know if this is a safer way to programm this!

Best

Kathrin

I tried to avoid this, but I feel provoked. Kathrin, nowady half of my postings here end with the words swak4Foam, so don't act surprised.

If I had to do such a thing (mesh region heated depending on a sensor) I'd do the following:

Add something like this to createFields.H (or some other appropriate location)
Code:

   
expressionSource<scalar> heaterSource
    (
        IOdictionary
        (
            IOobject
            (
                "heaterSourceDict",
                runTime.constant(),
                mesh,
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            )
        ),
        mesh
    );

then modify the equation like this
Code:

fvm::div(phi, T)
      - fvm::Sp(fvc::div(phi), T)
      - fvm::laplacian(kappaEff, T)
    ==
      heaterSource()

Now I'm done with C++ and for the rest the motto of Aleister Crowley (no, I'm not into satanism - although C++ is close enough) applies "Do what Thou Wilt".
The heaterSourceDict would look something like this (all of this may contain syntax-errors. I'm doing it from memory)
Code:

variables (
    "TThres=666;"  // here comes Aleister
    "TProbes{set'TSensor}=average(T);"
    "QHeat=42;"
    "cp0=1;"
);
dimensions [0 0 0 0 0 0 0]; // This will have to fit the equation
expression "(zone(heaterZone) && ? TProbes<TThres) ? QHeat/rho : 0";

This assumes that there is a cellZone names heaterZone in your mesh. The last thing that remains to be modified is the controlDict to provide the sensor
Code:

functions {
  theSensor {
    type createSampledSet;
    outputControl timeStep;
    outputInterval 1;
    setName TSensor;
    setName {
      type cloud;
      axis x;
      points (
        (0 0 0) // core center
      );
    }
  }
}

libs (
  "libswakFunctionObjects.so"
);

The nice thing about this approach is that
- C++-coding is kept to a minimum
- it works in parallel (not swaks doing: sampledSets in OF)
- further case-specific modifications go where the ought to be: into the case
- you can do all kinds of cool stuff without modifying the solver: make the heater depend on the state of a patch, a sampled surface. Using storedVariables you can do state-based heating (once we're heating: keep heating. Hysterese-like switching. Time-dependence ....). Propagate the switching informations to boundary conditions via global variables and groovyBC

Bernhard

PS: Kathrins method of generating a cellSet looks fine to me and is quite flexible. Of course it depends on your application whether you want to keep the cellSet for later computations. BTW: even there you can sneak swak in through the back-door via the expressionToCell-topoSource (am I getting obnoxious?)

kathrin_kissling October 27, 2011 09:56

Sorry for provoking you... :rolleyes:
and for getting Aleister in the game...

Thank you very much Bernhard. I should use swak4Foam a lot more often though.

If swak4Foam would not exist and neither cellSet nor sampledSet and I would like to have a cell based solution (in fact I don't want to but maybe sometimes for something else) I would need Pstream functionality, wouldn't I?

Best
Kathrin

gschaider October 27, 2011 14:52

Quote:

Originally Posted by kathrin_kissling (Post 329731)
Sorry for provoking you... :rolleyes:

You're forgiven ;)
Quote:

Originally Posted by kathrin_kissling (Post 329731)
and for getting Aleister in the game...

That was me.
Quote:

Originally Posted by kathrin_kissling (Post 329731)
Thank you very much Bernhard. I should use swak4Foam a lot more often though.

If swak4Foam would not exist and neither cellSet nor sampledSet and I would like to have a cell based solution (in fact I don't want to but maybe sometimes for something else) I would need Pstream functionality, wouldn't I?

You mean for distributing the temperature in a point to all processors? Depends on what you mean with Pstream-functionality: Sending around values through OPStreams/IPStreams or a simple reduce (which is based on that)

I THINK (untested and doing the API-calls from memory) this would do the trick:

Code:

scalar Tprobe=-1;
label cellID=mesh.findCell(coordinatesOfTheProbe_PickYourOwnName);
if(cellID>=0) { // is -1 if the point is not in the mesh == all other processors
  Tprobe=T[cellID];
}
reduce(Tprobe,maxOp<scalar>());
// now all the processors are on the same page

Of course this assumes that the temperature at the probe location is always positive which some people might think is a bit restrictive ;)

Bernhard

robingilbert October 27, 2011 16:08

Quote:

Originally Posted by gschaider (Post 329700)
- you can do all kinds of cool stuff without modifying the solver: make the heater depend on the state of a patch, a sampled surface. Using storedVariables you can do state-based heating (once we're heating: keep heating. Hysterese-like switching. Time-dependence ....). Propagate the switching informations to boundary conditions via global variables and groovyBC

Thank you Gschaider and Kathrin for your replies. Thats exactly what I want.

I have one more question: Do you think there is a way I can fix the temperature at a faceZone by removing heat from the room using the "heaterZone" as shown in the figure? Basically what I want is that the air flowing out through the faceZone should be at a fixed temperature.

Please forgive me if you think that I am asking way too many questions.

http://www.flickr.com/photos/67876844@N05/6286568527/#/http://www.flickr.com/photos/67876844@N05/6286568527/http://flic.kr/p/azwiNxhttp://www.cfd-online.com/Forums/%3C...%22%3E%3C/a%3Ehttp://img535.imageshack.us/img535/1...chwithcrac.png

http://www.flickr.com/photos/67876844@N05/6286568527

Bernhard October 28, 2011 02:06

Quote:

I have one more question: Do you think there is a way I can fix the temperature at a faceZone by removing heat from the room using the "heaterZone" as shown in the figure? Basically what I want is that the air flowing out through the faceZone should be at a fixed temperature.
Did you try a fixedValue boundary condition on that face? However, fixing the temperature of the outlet does not make sense physically, and I suppose fixing it as a boundary condition will give you nothing but troubles. I suppose convective heat transfer is larger than the heat diffusion in your case, so a fixed outlet temperature does not have a meaning in my opinion.

kathrin_kissling October 28, 2011 02:19

Hello Bernhard,

thanks again very very much. Now I have something to dig into! Fun stuff for the weekend! Maybe I find out how to send a negative temperature if desired ;)!

Best

Kathrin

robingilbert October 28, 2011 03:40

Quote:

Originally Posted by Bernhard (Post 329823)
Did you try a fixedValue boundary condition on that face? However, fixing the temperature of the outlet does not make sense physically, and I suppose fixing it as a boundary condition will give you nothing but troubles. I suppose convective heat transfer is larger than the heat diffusion in your case, so a fixed outlet temperature does not have a meaning in my opinion.

Hi Bernhard, it is not a boundary face. Its an internal faceZone. I am sorry that the picture is not so clear. Its a duct with heat removal inside the duct so that the air coming out of the duct is of constant temperature that I can fix. I tried something like :

Code:

LHS = - (flowDirection & U)*Area*(T-Treq)
(something like this. the actual setup is in my lab computer)

where "Area" is the area of the faceZone and "Treq" is the required temperature. But with this setup the temperature keeps on rising after sometime. I want to be able to fix the temperature at the faceZone or atleast the temperature of air coming out of the "heaterZone". I know I am doing something fundamentally wrong with the equation that I am using. Thanks for your help. Sorry to keep bothering you again and again.

Linse October 28, 2011 06:16

HowTos online
 
I guess some people were quicker than me. Fine as well! :-)

Just for the sake of completeness: The HowTo mentioned above in http://www.cfd-online.com/Forums/ope...tml#post329593 Post #10 and some commented code snippets now are online in the OpenFOAM-Section of http://cern.ch/blinseis .

Got something wrong there, will have to reedit the documents I linked...

samiam1000 June 22, 2012 03:54

Quote:

Originally Posted by kathrin_kissling (Post 329287)
Hi Robin,

so you're searching for a spatial dependent source term.

To get you values: The easiest way is to grap them at the cell center:

Something like

Code:

dimensionedScalar Tref("Tref", dimensionSet(0,0,0,1,0,0,0), 350.);

dimensionedScalar Qref1("Qref1", dimensionSet(yourDimensionsHere), scalarValue1);
dimensionedScalar Qref2("Qref2", dimensionSet(yourDimensionsHere), scalarValue2);

forAll(T, cellI) //This loops over all cell centers
{
    if(T[cellI]>Tref)
    {
      Q = Qref1;
    }
    else
    {
        Q = Qref2;
    }
}

This at least will set your field Q;

Be aware that the convergence can be poor!

Best

Kathrin

Dear All,

I am trying to do something similar..

I'd like to know in which file I should add this code. Also, how can I use it, once compiled? I mean: what should I change in the case directory? Just a Q file in the my_case/0 folder?

Thanks a lot,
Samuele

atoof February 17, 2013 12:35

Quote:

Originally Posted by gschaider (Post 329700)
Code:

expression "(zone(heaterZone) && ? TProbes<TThres) ? QHeat/rho : 0";
This assumes that there is a cellZone names heaterZone in your mesh.

Dear,
Do you have any suggestion to define a specified cellZone in a case?

Thank you in advance,
Hossein.

gschaider February 17, 2013 16:28

Quote:

Originally Posted by atoof (Post 408317)
Dear,
Do you have any suggestion to define a specified cellZone in a case?

Thank you in advance,
Hossein.

This depends on how you generate your mesh/your workflow: certain mesh converters support them, you can use utilities like topoSet ...

atoof August 21, 2013 03:25

Temporay heat source using swak4Foam
 
Quote:

Code:

fvm::div(phi, T)
      - fvm::Sp(fvc::div(phi), T)
      - fvm::laplacian(kappaEff, T)
    ==
      heaterSource()

The nice thing about this approach is that
- C++-coding is kept to a minimum
- it works in parallel (not swaks doing: sampledSets in OF)
- further case-specific modifications go where the ought to be: into the case
- you can do all kinds of cool stuff without modifying the solver: make the heater depend on the state of a patch, a sampled surface. Using storedVariables you can do state-based heating (once we're heating: keep heating. Hysterese-like switching. Time-dependence ....). Propagate the switching informations to boundary conditions via global variables and groovyBC
That was a good idea. Is there any possibility to use a heat source (such as above) for some seconds or time steps using swak4Foam?

Regards,

Hossein

gschaider August 21, 2013 04:31

Quote:

Originally Posted by atoof (Post 447042)
That was a good idea. Is there any possibility to use a heat source (such as above) for some seconds or time steps using swak4Foam?

Regards,

Hossein

Of course. Just use time() in the expression to switch the source on and off. For instance

Code:

"time()>timeOff ? 0 : heatSource"
(assuming you have variables timeOff and heatSource. But of course you can write the expressions directly there)

atoof August 21, 2013 05:03

Thanks. It is very powerful.

atoof August 22, 2013 03:32

Quote:

Originally Posted by gschaider (Post 447056)
Of course. Just use time() in the expression to switch the source on and off. For instance

Code:

"time()>timeOff ? 0 : heatSource"
(assuming you have variables timeOff and heatSource. But of course you can write the expressions directly there)

A question:
Is that condition (time()>timeOff) suitable for a steady state solver? in other word, does time() represent flow time or time name of the results?

Thank you in advance,

Hossein

gschaider August 22, 2013 04:59

Quote:

Originally Posted by atoof (Post 447350)
A question:
Is that condition (time()>timeOff) suitable for a steady state solver? in other word, does time() represent flow time or time name of the results?

Thank you in advance,

Hossein

time() wold be the iteration number. But isn't switching a sorce term and steady simulation a contradiction?

atoof August 22, 2013 07:22

Quote:

Originally Posted by gschaider (Post 447372)
time() wold be the iteration number. But isn't switching a sorce term and steady simulation a contradiction?

OK. Very Thanks.
My intention in the previous post was "How can add a source term to a field for some primary iterations in a steady state solver and then turn off it!

Thanks again,

Hossein

Kumudu October 28, 2013 10:55

Hi kathrin kissling,

I am almost new to OpenFoam and I want to add a transient heat source to specified points on the Mesh. Actually, I am working on Ground Source heat pump simulation problem. I want to add a source term representing the U-tube in the ground. In this U-tube water is circulating and this loop extract heat from the soil where the U-tube is buried. So, I want to add a volumetric source term such that,

q=UA(Ts-Tf),

where, Ts is the temperature at the soil and Tf is fluid temperature. U is the overall heat transfer coefficient. This source term should coincide with the ground loop configurations. That is in the three dimensional computational domain, I have to find a points that is in a U-curve and add the above source term to the points in the U-curve.

How could I do that. I saw that Kathrin has gave Robin a somewhat related answer. Could you please help me in this.

Kumudu October 30, 2013 01:32

Hi Robin,

I am new to OpenFoam and I want to add a source term into some specified points in the computational domain. I saw, that you have got some help from kathrin_kissling for same type of problem.

Can you please tell me how you define this defineQPositionDict other than create.H file. Also how to add this topoSetSource in LaplacianFoam. I think you also used LaplacianFoam for your problem.Please tell me each step to do this. I am really greatfull if you could help me on this. I have copied the answer gave by Kathrin, so that you can remember the steps

Best,
Kumudu

IOdictionary defineQPositionDict ( IOobject ( "defineQPositionDict", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); PtrList<entry> regions(defineQPositionDict.lookup("regions")); Info << regions << endl; forAll(regions, regionI) { const entry& region = regions[regionI]; autoPtr<topoSetSource> source = topoSetSource::New(region.keyword(), mesh, region.dict()); cellSet selectedCellsSet ( mesh, "cellSet", mesh.nCells()/10+1 //size estimate ); source->applyToSet ( topoSetSource::NEW, selectedCellsSet ); labelList selection = selectedCellsSet.toc(); forAll(selection, cellI) { alpha1[selection[cellI]] = 1.; //Replace this with your source term calculation } }

Kumudu November 3, 2013 02:33

Adding heat source into speciefied location in Mesh
 
Hi Bernhar,

I want to add a heat source into specified position in Mesh. I want to add this heat source for time dependent three dimensional diffusion equation. You have defined most of the things as a reply to transient heat source problem of Robin. Can you explain me how to use swak4Foam to define expression source, where I should define. I think heatSourceDict should be defined in system directory. Also I cannot understand how to define CellZones. Please tell me how to add this source term into Diffusion equation.

Actually, I want to add this heat source to points in Mesh coinciding ground loop configurations. I am working on ground heat exchanger simulations. This heat exchanger is consist with ground loops buried in ground. I want to simulate ground temperature after installing this loops which extract heat from ground. The heat source should show the loop configuration.

Could you please help me in this regard.

Kumudu
:confused:

gschaider November 3, 2013 10:59

Quote:

Originally Posted by Kumudu (Post 460312)
Hi Bernhar,

I want to add a heat source into specified position in Mesh. I want to add this heat source for time dependent three dimensional diffusion equation. You have defined most of the things as a reply to transient heat source problem of Robin. Can you explain me how to use swak4Foam to define expression source, where I should define.

You've got to add it to the solver otherwise it can't be used. But that is already explained in this thread:
http://www.cfd-online.com/Forums/ope...tml#post329700

Quote:

Originally Posted by Kumudu (Post 460312)
I think heatSourceDict should be defined in system directory. Also I cannot understand how to define CellZones.

That is a general OF-question which has been answered numerous times on the MessageBoard. Also is there no general answer because it depends on the program you use to construct your mesh

Quote:

Originally Posted by Kumudu (Post 460312)
Please tell me how to add this source term into Diffusion equation.

Actually, I want to add this heat source to points in Mesh coinciding ground loop configurations. I am working on ground heat exchanger simulations. This heat exchanger is consist with ground loops buried in ground. I want to simulate ground temperature after installing this loops which extract heat from ground. The heat source should show the loop configuration.

Could you please help me in this regard.

Kumudu
:confused:

Same here. For instance I don't know what a "ground loop" is.

So you want to have heat sources which are only on some locations. Specification depends on how the locations are specified. Either by cellZones (which is preferable for a number of reasons) or as coordinates where you'll have to write expressions. I'm sorry, but I don't have the time to answer questions were I have almost no information, especially as I suspect that what you need is already covered in some of the existing information/documentation

Kumudu November 3, 2013 15:06

[QUOTE=gschaider;460353]You've got to add it to the solver otherwise it can't be used. But that is already explained in this thread:
http://www.cfd-online.com/Forums/ope...tml#post329700


Hi gschaider,

Thank you very much for replying me. I start learning OpenFoam around three four days ago. And I am still reading the basic. However, I was able to define expressionSource using swaks and I did the same as you explained in the transient source term blog. But, I got an error,

kumudu21688@kumudu21688-Inspiron-N5040:~/OpenFOAM/kumudu21688-2.1.1/run/myheatsource$ mylaplacianFoam
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.1-221db2718bbb
Exec : mylaplacianFoam
Date : Nov 03 2013
Time : 11:01:29
Host : "kumudu21688-Inspiron-N5040"
PID : 4536
Case : /home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/run/myheatsource
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field T

Reading transportProperties

Reading diffusivity DT


SIMPLE: no convergence criteria found. Calculations will run for 15 steps.


Calculating temperature distribution

swak4Foam: Allocating new repository for sampledSets


--> FOAM FATAL IO ERROR:
Attempt to return dictionary entry as a primitive

file: /home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/run/myheatsource/system/controlDict::functions::theSensor::setName from line 59 to line 63.

From function ITstream& primitiveEntry::stream() const
in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 82.

FOAM aborting

#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::IOerror::abort() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 Foam::dictionaryEntry::stream() const in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#3 Foam::SetsRepository::getSet(Foam::dictionary const&, Foam::polyMesh const&) in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so"
#4 Foam::createSampledSet::createSampledSet(Foam::wor d const&, Foam::objectRegistry const&, Foam::dictionary const&, bool) in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#5 Foam::OutputFilterFunctionObject<Foam::createSampl edSet>::allocateFilter() in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#6 Foam::OutputFilterFunctionObject<Foam::createSampl edSet>::start() in "/home/kumudu21688/OpenFOAM/kumudu21688-2.1.1/platforms/linux64GccDPOpt/lib/libswakFunctionObjects.so"
#7 Foam::functionObjectList::read() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#8 Foam::Time::run() const in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#9 Foam::Time::loop() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#10 Foam::simpleControl::loop() in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#11
in "/opt/openfoam211/platforms/linux64GccDPOpt/bin/mylaplacianFoam"
#12 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#13
in "/opt/openfoam211/platforms/linux64GccDPOpt/bin/mylaplacianFoam"
Aborted (core dumped)


I can't understand how to relate the heaterZone with ControlDict.

This is where I defined the posted comment that you explained.

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}

libs (
"libswakFunctionObjects.so"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application mylaplacianFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 15;

deltaT 0.05;

writeControl runTime;

writeInterval 1;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true


// ************************************************** *********************** //
functions {
theSensor {
type createSampledSet;
outputControl timeStep;
outputInterval 1;
setName TSensor;
setName {
type cloud;
axis x;
points (
(0 0 0) // core center
);
}
}
}

libs (
"libswakFunctionObjects.so"
);



This is probably wrong. But, my problem is actually not this. I am still trying to undersatnd the addition of heat source into the LaplacianFoam.

Kumudu November 3, 2013 16:30

2 Attachment(s)
[QUOTE=gschaider;460353]For instance I don't know what a "ground loop" is.


I am sorry for not mentioning my problem beforehand.

Here is my problem definition.............

General idea about ground source heat pump.....


Ground source heat pumps are used to heat up and cool down a building in summer and winter. They used the utilization of temperature difference between air and ground to transfer heat from ground to buildings or reject heat from buildings to ground. However, ground temperature is usually lower than the building setpoint temperature, therefore, a heat pump is used to transfer heat from low temperature medium ground to building. This heat pumps actually act as a refrigerators. So first heat is extracted from ground through ground heat exchangers and them it is transfered to heat pump. I have attached a schematic of Ground source heat pump.

My main target is to simulate the ground temperature after installing this ground heat exchanger and also outlet fluid temperature of the ground heat exchanger.

Ground heat exchanger definition roughly....

Ground heat exchanger is consisted with U-pipes, where the water is circulating through it. This U-pipes are installed in a borehole (a hole in ground about 45-150m deep). This borefole is filled with grout (This grout is filled to prevent water draining into borehole and also to enhance heat transfer through U-pipes to soil). Grout has higher thermal conductivity than soil. I have attached the schematic of a borehole with this message.
These ground heat exchangers are used to extract or reject the heat into the ground.


Simulation targets
1. Simulate ground temperature using 3D diffusion equation.
ρc ∂ T/∂t =( ∇ .λ ∇ T)+S ---->(1)

So this S is the source term that I want add to the Mesh coinciding with U-pipes location and the configuration.


S is the volumetric heat source like this,


S=qn dV



The source term would be like this,
qn=- λ∂ Ts/∂n=U( Ts - Tf)


Tf is the fluid temperature
Ts is the soil temperature
U overall heat transfer coefficient

2. Simulate fluid temperature circulating through ground heat exchanger


ρc ∂ Tf/∂t+ hP (Tf- Ts ) = m ( Tf,out- Tf,in) ---->(2)

Tf,out is the outlet temperature of the U-pipes
Tf,in is the inlet fluid temperature
h is the force convection heat transfer coefficient

P is the perimeter of pipe

m is the mass flow rate of the pipe
c is the heat capacity


*** Equation (1) and (2) should be solved conjugately.


My supervisor told me that, I shouldn't mesh the U-pipes. But represent this U-pipe heat transfer with the term S(heat source) by adding it to the same location as the U-pipes. This S is dependent on location and fluid temperature as well. It is also a transient term.

So, could you please tell me how would I do this with OpenFoam. Is this possible to do in OpenFoam?.


Thanks.

I am sorry for writing long explanation.

Kumudu

gschaider November 4, 2013 18:35

[QUOTE=Kumudu;460370]
Quote:

Originally Posted by gschaider (Post 460353)
2. Simulate fluid temperature circulating through ground heat exchanger


ρc ∂ Tf/∂t+ hP (Tf- Ts ) = m ( Tf,out- Tf,in) ---->(2)

Tf,out is the outlet temperature of the U-pipes
Tf,in is the inlet fluid temperature
h is the force convection heat transfer coefficient

P is the perimeter of pipe

m is the mass flow rate of the pipe
c is the heat capacity


*** Equation (1) and (2) should be solved conjugately.


My supervisor told me that, I shouldn't mesh the U-pipes. But represent this U-pipe heat transfer with the term S(heat source) by adding it to the same location as the U-pipes. This S is dependent on location and fluid temperature as well. It is also a transient term.

So, could you please tell me how would I do this with OpenFoam. Is this possible to do in OpenFoam?.

The point that I don't understand is how you want to model T_fluid. The equation you gave is kind-of a equation for the average of T in that pipe and doesn't describe how the fluid is transported through the pipe.

Anyway: if you use this approximation for the average of T_fluid then it is possible with relatively little effort. Otherwise it is not that easy

Kumudu November 5, 2013 01:24

Transient heat source
 
[QUOTE=gschaider;460553]
Quote:

Originally Posted by Kumudu (Post 460370)

The point that I don't understand is how you want to model T_fluid. The equation you gave is kind-of a equation for the average of T in that pipe and doesn't describe how the fluid is transported through the pipe.

Anyway: if you use this approximation for the average of T_fluid then it is possible with relatively little effort. Otherwise it is not that easy


------------------------------------------------------
Hi gschaider,

Thanks for the reply. This is the way I have to simulate.

1. Guess minimum outlet fluid temperature(T_f,out,init) that would required to run the heat pump. Then, I can calculate heat extraction rate( There is a second order equation that relate the required heat load, outlet temperature of the ground U-pipe and heat extraction rate (Q_ext).


2. Calculate initial inlet temperature(T_f,in,init) from the following equation,

Q_ext=m_dot*cf(T_f,out,init-T_f,in,init)


3. Find initial fluid temperature of circulating fluid =(T_f,out,init +T_f,in,init)/2


4. Solve 3D diffusion equation first taking S=qn* δ(x-x_sf)*dV

qn=U*A*(Ts-Tf), Ts is the soil temperature , Tf :fluid temperature

δ is a dirac delta function(radial basis function) which use to smear this heat flux through some grid points (actually, will smear the heat flux into some radial distance from the points which coincide with the ground U-loop).

Using this delta function, I will be able to make this heat source 3 dimentional and shows the ground loop in the domain, without generating mesh for pipes.

x_sf= a point on the pipe ( r distance from points that we place the heat source initially)

//..........................................
Do you think this can be done?. If so, what is the solver I should use?. How to modify the existing solvers and .H files?:)
//.................................................


5. Soil temperature can be calculated from solving diffusion equation first

6. Solve the convection equation assuming 1D domain with having the same length as U-pipe.

ρc (∂T_f)/∂t+ h*P(T_f- T_s@pipe_surface )=m_dot*c_f (T_f,out-T_f,in)

Inlet temperature is specified.
Initial fluid temperature is given
T_s@pipe_surface is known
h and P are known
T_f,out is the fluid temperature at end point of 1 dimensional domain.

7. So, new fluid temperature is known, solve diffusion equation again. So, this is a conjugate process.


////////////////////////////////////

Please suggest me a method or some commands to find specified points which will be coinciding with U-loop

Then, how to add this heat source into the transient diffusion equation which will only applicable for specified points.


If OpenFoam has some commands to define a radial basis function, to smear this heat source within a r distance from this specified points which will make 3D heat source.


Then, how to solve, 1 Dimensional equation for fluid , without generating mesh for pipe. Is it possible??????


Thanks you very much for even replying me. I don't have someone to get some suggestion about this. Please tell me how to do this if you have some idea, about this.:)


//////////////////////////////////////////////////////////////////////











based on the required heat extraction rate.
Give inlet temperature value to fluid.

gschaider November 18, 2013 18:15

[QUOTE=Kumudu;460572]
Quote:

Originally Posted by gschaider (Post 460553)


------------------------------------------------------
Hi gschaider,

Thanks for the reply. This is the way I have to simulate.

1. Guess minimum outlet fluid temperature(T_f,out,init) that would required to run the heat pump. Then, I can calculate heat extraction rate( There is a second order equation that relate the required heat load, outlet temperature of the ground U-pipe and heat extraction rate (Q_ext).


2. Calculate initial inlet temperature(T_f,in,init) from the following equation,

Q_ext=m_dot*cf(T_f,out,init-T_f,in,init)


3. Find initial fluid temperature of circulating fluid =(T_f,out,init +T_f,in,init)/2


4. Solve 3D diffusion equation first taking S=qn* δ(x-x_sf)*dV

qn=U*A*(Ts-Tf), Ts is the soil temperature , Tf :fluid temperature

δ is a dirac delta function(radial basis function) which use to smear this heat flux through some grid points (actually, will smear the heat flux into some radial distance from the points which coincide with the ground U-loop).

Using this delta function, I will be able to make this heat source 3 dimentional and shows the ground loop in the domain, without generating mesh for pipes.

x_sf= a point on the pipe ( r distance from points that we place the heat source initially)

//..........................................
Do you think this can be done?. If so, what is the solver I should use?. How to modify the existing solvers and .H files?:)
//.................................................


5. Soil temperature can be calculated from solving diffusion equation first

6. Solve the convection equation assuming 1D domain with having the same length as U-pipe.

ρc (∂T_f)/∂t+ h*P(T_f- T_s@pipe_surface )=m_dot*c_f (T_f,out-T_f,in)

Inlet temperature is specified.
Initial fluid temperature is given
T_s@pipe_surface is known
h and P are known
T_f,out is the fluid temperature at end point of 1 dimensional domain.
Quote:

Originally Posted by Kumudu (Post 460572)
How are you planning to solve the 1D-equation? Not with OF, I guess

7. So, new fluid temperature is known, solve diffusion equation again. So, this is a conjugate process.


////////////////////////////////////

Please suggest me a method or some commands to find specified points which will be coinciding with U-loop
Quote:

Originally Posted by Kumudu (Post 460572)
That depends on how the location of the U-loop is stored

Then, how to add this heat source into the transient diffusion equation which will only applicable for specified points.
Quote:

Originally Posted by Kumudu (Post 460572)
For instance add an expressionSource with an expression "zone(ULoop) ? srcValue : 0". Assuming that you have a cellZone ULoop with the cells that it passes through. And srcValue will probably be more complex

If OpenFoam has some commands to define a radial basis function, to smear this heat source within a r distance from this specified points which will make 3D heat source.

Quote:

Originally Posted by Kumudu (Post 460572)
Don't know

Then, how to solve, 1 Dimensional equation for fluid , without generating mesh for pipe. Is it possible??????

Quote:

Originally Posted by Kumudu (Post 460572)
Don't think so

Thanks you very much for even replying me. I don't have someone to get some suggestion about this. Please tell me how to do this if you have some idea, about this.:)


//////////////////////////////////////////////////////////////////////











based on the required heat extraction rate.
Give inlet temperature value to fluid.


Kumudu November 19, 2013 01:18

Transient heat source
 
[QUOTE=gschaider;462458]
Thanks for reply. I give up that idea. These days, I am trying to combine, transient diffusion equation for solid and scalar transport equation for fluid. I have more than one solid regions (pipe, grout and soil).

I am hoping to define different cell zones for water, pipe, and grout using topoSet dict. I am following the chtMultiRegionFoam for this. I hope I can do this. The regoins are coupled through boundary conditions. Not through the source terms. It is a difficult task.

I saw a tutorial for blockCoupledTransientFoam posted by OpenFoam. This only deal with one fluid and solid region. But it handles the source term via defining alpha value. (0 for fluid , 1 for soild ). So, changing the given code that is applicable for multiple region is somewhat difficult for me. If it is also has been done by the openFoam group, please let me know. But, the regions should be defined by Toposet Dictionary not by patches. Dealing with topoSet is easy.

Thanks again:)


All times are GMT -4. The time now is 15:03.