unicfdlab / hybridCentralSolvers

United collection of hybrid Central solvers - one-phase, two-phase and multicomponent versions
GNU General Public License v3.0
95 stars 59 forks source link

coupling with adjointShapeOptimizationFoam #8

Open atenamsv opened 4 years ago

atenamsv commented 4 years ago

I am trying to couple pimplrCentralFoam with adjointShapeOptimization in openfoam, after replacing the default simple solver (defined inside adjointShapeOptimizationFoam.C) with pimpleCentral solver and compile it successfully, I have some problems to choose the right solver for pa (adjoint pressure) and Ua (adjoint velocity). In original fvSolution file in adjointShapeOptimizationFoam it looks like: "(p|pa)" { solver GAMG; tolerance 1e-08; relTol 0.01; smoother GaussSeidel; }

"(U|Ua|k|epsilon)"
{
    solver          smoothSolver;
    smoother        GaussSeidel;
    nSweeps         2;
    tolerance       1e-08;
    relTol          0.1;
}

with simple algorithm. The question is in which way can i define the right solvers inside adjoint solver which can calculate and simulate sonic flow without errors? I receive an error that i think is because of sudden temperature drop, although i have temperature limit between 299-300 K in fvOption. enclosed i included the fvSolution i already used, and an errorLog i receive during running this foam. I appriciate your help in this regard.

fvSchemes.txt fvSolution.txt errorLog.txt

unicfdlab commented 4 years ago

Hi, from the errorLog.txt it is seen that you have a very large continuity error just at the first iteration:

time step continuity errors : sum local = 0.000428673, global = 0.000428523, cumulative = 0

Later, pressure field diverges:

max/min p: 600000/-6952.36

I would recommend to change solver to PBiCGStab with DILU preconditioner, as well as to reduce target tolerance to 1e-8 and target relTol to 0.

If it doesn't work, then you can try to reduce order of spatial approximation by changing fvSchemes:

defaultAdvScheme uwpind; defaultAdvSchemeV upwind;

After that you can try to avoid sharp initial pressure jump (max/min p: 600000/100709) -- you can start with small pressure difference 106000/100709 and then increase it during the simulation

If the error persists, you must post here you U/p/T BCs and adjoint equations

atenamsv commented 4 years ago

Thanks for your tips, but unfortunately the error does not vanish. here are the required files. createFields.txt pa.txt T.txt U.txt Ua.txt p.txt PadjointShapeOptimizationFoam.txt

atenamsv commented 4 years ago

Here i could see in each loop pressure is calculating 2 time, that's where density goes minus and causes crash. errorLog2.txt

unicfdlab commented 4 years ago

Hello, it looks like there is a lot to be done with your custom solver. As the first step, can you post here LaTeX (PDF) or Doc file with derivation of equations?

atenamsv commented 4 years ago

I want to use adjointShapeOptimization for a compressible flow.

adjointShapeOptimizationFoam.txt createFields.txt

The default solver in openFoam is for incompressible flow, and uses SIMPLE algorithm. I tried to remove simple solver loop and instead include pimpleCentral loop in adjointShapeOptimization.

Here is the derivation of the equations: adjoint derivation equation.docx

Thanks in advance.

atenamsv commented 4 years ago

PimpleAdjointShapeOptimizationFoam.txt

hEqn.txt pEqn.txt UEqn.txt

I tried to alter the solver, pEqn, UEqn and hEqn. now it is working, and goes some steps forward, but now the problem is that the temperature drops suddenly and rho goes to a big minus quantity, then it crashes. errorLog.txt

unicfdlab commented 4 years ago

Hi, I think, you must add LTS support to your solver -- see https://github.com/unicfdlab/hybridCentralSolvers/blob/digitef-dev-1912/Sources/pimpleCentralFoam/pimpleCentralFoam.C and https://github.com/unicfdlab/hybridCentralSolvers/tree/digitef-dev-1912/Tutorials/compressible/LTS/ConvergingDivergingNozzle as examples.

After that, you have to try running your code w/o shape adjustment.

Also, if you use LTS, than maybe you have to add porosity alpha in temporal derivative term (I'm not sure)