Repository navigation
Conversation
…307) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parse_embeddedinsource/input.f90picks units by checking substrings in sequence, with each later match overwriting the earlier one. In three places a shorter substring was checked after a longer one that contains it, so correctly written units were overwritten by the wrong unit (1000x errors, no warning, exit code 0). This change checks the shorter substring first so the longer unit wins.Issue: djkees#306
Originally fixed and merged in the djkees/cea fork as djkees#307; this is the same commit cherry-picked onto nasa/cea
main.Changes
handu: checkc(cal/mole) beforekc(kcal/mole), sokcalis no longer read ascal.v: checkg(cm3/g) beforekg(m3/kg).rho: checkg(g/cm3) beforekg(kg/m3).test_embeddedinsource/input_test.pf:h(kcal),h,kcal,u(kcal),v(m**3/kg),rho(kg/m**3),rho,kg/m**3, plus the forms that already worked (h,cal,h,kj,v(cm**3/g),rho(g/cc)).Why some syntaxes were affected and others not: the problem-section scanner replaces commas with spaces, so
v,m**3/kg=1passesm**3/kgstraight toconvert_units_to_si(exact match) and never reachesparse_embedded; only the parenthesis formv(m**3/kg)/rho(kg/m**3)did. The reactant-section scanner keeps commas, soh,kcalandh(kcal)both go throughparse_embedded. The same applies to reactantrho,kg/m**3, which was also misread, although reactant density is currently parsed but not used in any calculation.t,pandtceswere checked for the same pattern and are not affected: none of their accepted unit names (k/r/c/f;bar/atm/psi/psia/mmhg) contains another's match string.This is a minimal interim fix. The planned units rework (exact name matching against one reference table, see #121 and #124) would remove this class of bug entirely;
parse_embeddedandconvert_units_to_siare not restructured here.Testing
OK (122 tests), includingtest_embedded.test_embeddedcases fail against the unfixed code (expected: <"kcal/mole">) and pass with the fix.test/main_interface/test_main.py): 14/14 passed.cea.exe, before -> after:h,kcal=-17.9(HP, CH4/O2)h(kcal)=-17.9h,cal=-17900h,kj=-74.8936v(m**3/kg)=1(TV, H2/Air, 3000 K)rho(kg/m**3)=1v,m**3/kg=1rho,kg/m**3=1Compatibility / Numerical behavior
Results change only for inputs that were misread before:
h/ugiven in kcal (either syntax), andv(m**3/kg)/rho(kg/m**3)in the parenthesis syntax (plus reactantrhoin kg/m**3, which is parsed but unused). Inputs that were already read correctly are unaffected:.outfiles for all 14 legacy examples andsamples/rp1311_examples.inpare byte-identical between unmodified nasa/ceamainand this branch.Drafted with Claude's assistance
parse_embeddedand the two scanner paths (replace_delimiterswith and without comma replacement) directly.mainand pass with the fix.cea.exebinaries (unfixed and fixed) and reading the.outfiles..outfiles from unmodified nasa/ceamainand this branch for all legacy examples andsamples/rp1311_examples.inp.🤖 Generated with Claude Code