CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to define Vacuum Conditions in OpenFoam (https://www.cfd-online.com/Forums/openfoam-pre-processing/219739-how-define-vacuum-conditions-openfoam.html)

Raza Javed August 7, 2019 07:05

How to define Vacuum Conditions in OpenFoam
 
Hello Everyone,


I am using chtMultiRegionSimpleFoam and my Openfoam version is 4.1


I am trying to simulate radiation heat transfer in a vacuum.


My questions are the following:


1. How can we generate a vacuum? For example If I have one rectangular region and I want to make it a vacuum, Do I need to change themophysical properties?


2. which radiation model would be suitable for vacuum?


I shall be very thankful for your help.


Thank you

simrego August 12, 2019 05:43

Hi!


1. Just set the reference pressure to your needs in the fvSolution file. I assume that you have a closed volume.
Change from what?



2. It depends. The medium is participating in the radiation, or not? It is optically thick, or not?

Raza Javed August 12, 2019 05:52

1 Attachment(s)
Quote:

Originally Posted by simrego (Post 741814)
Hi!


1. Just set the reference pressure to your needs in the fvSolution file. I assume that you have a closed volume.
Change from what?



2. It depends. The medium is participating in the radiation, or not? It is optically thick, or not?




Thank you so much for your reply.


My geometry is attached. Please have a look


The green region is a heater, and the blue region is the air, that I want to make vacuum. because I want to see the behavior of radiations in the vacuum coming out from the green heater.


Please let me know if you need further clarification about the case.


thank you

Raza Javed August 12, 2019 05:53

Quote:

Originally Posted by simrego (Post 741814)
Hi!


1. Just set the reference pressure to your needs in the fvSolution file. I assume that you have a closed volume.
Change from what?



2. It depends. The medium is participating in the radiation, or not? It is optically thick, or not?




I am putting viewFactor radiation model in the region air, and radiation model Opaque on the heater.

simrego August 12, 2019 07:24

Since this is air, the viewFactor model seems fine.
For the vacuum what is the pressure in the vacuum? And again this is a closed volume, right? without inlets/outlets.

Raza Javed August 12, 2019 07:37

Quote:

Originally Posted by simrego (Post 741834)
Since this is air, the viewFactor model seems fine.
For the vacuum what is the pressure in the vacuum? And again this is a closed volume, right? without inlets/outlets.


Yes this is a closed volume without inlets/outlets. Below is the mesh information for my air region:


Code:

2
(
    defaultFaces
    {
        type            wall;
        nFaces          8400;
        startFace      319164;
    }

    vacuum_to_heater
    {
        type            mappedWall;
        inGroups        1 ( wall );
        nFaces          336;
        startFace      327564;
        sampleMode      nearestPatchFace;
        sampleRegion    heater;
        samplePatch    heater_to_vacuum;
    }

)

Vacuum is the name of my Air region.

The pressure I am using is 1 bar, you can see below the changeDictionaryDict of my air(vacuum name used in the case) region:
I have put the zero velocity, so that there should be no heat transfer through convection.



Code:

boundary
{
    defaultFaces
    {
        type            wall;
    }
}

T
{
    internalField  uniform 300;

    boundaryField
    {
        defaultFaces
        {
            type            zeroGradient;
        }

        "vacuum_to_.*"
        {

            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod    fluidThermo;
            value          uniform 300;
        }
    }
}

U
{
    internalField  uniform (0 0 0);

    boundaryField
    {

        defaultFaces
        {
            type            noSlip;
        }
        "vacuum_to_.*"
        {
            type            noSlip;
        }

    }
}

p_rgh
{
    internalField  uniform 0;

    boundaryField
    {

        defaultFaces
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }

        ".*"
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }
    }
}

p
{
    internalField  uniform 100000;

    boundaryField
    {
        ".*"
        {
            type            fixedValue;
            value          uniform 100000;
        }
    }
}


simrego August 12, 2019 08:50

In this solver the calculated pressure field is p_rgh. p is calculated from p_rgh. You should just set calculated BC for every p field. Also these values are only the initial values. In your air/fvSolution file you have to define a reference cell, and a referecne pressure. You can set it to 1bar if your pressure is 1 bar in the domain.
For the material properties you can use what you want, but you need a temperature dependent density. You will have some convective heat transfer. In the U file all you do is set the velocity on the boundaries to zero, which is correct for a wall. But in the domain you will have non zero velocities. (nonuniform temperature field -> nonuniform density -> fluid will start moving.)

Raza Javed August 12, 2019 09:03

Quote:

Originally Posted by simrego (Post 741850)
In this solver the calculated pressure field is p_rgh. p is calculated from p_rgh. You should just set calculated BC for every p field. Also these values are only the initial values. In your air/fvSolution file you have to define a reference cell, and a referecne pressure. You can set it to 1bar if your pressure is 1 bar in the domain.
For the material properties you can use what you want, but you need a temperature dependent density. You will have some convective heat transfer. In the U file all you do is set the velocity on the boundaries to zero, which is correct for a wall. But in the domain you will have non zero velocities. (nonuniform temperature field -> nonuniform density -> fluid will start moving.)


So, the boundary conditions and initial values for p_rgh would remain as they are? like below:
Code:

p_rgh
{
    internalField  uniform 0;

    boundaryField
    {

        defaultFaces
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }

        ".*"
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }
    }
}


And for pressure I should put on each boundary "calculated"?



Material properties of my air region is below:


Code:

thermoType
{
    type            heRhoThermo;
    mixture        pureMixture;
    transport      const;
    thermo          hConst;
    equationOfState perfectGas;
    specie          specie;
    energy          sensibleEnthalpy;
}

mixture
{
    specie
    {
        nMoles          1;
        molWeight      28.9;
    }
    thermodynamics
    {
        Cp              1000;
        Hf              0;
    }
    transport
    {
        mu              1.8e-05;
        Pr              0.7;
    }
}


But there is no entry for density (rho). shall I put one?


I exactly dont know How to define the reference cell and reference pressure? Below is my air/fvSolution file


Code:

solvers
{
    rho
    {
        solver          PCG
        preconditioner  DIC;
        tolerance      1e-7;
        relTol          0;
    }

    p_rgh
    {
        solver          GAMG;
        tolerance        1e-7;
        relTol          0.01;

        smoother        GaussSeidel;

        cacheAgglomeration true;
        nCellsInCoarsestLevel 10;
        agglomerator    faceAreaPair;
        mergeLevels      1;

        maxIter          10;
    }

    "(U|h|k|epsilon)"
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance        1e-7;
        relTol          0.1;
    }
}

SIMPLE
{
    momentumPredictor on;
    nNonOrthogonalCorrectors 2;
    pRefCell        0;
    pRefValue      100000;
    rhoMin          rhoMin [1 -3 0 0 0] 700;
    rhoMax          rhoMax [1 -3 0 0 0] 1200;
}

relaxationFactors
{
    fields
    {
        rho            1;
        p_rgh          0.7;
    }
    equations
    {
        U              0.7;
        h              0.7;
        nuTilda        0.7;
        k              0.7;
        epsilon        0.7;
        omega          0.7;
        "ILambda.*"    0.7;
        Qr              0.7;
    }
}

// ************************************************************************* //


simrego August 12, 2019 09:21

So for p you can use calculated. The solver solves for p_rgh, and calculate p from p_rgh. So just let the solver to calculate everything for p.
For p_rgh, you should set the initial values to 1 bar since this is your operating pressure, and it can speed up the convergence if you have a better guess with the initial values.
Just replace every uniform 0; to uniform 100000; in the p_rgh sub-dictionary



You don't need rho because of that line:
equationOfState perfectGas;

with this model you calculate rho from molweight, temperature, and pressure. This is accurate but it can be unstable.
Your fvSolution seems fine, but your rhoMin and rhoMax will maked you mad. air density will be around 1, but you limit it between 700-1200. You can comment that lines out and use the limiter only if your density blows up (if during the solution you will have really large or small densities).
And you could use smaller relaxation factors. These kind of problems can be really unstable (bad convergence).

Raza Javed August 12, 2019 09:55

Quote:

Originally Posted by simrego (Post 741856)
So for p you can use calculated. The solver solves for p_rgh, and calculate p from p_rgh. So just let the solver to calculate everything for p.
For p_rgh, you should set the initial values to 1 bar since this is your operating pressure, and it can speed up the convergence if you have a better guess with the initial values.
Just replace every uniform 0; to uniform 100000; in the p_rgh sub-dictionary



You don't need rho because of that line:
equationOfState perfectGas;

with this model you calculate rho from molweight, temperature, and pressure. This is accurate but it can be unstable.
Your fvSolution seems fine, but your rhoMin and rhoMax will maked you mad. air density will be around 1, but you limit it between 700-1200. You can comment that lines out and use the limiter only if your density blows up (if during the solution you will have really large or small densities).
And you could use smaller relaxation factors. These kind of problems can be really unstable (bad convergence).


I changed the boundary conditions for p and p_rgh like below:


Code:

p_rgh
{
    internalField  uniform 100000;

    boundaryField
    {

        defaultFaces
        {
            type            fixedFluxPressure;
            value          uniform 100000;
        }

        ".*"
        {
            type            fixedFluxPressure;
            value          uniform 100000;
        }
    }
}

p
{
    internalField  uniform 100000;

    boundaryField
    {
        ".*"
        {
            type            calculated;
            value          uniform 100000;
        }
    }
}


First I tried putting 0 value in p instead of 100000, but then the solver was giving error, then I changed that also to 100000 like p_rgh. Is this correct?



And I removed those two lines for rhomin and rhomax from fvSolutions.

simrego August 12, 2019 10:14

Yes, it should.
It crashed because of your "density model" i think.
you set the p for 0. For the first time it will tries to calculate the density as:
rho = p/(R*T)
With 0 p you will get 0 density. And everything goes wrong.

In the next step it should be fine since p is recalculated from p_rgh and it will be correct. But you can't get there since you failed already.
So 1bar for p is correct, but doesn't really matter since it is just an initial value. Just survive the first few iterations! :D


And now your case is running?

Raza Javed August 12, 2019 10:31

Quote:

Originally Posted by simrego (Post 741860)
Yes, it should.
It crashed because of your "density model" i think.
you set the p for 0. For the first time it will tries to calculate the density as:
rho = p/(R*T)
With 0 p you will get 0 density. And everything goes wrong.

In the next step it should be fine since p is recalculated from p_rgh and it will be correct. But you can't get there since you failed already.
So 1bar for p is correct, but doesn't really matter since it is just an initial value. Just survive the first few iterations! :D


And now your case is running?


Yes. with the initial values and boundary conditions I attached in the last post, the solver is running.


I am sorry I have one another question related to fvOptions. In my heater region inside the air region, I am putting power using fvOptions file. I want to put 10W of power in that. The volume of my heater region is 1e-12 cubic meter. What value should I write in fvOptions if I am using specific volume mode?



shall I divide 10 watts with the volume of heater and then put the result in fvOptions?


Code:

heatSource
{
    type            scalarSemiImplicitSource;
    active          true;
 
    scalarSemiImplicitSourceCoeffs
    {
        selectionMode  all; // all, cellSet, cellZone, points
      // cellZone        hot;       
        //cellSet        c1;
        volumeMode      specific; // absolute;
        injectionRateSuSp
        {
            h    (1e13 0);
        }
    }
}


simrego August 12, 2019 10:35

Feel free to ask. If i can i'll try to help you :)
There is a simpler solution. Set the volumeMode to absolute. So you can simply write 10.
https://openfoam.com/documentation/guides/latest/api/classFoam_1_1fv_1_1SemiImplicitSource.html#details

:
Valid options for the volumeMode entry include:
  • absolute: values are given as <quantity>
  • specific: values are given as <quantity>/m3

simrego August 12, 2019 10:37

But to answer your question. in specific mode you just have to divide 10 W with the volume. So 1e13 seems correct. But I suggest you to let the solver calculate these thing so you'll have less sources for the mistakes. :)

Raza Javed August 13, 2019 04:25

Quote:

Originally Posted by simrego (Post 741865)
But to answer your question. in specific mode you just have to divide 10 W with the volume. So 1e13 seems correct. But I suggest you to let the solver calculate these thing so you'll have less sources for the mistakes. :)


Thank you. I did and now the solver is running. :)


Please correct me where I am wrong.


So, till here the solver is running with a heater inside air, and we put p_rgh and p equals to 1 bar.


Now, I need to change this air to vacuum, so I must decrease the pressure. I cannot put zero for p because then the solver stops.


So can I put p_rgh equals to zero, and p equals to very very small value for vacuum?


And in the U sub-dictionary, do I need to put some value for the velocity also?


Thank you

simrego August 13, 2019 05:11

I don't think if you can set zero pressure with this solver. I think this is not suitable for that. You can use small pressure, but with 0 I think it will blow up. But you can give it a try.
If you need a different pressure, just set it in the fvSolution file, and correct the p_rgh and p field to the same pressure (Again in the p_rgh and p files you just giving initial values, they shouldn't affect the solution.)
And if you decrease the pressure, you have to correct the material properties of the air to that pressure and temperature. Since the properties of air are depends on the pressure and temperature.
You can leave U as it is. You will have some air motion. Or you can set a "frozenFlow yes;" flag in the "air/fvSolution/SIMPLE", and you will solve only the energy equation, thus the velocity and pressure field will be the initialized value during the solution, so if you set 0 velocity, you will have only radiation, and conduction through the air.

Raza Javed August 13, 2019 05:32

Quote:

I don't think if you can set zero pressure with this solver. I think this is not suitable for that. You can use small pressure, but with 0 I think it will blow up. But you can give it a try.

I put everything zero like below:


Code:

p_rgh
{
    internalField  uniform 0;

    boundaryField
    {

        defaultFaces
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }

        ".*"
        {
            type            fixedFluxPressure;
            value          uniform 0;
        }
    }
}

p
{
    internalField  uniform 0;

    boundaryField
    {
        ".*"
        {
            type            calculated;
            value          uniform 0;
        }
    }
}


and I got the following error:


Code:

Time = 0.1


Solving for fluid region vacuum
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
#5  Foam::fluidThermo::nu() const at ??:?
#6  Foam::laminar<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > >::nuEff() const at ??:?
#7  Foam::linearViscousStress<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > >::divDevRhoReff(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&) const at ??:?
#8  ? at ??:?
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? at ??:?
Floating point exception (core dumped)


Quote:

If you need a different pressure, just set it in the fvSolution file, and correct the p_rgh and p field to the same pressure (Again in the p_rgh and p files you just giving initial values, they shouldn't affect the solution.)

where in fvSolution I can put pressure? at pRefValue?

In the fvSolution file, I will put p or p_rgh ?




Quote:

And if you decrease the pressure, you have to correct the material properties of the air to that pressure and temperature. Since the properties of air are depends on the pressure and temperature.

You mean to say that I need to change the values mentioned below with the new small pressure I will put?


Code:

thermoType
{
    type            heRhoThermo;
    mixture        pureMixture;
    transport      const;
    thermo          hConst;
    equationOfState perfectGas;
    specie          specie;
    energy          sensibleEnthalpy;
}

mixture
{
    specie
    {
        nMoles          1;
        molWeight      28.9;
    }
    thermodynamics
    {
        Cp              1000;
        Hf              0;
    }
    transport
    {
        mu              1.8e-05;
        Pr              0.7;
    }
}


simrego August 13, 2019 05:46

Yes this error is a figFpe, you have a division with 0 somewhere. Probably because of that 0 pressure.


Sorry, yes. Only the pRefValue have to be modified. You don't have to put anything else in the fvSolution, only modify the pRefvalue.


Yes you have to modify them. I think Pr=0.7 is only valid for air on atmospheric pressure and ~300 K. Also check the viscosity. But if you use frozenFlow maybe the viscosity is redundant.

Raza Javed August 13, 2019 05:55

Quote:

Sorry, yes. Only the pRefValue have to be modified. You don't have to put anything else in the fvSolution, only modify the pRefvalue.

Ok. for example: if I put pRefValue=2.5, then I have to change p and p_rgh in changeDictionaryDict to 2.5 also?

Raza Javed August 13, 2019 06:21

Quote:

Yes you have to modify them. I think Pr=0.7 is only valid for air on atmospheric pressure and ~300 K

I have checked about the Pr value for small pressure, but couldn't find it. and Pr is also not directly dependent on pressure,

Is there anyway to find Pr for different pressures?


All times are GMT -4. The time now is 13:42.