CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Defining custom Cp library under 2.2.x (https://www.cfd-online.com/Forums/openfoam-programming-development/120888-defining-custom-cp-library-under-2-2-x.html)

ChrisA July 16, 2013 20:13

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
(
    psiThermo,
    hePsiThermo,
    pureMixture,
    sutherlandTransport,
    sensibleEnthalpy,
    myJanafThermo,
    perfectGas,
    specie
);

This seems to not be sufficient in the new version. With the new ThemoType definitions there seems to be an additional place to declare the new library name.... what leads me to believe this is at runtime my code gives the following error:

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 
...

You'll notice that the place where "myJanaf" should appear as a valid choice is blank shoving all the columns over to the side. I interpret this as the runtime selection table is reading the thermotypes from psiThermos.C and picking out the valid thermotypes but when it gets to "myJanafThermo" it can't recognize it and it skips over it.

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]

for what appears to be all of the runTime selection tables... or something, I don't completely understand whats going on there but it started happening as I added my thermotype so I imagine (hope) both issues resolve themselves together as soon as I find the piece of the puzzle I'm missing.

ChrisA July 16, 2013 20:34

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() + '>';
        }

I guess stopping for a minute to put a problem to "paper" is enough to jar the brain into a different and often more productive thinking state :p Although I'm still getting the duplicate entry stuff at the start of my code... for reasons unknown.

zqlhzx September 14, 2013 06:28

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!

dkxls September 14, 2013 07:14

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

ChrisA September 14, 2013 14:04

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 >.>.

zqlhzx September 14, 2013 22:23

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!

zqlhzx September 15, 2013 04:43

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!

zqlhzx September 15, 2013 05:54

1 Attachment(s)
I have upload my attachement,Attachment 25371please help me to have a look!

dkxls September 15, 2013 08:43

@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!

dkxls September 15, 2013 08:57

Quote:

Originally Posted by ChrisA (Post 451727)
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).

Ah, ok I see. Sounds good! :)

Quote:

Originally Posted by ChrisA (Post 451727)
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...

I use for accurate temperature depended viscosity data a polynomial expression (the same as in CHEMKIN):
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.

zqlhzx September 15, 2013 09:55

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.

dkxls September 16, 2013 04:08

Quote:

Originally Posted by zqlhzx (Post 451809)
Do you mean that I also have to change 'chemistryReader' and 'chemistrySolver' classes if I want to build my own thermo type...?

I right now don't know exactly what would be needed to get this also working with absoluteEnthalpy, but at least you need to instantiate the 'chemistrySolver' with absoluteEnthalpy as well (in a similar way as I did with makeReactionThermo).
Also, you need to take care of the source terms in the transport equations!!!

Quote:

Originally Posted by zqlhzx (Post 451809)
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.

The solvers you mention don't use the chemistry classes, hence no restriction from that side.
So yes, if you want to use a chemistry solver you are limitied to sensibleEnthalpy in standard OpenFOAM.

Quote:

Originally Posted by zqlhzx (Post 451809)
Why do OpenFoam change thermo class?I can not understand.

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!

zqlhzx September 16, 2013 04:53

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!

dkxls September 16, 2013 05:43

Quote:

Originally Posted by zqlhzx (Post 451952)
Although the solver is used to simulation combustion ,but it do not solver transport equation ...

This sound strange! Or is it a 0-dim case, i.e. something like CHEMKIN or chemFoam?

Quote:

Originally Posted by zqlhzx (Post 451952)
...and do not use chemistry solver.

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");

Then you should actually be able to use 'myThermo' without changes, hence you use 'multiComponentMixture' instead of 'reactingMixture'.
IIRC, the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff.

zqlhzx September 16, 2013 08:56

Dear dkxls:
As you say,I use CHEMKIN in my solver.
Quote:

if you don't use the chemistry solver, then just get rid of this stuff altogether and use psiReactionThermo without the chemistry part.
I am sorry to do not understanding your words "get rid of this stuff ".what does the "stuff" refer to ?Is file of PaxHeaders.8962 or file in chemistry class?
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:

chem.inp :
ELEMENTS C H O N END
SPECIES CH3COCH3 C2H6 O2 H2O CO CO2 H2 CH2CO CH4 CH2O C2H4 C2H2 H2O2 C3H6O CH3OH C3H6 C3H8 OH N2 END
REACTIONS
2CH3COCH3 + C2H6 + 11.5O2 = 8CO2 + 9H2O 5.2e16 0 14906
END
Quote:

Then you should actually be able to use 'myThermo' without changes, hence you use 'multiComponentMixture' instead of 'reactingMixture'.
IIRC, the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff.
Do you mean I have to use multiComponentMixture because my solver does not use chemistry slover?If I have to use reactingMixture ,what shoud I do?For me ,you are a kinds expert in openfoam.

dkxls September 16, 2013 10:30

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!

zqlhzx September 16, 2013 12:03

Thank you for all your replys !I will have a try.

ChrisA September 18, 2013 17:23

Quote:

Originally Posted by dkxls (Post 451806)
I use for accurate temperature depended viscosity data a polynomial expression (the same as in CHEMKIN):
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.

So what unspeakable deeds does one have to preform to sneak a peek at your Wilke viscosity mixture code? :D I'd be very interested in seeing how you did it.

zqlhzx September 22, 2013 04:32

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:

I right now don't know exactly what would be needed to get this also working with absoluteEnthalpy, but at least you need to instantiate the 'chemistrySolver' with absoluteEnthalpy as well (in a similar way as I did with makeReactionThermo).
I changed makeChemistrySolvers.C and makeChemistrySolverTypes.H in a similar way like you.But it failed.please take a look on my attachment.
As you said,the 'reactingMixture' is a 'multiComponentMixture' plus some chemistryReader stuff. So ,I must modify chemisryReader class.I found the follow codes:
Quote:

//- The type of thermo package the reader was instantiated for
typedef ThermoType thermoType;
I think I should instantiate the 'chemistryReader' with absoluteEnthalpy in a similar way as the above codes did. If you think my idea is right ,could you give advices how to modify the codes?I have tried many times ,but failed all.[ATTACH]Attachment 25523[/ATTACH]

zqlhzx October 5, 2013 08:22

my attachment
 
1 Attachment(s)
Dear dkxls:
I send you a private message.This is my attachmentAttachment 25829.

zqlhzx October 5, 2013 21:43

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
(
psiThermo,
psiReactionThermo,
hePsiThermo,
homogeneousMixture,
gasHaThermoPhysics
);
makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
inhomogeneousMixture,
gasHaThermoPhysics
);
makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
veryInhomogeneousMixture,
gasHaThermoPhysics
);

Then I can define the new four thermotypes like the following:

Quote:

thermoType
{
type hePsiThermo;
mixture homogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture inhomogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture veryInhomogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture multiComponentMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
However the thermotype I want to use is
thermoType
{
type hePsiThermo;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
},so I add the codes:
Code:

makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
reactingMixture,
gasHaThermoPhysics
)

into "myThermos.C".When I run my case ,it gave me error :
Quote:

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"
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 also add the file of "mymakeChemistrySolvers.C","mypsiChemistryMode ls", I still failed with the same error.I think I should also add the file of "mymakeChemistryReaders.C",but I do not know how to do it.How should I change the codes to correct the above error?Please take a look on my attachment.Thanks in advance!After reading your replies on CFD-online,I am sure you are experted in OpenFOAM and C++.
Attachment 25835

Bryan S December 9, 2013 12:26

Quote:

Originally Posted by dkxls (Post 451645)
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.

-Armin

Hi Armin,
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:

/opt/openfoam220/src/finiteVolume/lnInclude/cyclicAMIFvPatchField.H:62:40: fatal error: cyclicAMILduInterfaceField.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/myThermos.o] Error 1
Any suggestions for a fix?

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

dkxls December 10, 2013 03:23

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.

dkxls December 10, 2013 03:28

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

Bryan S December 10, 2013 12:18

1 Attachment(s)
Quote:

Originally Posted by dkxls (Post 465642)
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.

Sure, I just changed a couple lines from the files you uploaded to reflect the model I want to use.

dkxls December 11, 2013 04:28

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
wmake libso

3. Linking your solver against myThermo is done by editing the options file of your solver to look like this (here e.g. reactingFoam):
Code:

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
    -I$(LIB_SRC)/ODE/lnInclude \
    -I$(LIB_SRC)/combustionModels/lnInclude

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lfiniteVolume \
    -lfvOptions \
    -lmeshTools \
    -lsampling \
    -lcompressibleTurbulenceModel \
    -lcompressibleRASModels \
    -lcompressibleLESModels \
    -lreactionThermophysicalModels \
    -lspecie \
    -lfluidThermophysicalModels \
    -lchemistryModel \
    -lODE \
    -lcombustionModels \
  -lmyThermo


Bryan S December 11, 2013 12:26

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

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file myThermos.C
could not open file cyclicAMILduInterfaceField.H for source file myThermos.C
could not open file cyclicAMILduInterface.H for source file myThermos.C
could not open file cyclicAMIPolyPatch.H for source file myThermos.C
SOURCE=myThermos.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam220/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam220/src/thermophysicalModels/reactionThermo/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/myThermos.o
In file included from /opt/openfoam220/src/finiteVolume/lnInclude/jumpCyclicAMIFvPatchField.H:47:0,
                from /opt/openfoam220/src/finiteVolume/lnInclude/fixedJumpAMIFvPatchField.H:71,
                from /opt/openfoam220/src/finiteVolume/lnInclude/fixedJumpAMIFvPatchFields.H:29,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/heThermo.C:32,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/heThermo.H:320,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/hePsiThermo.H:39,
                from myThermos.C:30:
/opt/openfoam220/src/finiteVolume/lnInclude/cyclicAMIFvPatchField.H:62:40: fatal error: cyclicAMILduInterfaceField.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/myThermos.o] Error 1

I have OpenFOAM 2.2.0, I can't find where it's trying to call cyclicAMILduInterfaceField.H from, and I don't know why it would be calling that in the first place.

dkxls December 11, 2013 13:39

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.

Bryan S December 11, 2013 13:58

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.

dkxls December 11, 2013 16:10

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

Bryan S December 11, 2013 16:44

Ha! That worked! I only had to include one more line in the file,
Code:

-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
No idea why it works now and not before, but such is the nature of programming. Thanks for your help!

SH_Zhong July 25, 2017 02:29

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.