CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   0 Folder for a dsmcFoam simulation (

Jesgonse November 15, 2011 03:38

0 Folder for a dsmcFoam simulation
Hi, I'm new in using the dsmc solver and I#m having the problem with the definition of the 0 folder because I don't know the exact meaning of the properties that you are defininig:

boundaryT (temperature)
boundaryU (velocity)
dsmcRhoN (numberdensity??)
dsmcRhoM (mass density??)
fD (Pressure??)
iDof (???)
rhoM (Why these rhoM and rhoN when you have already defined dsmcRhoN and RhonM?)

Is it really necessary to define all of them?

I would appreciate If someone could clarify my doubts and recommend me a tutorial, paper, link, book or whatever that could help me to understand this solver.

thanz November 21, 2011 13:59


Originally Posted by Jesgonse (Post 332142)
boundaryT (temperature)
boundaryU (velocity)
dsmcRhoN (dsmc particle number density)
dsmcRhoM (dsmc particle mass density)
fD (surface force density)
iDof (degrees of freedom)
internalE (internal energy)
internalKE (internal kinetic energy)
q (surface heat transfer)
rhoM (mass density)
rhoN (number density)

I am still reading Bird's book, so I cannot help you a lot.

alberto November 22, 2011 02:36

You find a description of the fields in the documentation of the DsmcCloud class:

To clarify your confusion about rhoN and dsmcRhoN, notice that rhoN is the number density (the actual one), while dsmcRhoN is the number density of the DSMC particles.


anon_a December 1, 2011 14:02

You have to define boundaryU and boundaryT according to the corresponding patch Maxwellian distribution properties.

The rest of them may be set to zeroGradient for all patches except symmetryPlanes and empty (it does not make a difference in the simulation).

Jesgonse February 6, 2012 03:30

Thank you all for your answers, definitely it is totally recommendable and form my point of view necessary to read Bird's book and the whole C++ code to understand the operation of this solver

dpham February 20, 2012 11:22

Hi all,

I'm also starting to use the dsmcFoam solver for my OpenFOAM simulations and to get more familiar with the solver, I set up an easy case:

2-D rectangle (1x10 mm) with simple Grading 10x100 cells; inlet and outlet on the short sides and all other sides set as walls. The number density is set to 2.6867774x10^25 for ambient conditions. For an average of 6 dsmcParticles in each cell, the nEquivalentParticles in the dsmcProperties was set to 4.47796x10^12. deltat was set to 10^-7 s to ensure that the gas molecules stayed approximately 3 iteration steps in one cell (assuming a molecule velocity of the speed of sound). boundaryT was set to 300 K and the velocity at the inlet to 50 m/s. All other files in the 0-folder were set to the appropriate values (zeroGradient for patches and calculated with value of 0 for the walls).

The calculated dsmcParticles and their movement as well as the pressure change with time look fine to me but I have had some difficulties understanding the other calculated values.

1. What is the difference between overallT, translationalT and internalT? Are they different temperature values or can they be used to calculate the temperature (units being kg*m^2/s^2 instead of K)?

2. I noticed that the boundary velocity at the inlet seems to be only 25 m/s even though it should be 50 m/s (same thing happens to boundaryT, e.g. when I set it to 700 K, paraView shows only 550 K). Additionally, the calculated velocity is unreasonable where it is 8 m/s within the first cell, then a step to 0 m/s which stays constant within the rectangle until the outlet where it goes back to 8 m/s.

Does anybody see where the problem(s) may be?

Thank you very much for the help

anon_a February 20, 2012 12:05

A few things to get you started.

The units you wrote (kg*m^2/s^2) correspond to energy. Maybe you mixed internalT with internalE?

These temperatures are calculated in dsmcFields.C
in lines 168-208. With a little patience, you can see their definition and verify that their units are indeed Kelvin. Keep in mind that many quantities (such as iDofMean, linearKEMean, etc) are naturally defined per unit of volume.

How did you define your inlet and outlet conditions?
In the default version of dsmcFoam you can only give a number density for all open boundary surfaces (unless they worked on that in 2.1, I didn't check that but I doubt it).

See the following:

When you say that you have incorrect velocities and temperatures in ParaFoam, are you visualising boundaryT and boundaryU or overallT and overallU? Because the first ones are not very meaningful, they only serve as boundary conditions and their inner field is not calculated.

Jesgonse February 21, 2012 10:22

The unit of overallT, translationalT and internalT is K, as anon_a said, you can check it in the C++ code.

You can see the definition of these temperatures, for example, in the first chapter (page 14) of Bird's book: Molecular Gas Dynamics and the Direct Simulation of Gas Flows (Oxford Engineering Science Series.

The translationalT is calculated from the velocities of a set of molecules. The internalT is calculated taking in account the vibrational and rotational energy of the molecules (so its value is zero for a monoatomic gas).

The overallT is defined as a weighted mean (taking in account the internal degrees of freedom) of the other two.

dpham February 22, 2012 06:45

Thank you very much for your answers! I’m not so familiar with C++ so I only looked in the calculated files for a specific time step (e.g. internalT). Here, the dimension is [1 2 -2 0 0 0 0], which confused me a bit (expected [0 0 0 1 0 0 0]). Is that always the case with temperatures (dimensions and actually calculated units are not the same) or is there something wrong with my case? Due to your comment I checked the dimensions of internalE, which would be [1 -1 -2 0 0 0 0], thus energy per volume? Seems like I have to learn a bit more about C++…

Do you mean the inlet and outlet conditions in the 0-folder? They are defined as patches in the blockMesh-file with these parameters in the 0-folder: boundaryT=300 K and boundaryU=(0 0 50) m/s and boundaryU=(0 0 0) for the inlet and outlet, respectively. Everything else is set to zeroGradient.

The overallU and overallT seem unreasonable. At the inlet, where there should be a velocity close to the boundary conditions (+50 m/s; shown boundaryU is +25 m/s) a value for UMean_z of -8 m/s is calculated (the opposite for the outlet: a velocity of +8). Within the geometry, the velocity is 0 after a while.

The calculated parameters of the tutorial case “freeSpaceStream” look strange to me, too. boundaryT is set to 700 K but overallT does only reach about 500. And shouldn’t the whole cube reach a constant temperature around 700 K after a while (all other boundaryT conditions are set to walls with zeroGradient).

Thanks a lot and regards

anon_a February 22, 2012 09:39

First off, sorry for not checking out the temperature files first but I was not in my PC. Second, to be honest, I am not exactly a C++ master myself too but it is worth investing time on the code.


Originally Posted by dpham (Post 345720)
... the dimension is [1 2 -2 0 0 0 0], which confused me a bit (expected [0 0 0 1 0 0 0])...

You are right about the temperature units. I would guess that the units of the Boltzmann constant are not passed through the .value() function (even though it is correctly set up in etc/controlDict). If k was dimensionless, the units would match those given in the temperature files. The same thing would happen with pressure p but in this case k is both in the numerator and denominator and therefore it's ok. I wouldn't worry too much about that anyway.


Originally Posted by dpham (Post 345720)
... I checked the dimensions of internalE, which would be [1 -1 -2 0 0 0 0], thus energy per volume?

That is correct.


Originally Posted by dpham (Post 345720)
... boundaryT=300 K and boundaryU=(0 0 50) m/s and boundaryU=(0 0 0) for the inlet and outlet...

In order to fully determine the distribution function of particles in a boundary patch (and assuming it is Maxwellian), you need the temperature, velocity and number density. The first two are imposed through the "boundaryT/U" files. The third one is imposed through the constant/dsmcProperties file, in the Inflow Boundary Model section (if you were changing only system/dsmcInitialiseDict, this refers to the initial conditions). However, in the default inflow models you can only impose a specific number density to all open boundaries simultaneously. See the links I sent for some hints on how to change that.


Originally Posted by dpham (Post 345720)
The overallU and overallT seem unreasonable...

Even if you change the patch inflow properties, you will not get exactly what you prescribe at these boundaries. On a boundary patch for example, the macroscopic quantities are calculated using the molecular properties of particles crossing the patch both ways and you can not be sure (in fact it rarely happens) that molecules moving in opposite directions have the properties you want. Also, their distribution is probably not Maxwellian. It is very common to include a part of the upstream and downstream reservoirs in the computational domain (see e.g. to solve this problem (but be warned that the computational effort is increased).

Also, the fields may be lost in noise if you have very slow flows and very low Kn.


Originally Posted by dpham (Post 345720)
The calculated parameters of the tutorial case “freeSpaceStream” look strange to me, too. boundaryT is set to 700 K but overallT does only reach about 500.

Sorry but I don't know what you are talking about: In my version of the freeSpaceStream tutorial, the boundaryT field is set to 300K and this is achieved in the overallT temperature. Also, I would highly recommend a small time step to eliminate non-uniformities at the boundaries (if you set a "large" time step, many molecules may enter in "pulses" and then exit with high velocity, causing some unnatural distributions of density and velocity at the boundaries. This is frequently mistaken as a coding error).

I hope these help.

dpham February 27, 2012 04:07

Hey everybody,

First of all, thanks a lot for the explanations, anon_a and Jesgonse. I’ve done some simulations over the weekend and the results look much better now (used a reservoir at the outlet).

Sorry about the freeSpaceStream tutorial. I mixed something up there with the temperatures.

Another case that I am running right now is about heat transfer. The geometry is a simple 2-D rectangle with walls on all sides. boundaryT is 700 K on one side, internalT is 300 K and all other sides have “zeroGradient” as boundaryT. All other parameters in the 0-folder are set to “zeroGradient” and InflowBoundaryModel is “none” due to the absence of patches. This way the whole rectangle should heat up to a constant temperature after some time, right? Unfortunately, the rectangle does not heat up. Only in a very small region close to the heated wall does the overallT reach an increased temperature (about 500 K) but stays at about 300 K everywhere else. For me, it seems like the heat transfer between the wall and the molecules or between the molecules themselves somehow do not work. BinaryCollisionModel is set to “LarsenBorgnakkeVariableHardSphere” and WallInteractionModel to “MaxwellianThermal”. Does anybody have an idea what’s wrong with my case?

Thanks in advance.

anon_a February 27, 2012 09:06


Originally Posted by dpham (Post 346421)
boundaryT is 700 K on one side, internalT is 300 K and all other sides have “zeroGradient” as boundaryT.

You are confusing boundaryT, internalT, internalField and initial temperature.

internalField: This is an entry existing in all quantities. It is the non-boundary value of each quantity, the internal field as the name says. Normally, if you wanted to impose a temperature in the internal field you would change this value in the file T. But dsmcFoam is an exception.

boundaryT: The temperature of the boundary, according to which the boundary Maxwellian is produced. The value given in the "internalField" of this file has no meaning, it is not used anywhere, only the boundary terms make sense.

internalT: This is the part of the temperature associated with internal energy. It is not used for the initial generation of the field.

initial conditions: These are imposed through the system/dsmcInitialiseDict. This is your initial distribution of particles.

Also, there might be a problem in using zeroGradient for boundaryT in DSMC.
Please check that everything is in order and we'll talk again.

dpham February 28, 2012 11:09

Hey anon_a,

I just checked all of the temperature settings and they are as follows:

In the 0-folder, for boundaryT: one wall is set at 700 K, all other wall are at 300 K. The internalField in this file is set to 300 K but as you said, it has no meaning/is not used.

In the constant-folder, for dsmcProperties: Tref of the BinaryCollisionModel is 273 (although I don’t know the meaning of this value)

In the system-folder, for dsmcInitialiseDict: temperature is set as 300K.

Other than these, I didn't find anything else with regard to temperature settings. Did I perhaps miss any, for example where can I find internalT? internalField is also not present in the dsmc solver (except of course in the boundaryT file)?

Is there a way to check if zeroGradient is working properly for boundaryT or can I simply use another condition for my case?

Thank you very much

anon_a February 28, 2012 13:53

How small is this affected area? can you post some pictures?
If it is extremely small, I would bet money that you have used specular boundary conditions in constant/dsmcProperties, especially since you started with the freeSpacePeriodic tutorial. Check for this line:
WallInteractionModel SpecularReflection;
and change it to
WallInteractionModel MaxwellianThermal;
Also study a little on the literature for the kinetic boundary conditions.

Regarding Tref, take a look at Appendix A in Bird's book.

Just forget about setting InternalT, you don't need to do that.
InternalT comes as a result, it is not a prerequisite.

I have only tried to use zeroGradient as a BC for boundaryT a long time ago and I remember it gave me an error (didn't it give you an error?). But it also makes sense: when zeroGradient is used, the boundary value is obtained using values from the internal field (which is meaningless for this file). Therefore, it would produce erroneous results.

anon_a March 2, 2012 05:32

I just noticed that you had mentioned using Maxwellian BCs (yes, 3 days after my post).
Sorry about that! It's a good thing noone called my bet :-)

Did you have any progress after all?

dpham March 2, 2012 10:00

Hey anon_a,
I did some more simulations with your comments in mind. The cell size is 0.01 mm^2 (see picture) where the inlet, outlet, and sides are defined as walls and boundaryT at the inlet is set to 700 K and dsmcInitialiseT is 300 K.

After applying “MaxwellianThermal”(see 1st picture), the temperature near the inlet gets close to the “boundaryT”, but the rest of the rectangle does not heat up. For me, it looks like the molecules at the inlet receive thermal energy from the boundary (as they were initialized at only 300 K) but somehow do not transfer the thermal energy to the rest of the geometry. This might make sense because as I understand, the molecules do not get reflected from the wall when “MaxwellianThermal” is used since this condition is usually for very small geometries/low pressures. Or the “boundaryU” condition (set to “zeroGradient”) could be wrong? Or even the particle-particle interaction (“LarsenBorgnakkeVariableHardSphere” with “Tref” set at 273 K and “relaxationCollisionNumber” at 5.0) could be wrong (see 2nd picture)? In these centerline “overallT” profiles along the length of the rectangle, one can see that initially there is quite a bit of variation in the temperature within the geometry but after some time it reaches equilibrium around 300 K.

For comparison, I applied “SpecularReflection”, but there is no interaction with the heated wall at all (remains at 300 K near the inlet). It looks like the molecules are reflected without absorbing any thermal energy.
I would also like to try the “MixedDiffuseSpecular” condition for my case but I don’t know the syntax. It requires a fraction of Maxwell and reflection, otherwise I get an error. Does anybody know how to use “MixedDiffuseSpecular”?
Also trying to get a copy of Bird’s book, but have not been successful as of yet.
Thank you and have a nice weekend

anon_a March 2, 2012 10:53

Hmmm... it seems that your field is almost not influenced at all by your wall (observe that only the first cell is practically warm). What is your Kn number? If it is too high, then a large temperature jump is justified on the wall. I would run the same simulation for Kn = 0.1, 1, 10 and observe the differences. You can control Kn by adjusting the number density, but make sure you also keep the same number of particles (by adjusting nEquivalentParticles).

Also, I would use fixedValue BCs in the boundaryT and boundaryU files and then, after being sure about my results, I would try zeroGradient (but, again, I seriously doubt that zeroGradient works the correct way).

The "variations" (a.k.a. fluctuations) you observe are due to the statistical noise and are to be expected in DSMC. There is nothing wrong with the models. In order to correct this, you usually average over a lot of time steps in steady state problems (this is what you currently do in overallT, even without knowing it :-) that's why the field is smoother at step 125 than at step 1).

The results regarding specular reflection are, off course, natural.
MixedDiffuseSpecular is practically a combination of MaxwellianThermal and SpecularReflection and its syntax should be something like:

type MixedDiffuseSpecular;
value uniform 300;
diffuseFraction 0.9;

(I did not confirm this before writing). diffuseFraction represents the percentage of molecules interacting diffusely with the wall, while the rest behave specularly.

By the way, what is the purpose of the study?
Have a nice weekend

dpham March 6, 2012 06:33

Hey anon_a,

Thank you very much for your help. I will run a few simulations with different Kn numbers and boundary conditions. As soon as I have any results, I will get back to you.

The future goal will be to simulate gas flows thru nano-porous layers. I have not worked with the dsmc solver before, so I wanted to start with a quite easy case to get familiar with the parameters.


dpham March 14, 2012 06:58


I have run one case with Kn 0.1 and one with Kn 1, where all other conditions were kept the same, such as wall interaction model (Maxwell), collision model (VariableHardSphere) and number of dsmcParticles per cell (4 in average). boundaryT was set to fixedValue as was suggested (or did you mean all boundary conditions should not be zeroGradient?) but there still seems to be no heat transfer from the wall to the rest of the geometry.

Right now, I’m running two more simulations: one with Kn 10 and one with Kn 0.1 and the MixedDiffuseSpecular wall interaction model. Hopefully, the results will be better this time with the syntax (thanks for your help, anon_a):

WallInteractionModel MixedDiffuseSpecular;
value uniform 300;
diffuseFraction 0.9;

In the meantime, a new question came up. Is there an easy way to calculate partial pressures, concentrations of a specific gas, or plot moving molecules? A similar question was already posted some time ago ( and partial pressures have also been discussed for fluent ( Does anybody know how this works with dsmcFoam? I would like to set a different gas composition at the boundary as compare to within the geometry in order to simulate the diffusion of different gas species within the structure. For me, it sounds like the positions of molecules are stored in each time step at lagrangian/dsmc/positions (fits to number of dsmcParticles) and their type in the same folder in typeld (e.g. 0 for N2 and 1 for O2).

Thank you very much

anon_a March 14, 2012 07:41

Could you please post your case here? I am getting very curious about what's going on and can not help you any further otherwise. The mixed boundary condition will not provide anything different since you add specular interaction and this should make things worse.

I have not been really involved with mixtures, so I can not help you with the partial pressures. The particles are indeed stored where you mention. In order to visualize them in with the paraFoam script, activate dsmc in the Mesh parts and your quantity of interest in the Lagrangian fields.

All times are GMT -4. The time now is 16:27.