Skip to content

Multicomponent diffusion coefficient documentation.#1227

Merged
speth merged 4 commits intoCantera:mainfrom
decaluwe:multiDiff
Mar 24, 2022
Merged

Multicomponent diffusion coefficient documentation.#1227
speth merged 4 commits intoCantera:mainfrom
decaluwe:multiDiff

Conversation

@decaluwe
Copy link
Copy Markdown
Member

@decaluwe decaluwe commented Mar 22, 2022

  • Adds content to multicomponent diffusion coefficient docstrings,
    to explain the matrix indexing.
  • Corrects an error in the multiDiffCoeffs.m docstring, regarding
    the data returned by the function (array vs. matrix).

If applicable, fill in the issue number this pull request is fixing

Closes Cantera/enhancements#143

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

- Adds content to multicomponent diffusion coefficient docstrings,
to explain the matrix indexing.
- Corrects an error in the multiDiffCoeffs.m docstring, regarding
the data returned by the function (array vs. matrix).
@speth
Copy link
Copy Markdown
Member

speth commented Mar 22, 2022

My thought on this is that the more critical thing to explain is that D[i,j] is the coefficient used for computing the contribution of the gradient in the concentration of species j to the diffusive flux of species i. The more generic statement that the first index is the row of the matrix and the second is the column doesn't even need to come into it.

Also, if you're updating the Python and Matlab docstrings, could you do the same for the C++ docstring as well?

@decaluwe
Copy link
Copy Markdown
Member Author

decaluwe commented Mar 22, 2022

I'll try to craft an update that covers both possible uncertainties.

By the C++ docstrings, do you mean in the include header files? Or is there another location?

@ischoegl
Copy link
Copy Markdown
Member

Also, if you're updating the Python and Matlab docstrings, could you do the same for the C++ docstring as well?

C++ docstring would be here ...

//! Return the Multicomponent diffusion coefficients. Units: [m^2/s].
/*!
* If the transport manager implements a multicomponent diffusion
* model, then this method returns the array of multicomponent
* diffusion coefficients. Otherwise it throws an exception.
*
* @param[in] ld The dimension of the inner loop of d (usually equal to m_nsp)
* @param[out] d flat vector of diffusion coefficients, fortran ordering.
* d[ld*j+i] is the D_ij diffusion coefficient (the diffusion
* coefficient for species i due to species j).
*/

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 22, 2022

Codecov Report

Merging #1227 (b0ba070) into main (5f94a85) will increase coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1227      +/-   ##
==========================================
+ Coverage   65.44%   65.47%   +0.03%     
==========================================
  Files         327      327              
  Lines       46321    46349      +28     
  Branches    19688    19688              
==========================================
+ Hits        30314    30349      +35     
  Misses      13475    13475              
+ Partials     2532     2525       -7     
Impacted Files Coverage Δ
include/cantera/transport/TransportBase.h 27.02% <ø> (ø)
include/cantera/kinetics/Falloff.h 74.57% <0.00%> (-3.39%) ⬇️
src/kinetics/Arrhenius.cpp 95.34% <0.00%> (-3.12%) ⬇️
include/cantera/kinetics/ReactionRate.h 84.09% <0.00%> (-2.28%) ⬇️
src/kinetics/ChebyshevRate.cpp 90.74% <0.00%> (-0.61%) ⬇️
src/kinetics/PlogRate.cpp 95.32% <0.00%> (-0.21%) ⬇️
include/cantera/kinetics/PlogRate.h 90.56% <0.00%> (ø)
include/cantera/kinetics/ChebyshevRate.h 98.46% <0.00%> (ø)
src/kinetics/Falloff.cpp 86.03% <0.00%> (+0.09%) ⬆️
src/oneD/Boundary1D.cpp 49.90% <0.00%> (+0.19%) ⬆️
... and 7 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

"""Multicomponent diffusion coefficients [m^2/s]."""
"""Multicomponent diffusion coefficients, D_{i,j} [m^2/s].

The coefficient D_{row,column} is used for computing the contribution of concentration gradients in species [column] to the diffusive flux of species [row]."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it's less obvious that row and column are placeholders for particular species indices here than just continuing to use i and j.

Copy link
Copy Markdown
Member Author

@decaluwe decaluwe Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are assuming, then, that all users understand that in D_{i,j} we mean that i = row and j = column?

I don't really know that I'd agree. But could cover this a different way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

The coefficient D_{i,j} is used for computing the contribution
of concentration gradients in species j to the diffusive flux of
species i, where i = row and j = column.

Copy link
Copy Markdown
Member Author

@decaluwe decaluwe Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, @speth I may be coming around to your point - knowing row and column is almost irrelevant, since the indices are how you access the individual coefficients, anyway. So regardless of which is row and which is column, D[i,j] in Python or D(i,j) in Matlab is how you access the value (C++ is different, since it is a flattened matrix, but that is already spelled out in the docstring).

I would be fine either with what I suggest in the comment above, or just replacing D_{i,j} with D[i,j] or D(i,j), as appropriate, in what I've currently got in the PR, dropping the row and column placeholders.

Thinking about it more, it is probably better to replace the D_{i,j}, no matter what.

Copy link
Copy Markdown
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stuff …

@decaluwe
Copy link
Copy Markdown
Member Author

Okay, one last set of tweaks. The C++ docstring was already pretty close to what we've been discussing, here (only missing the word "concentration" and the units, imho), so I just fixed that up, applied that in the Matlab and Python docstrings, and made each indexing expression match the format for that particular language.

I'll let y'all do with it what you will, at this point. :)

Copy link
Copy Markdown
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Copy Markdown
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @decaluwe, this came out really well!

@speth speth merged commit cd98c25 into Cantera:main Mar 24, 2022
@decaluwe decaluwe deleted the multiDiff branch March 24, 2022 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add to documentation: multi_diff_coeffs

4 participants