|
[Sponsors] |
Creating magnetocaloric solver from buoyantPimpleFoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 1, 2022, 12:13 |
Creating magnetocaloric solver from buoyantPimpleFoam
|
#1 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
I am trying to create a solver for ferrofluids under the influence of a static magnetic field from buoyantPimpleFoam. I want to add another source term, the Kelvin Body force, to the momentum equation. In my case the Kelvin Body Force defines as:
with If the current temperature of the fluid is closer to its curie temperature the KBF gets smaller. In green you see where I want to add the term. I managed to add H and T_Curie in createFields.H. But my question is how do I depict the current temperature in the momentum equation to calculate the Magnetization M each time step? It does not work like this: Code:
tmp<fvVectorMatrix> tUEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) + MRF.DDt(rho, U) + turbulence->divDevTau(U) + Foam::constant::electromagnetic::mu0*grad(H)*H*(Tc - T); == fvOptions(rho, U) |
|
April 4, 2022, 12:44 |
|
#2 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
Hi CharIie,
You are almost there. Just two comments that might help you 1) The expression for Magnetization seems incorrect... As you already know both M & H have dimensions of Amp/meter....However with the above expression the RHS will have dimesnsions of A.Kelvin/meter 2) Regarding the implementation, the only thing you need to worry about is the product of with M (or eventually H).....as is a tensor of rank 2 (9 components) whereas M or H is a tensor of rank 1 (3 components ) and the UEqn in which u wish to enter this source term is also a tensor of rank 1 (3 components)....Hence, the product of should be an inner product....which is implemented in the FOAM's love language as shown below Code:
volTensorField gradHH = fvc::grad(H); volVectorField KBF = Foam::constant::electromagnetic::mu0*(M & gradHH); |
|
April 7, 2022, 07:29 |
|
#3 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Thank you SHUBHAM for the answer.
The solver finally compiles when I use the inner product as you showed. (For the moment I replaced M with H.) But now I am trying to depict M as: This cancels out the Kelvin units and M_0 is the initial magnetization. Code:
volVectorField M = Mo*(Tc/T); This is the error message I get when compiling: Code:
UEqn.H: In function ‘int main(int, char**)’: UEqn.H:13:25: error: no match for ‘operator/’ (operand types are ‘Foam::dimensioned<double>’ and ‘<unresolved overloaded function type>’) 13 | volVectorField M = Mo*(Tc/T); | ~~~~~^~ Last edited by CharIie; April 7, 2022 at 11:17. |
|
April 7, 2022, 16:51 |
|
#4 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
Indeed it is because of the different declarations of ....
I assume u r providing both and as constant parameters.....as shown below Code:
// Curie Temp dimensionedScalar Tc(transportProperties.lookup("Tc")); //Equilibrium Magnetization dimensionedScalar Mo(transportProperties.lookup("Mo")); Code:
volVectorField M = Mo*(Tc/T); One of the many workarounds is you create volVectorField using the dimensionedScalar Code:
volVectorField Mnot ( IOobject ( "Mnot", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector("vU", dimensionSet(0,-1,0,0,0,1,0),vector(Mo.value(), Mo.value(), Mo.value())) ); Code:
volVectorField M = Mnot*(Tc/T); |
|
April 8, 2022, 06:38 |
|
#5 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Thank you again!
I have added Tc and Mo in createFileds.H like this: ( i will later a file with the magnetic properties to constant folder) Code:
Info<< "Reading magnetic properties\n" << endl; IOdictionary magneticProperties ( IOobject ( "magneticProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); dimensionedScalar Mo ( "Mo", magneticProperties.lookup("Mo")); dimensionedScalar Tc ( "Tc", magneticProperties.lookup("Tc")); volVectorField Mnot ( IOobject ( "Mnot", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector("Mnot", dimensionSet(0,-1,0,0,0,1,0),vector(Mo.value(), Mo.value(), Mo.value())) ); and my UEqn.H looks like this now: Code:
// Curie Temp dimensionedScalar Tc(magneticProperties.lookup("Tc")); //Equilibrium Magnetization dimensionedScalar Mo(magneticProperties.lookup("Mo")); volTensorField gradHH = fvc::grad(H); volVectorField M = Mnot*(Tc/T); volVectorField KBF = Foam::constant::electromagnetic::mu0*(M & gradHH); tmp<fvVectorMatrix> tUEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) + MRF.DDt(rho, U) + turbulence->divDevTau(U) + KBF == fvOptions(rho, U) ); Code:
In file included from fhdFoam.C:157: UEqn.H: In function ‘int main(int, char**)’: UEqn.H:17:28: error: no match for ‘operator/’ (operand types are ‘Foam::dimensionedScalar’ {aka ‘Foam::dimensioned<double>’} and ‘<unresolved overloaded function type>’) 17 | volVectorField M = Mnot*(Tc/T); | ~~^~ |
|
April 9, 2022, 10:21 |
|
#6 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
are you sure you didn't forgot to declare the Temperature field ?
Code:
UEqn.H:17:28: error: no match for ‘operator/’ .....and ’<unresolved overloaded function type>’) |
|
April 9, 2022, 10:30 |
|
#7 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
What do you mean by declaring the temperature field? Isn't the temperature already declared onboard with buoyantPimpleFoam?
|
|
April 9, 2022, 14:24 |
|
#8 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
buoyantPimpleFoam solve either enthalpy based or internal energy based equation (EEeqn) instead of directly solving for Temperature....(https://cfd.direct/openfoam/energy-equation/#x1-70004)
You can easily check out the contents of createFields.H....(https://develop.openfoam.com/Develop...createFields.H)...... there does not exist any field variable "T".... Last edited by SHUBHAM9595; April 9, 2022 at 16:25. |
|
April 10, 2022, 11:42 |
|
#9 | |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Ok, this brings me back to my initial question in this thread:
Quote:
How can I depict the current temperature in the momentum equation for simple calculations? |
||
April 12, 2022, 18:32 |
|
#10 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
There are two approaches....assuming that you want to stick with buoyancy driven flow solvers....
1) You can switch to buoyantBoussinesqPimpleFoam which inherently solves Temperature based energy equation. 2) In the current buoyantPimpleFoam version..... comment the EEqn.H in buoyantPimpleFoam.C.....and instead add TEqn.H....more details can be found here https://openfoamwiki.net/index.php/H...ure_to_icoFoam |
|
April 20, 2022, 13:12 |
|
#11 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
I decided to go with approach 2 since buoyantBoussinesqPimpleFoam isnot part of my OpenFOAM V8 .
I added the TEqn.H according to https://openfoamwiki.net/index.php/H...ure_to_icoFoam, I did not comment out old the EEqn.H, since it seems to do no harm to my solver. My solver also does compile now, but when I try to solve my test case I get the following error: Code:
--> FOAM FATAL ERROR: incompatible dimensions for operation [T[0 0 -1 1 0 0 0] ] + [T[1 -3 -1 1 0 0 0] ] |
|
April 26, 2022, 10:55 |
|
#12 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
Hi CharIie,
As you mentioned the issue seems to come from extra density....kg/m3 in one of your equations..... Code:
--> FOAM FATAL ERROR: incompatible dimensions for operation [T[0 0 -1 1 0 0 0] ] + [T[1 -3 -1 1 0 0 0] ] Now, if we follow the link https://openfoamwiki.net/index.php/H...ure_to_icoFoam about adding Temp...…we don't have any term that have dimensions of kg/m3....(T = K, phi = m3/s, DT = m2/s) So there's high probability that the error might be coming from the EEqn.H.....Have u tried any simulation without EEqn.H ? regards, Shubham |
|
April 27, 2022, 05:52 |
|
#13 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Hi I have added TEqn like this:
Code:
#include "UEqn.H" #include "EEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { turbulence->correct(); thermophysicalTransport->correct(); } } rho = thermo.rho(); //add these lines... Info<< "Temperature calculation\n" << endl; fvScalarMatrix TEqn ( fvm::ddt(rho,T) //added rho + fvm::div(phi, T) //- fvm::laplacian(DT, T) ); TEqn.solve(); //done adding lines... runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; I finally get results with my solver, but the courant number is way to high: Code:
Courant Number mean: 49.3032 max: 353.349 Last edited by CharIie; April 27, 2022 at 13:09. |
|
April 28, 2022, 14:31 |
|
#14 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
Glad to know that u r not getting any error. However, you should not solve the same governing equation TWICE.....as in ur modified version u have both EEqn.H & contents of TEqn.H........
Out of curiosity, can u specify exact steps and command u r follwoing after making the changes in .C file.....I'm afraid we might be missing out some intermediate steps here |
|
May 2, 2022, 06:40 |
|
#15 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Okay, here we go:
My new solver is a copy of buyantPimpleFoam saved in /OpenFOAM-8/applications/solvers/heatTransfer/fhdFoam. So I far I have made changes to fhdFoam.C, UEqn, createFields and the make files of course. I changed the column including the EEqn like this: // #include "EEqn.H" Then I type wclean and wmake in the terminal. The solver compiles. Then I go into my test case where I have added a H field with mapFields from another solver. I delete old solved time steps greater than 0. Then I start my solver with the command fhdFoam. Also when I only calculate the TEqn only, I get weird looking results and this courant result in the last time step: Courant Number mean: 49.3029 max: 353.347 |
|
May 16, 2022, 13:09 |
|
#16 |
Member
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9 |
The steps look correct. Regarding the high Courant number.....have u already tried using the following options in ur controlDict ?
Code:
maxCo 1; adjustTimeStep true; |
|
May 17, 2022, 05:12 |
|
#17 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Yes, that is what I did and gives me first results.
But computational time is 10x longer. Do you have an idea how I can include the the molecular transport. Now the temperature is static in my results and does not change and is not influenced by the fluid flow. |
|
June 29, 2022, 07:47 |
Final Answer
|
#18 | |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Quote:
Simply use: Code:
const volScalarField& T = mesh.lookupObject<volScalarField>("T"); |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
foam-extend-4.1 release | hjasak | OpenFOAM Announcements from Other Sources | 19 | July 16, 2021 06:02 |
Creating a solver for porous media | rsdevako | OpenFOAM Programming & Development | 4 | May 15, 2019 22:23 |
Unsteady solver in OpenFOAM: problems with using buoyantPimpleFoam for validation | Mukul.P | OpenFOAM Running, Solving & CFD | 12 | March 17, 2016 04:46 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |
Creating a new solver from chtMultiRegionFoam | David_010 | OpenFOAM Programming & Development | 0 | April 20, 2010 12:36 |