as you said now i’ve to do the implementation of the parameters " In multireactions.cc file
starting at line 60 where there is a series of if … else if … else if …
then i create a new paragraph with the parameter values and
equation .
As pointed out in the prerequisites section of the LIBPF™ SDK Developer manual, to develop models with LIBPF™ a basic knowledge of the C++11 programming language is required.
For the first screenshot specifically (multireactions.cc), first of all you have fallen prey of mistake #10 from the list of “The 10 Most Common C++ Mistakes”: you forgot a semicolon. Actually you forgot semicolons at the end of lines 103, 104 and 105. This is a classic mistake, we’ve all gone through !
Please note that Qt Creator, thanks to its excellent real-time Code Syntax Checking functionality, is trying to tell you about these errors: if you notice, these lines are highlighted with a red wavy line; and if you hover on that, it will very likely tell you “You forgot a semicolon”.
Also for the 1st screenshot, there are other errors so fix them one by one with the help of the Code Syntax Checking functionality !
Apart from the errors, I also have a style comment: although perfectly legit, declaring variables with non-ASCII characters such as θ is something we advise against; for example in the LIBPF™ Coding Standard we advise against using UNICODE characters at all in source files. So I would name that variable “theta” or “t”.
For the 2nd screenshot (multireactions.h), AFAICT there’s a stray colon after the semicolon at the end of the line. Again, the red wavy line is there to point you to your error.
As to the 3rd screenshot (McfcCcsMcc.cc), that looks fine to me.
In the last screenshot (multireactions.cc) it looks like some variables (p1, p2, p3…) are defined multiple times. The wavy line this time is green (because Qt Creator is not 100% sure it’s an error) but I think that’s an error: if you try to build the project, the compiler will tell you !
Just declare the only new variable you’ve added (θ), or better yet rename that to theta or t and declare it.
Back to the original problem of defining a new kinetic expression for the electrochemical hydrogen oxydation (MultiReactionMcfc class), it looks to me you have done the following:
in the header file for the electrochemical reaction multireactions.h:
documented, in the MultiReactionMcfc class, the new available value for the kinetic option (finalmodel)
in the implementation file of the electrochemical reaction multireactions.cc:
declared the new variable you need for the new kinetic expression (theta)
added the values of the existing (p1, p2, p3…) and of the new parameter (theta) in the series of if ... else if ... else if ... that begins on line 62
leave the default kinetic = CONTEX at line 24 (DEFINE), so that all existing models still use that
in implementation file for your flowsheet McfcCcsMcc.cc:
at line 87, override the default value for kinetic so that the new expression is used in you own model only
So it looks to me just this final step is missing:
in the series of if ... else if ... else if ... that begins around line 114, add the new functional expression (for where would the new parameter be used ?)
then i haven’t understand how i have to do at line 87 of McfcCcsMcc.cc file .
And in the file multi reactions.cc in what way i have to insert the new kinetic??
you have overridden the default value for the kinetic option (set at line 24 or multireactions.cc to CONTEX) with your new value finalmodel so that’s OK.
What is now missing in the file multireactions.cc around line 114, is that the if branch of the if ... else statement covers the cases when the string option kinetic has the values literature or Robystad3 or BocciardoGarbarino, in those cases it uses for the areic electrical resistance the functional expression:
That looks like a step in the right direction. Of course you need to uncomment this new line 122 (remove the double forward slashes at the beginning). The compiler will then yell at you because not all required variables are entered in proper C++ syntax.
The function MultiReactionMcfc::calcE0 implements the pure virtual function MultiReactionElectrochemical::calcE0, from whose documentation here you can read the meaning of the x0 and x1 parameters.
Use those to access the molar fractions at the anode and the cathode side. They are vectors indexed by integers. To know which integer correspond to which component, check lines 161-168 of McfcCcsDriver.cc:
that means water will have index 0, N2 index 1 etc.
Alternatively you can use the syntax x0[components.lookup("H2")] as in the CONTEX expression, that uses the convenient helper function ListComponents::lookup which returns the index of component with name “n”.
This latter approach is better because if someone shuffles the component list, altering the order or adding new components, indexes may change. By using the ListComponents::lookup you’re always sure the index is correct !
Mmmmh difficult to say. Normally you should look at the first errors first, as sometimes the first one may cause unrelated effects in the new few lines.
If you don’t get the handle of it, just do a git commit -a -m 'errors' then git push and I’ll take a look tomorrow.
src/multireactions.cc:122:185: error: no matching function for call to 'pow'
...pow(P1),-0.25)*pow(outp[1]->frac(components.lookup("O2"),-0.75)*(pow(outp[1]->frac(components.look...
^~~
src/multireactions.cc:122:242: error: too many arguments to function call, expected single argument 'i',
have 2 arguments
...outp[1]->frac(components.lookup("O2"),-0.75)*(pow(outp[1]->frac(components.lookup("CO2"),0.5) + ((...
~~~~~~~~~~~~~ ^~~~~
src/multireactions.cc:122:293: error: too many arguments to function call, expected single argument 'i',
have 2 arguments
...outp[1]->frac(components.lookup("CO2"),0.5) + ((p7*Teq*exp(p8/Teq)))/(P1*log(1+outp[0]->frac(compo...
~~~~~~~~~~~~~ ^~~
src/multireactions.cc:173:10: error: use of undeclared identifier 'resistivity'
DEFINE(resistivity, "Resistivity electrolyte correlation", "Fabbri2008"),
...
You have to address them one by one, starting from the first three. The errors from line 173 onward are fakes, and caused by the first ones.
BTW for the sake of readability I advise you to break up the very long line; I usually insert line breaks after the operators (+ * / …).
src/multireactions.cc:122:185: error: no matching function for call to 'pow'
...pow(P1),-0.25)*pow(outp[1]->frac(components.lookup("O2"),-0.75)*(pow(outp[1]->frac(components.look...
^~~
is different from partial pressure structure, for example [quote=“paolog, post:20, topic:58”]
pow(outp[1]->frac(components.lookup(“O2”),-0.75)
[/quote]
now the errors are 19 like is shown in the figure! but the problems of the other lines, excepted line 127 are solved!! Now i’m trying to modify parentheses but i don’t find a solution!
in this way, it should be easier to spot the error !
3) you can introduce auxiliary variables to break up the large expression in tinier bits; this is precisely what has been done for the CONTEX kinetic:
Value pCO2 = P1 * x1[components.lookup("CO2")]; // 0: anode, 1: cathode
Value pH2 = P1 * x0[components.lookup("H2")];
Value Rohm = p1 * exp(p2/(Teq - Value(273.15, "K")));
Value Rcat = p3 * T * exp(p4/Teq) / pCO2; // + p5 * Teq * exp(p6/Teq) / sqrt(pO2) * pCO2;
Value Ran = p7 * T * exp(p8/Teq) / sqrt(pH2);
Rarea = Rohm + Rcat + Ran;