-
Notifications
You must be signed in to change notification settings - Fork 54
[newchem-cpp] transcribe make consistent #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: newchem-cpp
Are you sure you want to change the base?
[newchem-cpp] transcribe make consistent #417
Conversation
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
…ub.com/ChristopherBignamini/grackle into newchem-cpp_transcribe_make_consistent
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
src/clib/make_consistent.C
Outdated
iSN0 = my_chemistry->metal_abundances + 1; | ||
for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { | ||
Ct[i] = my_rates->SN0_XC[iSN0 - 1] * metal(i, j, k); | ||
Ot[i] = my_rates->SN0_XO[iSN0 - 1] * metal(i, j, k); | ||
Mgt[i] = my_rates->SN0_XMg[iSN0 - 1] * metal(i, j, k); | ||
Alt[i] = my_rates->SN0_XAl[iSN0 - 1] * metal(i, j, k); | ||
Sit[i] = my_rates->SN0_XSi[iSN0 - 1] * metal(i, j, k); | ||
St[i] = my_rates->SN0_XS[iSN0 - 1] * metal(i, j, k); | ||
Fet[i] = my_rates->SN0_XFe[iSN0 - 1] * metal(i, j, k); | ||
|
||
Cg[i] = my_rates->SN0_fC[iSN0 - 1] * metal(i, j, k); | ||
Og[i] = my_rates->SN0_fO[iSN0 - 1] * metal(i, j, k); | ||
Mgg[i] = my_rates->SN0_fMg[iSN0 - 1] * metal(i, j, k); | ||
Alg[i] = my_rates->SN0_fAl[iSN0 - 1] * metal(i, j, k); | ||
Sig[i] = my_rates->SN0_fSi[iSN0 - 1] * metal(i, j, k); | ||
Sg[i] = my_rates->SN0_fS[iSN0 - 1] * metal(i, j, k); | ||
Feg[i] = my_rates->SN0_fFe[iSN0 - 1] * metal(i, j, k); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this suggestion properly addresses all relevant off-by-one indexing
iSN0 = my_chemistry->metal_abundances + 1; | |
for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { | |
Ct[i] = my_rates->SN0_XC[iSN0 - 1] * metal(i, j, k); | |
Ot[i] = my_rates->SN0_XO[iSN0 - 1] * metal(i, j, k); | |
Mgt[i] = my_rates->SN0_XMg[iSN0 - 1] * metal(i, j, k); | |
Alt[i] = my_rates->SN0_XAl[iSN0 - 1] * metal(i, j, k); | |
Sit[i] = my_rates->SN0_XSi[iSN0 - 1] * metal(i, j, k); | |
St[i] = my_rates->SN0_XS[iSN0 - 1] * metal(i, j, k); | |
Fet[i] = my_rates->SN0_XFe[iSN0 - 1] * metal(i, j, k); | |
Cg[i] = my_rates->SN0_fC[iSN0 - 1] * metal(i, j, k); | |
Og[i] = my_rates->SN0_fO[iSN0 - 1] * metal(i, j, k); | |
Mgg[i] = my_rates->SN0_fMg[iSN0 - 1] * metal(i, j, k); | |
Alg[i] = my_rates->SN0_fAl[iSN0 - 1] * metal(i, j, k); | |
Sig[i] = my_rates->SN0_fSi[iSN0 - 1] * metal(i, j, k); | |
Sg[i] = my_rates->SN0_fS[iSN0 - 1] * metal(i, j, k); | |
Feg[i] = my_rates->SN0_fFe[iSN0 - 1] * metal(i, j, k); | |
} | |
iSN0 = my_chemistry->metal_abundances; | |
for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { | |
Ct[i] = my_rates->SN0_XC[iSN0] * metal(i, j, k); | |
Ot[i] = my_rates->SN0_XO[iSN0] * metal(i, j, k); | |
Mgt[i] = my_rates->SN0_XMg[iSN0] * metal(i, j, k); | |
Alt[i] = my_rates->SN0_XAl[iSN0] * metal(i, j, k); | |
Sit[i] = my_rates->SN0_XSi[iSN0] * metal(i, j, k); | |
St[i] = my_rates->SN0_XS[iSN0] * metal(i, j, k); | |
Fet[i] = my_rates->SN0_XFe[iSN0] * metal(i, j, k); | |
Cg[i] = my_rates->SN0_fC[iSN0] * metal(i, j, k); | |
Og[i] = my_rates->SN0_fO[iSN0] * metal(i, j, k); | |
Mgg[i] = my_rates->SN0_fMg[iSN0] * metal(i, j, k); | |
Alg[i] = my_rates->SN0_fAl[iSN0] * metal(i, j, k); | |
Sig[i] = my_rates->SN0_fSi[iSN0] * metal(i, j, k); | |
Sg[i] = my_rates->SN0_fS[iSN0] * metal(i, j, k); | |
Feg[i] = my_rates->SN0_fFe[iSN0] * metal(i, j, k); | |
} |
src/clib/make_consistent.C
Outdated
|
||
namespace grackle::impl { | ||
|
||
void make_consistent(const int* imetal, const double* dom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind refactoring so that imetal
and dom
are passed by value (and not passed by pointer)?
For reference, imetal
is a regular integer and dom
is a regular double
src/clib/make_consistent.C
Outdated
//===----------------------------------------------------------------------===// | ||
/// | ||
/// @file | ||
/// Declares signature of make_consistent_g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Declares signature of make_consistent_g | |
/// Implements the `make_consistent_g` function |
src/clib/make_consistent.C
Outdated
SN_i[1 - 1] = 1; | ||
//_// PORT: SN_metal(:, 1) = metal_loc(:,j,k) | ||
SN_i[2 - 1] = 2; | ||
//_// PORT: SN_metal(:, 2) = metal_C13(:,j,k) | ||
SN_i[3 - 1] = 3; | ||
//_// PORT: SN_metal(:, 3) = metal_C20(:,j,k) | ||
SN_i[4 - 1] = 4; | ||
//_// PORT: SN_metal(:, 4) = metal_C25(:,j,k) | ||
SN_i[5 - 1] = 5; | ||
//_// PORT: SN_metal(:, 5) = metal_C30(:,j,k) | ||
SN_i[6 - 1] = 6; | ||
//_// PORT: SN_metal(:, 6) = metal_F13(:,j,k) | ||
SN_i[7 - 1] = 7; | ||
//_// PORT: SN_metal(:, 7) = metal_F15(:,j,k) | ||
SN_i[8 - 1] = 8; | ||
//_// PORT: SN_metal(:, 8) = metal_F50(:,j,k) | ||
SN_i[9 - 1] = 9; | ||
//_// PORT: SN_metal(:, 9) = metal_F80(:,j,k) | ||
SN_i[10 - 1] = 10; | ||
//_// PORT: SN_metal(:,10) = metal_P170(:,j,k) | ||
SN_i[11 - 1] = 11; | ||
//_// PORT: SN_metal(:,11) = metal_P200(:,j,k) | ||
SN_i[12 - 1] = 12; | ||
//_// PORT: SN_metal(:,12) = metal_Y19(:,j,k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a reminder any line that starts with "//_// PORT: " is a line that the transcription script could not transcribe. Consequently, fixing the highlighted region will probably fix the failing tests
src/clib/CMakeLists.txt
Outdated
# C++ Source (and Private Header Files) | ||
cool_multi_time_g-cpp.C cool_multi_time_g-cpp.h | ||
internal_types.C internal_types.hpp | ||
make_consistent.C make_consistent.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably rename make_consistent.C
to make_consistent.cpp
. That is the new convention that we're adopting. But, I can fix that later if you prefer
… implemented manually
…ub.com/ChristopherBignamini/grackle into newchem-cpp_transcribe_make_consistent
pre-commit.ci autofix |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
…hem-cpp_transcribe_make_consistent
…ub.com/ChristopherBignamini/grackle into newchem-cpp_transcribe_make_consistent
I think the test is failing because you forgot to add |
correctH = | ||
(gr_float)(my_chemistry->HydrogenFractionByMass * metalfree[i] / | ||
totalH[i]); // TODO: which one is correct? | ||
// correctH = (gr_float)(my_chemistry->HydrogenFractionByMass*(1. - | ||
// my_chemistry->DeuteriumToHydrogenRatio)*metalfree[i]/totalH[i] | ||
// ); | ||
// // ! GC202005 | ||
// //- ! correctH = real(fh*metalfree(i)/totalH(i), RKIND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here? Did you manually add these comments yourself?
This logic doesn't seem to be present in the original version of the function...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that there were some changes to the make_consistent_g at one point. Is there a chance you transcribed an old version of the branch rather than the most recent version?
No description provided.