CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Calculation of a dimensionedScalar in a modified turbulence model

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By raumpolizei
  • 2 Post By raumpolizei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2019, 01:49
Lightbulb Calculation of a dimensionedScalar in a modified turbulence model
  #1
New Member
 
Rahul
Join Date: Aug 2018
Posts: 6
Rep Power: 8
blue_arrow98 is on a distinguished road
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!
blue_arrow98 is offline   Reply With Quote

Old   June 9, 2019, 06:28
Default
  #2
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
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 likes this.
raumpolizei is offline   Reply With Quote

Old   June 10, 2019, 00:11
Default
  #3
New Member
 
Rahul
Join Date: Aug 2018
Posts: 6
Rep Power: 8
blue_arrow98 is on a distinguished road
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
blue_arrow98 is offline   Reply With Quote

Old   June 10, 2019, 05:39
Default
  #4
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
Quote:
Originally Posted by blue_arrow98 View Post
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
vivek05 and blue_arrow98 like this.
raumpolizei is offline   Reply With Quote

Old   June 11, 2019, 05:10
Default
  #5
New Member
 
Rahul
Join Date: Aug 2018
Posts: 6
Rep Power: 8
blue_arrow98 is on a distinguished road
Hey, Thanks a lot. I will try this.
blue_arrow98 is offline   Reply With Quote

Old   June 26, 2019, 04:55
Default
  #6
New Member
 
Rahul
Join Date: Aug 2018
Posts: 6
Rep Power: 8
blue_arrow98 is on a distinguished road
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.
blue_arrow98 is offline   Reply With Quote

Reply

Tags
mhd, modified turbulence model, programming, turbulencemodel


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of k-epsilon and k-omega Models Jade M Main CFD Forum 40 January 27, 2023 08:18
Turbulence model choice dave13 CFX 3 December 22, 2015 08:12
What model of turbulence choose to study an external aerodynamics case raffale OpenFOAM 0 August 23, 2012 06:45
question about turbulence model selection and sensitivity karananand Main CFD Forum 1 February 26, 2010 05:41
Turbulence Model and Accuracy of convective flux calculation Lokesh Agrawal Main CFD Forum 1 November 15, 1998 00:24


All times are GMT -4. The time now is 16:49.