CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   dsmcFoam Vacuum (https://www.cfd-online.com/Forums/openfoam-programming-development/93535-dsmcfoam-vacuum.html)

bitguang October 18, 2011 11:18

dsmcFoam Vacuum
 
Hello,
a gas from inlet (atmospheric conditions) to outlet (vacuum)

How to set the parameter of the vacuum boundary (rho, or ?) of outlet in the dsmcFoam ?
And how to set the the parameter of boundary (V, rhoN, or P) of inlet ?

Thanks.

Erik October 24, 2011 03:13

Hello Bitguang,

For the inlet and outlet patches the dsmcFoam code, by default, puts a numberdensity of particles defined in the freeStream entry of your control/dsmcProperties. Other than this it reads the boundaryU and boundaryT entries in the time directory and controls these boundaries accordingly.

The quick fix for simulating vacuum is to set a velocity boundary at the vacuum patch which "blows" the newly created particles out of the domain directly i.e. a high velocity in direction out of the domain.

Alternativly you can enter the file src/dscm/submodels/InflowBoundaryModel/FreeStream/FreeStream.C (around line 200)

and enter something like:
Code:


            // From Bird eqn 4.22
            scalar nd= numberDensities_[i];

scalar nIn=<inlet value>;//enter here desired inlet number density
scalar nOut=<outlet value>;//enter here desired outlet number density

//name your inlet "inLet" and your outlet "outLet"
if("inLet"==patch.name())
nd= nIn/cloud.nParticle();

if("outLet"==patch.name())
nd= nOut/cloud.nParticle();


Info << "target number density for patch  <" <<  patch.name() << ">  is  :" << nd*cloud.nParticle() << endl;


            pFA[i] =
                mag(patch.faceAreas())*nd*deltaT
              *mostProbableSpeed
              *(
                  exp(-sqr(sCosTheta)) + sqrtPi*sCosTheta*(1 + erf(sCosTheta))
                )
              /(2.0*sqrtPi);

Then compile the dsmc library and then compile the solver.

Cheers and hope this helps,
Erik

spk December 6, 2011 15:50

Hi Erik,

I have the same problem! Can you help me?
In the file FreeStream.C what value i have to enter for the desired inlet number density and outlet?
The only value known is the input particle number density for inlet and vacuum for outlet.
If you have time in this thread i describe my problem!
http://www.cfd-online.com/Forums/ope...am-solver.html

Thanks a lot,
spk

Erik December 7, 2011 02:49

Hi Spk,

This depends on the problem which you want to solve, if I understand you question correctly.

If you instead know what pressure and temperature you want at the inlet or outlet of your case then determine the number density by n=p/kT (ideal gas law). Then enter these values for nIn and nOut.

Cheers and hope this helps,
Erik

spk December 7, 2011 06:40

Hi Erik,

Thanks a lot for your answer!
Yes i know pressure and temperature for the inlet so i know nIn!
The outlet is vacuum and also i know the temperature!
What value should i enter for nOut?

Thanks,
spk

Erik December 7, 2011 06:53

Hi spk,

No problem. If your outlet is perfect vacuum set nOut = 0. And it wont matter what temperature you set (have) there.

Cheers,
Erik

spk December 7, 2011 07:14

Hi Erik,

Thanks for your fast answer! :)
Ok i understand! I would like to ask you an another question!
These values nIn and nOut, i have to enter also to folder 0 at files
dsmcRhoN and rhoN?

Thanks,
spk

Erik December 7, 2011 07:19

The way I am describing here might be a bit of dirty coding.

What you write here over-rides what is written for the same boundaries in the time directory.

For the freeStream utility it is only the temperature and the bulkVelocity which are read from the time directory.

Cheers,
Erik

spk December 7, 2011 07:29

Thanks Erik,

You mean that it wont matter what values are entered to dsmcRhoN and rhoN?
I thought to enter these values to 0 folder as fixed values.
Also at boundaryU file, i think to enter 0 and fixed value for inlet(according to my problem) and 0 and calculated for outlet!

spk

Erik December 7, 2011 07:33

yes, it wont matter what number density you prescribe for these patches in the 0 directory. But the bulk-velocity and the temperature is still read from the 0 directory so these need to be correct.

Cheers

spk December 7, 2011 07:35

Ok i understand!
Thanks a lot Erik for your time!!! :) :)

spk December 8, 2011 17:52

Hi Erik again,

I changed and saved the FreeStream.C file. In order to compile
the dsmc library and solver, i have to create a Make folder with options and files? Then use wmake?
Can you give some instructions? I'm new OpenFoam user!

Thanks a lot,
spk

liuwy86 March 2, 2012 03:56

dsmcInitialise
 
Quote:

Originally Posted by Erik (Post 329133)
Hello Bitguang,

For the inlet and outlet patches the dsmcFoam code, by default, puts a numberdensity of particles defined in the freeStream entry of your control/dsmcProperties. Other than this it reads the boundaryU and boundaryT entries in the time directory and controls these boundaries accordingly.

The quick fix for simulating vacuum is to set a velocity boundary at the vacuum patch which "blows" the newly created particles out of the domain directly i.e. a high velocity in direction out of the domain.

Alternativly you can enter the file src/dscm/submodels/InflowBoundaryModel/FreeStream/FreeStream.C (around line 200)

and enter something like:
Code:


            // From Bird eqn 4.22
        scalar nd= numberDensities_[i];

scalar nIn=<inlet value>;//enter here desired inlet number density
scalar nOut=<outlet value>;//enter here desired outlet number density

//name your inlet "inLet" and your outlet "outLet"
if("inLet"==patch.name())
nd= nIn/cloud.nParticle();

if("outLet"==patch.name())
nd= nOut/cloud.nParticle();


Info << "target number density for patch  <" <<  patch.name() << ">  is  :" << nd*cloud.nParticle() << endl;


            pFA[i] =
                mag(patch.faceAreas())*nd*deltaT
              *mostProbableSpeed
              *(
                  exp(-sqr(sCosTheta)) + sqrtPi*sCosTheta*(1 + erf(sCosTheta))
                )
              /(2.0*sqrtPi);

Then compile the dsmc library and then compile the solver.

Cheers and hope this helps,
Erik

Hi Erik,

I have two questions:

1. For scalar nIn=<inlet value>;
scalar nOut=<outlet value>;
I think for one patch (e.g. inLet) I can only input one desired number density value. I got the same number density value if I use more than one spieces (N2 and O2), but actually they should not be the same (i.e. N2 78%, O2 22%). So I wonder how to get the different values for different spieces if only one number density values is input, or is there another way to do it?

1. Is it possible to set ununiform number density values so as to get a ununiformly distributed pressure?

Thanks in advance.

Liu

Erik March 5, 2012 03:29

Hi Liu,

1) The lines I wrote were meant for a single specie gas. If you have more than one specie you could try and enter an if condition to the code above as follows:

if("inLet"==patch.name() && typeId==0)
nd= nIn0/cloud.nParticle();

if("outLet"==patch.name()&& typeId==0)
nd= nOut0/cloud.nParticle();


if("inLet"==patch.name() && typeId==1)
nd= nIn1/cloud.nParticle();

if("outLet"==patch.name()&& typeId==1)
nd= nOut1/cloud.nParticle();

2) The distribution of pressure should depend on the configuration of your case. If the inLet and outLet are set similarly you should achieve the set and desired values uniformly in the whole domain.

Cheers,
Erik

liuwy86 March 5, 2012 04:54

Hi Erik,

Thank you very much for your reply!

Liu

thanz March 24, 2012 12:19

Hi Erik,

Could you give a hint how the code should be modified in order to read the number of density values from a file. I am new in C++

Thanks

Erik September 24, 2012 15:03

Hi Thanasis,

Sorry for giving a late reply.

To read data from a file:

//Add the following lines among you inclusion files

#include <iostream>
#include <fstream>
using namespace std;

//add the following lines where you want to read the data (here the file which is read should have two scalar numbers)


scalar p=0,Ux=0;

ifstream strData; // indata is like cin

strData.open("nameOfFile");

strData >> p;
strData >> Ux;

strData.close();

hope this helps,
Erik

Erik September 24, 2012 15:08

Alternatively you can use OpenFOAMs format to read from dictionaries as follows:

IOdictionary setParam
(
IOobject
(
"myDict",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

scalar buffRI =
readScalar
(
setParam.lookup("buffResInt")
);

Cheers,
Erik

jiaoxiaolei May 2, 2013 04:53

How to see the molecular in paraview
 
Hi,Erik
I am using dsmcFoam to do a simulation on vaccum plume,I have a question,can we see all the moleculars in paraview?or how to display these moleculars?:confused:

lojodr November 10, 2014 11:12

pressure and velocity on inlet?
 
Hello Erik,

I know this reply might be a little late but I am currently considering your option to calculate pressure driven flows. I already used your "dirty method" and I am pretty sure the method does not affect the inflow velocity (still read in the boundaryU file). It is quite uncommon to have a velocity and a pressure specified at an inlet. I thought of setting a zero gradient velocity on inlet and outlet. Or shall I still specify a fixedValue at the inlet (something like (0 0 0))? What would you suggest? Thank you very much.

Vigneshramaero May 18, 2015 09:48

Reg DSMC - Micro nozzle
 
1 Attachment(s)
Hi,
I'm working on micro nozzle (throat 20 um). similar to Eshan Roohi's Test Case (DOI:10.1007/s10404-010-0671-7).
I need to setup with pressure difference. So I modified the Freestream.C to set the specified numberdensity values according to pressure(In and Out).
I'm getting a weard result, it looks unphysical solution (Even though it is
subsonic at throat, diverging section still accelarates). Usually the sonic line will be little down stream of the throat in micro nozzle case. But for me at the exit of the nozzle it gets around 0.8- 0.9.
So can any one help me to sort this problem. I can post my problem setup also, If someone like to review it.

Thank you

~Vignesh~


All times are GMT -4. The time now is 10:40.