|
[Sponsors] |
July 16, 2013, 21:13 |
Defining custom Cp library under 2.2.x
|
#1 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14 |
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 ( psiThermo, hePsiThermo, pureMixture, sutherlandTransport, sensibleEnthalpy, myJanafThermo, perfectGas, specie ); Code:
Unknown psiThermo type thermoType { type hePsiThermo; mixture pureMixture; transport sutherland; thermo myJanaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Valid psiThermo types are: type mixture transport thermo equationOfState specie energy ... hePsiThermo pureMixture sutherland janaf perfectGas specie sensibleInternalEnergy hePsiThermo pureMixture sutherland perfectGas specie sensibleEnthalpy hePsiThermo reactingMixture const hConst perfectGas specie sensibleEnthalpy ... 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 #0 /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x25) [0x7ffd89369cd5] #1 /home/carisman/OpenFOAM/carisman-2.2.0/platforms/linux64GccDPOpt/lib/libRCBFV2.0Specie.so(+0x148e9c) [0x7ffd8acd3e9c] #2 /lib64/ld-linux-x86-64.so.2(+0xf306) [0x7ffd8dac6306] #3 /lib64/ld-linux-x86-64.so.2(+0xf3df) [0x7ffd8dac63df] #4 /lib64/ld-linux-x86-64.so.2(+0x16ea) [0x7ffd8dab86ea] Duplicate entry irreversibleArrheniusReaction in runtime selection table Reaction #0 /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x25) [0x7ffd89369cd5] #1 /home/carisman/OpenFOAM/carisman-2.2.0/platforms/linux64GccDPOpt/lib/libRCBFV2.0Specie.so(+0x14fc88) [0x7ffd8acdac88] #2 /lib64/ld-linux-x86-64.so.2(+0xf306) [0x7ffd8dac6306] #3 /lib64/ld-linux-x86-64.so.2(+0xf3df) [0x7ffd8dac63df] #4 /lib64/ld-linux-x86-64.so.2(+0x16ea) [0x7ffd8dab86ea] Duplicate entry reversibleArrheniusReaction in runtime selection table Reaction #0 /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x25) [0x7ffd89369cd5] #1 /home/carisman/OpenFOAM/carisman-2.2.0/platforms/linux64GccDPOpt/lib/libRCBFV2.0Specie.so(+0x14fc34) [0x7ffd8acdac34] #2 /lib64/ld-linux-x86-64.so.2(+0xf306) [0x7ffd8dac6306] #3 /lib64/ld-linux-x86-64.so.2(+0xf3df) [0x7ffd8dac63df] #4 /lib64/ld-linux-x86-64.so.2(+0x16ea) [0x7ffd8dab86ea] |
|
July 16, 2013, 21:34 |
|
#2 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14 |
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 static word typeName() { return "janaf<" + EquationOfState::typeName() + '>'; } |
|
September 14, 2013, 07:28 |
|
#3 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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! |
|
September 14, 2013, 08:14 |
|
#4 |
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
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 |
|
September 14, 2013, 15:04 |
|
#5 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14 |
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 >.>. |
|
September 14, 2013, 23:23 |
|
#6 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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! |
|
September 15, 2013, 05:43 |
|
#7 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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:pen(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! |
|
September 15, 2013, 06:54 |
|
#8 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
I have upload my attachement,myThermo.zipplease help me to have a look!
Last edited by zqlhzx; September 15, 2013 at 08:09. |
|
September 15, 2013, 09:43 |
|
#9 |
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
@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! |
|
September 15, 2013, 09:57 |
|
#10 | ||
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
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. |
|||
September 15, 2013, 10:55 |
|
#11 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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. |
|
September 16, 2013, 05:08 |
|
#12 | ||
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
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. Well the new thermo classes bring many really good changes and remove a lot of duplicated code! Even if there are right now not that many new features, the infrastructure is now in place to add them! 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! |
|||
September 16, 2013, 05:53 |
|
#13 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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! |
|
September 16, 2013, 06:43 |
|
#14 | |
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
Quote:
Well, if you don't use the chemistry solver, then just get rid of this stuff altogether and use psiReactionThermo without the chemistry part. The code in createFields.H should then look something like this (similar to PDRFoam): Code:
autoPtr<psiReactionThermo> pThermo ( psiReactionThermo::New(mesh) ); psiReactionThermo& thermo = pThermo(); thermo.validate(args.executable(), "ha"); IIRC, the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff. |
||
September 16, 2013, 09:56 |
|
#15 | |||
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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:
|
||||
September 16, 2013, 11:30 |
|
#16 |
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19 |
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! |
|
September 16, 2013, 13:03 |
|
#17 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
Thank you for all your replys !I will have a try.
|
|
September 18, 2013, 18:23 |
|
#18 | |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14 |
Quote:
|
||
September 22, 2013, 05:32 |
|
#19 | ||
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
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:
|
|||
October 5, 2013, 09:22 |
my attachment
|
#20 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 13 |
Dear dkxls:
I send you a private message.This is my attachmentmyThermo.zip. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Multi species mass transport library [update] | novyno | OpenFOAM Community Contributions | 111 | November 10, 2021 00:37 |
flow solver won't recognize custom library | hakonbar | OpenFOAM Programming & Development | 2 | April 7, 2014 09:09 |
Compiled library vs. inInclude Files, DSMC solver crashes after run | GPesch | OpenFOAM Programming & Development | 8 | April 18, 2013 08:17 |
defining custom convetive terms | CFD user | CFX | 1 | February 22, 2009 23:40 |
OpenFOAM141dev linking error on IBM AIX 52 | matthias | OpenFOAM Installation | 24 | April 28, 2008 16:49 |