CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   2D nozzle in rhoSimpleFoam (https://www.cfd-online.com/Forums/openfoam-solving/186174-2d-nozzle-rhosimplefoam.html)

johny0688 April 12, 2017 07:49

2D nozzle in rhoSimpleFoam
 
1 Attachment(s)
Hello all,
I'm loosing patient with OF. I'm trying to calculate simple nozzle like in attachment. Inlet at left outlet at right, front and back empty, rest are wall. I use HELYX OS to prepare case. I want to use compressible SST model. At bottom I paste the "0" files.

For k
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object k;
}
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 0.01;
boundaryField
{
    frontandback
    {
        type empty;
    }

    inlet
    {
        type turbulentIntensityKineticEnergyInlet;
        value uniform 0.01;
        intensity 0.05;
    }

    outlet
    {
        type turbulentIntensityKineticEnergyInlet;
        value uniform 0.01;
        intensity 0.05;
    }

    wall
    {
        type kqRWallFunction;
        value uniform 1e-20;
    }

}

For Omega
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object omega;
}
dimensions [ 0 0 -1 0 0 0 0 ];
internalField uniform 0.0;
boundaryField
{
    frontandback
    {
        type empty;
    }

    inlet
    {
        type turbulentMixingLengthFrequencyInlet;
        value uniform 0.01;
        mixingLength 0.1;
    }

    outlet
    {
        type turbulentMixingLengthFrequencyInlet;
        value uniform 0.01;
        mixingLength 0.1;
    }

    wall
    {
        type omegaWallFunction;
        value uniform 1;
    }

}

For p
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object p;
}
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 100000.0;
boundaryField
{
    frontandback
    {
        type empty;
    }

    inlet
    {
        type totalPressure;
        value uniform 0.0;
        p0 uniform 300000.0;
        gamma 1.4;
    }

    outlet
    {
        type totalPressure;
        value uniform 0.0;
        p0 uniform 100000.0;
        gamma 1.4;
    }

    wall
    {
        type zeroGradient;
    }

}

for U
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volVectorField;
    location "0";
    object U;
}
dimensions [ 0 1 -1 0 0 0 0 ];
internalField uniform (0.0 0.0 0.0);
boundaryField
{
    frontandback
    {
        type empty;
    }

    inlet
    {
        type zeroGradient;
        value uniform ( 0.0 0.0 0.0 );
    }

    outlet
    {
        type zeroGradient;
        value uniform ( 0.0 0.0 0.0 );
    }

    wall
    {
        type fixedValue;
        value uniform ( 0 0 0);
    }

}

Output
Code:

******************
*    Run Case    *
******************
Case        : /home/jan/open_test/nozzle
Procs        : -1
Log          : /home/jan/open_test/nozzle/log/rhoSimpleFoam.log
Env          : /opt/openfoam4/etc/bashrc
Vendor      : /opt
Paraview    :
MachineFile  :
Solver      : rhoSimpleFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  4.1                                  |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 4.1
Exec  : rhoSimpleFoam -case /home/jan/open_test/nozzle
Date  : Apr 12 2017
Time  : 13:29:29
Host  : "jan-VirtualBox"
PID    : 29271
Case  : /home/jan/open_test/nozzle
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

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

Create mesh for time = 0


SIMPLE: convergence criteria
    field U        tolerance 1e-05
    field k        tolerance 1e-05
    field epsilon        tolerance 1e-05
    field omega        tolerance 1e-05
    field nuTilda        tolerance 1e-05
    field T        tolerance 1e-05
    field p_rgh        tolerance 1e-05
    field p        tolerance 1e-05

Reading thermophysical properties

Selecting thermodynamics package
{
    type            hePsiThermo;
    mixture        pureMixture;
    transport      const;
    thermo          hConst;
    equationOfState perfectGas;
    specie          specie;
    energy          sensibleEnthalpy;
}

Reading field U

Reading/calculating face flux field phi

Creating turbulence model

Selecting turbulence model type RAS
Selecting RAS turbulence model kOmegaSST
Selecting patchDistMethod meshWave
bounding omega, min: 0 max: 0.01 average: 0
kOmegaSSTCoeffs
{
    label          "k-\u03C9 SST";
    fieldMaps
    {
        k              k;
        omega          omega;
        nut            nut;
        alphat          alphatCompressible;
    }
    alphaK1        0.85034;
    alphaK2        1;
    alphaOmega1    0.5;
    alphaOmega2    0.85616;
    gamma1          0.5532;
    gamma2          0.4403;
    beta1          0.075;
    beta2          0.0828;
    betaStar        0.09;
    a1              0.31;
    c1              10;
    Cmu            0.09;
    alphah          1.111;
    b1              1;
    F3              false;
}

Creating MRF zone list from MRFProperties
Creating finite volume options from "system/fvOptions"

#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::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > > >, Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > >::F2() const at ??:?
#6  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > > >, Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > >::F23() const at ??:?
#7  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > > >, Foam::EddyDiffusivity<Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::fluidThermo> > > >::correctNut() at ??:?
#8  ? at ??:?
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? at ??:?
/home/jan/open_test/nozzle/solver_serial.run: line 32: 29271 Floating point exception(core dumped) $SOLVER -case $CASE 2>&1
    29272 Done                    | tee -a $LOG

I tried different BC different initialization and there is no way to start the calculation. What I am doing wrong? It is the simplest case I can imagine and even this can run.

Please help me because I'm sick of OF right now.

me3840 April 13, 2017 11:52

Your boundary conditions don't make any sense. Why do k and omega have inlet conditions specified for the outlet? Is it really reasonable to initialize omega as zero everywhere?

From the error the problem is clearly in the turbulence model. Have you tried disabling it and seeing if the case runs to check if everything else is OK?

Does it make sense to specify total pressure on the inlet and outlet? I think it only makes sense to do so on the inlet. The outlet should be a static pressure.

johny0688 April 14, 2017 03:01

5 Attachment(s)
Thank you for your respond.
I tried lamina flow which worked fine, even Spalart-Allamaras seams to be stable and give good results. But for k-epsilon and SST it is very hard to run calculation. It usually collapsed after few iteration.
In previous post is only an example of of BC. As you said I tried total pressure at inlet and fixedValue at outlet for velocity both was zeroGradient.
Is it good to use zeroGradient for velocity with totalPressure? Or should I use pressureInletVelocity?
I also tried different initialization. I affect in one or few iteration more but no more than six to seven.
I changed mesh for hexa and tried calculation by rhoPimpleFoam with adaptive deltaT and courant number < 0.8. It also collapsed but give results (find in attachment). How to initialize k and omega while it has very different value in different place in model? The nozzle is very simple model, I can't image problem with more complex one with multiple inlet and outlet.
I'm new in FOAM I used to work with fluent.

One more question, I use openFOAM on virtualBox Ubuntu. Could it produce errors in calculation?

johny0688 April 14, 2017 09:34

Ok, i manage to run with different boundary condition. I used fixed velocity at inlet. With totalPressure it didn't work.
U
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volVectorField;
    location "0";
    object U;
}
dimensions [ 0 1 -1 0 0 0 0 ];
internalField uniform (0.0 0.0 0.0);
boundaryField
{
    front
    {
        type empty;
    }

    inlet
    {
        type fixedValue;
        value uniform ( 5.0 0.0 0.0 );
    }

    outlet
    {
        type pressureInletOutletVelocity;
        value uniform ( 0 0 0);
    }

    wall
    {
        type fixedValue;
        value uniform ( 0 0 0);
    }

    back
    {
        type empty;
    }

}

p
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object p;
}
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 100000.0;
boundaryField
{
    front
    {
        type empty;
    }

    inlet
    {
        type zeroGradient;
    }

    outlet
    {
        type totalPressure;
        p0 uniform 100000.0;
        value uniform 1e5;
        rho rho;
        psi none;
        U U;
        phi phi;
        gamma 1.0;
    }

    wall
    {
        type zeroGradient;
    }

    back
    {
        type empty;
    }

}

k
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object k;
}
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 0.3;
boundaryField
{
    front
    {
        type empty;
    }

    inlet
    {
        type fixedValue;
        value uniform 0.3;
    }

    outlet
    {
        type inletOutlet;
        value uniform 0.1;
        inletValue uniform 2.0;
    }

    wall
    {
        type kqRWallFunction;
        value uniform 1e-20;
    }

    back
    {
        type empty;
    }

}

omega
Code:

/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HELYX-OS                                                  |
|  o  O  o      | Version: v2.4.0                                          |
|    o    o      | Web:    http://www.engys.com                            |
|      o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "0";
    object omega;
}
dimensions [ 0 0 -1 0 0 0 0 ];
internalField uniform 78.9;
boundaryField
{
    front
    {
        type empty;
    }

    inlet
    {
        type fixedValue;
        value uniform 78.9;
    }

    outlet
    {
        type inletOutlet;
        value uniform 0.1;
        inletValue uniform 100.0;
    }

    wall
    {
        type omegaWallFunction;
        value uniform 1;
    }

    back
    {
        type empty;
    }

}

I calculated values for k and omega at inlet by instruction:
https://www.cfd-online.com/Wiki/Turb...ary_conditions

but with the same strategy for different inlet velocity the problem with starting occurred again. It is impossible to run calculation.
How can I estimate the value for k and omega as I don't know anything about outlet condition? And how to estimate initial value? By the way in fluent it almost doesn't matter what initial value you set. It usually works perfect for initialize all with 0 values. Why openFOAM is so sensitive for initialization?

me3840
What boundary condition will you suggest for this calculation?

piu58 April 14, 2017 10:03

I don't understand which physical reality you want to cover with your rather complicated initiat conditions for k and \omega. Why don't you use constant value at the inlet and in the field and zero gradient in the outlet region? Why do you set the whole outlet plane to a constant pressure?

me3840 April 14, 2017 10:36

Quote:

Originally Posted by johny0688 (Post 644912)

How can I estimate the value for k and omega as I don't know anything about outlet condition?

Why would you need to specify these values at the outlet? Think about this. Do you have to specify velocity at the outlet? Why not?

Quote:

Originally Posted by johny0688 (Post 644912)

And how to estimate initial value?

It looks like you did that yourself already.

Quote:

Originally Posted by johny0688 (Post 644912)
By the way in fluent it almost doesn't matter what initial value you set. It usually works perfect for initialize all with 0 values. Why openFOAM is so sensitive for initialization?

First, Fluent is a commercial code. There are lots of tricks and code developed that do things automatically for you to get to a solution quickly. This doesn't mean those tricks are always a good idea, but you have no real clue as to what it's doing.

In reality many flows do not see great changes from changes in turbulence initial conditions, OpenFOAM doesn't change that. We have not established that OpenFOAM is being sensitive to these values, there can be lots of other things wrong with your simulation.

Just because something 'works' in another code doesn't make it right. The whole point of an initial solution is to be somewhat close to the final one. Making everything 0 everywhere just makes your life harder, but it probably won't change the answer if the model converges.

Quote:

Originally Posted by johny0688 (Post 644912)
What boundary condition will you suggest for this calculation?

Start with standard, easy boundary conditions for this type of flow. Total pressure in, static pressure out or velocity in, pressure out. Start by lowering your inlet velocity/pressure so that the flow isn't getting into high mach numbers.

rhoSimpleFoam is not very stable for these kinds of simulations in the first place. You will probably have to start with low pressure ratios and work your way up. This may only be runnable with a transient solver, or rhoCentralFoam.

johny0688 April 20, 2017 03:04

Thank you all for respond.
Quote:

Start with standard, easy boundary conditions for this type of flow.
I used at inlet fixedValue velocity and zeroGradient for pressure for turbulence i calculated k and omega. At outlet zeroGradient for velocity and fixedValue for pressure and zeroGradient for turbulence. I initialized with uniform(0 0 0) velocity, uniform 100000 pressure (the same value as at outlet). Turbulence I initialized by the same value as at inlet. It worked for low velocity for higher it was impossible to start calculation, and also as I said before it is very sensitive for k and omega initialization.

Quote:

Start by lowering your inlet velocity/pressure so that the flow isn't getting into high mach numbers.
Good idea, but how to increase the velocity at inlet during calculation? I read about groovyBC but I found that swak4foam doesn't work with openFOAM v4.1. When I tried to change velocity at inlet in HELYX during the calculation, results was completely rubbish.

karamiag May 9, 2017 02:39

I think the last post of this thread could help.

arjun May 9, 2017 02:55

Quote:

Originally Posted by me3840 (Post 644928)

First, Fluent is a commercial code. There are lots of tricks and code developed that do things automatically for you to get to a solution quickly. This doesn't mean those tricks are always a good idea, but you have no real clue as to what it's doing.

If tricks are to get solution quickly then how they are a bad idea? I thought getting solution efficiently is one big part of why someone would pay for something like fluent.

Quote:

Originally Posted by me3840 (Post 644928)

Just because something 'works' in another code doesn't make it right.

So as long as it does not work in openfoam it is right and when it would work in openfoam (after lots of efforts), are you saying that it is not necessarily be going to be right? (since now it works)

enginpower May 9, 2017 08:24

Hi all,
I have the same problem with rhoSimpleFoam using OpenFoam and not Helyx.
I described my case here
Surely your case will generally work also for me

@johny0688 Could you share the working boundary conditions you set to start your simulation.

Thanks

johny0688 May 9, 2017 08:29

karamiag
Thank you for good advice.

Now I'm further with simulation, I'm calculating different model (I don't have access to computer at work, when I do I will paste the pictures). I manage to increase the velocity and pressure at BC during the calculation by table depends on time. I also initialize domain with different values by setFieldsDict. I realized that after some timesteps the temperature grows to enormous value. By analyzing step by step I found that it occurred wherever inside the domain even if the flow is very slow. So I bounded the temperature in fvOptions. Now the case works but only with rhoPimpleFoam (transient). Still the Courant number is very high over 3 with timeStep 2e-8 so the simulation take very long to reaches steady flow. At the end of this week I will try to run case with rhoSimpleFoam including yours advice. Will find out if it helps :)

Quote:

If tricks are to get solution quickly then how they are a bad idea? I thought getting solution efficiently is one big part of why someone would pay for something like fluent.
I agree. OpenFoam as open source never will be better than Fluent or CFX. Maybe it can give the same results as Fluent but how long it take to run calculations? OpenFoam is good for academic but not for industry. In industry the most important is time.

Quote:

So as long as it does not work in openfoam it is right and when it would work in openfoam (after lots of efforts), are you saying that it is not necessarily be going to be right? (since now it works)
I think me3840 wanted to say that if my initial conditions work in Fluent it does not mean that they are good. They can be very wrong but Fluent can handle this. Now ANSYS heads to create software to be, I can say 'noobresistant'. Is it good? No coment.

I will post all my cases when I get acces to computer at work.

All the best,

arjun May 9, 2017 13:21

Quote:

Originally Posted by johny0688 (Post 648191)
karamiag
Thank you for good advice.

Now I'm further with simulation, I'm calculating different model (I don't have access to computer at work, when I do I will paste the pictures). I manage to increase the velocity and pressure at BC during the calculation by table depends on time. I also initialize domain with different values by setFieldsDict. I realized that after some timesteps the temperature grows to enormous value. By analyzing step by step I found that it occurred wherever inside the domain even if the flow is very slow. So I bounded the temperature in fvOptions. Now the case works but only with rhoPimpleFoam (transient). Still the Courant number is very high over 3 with timeStep 2e-8 so the simulation take very long to reaches steady flow. At the end of this week I will try to run case with rhoSimpleFoam including yours advice. Will find out if it helps :)


I agree. OpenFoam as open source never will be better than Fluent or CFX. Maybe it can give the same results as Fluent but how long it take to run calculations? OpenFoam is good for academic but not for industry. In industry the most important is time.


I think me3840 wanted to say that if my initial conditions work in Fluent it does not mean that they are good. They can be very wrong but Fluent can handle this. Now ANSYS heads to create software to be, I can say 'noobresistant'. Is it good? No coment.

I will post all my cases when I get acces to computer at work.

All the best,

I was developer for starccm+ and I benchmarked it internally and have studied its code. I can not divulge the details but I can vouch that effort put to make the code accurate is far greater than I could have imagined. There are no corners cut for stability, in fact accuracy gets the most priority. Since many developers who wrote this were also developers at fluent i assume that fluent it the same.


I have seen openFOAM's code too and it is nowhere near in terms of following things for accuracy.

I carried the same attitude for FVUS, that is accuracy first, then stability and it has to be stable for industrial cases.


PS: Samir muzaferija once told me that let the solver diverge and then user fix the mesh then to give it stable and inaccurate results. This he said when i was showing him how I can make a very difficult case stable that has near zero or negative cell volumes. He also said that lot of money riding on it so inaccurate results are big No No.


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