CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Particle injection with normal distribution of density

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 28, 2023, 03:36
Default Particle injection with normal distribution of density
  #1
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Hello guys, I'm trying to implement into my kinematicCloudProperties file normal distribution of particle density. Trying with this code but it doesn't work.
Code:
constantProperties
{
    rho0
    {
             type            normal;
             normalDistribution
             {
                 mu              1300;
                 sigma           50;
                 minValue        1150;
                 maxValue        1450;
             }
    }

    alphaMax        0.99;
}
I'm getting this error:
Code:
--> FOAM FATAL IO ERROR: (openfoam-2212 patch=230110)
Attempt to return dictionary entry as a primitive

file: constant/kinematicCloudProperties.constantProperties.rho0 at line 54 to 60.
Is it even possible to do this?
lolo7331 is offline   Reply With Quote

Old   April 28, 2023, 20:10
Default
  #2
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
That is not supported in OpenFOAM. You need to modify the code. If you will do that then I think it would be easier to implement it under the injection model instead of using constantProperties dictionary.
dscian is offline   Reply With Quote

Old   May 10, 2023, 16:24
Default
  #3
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by dscian View Post
That is not supported in OpenFOAM. You need to modify the code. If you will do that then I think it would be easier to implement it under the injection model instead of using constantProperties dictionary.
Do you have any idea how to do that?
Thanks
lolo7331 is offline   Reply With Quote

Old   May 11, 2023, 04:10
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hello,

There are examples in the tutorials, for instance here: https://develop.openfoam.com/Develop...loudProperties

Hope this helps,
Yann
Yann is offline   Reply With Quote

Old   May 11, 2023, 06:46
Default
  #5
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by Yann View Post
Hello,

There are examples in the tutorials, for instance here: https://develop.openfoam.com/Develop...loudProperties

Hope this helps,
Yann
Thanks for the reply. So, I'm trying to combine sizeDistribution with distribution of density within the particles. I tried to implement it like this, but the simulation just ends with SOI.

Code:
    
injectionModels
    {
        model1
        {
            type            manualInjection;
            massTotal       0;
            parcelBasisType fixed;
            nParticle       1;
            SOI             0;
            positionsFile   "kinematicCloudPositions";
            U0              (0 0 0);
            rho0
	    {
	            sizeDistribution
         		   {
             			   type            normal;
           		  	   normalDistribution
             			   {
             			       mu              1300;
              			       sigma           50;
               			       minValue        1150;
               			       maxValue        1450;
         			    }
      		            }
	    }

            sizeDistribution
            {
                type            uniform;
                uniformDistribution
                {
                    minValue        2e-4;
                    maxValue        7e-4;
                }
            }
       }
    }
lolo7331 is offline   Reply With Quote

Old   May 11, 2023, 19:21
Default
  #6
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
The attached PatchInjection code assigns density value within the injection model definition, but it must be a scalar value, so constant. You may go from there.

In the same file, the following part of the code is responsible for the size distribution
Code:
    sizeDistribution_
    (
        distributionModel::New
        (
            this->coeffDict().subDict("sizeDistribution"),
            owner.rndGen()
        )
    )
and it assigns the diameter in
Code:
    // set particle diameter
    parcel.d() = sizeDistribution_->sample();
You may define another distributionModel for density (i.e densityDistribution_)
Code:
    densityDistribution_
    (
        distributionModel::New
        (
            this->coeffDict().subDict("densityDistribution"),
            owner.rndGen()
        )
    )
and use that object for density in the following line
Code:
    // set particle density
    parcel.rho() = densityDistribution_->sample(); // rho0_
Hope that works.
Attached Files
File Type: c PatchInjection.C (5.4 KB, 6 views)
File Type: h PatchInjection.H (5.4 KB, 6 views)
dscian is offline   Reply With Quote

Old   May 12, 2023, 10:06
Default
  #7
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by dscian View Post
The attached PatchInjection code assigns density value within the injection model definition, but it must be a scalar value, so constant. You may go from there.

In the same file, the following part of the code is responsible for the size distribution
Code:
    sizeDistribution_
    (
        distributionModel::New
        (
            this->coeffDict().subDict("sizeDistribution"),
            owner.rndGen()
        )
    )
and it assigns the diameter in
Code:
    // set particle diameter
    parcel.d() = sizeDistribution_->sample();
You may define another distributionModel for density (i.e densityDistribution_)
Code:
    densityDistribution_
    (
        distributionModel::New
        (
            this->coeffDict().subDict("densityDistribution"),
            owner.rndGen()
        )
    )
and use that object for density in the following line
Code:
    // set particle density
    parcel.rho() = densityDistribution_->sample(); // rho0_
Hope that works.
Thanks for the reply. Although, I am setting up the simulation with manual injection, therefore I should be looking at ManualInjection(.C, .H)? But my manual injection file (and also PatchInjection.C file) doesn't contain rho0 defined inside of it. I have found inside \usr\lib\openfoam\openfoam2212\src\lagrangian\inte rmediate\clouds\Templates\KinematicCloud rho0 defined as:
Code:
{
    // If rho0 is given in the const properties
    if (constProps_.rho0() != -1)
    {
        parcel.rho() = constProps_.rho0();
    }
}
Could I redefine it here somehow?
Attached Files
File Type: c KinematicCloud.C (22.3 KB, 3 views)
File Type: c ManualInjection.C (6.1 KB, 2 views)
lolo7331 is offline   Reply With Quote

Old   May 12, 2023, 16:04
Default
  #8
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
The files I attached have the density update, so you can reference that. Those are the modifications I made. You'll add 3 lines in ManualInjection.C file and 1 line in ManualInjection.H file.

The density is set with the value in constantProperties, though that won't matter because the density update in the injection model will overwrite it.
dscian is offline   Reply With Quote

Old   May 12, 2023, 18:01
Default
  #9
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by dscian View Post
The files I attached have the density update, so you can reference that. Those are the modifications I made. You'll add 3 lines in ManualInjection.C file and 1 line in ManualInjection.H file.

The density is set with the value in constantProperties, though that won't matter because the density update in the injection model will overwrite it.
This is the code I'm trying, but the simulation stops at SOI. I have uploaded the files that I edited also.
Code:
constantProperties
{
}

subModels
{
    particleForces
    {
        gravity;
        interface
        {
            C            -10;
            alpha        alpha.water;
        }
    }

    injectionModels
    {
        model1
        {
            type            manualInjection;
            massTotal       0;
            parcelBasisType fixed;
            nParticle       1;
            SOI             0;
            positionsFile   "kinematicCloudPositions";
            U0              (0 0 0);
            densityDistribution
            {
                type            uniform;
                uniformDistribution
                {
                    minValue        1350;
                    maxValue        1600;
                }
            }
            sizeDistribution
            {
                type            uniform;
                uniformDistribution
                {
                    minValue        2e-4;
                    maxValue        7e-4;
                }
            }
       }
    }
Code:
...
Selecting U integration scheme Euler
Selecting turbulence model type laminar
Selecting laminar stress model Stokes
No MRF models present

No finite volume options present
DICPCG:  Solving for pcorr, Initial residual = 1, Final residual = 8.60384e-06, No Iterations 44
time step continuity errors : sum local = 1, global = 1, cumulative = 1
Courant Number mean: 0.0403565 max: 1.83827

Starting time loop

Courant Number mean: 0.00403565 max: 0.183827
Interface Courant Number mean: 0 max: 0
deltaT = 0.05
Time = 0.05

Evolving kinematicCloud

Solving3-D cloud kinematicCloud
openfoam2212:....
Attached Files
File Type: c ManualInjection.C (6.2 KB, 1 views)
File Type: h ManualInjection.H (5.6 KB, 1 views)
lolo7331 is offline   Reply With Quote

Old   May 12, 2023, 19:34
Default
  #10
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
The code is doing nothing for the density. Try adding the following in "setProperties" function.

Code:
    // set particle diameter
    parcel.rho() = densityDistribution_->sample();
dscian is offline   Reply With Quote

Old   May 13, 2023, 04:08
Default
  #11
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by dscian View Post
The code is doing nothing for the density. Try adding the following in "setProperties" function.

Code:
    // set particle diameter
    parcel.rho() = densityDistribution_->sample();
Still, unfortunately it's not affecting anything. The injection won't start unless I set rho0 to some value.
lolo7331 is offline   Reply With Quote

Old   May 14, 2023, 05:18
Default
  #12
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
You should define something for rho0 but since the sampling using the density distribution object in ManualInjection will overwrite that value, I'd expect different densities in the simulation.
dscian is offline   Reply With Quote

Old   May 25, 2023, 12:13
Smile
  #13
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Quote:
Originally Posted by dscian View Post
You should define something for rho0 but since the sampling using the density distribution object in ManualInjection will overwrite that value, I'd expect different densities in the simulation.
I've tried to change the ManualInjection files multiple times using different ways, but with no success. Always getting same density for all particles. Could be I'm missing something?
Thanks
lolo7331 is offline   Reply With Quote

Old   May 31, 2023, 07:41
Default
  #14
Senior Member
 
alainislas's Avatar
 
Alain Islas
Join Date: Nov 2019
Location: Mexico
Posts: 142
Rep Power: 7
alainislas is on a distinguished road
May I ask why do you want to inject particles with different densities? What is the purpose? To represent different materials? If you do so, not only the density will change, but also the other particle properties, like cp, epsilon0, f0, composition, etc...



PLease keep in mind that based on your total mass to inject, parcelBasisType and particle diameter, OpenFOAM adjusts the nParticles in each parcel. IF you really want to inject different materials I wouldnt change rho0, because by default in OpenFOAM this is meant to be a constant property for particles (except for reactive particles). I would simply inject additional clouds, and change rho0 there. Also I think you are missing the flag "duration" to tell OpenFOAM for how long your particles will be injected.
alainislas is offline   Reply With Quote

Old   August 13, 2023, 12:15
Default
  #15
New Member
 
Italy
Join Date: Apr 2022
Posts: 12
Rep Power: 4
lolo7331 is on a distinguished road
Could the definition of rho_ be changed within "KinematicParcelI.H" file? I've tried with a couple of different ways, but it doesn't work. This should work?

Code:
template<class ParcelType>
inline Foam::KinematicParcel<ParcelType>::KinematicParcel
(
    const polyMesh& owner,
    const barycentric& coordinates,
    const label celli,
    const label tetFacei,
    const label tetPti,
    const label typeId,
    const scalar nParticle0,
    const scalar d0,
    const scalar dTarget0,
    const vector& U0,
    const constantProperties& constProps
)
:
    ParcelType(owner, coordinates, celli, tetFacei, tetPti),
    active_(true),
    typeId_(typeId),
    nParticle_(nParticle0),
    d_(d0),
    dTarget_(dTarget0),
    U_(U0),
    rho_(constProps.rho0()),
    age_(0.0),
    tTurb_(0.0),
    UTurb_(Zero)
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::normal_distribution<> normalDist(constProps.rho0(), 10.0);
    rho_ = normalDist(gen);
}

Last edited by lolo7331; August 16, 2023 at 12:07.
lolo7331 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Lagrangian] Injection model for two density classes within one cloud m.kurjata OpenFOAM Pre-Processing 4 November 6, 2022 14:12
[snappyHexMesh] Invalid Normals for source face to target face while making AMI? Sorabh OpenFOAM Meshing & Mesh Conversion 1 August 3, 2021 07:35
Need help setting up chtMultiRegion OskarT OpenFOAM Pre-Processing 1 September 25, 2019 16:51
particle size distribution -Introduce the Log Normal Distribution- souria FLUENT 0 January 25, 2016 08:35
Particle velocity - Injection With Line Weighting Danuta CFX 0 October 10, 2007 07:21


All times are GMT -4. The time now is 21:19.