CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [Other] Injection molding solver for OpenFOAM (https://www.cfd-online.com/Forums/openfoam-community-contributions/188392-injection-molding-solver-openfoam.html)

krikre May 29, 2017 06:44

Injection molding solver for OpenFOAM
 
Hello everybody!

I'd like to invite anyone who's interested to try out our solver for injection molding https://github.com/krebeljk/openInjMoldSim. I'd be very grateful for any kind of feedback.

We implemented the Tait-equation of state and the Cross-WLF model in compressibleInterFoam from OpenFOAM version 3.0.1 and named it openInjMoldSim. Along the solver there are four cases: a demo case for filling and packing and three tests.

The demonstration of filling and packing compares the simulated pressures with experimental values. The cavity is modeled as a 2D case. The experimental pressure evolution from the first measuring position is imposed at one end of the cavity and the other two positions are compared.

The validations test
  • the Cross-WLF viscosity in a perfect shearing flow at a particular temperature,
  • the heat transfer coefficient in a quasi 1D dimensional heat conduction case and
  • the Tait equation for a confined material being heated and pressurized.

The cases include gnuplot and python scripts to plot the results.

krikre June 8, 2017 10:17

Trouble finding a converged solution
 
5 Attachment(s)
Edit:
It looks like a common convergence issue. I'm looking into:
https://www.cfd-online.com/Forums/fl...tml#post314914
https://www.cfd-online.com/Forums/op...tml#post637083
Also, I think there was a mistake in the fvSolution file, where under-relaxation for p was set instead of p_rgh.


Trouble finding a converged solution
I'd like to ask for some help with setting up the demo case. The simulation finishes but the solution looks invalid. So far I tried setting stricter convergence tolerances but with limited success.
I described the case and what I tried in a readme file in the repository on a new branch. Please see the link, because there are more images and details (plus all the files).

I first copied the demo case (fill_pack_00) and simplified it: made the flow practically single phase and more or less isothermal (cases pack_01 ... pack_04). The tolerances were made stricter in the cases pack_05 ... pack_09. This was then also attempted in the demo case: fill_pack_01.

In the following I try to state the relevant facts so the text is a bit dull, but please let me know if there's something else I can provide.

The case (fill_pack_00)
The solver used is basically compressibleInterFoam (OpenFOAM 3.0.1) but with some modifications. Cavity (2D) of 1.2 mm thickness and length of approx. 65 mm is being filled by polymer (melt temperature 230 degC) through the inlet - a pressure boundary condition is prescribed and the experimental pressure evolution P1 is imposed. When the cavity is full (t=0.15s), the outlet is closed and the pressure is still applied at the inlet forcing the material to compress. At the same time the polymer is cooling (mold temperature 50 degC) - heat transfer coefficient on the walls 1.25 kW/(m2K). At about 100 degC the material solidifies - the viscosity is increased to 100 MPas.
Note also, that the viscosity is pressure dependent. Removing the dependence appears to make the issue less severe but not vanish.
The packing phase is divided into pack1 phase with the result write frequency of 0.01s and pack2 phase starting at t=1s and the result write frequency of 0.1s finishing at t=6s.

https://www.cfd-online.com/Forums/at..._pack_geom.jpg

The issue
The cavity pressure should not be greater than the injection pressure. A smoother solution is expected.
https://www.cfd-online.com/Forums/at...ll_pack_00.png

Simplification (cases: pack_01, ...)
The demo case is copied and the simulation of the filling stage is removed (skipped) by modifying the AllRun script. The call to setFields is also removed to simply start with a full cavity.
The mold temperature is set to 230 degC which is equal to the melt temperature making heat transfer insignificant, again eliminating complexity. The outlet patch still transfers heat (mold temperature 50 degC by mistake) but this has little effect.
https://www.cfd-online.com/Forums/at...am-pack_04.png

Attempt to resolve

A fixed timestep of 1e-5s is prescribed - at least 10 times shorter than the automatically chosen in pack_04. One second of simulated time required almost 3h of calculation on a laptop. The result appears resonable.
https://www.cfd-online.com/Forums/at...am-pack_05.png

Alternative attempt
The PIMPLE p_rgh tolerance set to 1e-5 Pa. Solution improved with respect to the case pack_04. Calculation takes 30 min on a regular laptop.
The value 1e-5 Pa made the solver do more iterations but has no physical significance.

Applying the alternative atempt to the demo case
The anomaly at the start of packing is resolved but the issue remains. Non-smoothness is evident at t=1s which is when the pack2 phase starts.
https://www.cfd-online.com/Forums/at...ll_pack_01.png

Setup for the pack_04 case
fvSolution
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  3.0.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    alpha.poly
    {
        nAlphaCorr      1;
        nAlphaSubCycles 1;
        cAlpha          1;
    }

    ".*(rho|rhoFinal)"
    {
        solver          diagonal;
    }

    pcorr
    {
        solver          PCG;
        preconditioner
        {
            preconditioner  GAMG;
            tolerance      1e-05;
            relTol          0;
            smoother        DICGaussSeidel;
            nPreSweeps      0;
            nPostSweeps    2;
            nFinestSweeps  2;
            cacheAgglomeration true;
            nCellsInCoarsestLevel 10;
            agglomerator    faceAreaPair;
            mergeLevels    1;
        }
        tolerance      1e-05;
        relTol          0;
        maxIter        100;
    }

    p_rgh
    {
        solver          GAMG;
        tolerance      1e-07;
        relTol          0.01;
        smoother        DIC;
        nPreSweeps      0;
        nPostSweeps    2;
        nFinestSweeps  2;
        cacheAgglomeration true;
        nCellsInCoarsestLevel 10;
        agglomerator    faceAreaPair;
        mergeLevels    1;
    }

    p_rghFinal
    {
        solver          PCG;
        preconditioner
        {
            preconditioner  GAMG;
            tolerance      1e-07;
            relTol          0;
            nVcycles        2;
            smoother        DICGaussSeidel;
            nPreSweeps      2;
            nPostSweeps    2;
            nFinestSweeps  2;
            cacheAgglomeration true;
            nCellsInCoarsestLevel 10;
            agglomerator    faceAreaPair;
            mergeLevels    1;
        }
        tolerance      1e-07;
        relTol          0;
        maxIter        20;
    }

    U
    {
        solver          smoothSolver;
        smoother        GaussSeidel;
        tolerance      1e-06;
        relTol          0;
        nSweeps        1;
    }

    "(T|k|B|nuTilda).*"
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance      1e-08;
        relTol          0;
    }
}

PIMPLE
{
    momentumPredictor no;
    transonic      no;
    nOuterCorrectors 1000;
    nCorrectors    2;
    nNonOrthogonalCorrectors 0;

    residualControl
    {
        p_rgh
        {
                tolerance  1.0;
                relTol      0;
        }
        T
        {
                tolerance  0.01;
                relTol      0;
        }
        /*p
        {
                tolerance  1e6;
                relTol      1e-2;
        }*/
    }
}

relaxationFactors
{
    fields
    {
        p      0.3;
        pFinal  1;
        T      0.3;
    }
    equations
    {
        "U|k|epsilon|T"    0.3;
        "(U|k|epsilon|T)Final"  1;
    }
}


// ************************************************************************* //

fvSchemes
I haven't tried anything new in this file.
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  3.0.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default        Euler;
}

gradSchemes
{
    default        Gauss linear;
}

divSchemes
{
    div(phi,alpha)  Gauss vanLeer;
    div(phirb,alpha) Gauss linear;

    div(rhoPhi,U)  Gauss upwind;
    div(phi,thermo:rho.poly) Gauss upwind;
    div(phi,thermo:rho.air) Gauss upwind;
    div(rhoPhi,T)  Gauss upwind;
    div(rhoPhi,K)  Gauss upwind;
    div(phi,p)      Gauss upwind;
    div(phi,k)      Gauss upwind;

    div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
}

laplacianSchemes
{
    default        Gauss linear uncorrected;
}

interpolationSchemes
{
    default        linear;
}

snGradSchemes
{
    default        uncorrected;
}

// ************************************************************************* //


OpenFoamlove September 13, 2017 08:56

Solver does not work on me :(
 
Hi thank you so much for sharing your solver.

I tried to work your solver but while executing Allwmake it shows me erros as below e.g.:

mojThermos.C:32:38: error: incompressiblePerfectGas.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:33:22: error: rhoConst.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:34:26: error: perfectFluid.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:35:29: error: PengRobinsonGas.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:36:35: error: adiabaticPerfectFluid.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:40:30: error: sensibleEnthalpy.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:41:36: error: sensibleInternalEnergy.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:42:20: error: thermo.H: Datei oder Verzeichnis nicht gefunden
mojThermos.C:55:25: error: heRhoThermo.H: Datei oder Verzeichnis nicht gefunden
In file included from mojThermos.C:56:
./crossWlfInSorodno/mojHeRhoThermo.H:39:22: error: heThermo.H: Datei oder Verzeichnis nicht gefunden
In file included from ./crossWlfInSorodno/mojFluidThermo.H:38,
from ./crossWlfInSorodno/mojRhoThermo.H:38,
from mojThermos.C:27:
./crossWlfInSorodno/mojBasicThermo.H: In static member function »static Foam::word Foam::mojBasicThermo::phasePropertyName(const Foam::word&, const Foam::word&)«:
./crossWlfInSorodno/mojBasicThermo.H:188: Fehler: »groupName« is not a member of »Foam::IOobject«
In file included from mojThermos.C:56:
./crossWlfInSorodno/mojHeRhoThermo.H: At global scope:
./crossWlfInSorodno/mojHeRhoThermo.H:53: Fehler: expected template-name before »<« token
./crossWlfInSorodno/mojHeRhoThermo.H:53: Fehler: expected »{« before »<« token
./crossWlfInSorodno/mojHeRhoThermo.H:53: Fehler: expected unqualified-id before »<« token
In file included from ./crossWlfInSorodno/mojHeRhoThermo.H:98,


the errors tell me that files e.g. incompressiblePerfectGas.H is not found.

are there missing some files or am I doing something wrong. Can you please help me to run the solver.
For your help I would be very thankful.

with best regards
Anna

krikre September 13, 2017 11:48

Thank you for trying it out!

I think the compiler isn't finding all the source filles needed.

Are you sure your OpenFOAM 3.0.1 is properly set up?

Have you compiled other solvers before? Like icoFoam?

OpenFoamlove September 13, 2017 15:43

I am trying it in OF 4. Is it incompatible in of4


Sent from my iPhone using CFD Online Forum mobile app

krikre September 13, 2017 16:32

I'm pretty sure it's incompatible with OF 4. :(

You can have multiple versions of OF on your computer using aliases.

Have a look at these (or google it):

https://www.cfd-online.com/Forums/op...e-machine.html

http://openfoamwiki.net/index.php/In...nFOAM_versions

I hope you find it worth it! :)

I'll be updating the repository in the next week or two, if you're interested. I've improved the demo case to run reliably and added the possibility of tabulated thermal conductivity, specific heat and enthalpy. You can have at some of it already in the develop branch of the repository.

OpenFoamlove September 15, 2017 05:44

Thank you so much for your reply. It would be very kind of you to have the repository.

With best regards
Anna


Sent from my iPhone using CFD Online Forum mobile app

samiam1000 September 4, 2020 02:16

Dear Krikre,

your software seems to be what I am looking for. I would like to ask you some questions, in order to understand is it is feasible what I do have in mind.

I do have a cavity (filled with an isotropic mat - I am going to simulate this with porous media, I guess) and I want to fill it with a liquid.

I would like to understand how the fluid front moves inside the cavity.

Is that what I can do, with your software? Would you mind explaining how it works and which version of OpenFOAM i shuould install?

Thanks a lot,
Samuele

hectrodebac October 6, 2020 08:29

Dear Krikre,
First of all I want to thank you for post this solver since I think it is exactly what I need. But I have a little problem, I'm following the steps that you state at Github and I am obtaining the following error when I run ./Allrun,
Code:

--> FOAM FATAL ERROR:
cannot find file "/home/trial/Downloads/openInjMoldSim-master/tutorials/demo/fill_pack/system/dictionaryReplacement"

    From function virtual Foam::autoPtr<Foam::ISstream> Foam::fileOperations::uncollatedFileOperation::readStream(Foam::regIOobject&, const Foam::fileName&, const Foam::word&, bool) const
    in file global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C at line 538.


I am using openFOAM 7, since is the last one that I see that this solver can work.



I tried to find the dictionaryReplacement on the repository but I'm unable to.
I'm sorry if this is a silly question, I'm quite new at OpenFOAM and I am not really familiar with the parameters.
Best regards.

krikre October 7, 2020 04:06

I'm in the middle of updating the tutorials to v7, since they were still at v3.0.1. Check the "develop" branch of the repo for the latest state.


Keep in touch!

divyaa September 10, 2021 02:51

what do those 2 tables in OPENINJMOLDSIM solver represent mate?
the table named fim_01_01_F_00_00_01_08.txt & fim_01_01_F_00_01_08.txt?


To be specific in my question, fim_01_01_F_00_00_01_08.txt has

((0. 293048.4625)
(0.010000000000000009 572789.025)
(0.020000000000000018 852526.165625)
what do those paired numbers represent? Please can i know?

similarly, in fim_01_01_F_00_01_08.txt, has

0. 293048.4625 100000. 100000.
0.010000000000000009 572789.025 100000. 100000.
0.020000000000000018 852526.165625 100000. 100000.

what does these numbers represent?

I am trying to apply this solver to my injection molding simulation, hence raised this doubt? sorry if this seemed too obvious of a question. I am just getting started.

Thank you.

krikre September 11, 2021 09:44

Quote:

Originally Posted by divyaa (Post 811942)
what do those 2 tables in OPENINJMOLDSIM solver represent mate?
the table named fim_01_01_F_00_00_01_08.txt & fim_01_01_F_00_01_08.txt?


To be specific in my question, fim_01_01_F_00_00_01_08.txt has

((0. 293048.4625)
(0.010000000000000009 572789.025)
(0.020000000000000018 852526.165625)
what do those paired numbers represent? Please can i know?

similarly, in fim_01_01_F_00_01_08.txt, has

0. 293048.4625 100000. 100000.
0.010000000000000009 572789.025 100000. 100000.
0.020000000000000018 852526.165625 100000. 100000.

what does these numbers represent?

I am trying to apply this solver to my injection molding simulation, hence raised this doubt? sorry if this seemed too obvious of a question. I am just getting started.

Thank you.


Hi,


the fim_01_01_F_00_00_01_08.txt sets the time dependence of the inlet pressure. It's called form here:

https://github.com/krebeljk/openInjM...ack/org0/p_rgh


the fim_01_01_F_00_01_08.txt contains the measured pressure evolutions and is only needed after your simulation is done and you want to compare the computed values with the measurements. This is the script that calls it:

the https://github.com/krebeljk/openInjM...l_pack/AllPlot


Regards!


All times are GMT -4. The time now is 17:53.