Defining custom Cp library under 2.2.x
I'm trying to update my code to run with 2.2.x and part of doing this involves porting over our Cp and viscosity libraries. Prior to this, declaring a new library for the various thermotypes involved adding the thermotype to the list of thermotypes in the *thermos.C files (like psiThermos.C). For example:
Code:
makeThermo Code:
Unknown psiThermo type Does anyone know where this magic happens? Or what I'm missing? I've spent far more time than any one person should trying to find this and I can't imagine I'm alone in having this issue. Also related is that upon execution the code spews the following: Code:
Duplicate entry irreversibleArrheniusReaction in runtime selection table Reaction |
For some reason 90% of the time I post something here I find the answer 5 minutes later. It looks like I was missing the following in my janaf code:
Code:
//- Return the instantiated type name |
Dear ChrisA:
I have some problem like you.I want use the thermo type as the following: thermoType { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; } but class hePsiThermo only have "sensibleEnthalpy" insteadingof "absoluteEnthalpy".In 2.2.1,only when I use heheuPsiThermo,can I use "absoluteEnthalpy".So I have to according to class heheuPsiThermo to add "absoluteEnthalpy" in class hePsiThermo .However,when I run my case,the error showed me that there no change with "Valid psiThermo types ".In other word ,my modifies did not work.the file I modified is "thermophysicalModels/reactionThermo/psiReactionThermos.C"I just put the following code: makeReactionThermo ( PsiThermo, PsiReactionThermo, hePsiThermo, reactingMixture, sutherland, absoluteEnthalpy, janafThermo, perfectGas, specie; ) and #include "absoluteEntalpy.H" to psiReactionThermos.C.As you know ,it did not work.could you tell me how to modify psiReactionThermos.C to make my difined thermo type : { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; }to be useful? I think you can tell me something about my problem.With your post,abviously,you know of2.2.1 better then me. Please! |
1 Attachment(s)
OK here is how you enable e.g. the absolute enthalpy in your solver. The coding involved is very simple, once you know what to do. :)
1. Create a new library that assembles the necessary bits: I attached a zip archive with the necessary code to include the standard OpenFOAM absolute enthalpy thermo, but this can be extended easily to own implementations of e.g. Cp or viscosity as well. 2. Link your solver against that new library: I assume you know how to link your solver against new libraries, at least there should be some tutorial/wiki somewhere. @ChrisA: Just out of curiosity, which new "Cp and viscosity libraries" do you wanna implement? -Armin |
That looks marvelously simple, I knew there had to be an easy way to add things to the run time selection table... I just never thought of compiling a new library with them in there. (The run time selection stuff is still largely a mystery to me) I'll give it a try when I get a chance, thank you for posting that.
With regards to the libraries I want to implement, the Cp one is simply a higher order polynomial fit than what JanaF uses. I'm fitting a polynomial to Cp for temperatures between 50K and 500K and an extra coefficient makes the fit much better. (rather than fitting -everything- using the polynomial thermotypes). The viscosity model is a kinetic theory based viscosity model... however that is less important as I would need to change how viscosity is mixed at present... So mostly this is so I can have an extra coefficient on the end of my JanaFesq Cp polynomial >.>. |
Dear dkxls:
Thank you very much for you reply and your zip archive !But I have some thing can not understang.Would you tell me some explainasions? 1.According your new library myThernmo,There should be only myThermos.C,myThermoTypes.H,and file of "make" in myThermos.What do other file work in your myThernmo? 2.I delete other file leaving myThermos.C,myThermoTypes.H,files and options in "make".I don not chang any codes and use "wmake "with myThernmo.Then,I add "libs("myThermos.so");" in the controlDict of my case.when I run my case,it gives me error: From function dlopen(const fileName&,const bool) in file POSIX.C at line 1179 dlopen errer:myThermos.so:can notopenshared object file:Nosuch file or diretory I have not linked solver against new libraries before.please give a guide to define my thermotype: thermoType { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; }in your mythermo.I think it is easy to give me advise for you.please,please! |
Dear dkxls:
I can link solver against new libraries.I successed to build myThermos.so,and I add the codes:libs("libThermos.so") in the start of "controlDict".Then I run my case,it still give me error: FOAM Warning : From function dlOpen(const fileName&, const bool) in file POSIX.C at line 1179 dlopen error : /home/administrator/OpenFOAM/administrator-2.2.1/platforms/linuxGccDPOpt/lib/libmyThermos.so: undefined symbol: _ZN4Foam15chemistryReaderINS_19sutherlandTransport INS_7species6thermoINS_11janafThermoINS_10perfectG asINS_6specieEEEEENS_16absoluteEnthalpyEEEEEE30dic tionaryConstructorTablePtr_E --> FOAM Warning : From function dlLibraryTable::open(const fileName&, const bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99 could not load "libmyThermos.so". I think myThermotypes.H may have something wrong,and I also can not understand the codes in your myThermotypes.H .Attachement is my new lirary accoring to your zip archive .Plese take a look on my attachement,and could you give me some advice ?Thanks inadvance! |
1 Attachment(s)
I have upload my attachement,Attachment 25371please help me to have a look!
|
@zqlhzx:
After having a closer look at what you actually wanna do, I just can recommend you to use 'sensibleEnthalpy'! The whole OpenFOAM chemistry implementation is build for sensible enthalpy. In particular, the 'chemistryReader' and 'chemistrySolver' classes are build around sensible enthalpy. Also the top-level solver (e.g. 'chemFoam', 'reactingFoam', ...) are build for sensible enthalpy, as they all include the source term from chemistry in their transport equations. Now you can "easily" implement all this also for absolute enthalpy, but it involves some more coding than just building the thermodynamics for absolute enthalpy. If you don't want to change/implement all these things for absolute enthalpy you should just use the sensible enthalpy. From the thermo-chemistry point of view, it doesn't really matter if you are using absolute or sensible enthalpy, you just have to implement it accordingly - but the end result won't change! |
Quote:
Quote:
ln(mu) = sum_i=1^N( a[i] * ln(T)^(i-1) ) I submitted the implementation to OpenFOAM (mantis bug #978), but the developers haven't included it yet. The code, is a straight forward implementation based on the polynomialTransport class and available in the bug report: http://www.openfoam.org/mantisbt/view.php?id=978 For mixture I use the formulations due to Wilke (viscosity) and Mathur (conductivity), but I haven't contributed that code to OpenFOAM yet. |
Dear dkxls:
Do you mean that I also have to change 'chemistryReader' and 'chemistrySolver' classes if I want to build my own thermo type: thermoType { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie;}?In other word ,most users who use OF2.2.1 only can use sensibleEnthalpy.I found just XiFoam,PDRFoam and engineFoam use absoluteEnthalpy,but the there solvers are only used in premixed-combustion or partly-premixedcombustion.Compare with old vision,we can use absoluteEnthalpy like in reactingFoam or FireFoam.So I do not think it is not more convenient than old vision when using thermo class to define thermo type in OF2.2.1.Why do OpenFoam change thermo class?I can not understand. |
Quote:
Also, you need to take care of the source terms in the transport equations!!! Quote:
So yes, if you want to use a chemistry solver you are limitied to sensibleEnthalpy in standard OpenFOAM. Quote:
But why would you anyways want to use absoluteEnthalpy instead of sensibleEnthalpy? I don't see any reason for this! Seems right now only to be trouble with no advantage whatsoever! In fact, I do understand why the OpenFOAM developers preferred sensibleEnthalpy over absoluteEnthalpy enthalpy, especially when thinking of sprays and other source terms in the transport equations. But as already said, it's mainly a matter of taste which which one you choose, the results is the same in the end! |
Dear dkxls:
Thanks for your reply again.The solver I use is not developed by myself.It is based on openfoam2.0.1.My teacher ask me to make the solver use in openfoam2.2.1.Although the solver is used to simulation combustion ,but it do not solver transport equation and do not use chemistry solver.Due to the conbustion model the solver uses ,I have to use absoluteEnthalpy,and the original solver(2.0.1) also use absoluteEnthalpy.It is why I use absoluteEnthalpy. Today,I use your attached file "myThermo" without any change.when I run my case,I found there are more two thermotype you defined as following: thermoType { type hePsiThermo; mixture multiComponentMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; } thermoType { type hePsiThermo; mixture multiComponentMixture; transport sutherland; thermo hConst; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; } However if I replace "multiComponentMixture" to "reactingMixture" and add "#include "reactingMixture.H" in your myThermos.C,then run command "wmake libso" and run my case,it gives me error.There have no new thermotype combination.I really do not understand.Is it related to the number in file "PaxHeaders.8962",what does other file which contain numbers use?The numbers are like: 30 mtime=1379156401.926678512 30 atime=1379156401.926678512 30 ctime=1379156401.929678475 30 mtime=1379156508.559345421 30 atime=1379156508.559345421 30 ctime=1379156508.566345333 Does the keyword "multiComponentMixture" corresponding to these numbers?If it is ,what numbers can corresponding to "reactingMixture"?please give me some advise,thank you in advance! |
Quote:
Quote:
The code in createFields.H should then look something like this (similar to PDRFoam): Code:
autoPtr<psiReactionThermo> pThermo IIRC, the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff. |
Dear dkxls:
As you say,I use CHEMKIN in my solver. Quote:
I changed codes in my createFields.H as you say ,but do not get rid of "this stuff".My thermopysicalProperties is as following: FoamFile { version 2.0; format binary; class dictionary; location "constant"; object thermophysicalProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // thermoType { type hePsiThermo; mixture multiComponentMixtureMixture; transport sutherland; thermo janaf; energy absuluteEnthalpy; equationOfState perfectGas; specie specie; } CHEMKINFile "$FOAM_CASE/chemkin/chem.inp"; CHEMKINThermoFile "$FOAM_CASE/chemkin/therm.dat"; inertSpecie N2; /************************************************** *******************/ when I run my case ,it gives me error : keyword species is undefined in dictionary "/home/.../thermophysicalProperties".My specises is defined in chem.inp,why it still give me error? Quote:
Quote:
|
This looks very much like you are using the OpenFOAM chemistry solver and the CHEMKIN reader!
I have just one recommendation for you in this case: Use sensibleEnthalpy! |
Thank you for all your replys !I will have a try.
|
Quote:
|
2 Attachment(s)
Dear dkxls:
I have used "sensibleEnthalpy" to run my case,but the temperature is not right and it is lower than before.I think it is related to "sensibleEnthalpy" I used.I should use "absoluteEnthalpy " solver the problem. You have said to me that : Quote:
As you said,the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff. So ,I must modify chemisryReader class.I found the follow codes: Quote:
|
my attachment
1 Attachment(s)
Dear dkxls:
I send you a private message.This is my attachmentAttachment 25829. |
1 Attachment(s)
Dear dkxls:
Thank you for your previous replies! I think I still have to use "absoluteEnthalpy".I am new to OpenFOAM.I had a great progress by your help about my problem ,But if I would like to solve my problemcompletely, your help is necessary for me. According to your "myThermos.C",I add the following codes into "myThermos.C": Code:
makeReactionMixtureThermo Quote:
thermoType { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy absoluteEnthalpy; equationOfState perfectGas; specie specie; },so I add the codes: Code:
makeReactionMixtureThermo Quote:
Attachment 25835 |
Quote:
I'm trying to create a thermo model that combines hConst thermodynamics with Sutherland transport for a multiComponentMixture. I edited a couple lines in the files you provided to do this, but when I try to wmake I get the following error: Quote:
Also I'm not clear how to link a solver against a new library, do you think you could give me a quick step-by-step? Thanks. -B |
Can you upload your modified version?
The error looks rather strange as a thermo shouldn't pull in any dependencies on AMI or the like. |
I posted earlier some instructions on how to include a lib in a solver (or even a case):
http://www.cfd-online.com/Forums/ope...tml#post452252 http://www.cfd-online.com/Forums/ope...tml#post451937 |
1 Attachment(s)
Quote:
|
I checked your code and it seems fine.
I also don't get any compilation error, it just compiles fine! Just to make sure: 1. You need OpenFOAM version 2.2.x 2. Compiling is done like this: Code:
cd path/to/myThermo Code:
EXE_INC = \ |
Thanks, I'm still getting the same error. The full message looks like this:
Code:
~/OpenFOAM/bschmidt-2.2.0/src/thermoPhysicalModels/myThermo$ wmake libso |
OK, sounds a bit strange. I doubt that it has something to do with the OF version (I never used 2.2.0 though, I upgraded directly from 2.0.x to a 2.2.x git version newer than 2.2.1).
Are these files (cyclicAMILduInterfaceField.H, ...) listed in your myThermos.dep file? In mine they are not, actually there is no *AMI*.H file at all in my myThermos.dep. Just to make sure: You ran 'wclean' in the 'myThermo' directory? And there is no old 'myThermos.dep' left? (You can savely remove the *.dep files, wmake will generate new ones.) Otherwise, I have no idea since I cannot reproduce your error. |
Those files are not in my dependency file, and I always run wclean before wmake. The only *AMI* files in myThermos.dep are *AMIFvPatch* files. I was trying to trace back from the error message what line of code was calling for this *AMILdu* file, but I can't find it.
Maybe you can help me with this: why does the Make/options file need to include a link to the $LIB_SRC/finiteVolume/lnInclude folder? I can't find anything in the .C file or .H file that link to anything there. Maybe that will help me find where the erroneous call to *AMILdu* is being made. |
The files you include in your lib will include themselves new dependencies and you need to tell the compiler where to find them.
Something you could try is to change the options file to match the one in the thermo library: https://github.com/OpenFOAM/OpenFOAM...o/Make/options |
Ha! That worked! I only had to include one more line in the file,
Code:
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude |
Hi dkxls,
Have you shared your code to calculate the mixture viscosity and conductivity to public. "For mixture I use the formulations due to Wilke (viscosity) and Mathur (conductivity)" If you can share the code with me, it will be very helpful. And many thanks in advance. Zhong |
All times are GMT -4. The time now is 17:04. |