View Issue Details

IDProjectCategoryView StatusLast Update
0003647OpenFOAMPatchpublic2021-03-24 11:11
ReporterJuho Assigned Towill  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOtherOS Version(please specify)
Product Versiondev 
Fixed in Versiondev 
Summary0003647: multiphaseEulerFoam: linearTsub diameterModel does not find the saturationModels
DescriptionlinearTsub diameterModel still has the old style global saturation model lookup instead of the phase pair specific saturation models used currently. Thus, the saturationModel is not found and diameter is not updated during the simulations.

Modified linearTsubDiameter attached. Changes:
- Updated to use the current phase pair specific saturation models.
- Changed subcooling sign convention to to be compatible with the default parameters
- Added default values to the read function as well
- Print selected parameters to log
TagsNo tags attached.

Activities

Juho

2021-03-24 08:48

reporter  

linearTsubDiameter.C (4,884 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Copyright (C) 2018-2021 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "linearTsubDiameter.H"
#include "phaseSystem.H"
#include "saturationModel.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace diameterModels
{
    defineTypeNameAndDebug(linearTsub, 0);
    addToRunTimeSelectionTable(diameterModel, linearTsub, dictionary);
}
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::diameterModels::linearTsub::linearTsub
(
    const dictionary& diameterProperties,
    const phaseModel& phase
)
:
    spherical(diameterProperties, phase),
    liquidPhaseName_(diameterProperties.lookup("liquidPhase")),
    d2_("d2", dimLength, diameterProperties.lookupOrDefault("d2", 0.0015)),
    Tsub2_(
        "Tsub2",
         dimTemperature,
         diameterProperties.lookupOrDefault("Tsub2", 0)
    ),
    d1_("d1", dimLength, diameterProperties.lookupOrDefault("d1", 0.00015)),
    Tsub1_
    (
        "Tsub1",
        dimTemperature,
        diameterProperties.lookupOrDefault("Tsub1", 13.5)
    ),
    d_
    (
        IOobject
        (
            IOobject::groupName("d", phase.name()),
            phase.time().timeName(),
            phase.mesh()
        ),
        phase.mesh(),
        d1_
    )
{
    Info<< "    d2: " << d2_.value() << endl
        << "    Tsub2: " << Tsub2_.value() << endl
        << "    d1: " << d1_.value() << endl
        << "    Tsub1: " << Tsub1_.value() << endl;
}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::diameterModels::linearTsub::~linearTsub()
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField> Foam::diameterModels::linearTsub::d() const
{
    return d_;
}


void Foam::diameterModels::linearTsub::correct()
{
    // Lookup the fluid model
    const phaseSystem& fluid =
        refCast<const phaseSystem>
        (
            phase().mesh().lookupObject<phaseSystem>("phaseProperties")
        );

    const phaseModel& liquid(fluid.phases()[liquidPhaseName_]);
    const phasePair pair(phase(), liquid);

    if
    (
        phase().mesh().foundObject<saturationModel>
        (
            IOobject::groupName("saturationModel", pair.name())
        )
    )
    {
        const saturationModel& satModel =
            phase().mesh().lookupObject<saturationModel>
            (
                IOobject::groupName("saturationModel", pair.name())
            );

        const volScalarField Tsub
        (
            satModel.Tsat(liquid.thermo().p()) - liquid.thermo().T()
        );

        d_ = max
        (
            d1_,
            min
            (
                d2_,
                (d1_*(Tsub - Tsub2_) + d2_*(Tsub - Tsub1_))/(Tsub2_ - Tsub1_)
            )
        );
    }
}


bool Foam::diameterModels::linearTsub::read(const dictionary& phaseProperties)
{
    spherical::read(phaseProperties);

    diameterProperties().lookup("liquidPhase") >> liquidPhaseName_;
    d2_ = dimensionedScalar
        (
            dimLength,
            diameterProperties().lookupOrDefault<scalar>("d2", 0.0015)
    );
    Tsub2_ = dimensionedScalar
        (
            dimTemperature,
            diameterProperties().lookupOrDefault<scalar>("Tsub2", 0)
        );
    d1_ = dimensionedScalar
        (
            dimLength,
            diameterProperties().lookupOrDefault("d1", 0.00015)
        );
    Tsub1_ = dimensionedScalar
        (
            dimTemperature,
            diameterProperties().lookupOrDefault<scalar>("Tsub1", 13.5)
        );

    return true;
}


// ************************************************************************* //
linearTsubDiameter.C (4,884 bytes)   

will

2021-03-24 09:20

manager   ~0011951

Thanks for the patch, Juho. Small suggestion. Is it possible to use the phase system's lookup instead? It would save doing the name manipulations manually. E.g.:

    if (phase().fluid().foundSubModel<saturationModel>(pair))
    {
        const saturationModel& satModel =
            phase().fluid().lookupSubModel<saturationModel>(pair);

        ...
    }

I'd try it myself, but I don't have a test case with this model active. I assume you do.

Juho

2021-03-24 09:43

reporter   ~0011952

Updated file attached. Much neater this way.
linearTsubDiameter-2.C (4,684 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Copyright (C) 2018-2021 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "linearTsubDiameter.H"
#include "phaseSystem.H"
#include "saturationModel.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace diameterModels
{
    defineTypeNameAndDebug(linearTsub, 0);
    addToRunTimeSelectionTable(diameterModel, linearTsub, dictionary);
}
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::diameterModels::linearTsub::linearTsub
(
    const dictionary& diameterProperties,
    const phaseModel& phase
)
:
    spherical(diameterProperties, phase),
    liquidPhaseName_(diameterProperties.lookup("liquidPhase")),
    d2_("d2", dimLength, diameterProperties.lookupOrDefault("d2", 0.0015)),
    Tsub2_(
        "Tsub2",
         dimTemperature,
         diameterProperties.lookupOrDefault("Tsub2", 0)
    ),
    d1_("d1", dimLength, diameterProperties.lookupOrDefault("d1", 0.00015)),
    Tsub1_
    (
        "Tsub1",
        dimTemperature,
        diameterProperties.lookupOrDefault("Tsub1", 13.5)
    ),
    d_
    (
        IOobject
        (
            IOobject::groupName("d", phase.name()),
            phase.time().timeName(),
            phase.mesh()
        ),
        phase.mesh(),
        d1_
    )
{
    Info<< "    d2: " << d2_.value() << endl
        << "    Tsub2: " << Tsub2_.value() << endl
        << "    d1: " << d1_.value() << endl
        << "    Tsub1: " << Tsub1_.value() << endl;
}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::diameterModels::linearTsub::~linearTsub()
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField> Foam::diameterModels::linearTsub::d() const
{
    return d_;
}


void Foam::diameterModels::linearTsub::correct()
{
    // Lookup the fluid model
    const phaseSystem& fluid =
        refCast<const phaseSystem>
        (
            phase().mesh().lookupObject<phaseSystem>("phaseProperties")
        );

    const phaseModel& liquid(fluid.phases()[liquidPhaseName_]);
    const phasePair pair(phase(), liquid);

    if (fluid.foundSubModel<saturationModel>(pair))
    {
        const saturationModel& satModel =
            fluid.lookupSubModel<saturationModel>(pair);

        const volScalarField Tsub
        (
            satModel.Tsat(liquid.thermo().p()) - liquid.thermo().T()
        );

        d_ = max
        (
            d1_,
            min
            (
                d2_,
                (d1_*(Tsub - Tsub2_) + d2_*(Tsub - Tsub1_))/(Tsub2_ - Tsub1_)
            )
        );
    }
}


bool Foam::diameterModels::linearTsub::read(const dictionary& phaseProperties)
{
    spherical::read(phaseProperties);

    diameterProperties().lookup("liquidPhase") >> liquidPhaseName_;
    d2_ = dimensionedScalar
        (
            dimLength,
            diameterProperties().lookupOrDefault<scalar>("d2", 0.0015)
    );
    Tsub2_ = dimensionedScalar
        (
            dimTemperature,
            diameterProperties().lookupOrDefault<scalar>("Tsub2", 0)
        );
    d1_ = dimensionedScalar
        (
            dimLength,
            diameterProperties().lookupOrDefault("d1", 0.00015)
        );
    Tsub1_ = dimensionedScalar
        (
            dimTemperature,
            diameterProperties().lookupOrDefault<scalar>("Tsub1", 13.5)
        );

    return true;
}


// ************************************************************************* //
linearTsubDiameter-2.C (4,684 bytes)   

will

2021-03-24 11:11

manager   ~0011953

Thanks for that. Pushed as commit https://github.com/OpenFOAM/OpenFOAM-dev/commit/42a558a1b0596896a244ce0489545421aa6260bf

Issue History

Date Modified Username Field Change
2021-03-24 08:48 Juho New Issue
2021-03-24 08:48 Juho File Added: linearTsubDiameter.C
2021-03-24 09:20 will Note Added: 0011951
2021-03-24 09:43 Juho File Added: linearTsubDiameter-2.C
2021-03-24 09:43 Juho Note Added: 0011952
2021-03-24 11:11 will Assigned To => will
2021-03-24 11:11 will Status new => resolved
2021-03-24 11:11 will Resolution open => fixed
2021-03-24 11:11 will Fixed in Version => dev
2021-03-24 11:11 will Note Added: 0011953