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

Custom definition for viscosity

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2020, 22:06
Default Custom definition for viscosity
  #1
Member
 
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 9
PositronCascade is on a distinguished road
Hello everyone. I try to define viscosity for multi phase problem, by considering a relation. To do that I wrote the code below:

Code:
    forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
    {
        phaseModel& phase = iter();
        const volScalarField& alpha = phase;
        phaseModel& phase2 = iter();
        const volScalarField& alpha2 = phase2;        


            dimensionedScalar ksi11a = 1 + sqrt(phase.eta()/phase.eta())*pow(phase.mol()/phase.mol(), 1.0/4.0);
            dimensionedScalar ksi12a = 1 + sqrt(phase.eta()/phase2.eta())*pow(phase2.mol()/phase.mol(), 1.0/4.0);
            dimensionedScalar ksi11 = pow(ksi11a,2)/sqrt(8* (1 + phase.mol()/phase.mol()));
            dimensionedScalar ksi12 = pow(ksi12a,2)/sqrt(8* (1 + phase.mol()/phase2.mol()));
             
            phase.nu() = alpha*phase.eta() / (alpha*ksi11 + alpha2*ksi12)/phase.rho();

        }
So, ksi11 must be 1 and ksi12 must be 0.331. However, both values become 1; so probably, I cannot obtain phase and phase2 values separately and both ksi values turn into 1. May you suggest me a way to obtain values of both phases at the same time?
PositronCascade is offline   Reply With Quote

Old   May 31, 2020, 01:48
Default
  #2
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Your phase and phase2 are the same phases since you set them with the same iterator in the same step. So you solve ksi12a = 1+1*1 = 2 and ksi12 =4/4 =1. And the same for ksi11a but there you even divide by its own valus, so i dont get the point for these.
superkelle is offline   Reply With Quote

Old   May 31, 2020, 05:11
Default
  #3
Member
 
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 9
PositronCascade is on a distinguished road
Quote:
Originally Posted by superkelle View Post
Your phase and phase2 are the same phases since you set them with the same iterator in the same step. So you solve ksi12a = 1+1*1 = 2 and ksi12 =4/4 =1. And the same for ksi11a but there you even divide by its own valus, so i dont get the point for these.
Currently yes, ksi11 and ksi12 are same; because I cannot iterate through phases. I have two phases and I need to access their phase values under the same forAllIter loop at the same time. So, somehow phase2 must be something like iter++, but I couldn't do that. I need help at that point.
PositronCascade is offline   Reply With Quote

Old   May 31, 2020, 08:22
Default
  #4
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Well I am currently learning OF and c++ my self, so please don't be too harsh on me if I am wrong^^. So I dont have any knowledge about these phaseModel handling and so on, but I think you can just use something like *(iter-1). I tried it for a simple List of Lists:
Code:
List<List<int>> myListList({{1, 2, 3, 4},{5, 6, 7, 8, 9},{10, 11, 12}});
    
    
    forAllIter(List<List<int>>, myListList, iter)
    {    
         
         Info << "current List" << endl;
         Info << (*iter)<< endl << endl;
         
        if(iter != myListList.end()-1)
        {
            Info << "next List" << endl;
            Info << *(iter+1) << endl <<  endl;
        }
        else
        {
            Info << "no next List" << endl;
        }
    }
What resulted in:


Code:
current List
4(1 2 3 4)

next List
5(5 6 7 8 9)

current List
5(5 6 7 8 9)

next List
3(10 11 12)

current List
3(10 11 12)

no next List
superkelle is offline   Reply With Quote

Old   May 31, 2020, 08:47
Default
  #5
Member
 
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 9
PositronCascade is on a distinguished road
Quote:
Originally Posted by superkelle View Post
Well I am currently learning OF and c++ my self, so please don't be too harsh on me if I am wrong^^. So I dont have any knowledge about these phaseModel handling and so on, but I think you can just use something like *(iter-1). I tried it for a simple List of Lists:
Code:
List<List<int>> myListList({{1, 2, 3, 4},{5, 6, 7, 8, 9},{10, 11, 12}});
    
    
    forAllIter(List<List<int>>, myListList, iter)
    {    
         
         Info << "current List" << endl;
         Info << (*iter)<< endl << endl;
         
        if(iter != myListList.end()-1)
        {
            Info << "next List" << endl;
            Info << *(iter+1) << endl <<  endl;
        }
        else
        {
            Info << "no next List" << endl;
        }
    }
What resulted in:


Code:
current List
4(1 2 3 4)

next List
5(5 6 7 8 9)

current List
5(5 6 7 8 9)

next List
3(10 11 12)

current List
3(10 11 12)

no next List
Thanks. I agree, I would do this way as well. But I just couldn't fınd a working way to express these in OpenFOAM.
PositronCascade is offline   Reply With Quote

Reply


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
Custom variable definition henriquecar FLUENT 0 June 20, 2019 07:43
How to consider interfacial area in GUI after defining custom drag coefficient? ssa Fluent UDF and Scheme Programming 0 November 13, 2017 14:26
(AutoGRID 5) Problem in Geometry definition of propeller venkat_aero2007 Fidelity CFD 14 July 31, 2012 14:05
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
defining custom convetive terms CFD user CFX 1 February 22, 2009 22:40


All times are GMT -4. The time now is 19:14.