Skip to content

Commit 668db6a

Browse files
committed
add log based calculation of aggregate in utility file
1 parent b2a084b commit 668db6a

File tree

11 files changed

+2214
-117
lines changed

11 files changed

+2214
-117
lines changed

src/common/printers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void print( CArrayWrapper< T, NROWS, NCOLS > const & matrix, char const * name,
2525
char format[8];
2626
snprintf( format, 8, "%%%d.%de", numDigits+7, numDigits );
2727

28-
printf( "%-9s = { \n", name );
28+
printf( "%-9s = \n{ \n", name );
2929
for( int i=0; i<NROWS; ++i )
3030
{
3131
printf( " { " );
@@ -37,7 +37,7 @@ void print( CArrayWrapper< T, NROWS, NCOLS > const & matrix, char const * name,
3737
printf( ", " );
3838
}
3939
}
40-
printf( "},\n" );
40+
printf( " },\n" );
4141
}
4242
printf( " }\n" );
43-
}
43+
}

src/common/symmetricMatrix.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ struct symmetricMatrix
55
{
66
static constexpr INDEX_TYPE size() { return ( N*(N+1) ) / 2; }
77

8-
static inline INDEX_TYPE linearIndex( INDEX_TYPE const i, INDEX_TYPE const j )
9-
{
10-
return (( i*(i+1) ) >> 1) + j;
8+
static inline INDEX_TYPE linearIndex( INDEX_TYPE const i, INDEX_TYPE const j )
9+
{
10+
return (( i*(i+1) ) >> 1) + j;
1111
}
12-
13-
inline T & operator()( INDEX_TYPE const i, INDEX_TYPE const j )
14-
{
15-
return m_data[linearIndex(i,j)];
12+
13+
inline T & operator()( INDEX_TYPE const i, INDEX_TYPE const j )
14+
{
15+
return m_data[linearIndex( i, j )];
1616
}
17-
18-
inline T const & operator()( INDEX_TYPE const i, INDEX_TYPE const j ) const
19-
{
20-
return m_data[linearIndex(i,j)];
17+
18+
inline T const & operator()( INDEX_TYPE const i, INDEX_TYPE const j ) const
19+
{
20+
return m_data[linearIndex( i, j )];
2121
}
2222

2323
T m_data[ size() ];
2424

25-
};
25+
};

src/docs/unitTestSolutions.nb

Lines changed: 175 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
NotebookFileLineBreakTest
1111
NotebookFileLineBreakTest
1212
NotebookDataPosition[ 154, 7]
13-
NotebookDataLength[ 82206, 1786]
14-
NotebookOptionsPosition[ 31799, 870]
15-
NotebookOutlinePosition[ 78081, 1723]
16-
CellTagsIndexPosition[ 78038, 1720]
13+
NotebookDataLength[ 87425, 1920]
14+
NotebookOptionsPosition[ 36820, 1002]
15+
NotebookOutlinePosition[ 83103, 1855]
16+
CellTagsIndexPosition[ 83060, 1852]
1717
WindowFrame->Normal*)
1818

1919
(* Beginning of Notebook Content *)
@@ -788,13 +788,45 @@ Cell[BoxData["ExpectedReactionRates"], "Output",
788788
Cell[CellGroupData[{
789789

790790
Cell[BoxData[{
791-
RowBox[{
792-
RowBox[{"Soln", "=",
793-
RowBox[{"NSolve", "[",
791+
RowBox[{"NSolve", "[",
792+
RowBox[{
793+
RowBox[{"{",
794794
RowBox[{
795-
RowBox[{"{",
796-
RowBox[{
795+
RowBox[{
796+
FractionBox[
797+
RowBox[{
798+
RowBox[{"(",
799+
RowBox[{"0", "+", "\[Xi]1"}], ")"}], " ",
800+
RowBox[{"(",
801+
RowBox[{"0.5", "\[VeryThinSpace]", "+", "\[Xi]1", "-", "\[Xi]2"}],
802+
")"}]}],
803+
SuperscriptBox[
804+
RowBox[{"(",
805+
RowBox[{"1", "-",
806+
RowBox[{"2", " ", "\[Xi]1"}]}], ")"}], "2"]], "\[Equal]", "1"}],
807+
",",
808+
RowBox[{
809+
FractionBox[
810+
SuperscriptBox[
811+
RowBox[{"(",
812+
RowBox[{"0", "+",
813+
RowBox[{"2", " ", "\[Xi]2"}]}], ")"}], "2"],
797814
RowBox[{
815+
RowBox[{"(",
816+
RowBox[{"1", "-", "\[Xi]2"}], ")"}], " ",
817+
RowBox[{"(",
818+
RowBox[{"0.5", "\[VeryThinSpace]", "+", "\[Xi]1", "-", "\[Xi]2"}],
819+
")"}]}]], "\[Equal]", "1"}]}], "}"}], ",",
820+
RowBox[{"{",
821+
RowBox[{"\[Xi]1", ",", "\[Xi]2"}], "}"}], ",", "Reals"}],
822+
"]"}], "\[IndentingNewLine]",
823+
RowBox[{"Soln", "=",
824+
RowBox[{"NSolve", "[",
825+
RowBox[{
826+
RowBox[{"{",
827+
RowBox[{
828+
RowBox[{
829+
RowBox[{"Log", "[",
798830
FractionBox[
799831
RowBox[{
800832
RowBox[{"(",
@@ -805,9 +837,10 @@ Cell[BoxData[{
805837
SuperscriptBox[
806838
RowBox[{"(",
807839
RowBox[{"1", "-",
808-
RowBox[{"2", " ", "\[Xi]1"}]}], ")"}], "2"]], "\[Equal]", "1"}],
809-
",",
810-
RowBox[{
840+
RowBox[{"2", " ", "\[Xi]1"}]}], ")"}], "2"]], "]"}], "\[Equal]",
841+
"0"}], ",",
842+
RowBox[{
843+
RowBox[{"Log", "[",
811844
FractionBox[
812845
SuperscriptBox[
813846
RowBox[{"(",
@@ -818,58 +851,157 @@ Cell[BoxData[{
818851
RowBox[{"1", "-", "\[Xi]2"}], ")"}], " ",
819852
RowBox[{"(",
820853
RowBox[{"0.5", "\[VeryThinSpace]", "+", "\[Xi]1", "-", "\[Xi]2"}],
821-
")"}]}]], "\[Equal]", "1"}]}], "}"}], ",",
822-
RowBox[{"{",
823-
RowBox[{"\[Xi]1", ",", "\[Xi]2"}], "}"}], ",", "Reals"}], "]"}]}],
824-
";"}], "\[IndentingNewLine]",
825-
RowBox[{"Ceq", "=",
826-
RowBox[{
854+
")"}]}]], "]"}], "\[Equal]", "0"}]}], "}"}], ",",
855+
RowBox[{"{",
856+
RowBox[{"\[Xi]1", ",", "\[Xi]2"}], "}"}], ",", "Reals"}],
857+
"]"}]}], "\[IndentingNewLine]",
858+
RowBox[{"MatrixForm", "[",
859+
RowBox[{"Ceq", "=",
827860
RowBox[{"(",
828861
RowBox[{
829-
RowBox[{"c\[Xi]sub", "/.", "Soln"}], "/.", "params"}], ")"}], "[",
830-
RowBox[{"[", "3", "]"}], "]"}]}], "\[IndentingNewLine]",
831-
RowBox[{"CForm", "[", "Ceq", "]"}]}], "Input",
862+
RowBox[{"c\[Xi]sub", "/.", "Soln"}], "/.", "params"}], ")"}]}],
863+
"]"}]}], "Input",
832864
CellChangeTimes->{{3.950621622967383*^9, 3.950621682644403*^9}, {
833865
3.9506217524874353`*^9, 3.950621757449176*^9}, {3.950621847834559*^9,
834866
3.950621914741967*^9}, {3.9506219682108183`*^9, 3.950621985732566*^9}, {
835867
3.9506220569636793`*^9, 3.950622110061811*^9}, {3.950622530822591*^9,
836-
3.9506225404486094`*^9}, {3.9506225782489367`*^9, 3.9506226038553057`*^9}},
868+
3.9506225404486094`*^9}, {3.9506225782489367`*^9, 3.9506226038553057`*^9}, {
869+
3.950640959674222*^9, 3.950640992498761*^9}, {3.95064122966012*^9,
870+
3.9506412419950438`*^9}, {3.9506412908715553`*^9, 3.950641308127881*^9}},
837871
CellLabel->
838-
"In[163]:=",ExpressionUUID->"7155e2a2-6d83-4e5d-9e3b-07e69a5cf2e6"],
872+
"In[177]:=",ExpressionUUID->"7155e2a2-6d83-4e5d-9e3b-07e69a5cf2e6"],
839873

840874
Cell[BoxData[
841875
RowBox[{"{",
842876
RowBox[{
843-
RowBox[{"c1", "\[Rule]", "0.39213829392412436`"}], ",",
844-
RowBox[{"c2", "\[Rule]", "0.3039308530379378`"}], ",",
845-
RowBox[{"c3", "\[Rule]", "0.5059454807719976`"}], ",",
846-
RowBox[{"c4", "\[Rule]", "0.7020146277340598`"}], ",",
847-
RowBox[{"c5", "\[Rule]", "0.5959707445318804`"}]}], "}"}]], "Output",
877+
RowBox[{"{",
878+
RowBox[{
879+
RowBox[{"\[Xi]2", "\[Rule]",
880+
RowBox[{"-", "1.6073650941506716`"}]}], ",",
881+
RowBox[{"\[Xi]1", "\[Rule]", "1.8562110873209028`"}]}], "}"}], ",",
882+
RowBox[{"{",
883+
RowBox[{
884+
RowBox[{"\[Xi]2", "\[Rule]", "0.4093759165599023`"}], ",",
885+
RowBox[{"\[Xi]1", "\[Rule]", "1.0443695326897278`"}]}], "}"}], ",",
886+
RowBox[{"{",
887+
RowBox[{
888+
RowBox[{"\[Xi]2", "\[Rule]", "0.2979853722659402`"}], ",",
889+
RowBox[{"\[Xi]1", "\[Rule]", "0.3039308530379378`"}]}], "}"}], ",",
890+
RowBox[{"{",
891+
RowBox[{
892+
RowBox[{"\[Xi]2", "\[Rule]",
893+
RowBox[{"-", "0.8499961946751704`"}]}], ",",
894+
RowBox[{"\[Xi]1", "\[Rule]", "0.2121551936180979`"}]}], "}"}]}],
895+
"}"}]], "Output",
848896
CellChangeTimes->{
849897
3.9506214931045713`*^9, {3.9506216160942087`*^9, 3.950621642955104*^9},
850898
3.9506216847753563`*^9, 3.950621757962051*^9, {3.950621854695477*^9,
851899
3.950621986048752*^9}, {3.950622058080862*^9, 3.950622110419211*^9},
852-
3.950622541334856*^9, 3.950622626076048*^9},
900+
3.950622541334856*^9, {3.9506409645439043`*^9, 3.950640992901922*^9},
901+
3.950641242594755*^9, {3.950641288609098*^9, 3.9506413084502897`*^9}},
853902
CellLabel->
854-
"Out[164]=",ExpressionUUID->"e488c769-c308-42d7-9cac-9964c9ee417b"],
903+
"Out[177]=",ExpressionUUID->"195e6961-fb79-4c6c-adb3-3f720ef6798e"],
855904

856-
Cell["\<\
857-
List(Rule(c1,0.39213829392412436),Rule(c2,0.3039308530379378),Rule(c3,0.\
858-
5059454807719976),Rule(c4,0.7020146277340598),Rule(c5,0.5959707445318804))\
859-
\>", "Output",
905+
Cell[BoxData[
906+
TemplateBox[{
907+
"NSolve", "ratnz",
908+
"\"NSolve was unable to solve the system with inexact coefficients. The \
909+
answer was obtained by solving a corresponding exact system and numericizing \
910+
the result.\"", 2, 178, 37, 18570802661536798748, "Local"},
911+
"MessageTemplate"]], "Message", "MSG",
912+
CellChangeTimes->{
913+
3.95064124259179*^9, {3.950641288606017*^9, 3.950641308469611*^9}},
914+
CellLabel->
915+
"During evaluation of \
916+
In[177]:=",ExpressionUUID->"d31e37c6-f0ae-415d-82e0-a5e91d291f0b"],
917+
918+
Cell[BoxData[
919+
RowBox[{"{",
920+
RowBox[{
921+
RowBox[{"{",
922+
RowBox[{
923+
RowBox[{"\[Xi]1", "\[Rule]", "0.21215519361809793`"}], ",",
924+
RowBox[{"\[Xi]2", "\[Rule]",
925+
RowBox[{"-", "0.8499961946751705`"}]}]}], "}"}], ",",
926+
RowBox[{"{",
927+
RowBox[{
928+
RowBox[{"\[Xi]1", "\[Rule]", "0.3039308530379379`"}], ",",
929+
RowBox[{"\[Xi]2", "\[Rule]", "0.2979853722659402`"}]}], "}"}], ",",
930+
RowBox[{"{",
931+
RowBox[{
932+
RowBox[{"\[Xi]1", "\[Rule]", "1.0443695326897278`"}], ",",
933+
RowBox[{"\[Xi]2", "\[Rule]", "0.40937591655990224`"}]}], "}"}], ",",
934+
RowBox[{"{",
935+
RowBox[{
936+
RowBox[{"\[Xi]1", "\[Rule]", "1.8562110873209032`"}], ",",
937+
RowBox[{"\[Xi]2", "\[Rule]",
938+
RowBox[{"-", "1.607365094150672`"}]}]}], "}"}]}], "}"}]], "Output",
939+
CellChangeTimes->{
940+
3.9506214931045713`*^9, {3.9506216160942087`*^9, 3.950621642955104*^9},
941+
3.9506216847753563`*^9, 3.950621757962051*^9, {3.950621854695477*^9,
942+
3.950621986048752*^9}, {3.950622058080862*^9, 3.950622110419211*^9},
943+
3.950622541334856*^9, {3.9506409645439043`*^9, 3.950640992901922*^9},
944+
3.950641242594755*^9, {3.950641288609098*^9, 3.950641308472361*^9}},
945+
CellLabel->
946+
"Out[178]=",ExpressionUUID->"8b9e8922-9e93-44f7-90fe-ecb2a1465f07"],
947+
948+
Cell[BoxData[
949+
TagBox[
950+
RowBox[{"(", "\[NoBreak]", GridBox[{
951+
{
952+
RowBox[{"c1", "\[Rule]", "0.5756896127638041`"}],
953+
RowBox[{"c2", "\[Rule]", "0.21215519361809793`"}],
954+
RowBox[{"c3", "\[Rule]", "1.5621513882932683`"}],
955+
RowBox[{"c4", "\[Rule]", "1.8499961946751706`"}],
956+
RowBox[{"c5", "\[Rule]",
957+
RowBox[{"-", "1.699992389350341`"}]}]},
958+
{
959+
RowBox[{"c1", "\[Rule]", "0.39213829392412425`"}],
960+
RowBox[{"c2", "\[Rule]", "0.3039308530379379`"}],
961+
RowBox[{"c3", "\[Rule]", "0.5059454807719976`"}],
962+
RowBox[{"c4", "\[Rule]", "0.7020146277340598`"}],
963+
RowBox[{"c5", "\[Rule]", "0.5959707445318804`"}]},
964+
{
965+
RowBox[{"c1", "\[Rule]",
966+
RowBox[{"-", "1.0887390653794555`"}]}],
967+
RowBox[{"c2", "\[Rule]", "1.0443695326897278`"}],
968+
RowBox[{"c3", "\[Rule]", "1.1349936161298255`"}],
969+
RowBox[{"c4", "\[Rule]", "0.5906240834400978`"}],
970+
RowBox[{"c5", "\[Rule]", "0.8187518331198045`"}]},
971+
{
972+
RowBox[{"c1", "\[Rule]",
973+
RowBox[{"-", "2.7124221746418065`"}]}],
974+
RowBox[{"c2", "\[Rule]", "1.8562110873209032`"}],
975+
RowBox[{"c3", "\[Rule]", "3.9635761814715753`"}],
976+
RowBox[{"c4", "\[Rule]", "2.607365094150672`"}],
977+
RowBox[{"c5", "\[Rule]",
978+
RowBox[{"-", "3.214730188301344`"}]}]}
979+
},
980+
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
981+
GridBoxSpacings->{"Columns" -> {
982+
Offset[0.27999999999999997`], {
983+
Offset[0.7]},
984+
Offset[0.27999999999999997`]}, "Rows" -> {
985+
Offset[0.2], {
986+
Offset[0.4]},
987+
Offset[0.2]}}], "\[NoBreak]", ")"}],
988+
Function[BoxForm`e$,
989+
MatrixForm[BoxForm`e$]]]], "Output",
860990
CellChangeTimes->{
861991
3.9506214931045713`*^9, {3.9506216160942087`*^9, 3.950621642955104*^9},
862992
3.9506216847753563`*^9, 3.950621757962051*^9, {3.950621854695477*^9,
863993
3.950621986048752*^9}, {3.950622058080862*^9, 3.950622110419211*^9},
864-
3.950622541334856*^9, 3.9506226260766983`*^9},
994+
3.950622541334856*^9, {3.9506409645439043`*^9, 3.950640992901922*^9},
995+
3.950641242594755*^9, {3.950641288609098*^9, 3.9506413084732027`*^9}},
865996
CellLabel->
866-
"Out[165]//CForm=",ExpressionUUID->"4c36d946-e59c-4a3c-a3a5-66e38520f0e1"]
997+
"Out[179]//MatrixForm=",ExpressionUUID->"407f4898-0e4c-4a1e-8aee-\
998+
70ded463acc9"]
867999
}, Open ]]
8681000
}, Open ]]
8691001
}, Open ]]
8701002
},
871-
WindowSize->{1699, 1665},
872-
WindowMargins->{{507, Automatic}, {-48, Automatic}},
1003+
WindowSize->{1699, 1051},
1004+
WindowMargins->{{360, Automatic}, {-192, Automatic}},
8731005
DockedCells->{
8741006
Cell[
8751007
BoxData[
@@ -1782,9 +1914,11 @@ Cell[27946, 771, 349, 6, 33, "Output",ExpressionUUID->"4d3faebd-101c-48e5-927a-c
17821914
Cell[28298, 779, 345, 5, 33, "Output",ExpressionUUID->"7b951bf1-2b60-4693-9a7d-fc1c2b23f8bc"]
17831915
}, Open ]],
17841916
Cell[CellGroupData[{
1785-
Cell[28680, 789, 1797, 48, 92, "Input",ExpressionUUID->"7155e2a2-6d83-4e5d-9e3b-07e69a5cf2e6"],
1786-
Cell[30480, 839, 721, 14, 33, "Output",ExpressionUUID->"e488c769-c308-42d7-9cac-9964c9ee417b"],
1787-
Cell[31204, 855, 555, 10, 47, "Output",ExpressionUUID->"4c36d946-e59c-4a3c-a3a5-66e38520f0e1"]
1917+
Cell[28680, 789, 2900, 82, 116, "Input",ExpressionUUID->"7155e2a2-6d83-4e5d-9e3b-07e69a5cf2e6"],
1918+
Cell[31583, 873, 1248, 29, 33, "Output",ExpressionUUID->"195e6961-fb79-4c6c-adb3-3f720ef6798e"],
1919+
Cell[32834, 904, 503, 11, 26, "Message",ExpressionUUID->"d31e37c6-f0ae-415d-82e0-a5e91d291f0b"],
1920+
Cell[33340, 917, 1244, 28, 33, "Output",ExpressionUUID->"8b9e8922-9e93-44f7-90fe-ecb2a1465f07"],
1921+
Cell[34587, 947, 2193, 50, 94, "Output",ExpressionUUID->"407f4898-0e4c-4a1e-8aee-70ded463acc9"]
17881922
}, Open ]]
17891923
}, Open ]]
17901924
}, Open ]]

src/reactions/bulkGeneric/EquilibriumReactions.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class EquilibriumReactions
5050

5151
private:
5252
template< typename PARAMS_DATA,
53-
typename ARRAY_1D,
54-
typename ARRAY_1D_TO_CONST,
55-
typename ARRAY_1D_TO_CONST2,
56-
typename ARRAY_2D >
53+
typename ARRAY_1D,
54+
typename ARRAY_1D_TO_CONST,
55+
typename ARRAY_1D_TO_CONST2,
56+
typename ARRAY_2D >
5757
static HPCREACT_HOST_DEVICE void
5858
computeResidualAndJacobianReactionExtents( RealType const & temperature,
5959
PARAMS_DATA const & params,
@@ -79,11 +79,11 @@ void
7979
EquilibriumReactions< REAL_TYPE,
8080
INT_TYPE,
8181
INDEX_TYPE >::computeResidualAndJacobian( REAL_TYPE const & temperature,
82-
PARAMS_DATA const & params,
83-
ARRAY_1D_TO_CONST const & speciesConcentration0,
84-
ARRAY_1D_TO_CONST2 const & xi,
85-
ARRAY_1D & residual,
86-
ARRAY_2D & jacobian )
82+
PARAMS_DATA const & params,
83+
ARRAY_1D_TO_CONST const & speciesConcentration0,
84+
ARRAY_1D_TO_CONST2 const & xi,
85+
ARRAY_1D & residual,
86+
ARRAY_2D & jacobian )
8787
{
8888

8989
HPCREACT_UNUSED_VAR( temperature );
@@ -163,9 +163,9 @@ void
163163
EquilibriumReactions< REAL_TYPE,
164164
INT_TYPE,
165165
INDEX_TYPE >::enforceEquilibrium( REAL_TYPE const & temperature,
166-
PARAMS_DATA const & params,
167-
ARRAY_1D_TO_CONST const & speciesConcentration0,
168-
ARRAY_1D & speciesConcentration )
166+
PARAMS_DATA const & params,
167+
ARRAY_1D_TO_CONST const & speciesConcentration0,
168+
ARRAY_1D & speciesConcentration )
169169
{
170170
HPCREACT_UNUSED_VAR( temperature );
171171
constexpr int numSpecies = PARAMS_DATA::numSpecies;
@@ -249,4 +249,3 @@ EquilibriumReactions< REAL_TYPE,
249249

250250
} // namespace bulkGeneric
251251
} // namespace hpcReact
252-

0 commit comments

Comments
 (0)