Using another solver to modify OpenFOAM-Nutils CHT tutorial

Hello!

I am adjusting the CHT tutorial for OpenFOAM and Nutils. I have 2 questions about this.

The first is about OpenFOAM. I am using the buoyantBoussinesqSimpleFoam solver, since i want to solve the heat transfer in a turbulent fluid. (i have neglected the buoyancy term by putting the gravity to 0 and the buoyancy by putting beta to 0). I have tested this with a constant heat flux on the ‘interface’ boundary only in OpenFOAM and compared it to ansys, which validated the case. Now i am trying to run it with preCICE and get the heat flux from Nutils (I am not yet using the solver, but I first want to exchange a constant value from nutils to see if it works), however i get an error i do not know how to solve. It states:

-> FOAM Warning : 
    From void adapterInfo(std::string, std::string)
    in file Utilities.C at line 50
    Error (deferred - will exit later) in the preCICE adapter: 
Error in the preCICE adapter: 
Cannot find the Prandtl number in preciceDict/CHT using the name Pr

I do state the Prandtl number however in my transportProperties. Do you maybe know what i am doing wrong here? I have left the xml file untouched, since i want to interchange the heat flux.

The second question is about the nutils part.
The heat flux is computed using:

fluxvalues = res.eval(lhs0=lhs0, lhs=lhs, dt=dt)
      writedata = couplingsampleCC.eval('-flux' @ ns, fluxdofs=fluxdofs(fluxvalues))

However when you evaluate the residual of the weak form, it should be (close to) 0? I don’t see how this computes the heat flux.

Thank you for your time!

Kind regards,

Cars

I think it is easier if i post the files I am using for OpenFOAM. First the normal settings

fvSolution.txt (1.6 KB) preciceDict.txt (426 Bytes) controlDict.txt (1.3 KB) fvSchemes.txt (1.5 KB)

transportProperties.txt (1.1 KB) turbulenceProperties.txt (1.1 KB) g.txt (933 Bytes)

and the 0 folder.

k.txt (1.5 KB) nut.txt (1.5 KB) omega.txt (1.5 KB) p.txt (1.5 KB) p_rgh.txt (1.4 KB) T.txt (1.4 KB) U.txt (1.4 KB) alphat.txt (1.6 KB) epsilon.txt (1.6 KB)

I am not sure if this is a good reason to select this solver, but it is definitely supported. For the future reader: this is an incompressible (with the Boussinesq approximation for density) steady-state solver.

This is unfortunately a bit ugly, but we currently need to read the Prandtl number to compute the heat flux. As far as I know (please correct me/refer to resources if I am wrong), this solver does not read the Prandtl number from the transportProperties, so we read it separately from the preciceDict.

I added a point in the documentation (this was previously undocumented, but I don’t remember the reason), please try modifying your preciceDict:

modules (CHT);

interfaces
{
  Interface1
  {
    mesh              OpenFOAM-Mesh;
    patches           (interface);
    
    readData
    (
      Heat-Flux
    );
    
    writeData
    (
      Temperature
    );
  };
};

CHT
{
    rho [ 1 -3  0  0 0 0 0 ] 50; // set your value
    Cp  [ 0  2 -2 -1 0 0 0 ] 5; // set your value
    Pr  0.71;
};

It is a question how you could distinguish between the laminar and turbulent Prandtl, but the turbulent part should be already provided by OpenFOAM in alphat (see code I linked to above).

This is something we could improve in the future, but we currently don’t have many users using the Boussinesq solvers, so we lack some experience here.

I would strongly suggest to not handle this question here, but open a separate topic.

1 Like

Second part handled here: Compute flux from weak form

1 Like

Is a modified simpleFoam also supported then?

I might try that out so i just add another temperature equation? Another option for me would be to modify the simpleFoam solver, however with some parameteres adjusted in the buoyantBoussinesqSimpleFoam, the equations will be the same as simpleFoam with a temperature equation added.

Thank you! I will try this out.

Kind regards,

Cars

Adding temperature to simpleFoam should also be supported if it registers temperature the same way as the standard OpenFOAM solvers, but why not use the full buoyantSimpleFoam? Why do you need the Boussinesq approximation?

Okay, good to know for future other solver uses! In the problem I am facing, the temperature difference/ pressure difference is not very high. Therefore incompressibility is assumed to reduce computation time. It is indeed interesting to check difference in computation time with the coupling, so I will probably do that.

I have implemented it and the coupling worked! Thank you :smiley:

1 Like