CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Calculation of a dimensionedScalar in a modified turbulence model (https://www.cfd-online.com/Forums/openfoam-programming-development/218108-calculation-dimensionedscalar-modified-turbulence-model.html)

blue_arrow98 June 9, 2019 00:49

Calculation of a dimensionedScalar in a modified turbulence model
 
Hey guys, I am actually working on developing a turbulence model for magneto hydrodynamic flow. I need to modify a coefficient (which is dimensionedScalar) used in the model. In the original model, it has a constant number value, but in my case I need it to be a function of ratio of Hartmann number to Reynold's number (Ha/Re), but it should be still a dimensioned Scalar.

Now while defining the ratio, Ha/Re = sigma*(B)^2/(U)^2*rho.

Now here, B is magnetic field and U is Velocity (both of which are volVectorField). How do I perform this operation so that my LHS and RHS become of same type. I tried a lot, but I always end up with "error: no match for operator="

Any suggestions are more than welcome!

raumpolizei June 9, 2019 05:28

Hey there,
as you already figured out, you will need an additional field for your dynamic variable (checkout the type volScalarField). Additionally, in order to calculate the HaByRe field with your equation, you will have to be aware of the syntax for different vector/tensor operations in OpenFoam. For example, the inner product between two vectors a and b is a & b. You can find all possible operations in the OF programmers guide p. 22 (google).
Good luck!
RP

blue_arrow98 June 9, 2019 23:11

Hey, Thanks for your reply.

I had read through the various operations before, but I am never able to achieve the desired operation to make sure that the value of the turbulence coefficient remains dimensionedScalar. Could you please elaborate on how I can perform the operation?

Rahul

raumpolizei June 10, 2019 04:39

Quote:

Originally Posted by blue_arrow98 (Post 735806)
I had read through the various operations before, but I am never able to achieve the desired operation to make sure that the value of the turbulence coefficient remains dimensionedScalar. Could you please elaborate on how I can perform the operation?

dimensionedScalar is an OpenFOAM concept. A dimensionedScalar is a scalar (a single value) with some dimensions. You can't you use a dimensionedScalar for a variable that is changing in space in your computational domain. You need a field (different in each cell, as B and U). This is why you need a volScalarField (checkout the OpenFOAM extended code guide). You could initialize your field like this. (check https://www.openfoam.com/documentati...ensionSet.html for the dimensions).


Code:

volScalarField HaByRe
 (
    IOobject
    (
        "HaByRe",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE // NO_WRITE if no output desired
    ),
    mesh,
    dimensionedScalar("0", dimensionSet(0, 0, 0 , 0, 0, 0, 0), 0.0) // init to zero, dimensions must be set via dimensionSet
);

After initialization, it should be possible to assign something to that field. I think it is also possible to do it directly at construction time. Check the geometricField constructors in order to find the right interface for that (also extended code guide).
Cheers

RP

blue_arrow98 June 11, 2019 04:10

Hey, Thanks a lot. I will try this.

blue_arrow98 June 26, 2019 03:55

Hey guys, I solved this problem in a different, but less complicated way without changing the existing code. The only thing that varies in my problem with Ha/Re value is the closure coefficient used in the turbulent model. So, one can easily change it by editing the turbulenceProperties file in the case directory. This is a very common fact which took me long enough to figure out.

Code:

simulationType  RAS;

RAS
{
RASModel        SpalartAllmaras;

SpalartAllmarasCoeffs
{
Cv1 30;
}

turbulence      on;

printCoeffs    on;

}

Hope it helps someone in the future. Also, yes, the only drawback of this method is that you need to calculate the value of closure coefficient manually and then give it as input, which is okay as long as you have limited simulations to run and don't miss out changing the value of everytime the ratio changes.


All times are GMT -4. The time now is 09:40.