# Changing viscosity in interFoam

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 11, 2015, 05:14 Changing viscosity in interFoam #1 Member   Thomas Vossel Join Date: Aug 2013 Location: Germany Posts: 45 Rep Power: 5 Hi! I want to use interFoam and change the viscosity depending on the temperature. I already included the temperature transport and a method for interpolating the respective viscosity values based on some actually measured data. I'm now struggling to get access to the viscosity field / understanding how all of this works... 1.) The viscosity is calculated via the incompressibleTwoPhaseMixture model. There a volScalarField "nu_" is created but it's protected so I cannot change it via my solver's code... 2.) I had a look at the velocity / pressure solver itself to see where the viscosity is passed on to the solver so I could like clone the internally calculated viscosity field in order to pass on an altered version to the actual velocity equations. I would have expected to see it in the momentum equation but for U there's just this: Code: ``` fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) + turbulence->divDevRhoReff(rho, U) ); UEqn.relax(); if (pimple.momentumPredictor()) { solve ( UEqn == fvc::reconstruct ( ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) ) * mesh.magSf() ) ); }``` So at which point in the solver's code does the viscosity play a role and how can I get access to the viscosity field in order to change it?

 March 11, 2015, 10:55 #2 Member   ali alkebsi Join Date: Jan 2012 Location: Strasbourg, France Posts: 82 Rep Power: 6 hello I'm also interested in doing this ( I have to. ) I think, if you are not going to use any turbulence model (laminar case) then you could just exchange the line + turbulence->divDevRhoReff(rho, U) with one like in icoFoam where you will have to go to createFields.H and create you nu1 nu2 and nu and make it calculated like rho (averaging). However it might prove not effective (its just an idea i came up with to try) in case you find another solution i'm very interested in knowing how and i think that the slover uses the nu as calculated in incompressibleTwoPhaseMixture.C by calling twoPhaseProperties.correct();

 March 12, 2015, 00:45 #3 Member   Yogesh Bapat Join Date: Oct 2010 Posts: 43 Rep Power: 8 Hello Thomas, You can write your own viscosity model as in src/transportModels/viscosityModel. Here you can find different viscosity models are implemented. Regards, -Yogesh

 March 12, 2015, 03:47 #4 Member   Thomas Vossel Join Date: Aug 2013 Location: Germany Posts: 45 Rep Power: 5 Hi! Thanks for your suggestions. Writing a viscosity model of my own might be a solution but after quite a struggle to get a boundary condition of mine to work I want to avoid writing more template code plus it usually costs quite some time to understand how those models are supposed to work. But maybe I should have a look at this again - perhaps OpenFOAM surprises me for once by giving a straightforward process for integrating something new... Right now I'm trying to implement a "dirty trick". I just copied the entire transport model sources to my solver in order to compile all of this as a custom library. I then added a function which passes on a pointer to the nu_ volScalarField. In my solver I know use the pointer to simply overwrite nu_ with a field of my own. This seems to work so far but recently I just did some tests without the U and p calculations so I still have to check that it won't become overwritten by something. There also seems to be a bug in my interpolation code I have to fix first... If none of all this will work I guess I'll try kebsiali's approach. So the viscosity is implemented via the turbulence model?

 March 12, 2015, 05:45 #5 Senior Member   Olivier Join Date: Jun 2009 Location: France, grenoble Posts: 266 Rep Power: 10 hello, This has already been done ... check http://www.tfd.chalmers.se/~hani/kur...nFoam%20v2.pdf Regards, olivier ThomasV likes this.

 March 12, 2015, 07:43 #6 Member   Thomas Vossel Join Date: Aug 2013 Location: Germany Posts: 45 Rep Power: 5 Thanks - that's a nice source. Way more easy than my approach...

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post TDK FLUENT 11 July 31, 2016 06:03 zfaraday OpenFOAM 13 December 9, 2014 19:58 vitorspadetoventurin OpenFOAM Running, Solving & CFD 3 December 2, 2014 08:18 pbryant OpenFOAM Running, Solving & CFD 22 October 29, 2012 04:43 Jun Kwon Park OpenFOAM Running, Solving & CFD 0 October 9, 2009 08:29

All times are GMT -4. The time now is 18:25.