mirror of
https://github.com/Cantera/cantera.git
synced 2026-08-08 20:18:24 -05:00
[Input] Improve errors for bad float formatting in NASA7 entries
This commit is contained in:
committed by
Ingmar Schoegl
parent
e0eeb20262
commit
3f4c856fd9
@@ -937,8 +937,8 @@ class Parser:
|
||||
for i,j,k in [(1,0,15), (1,15,30), (1,30,45), (1,45,60),
|
||||
(1,60,75), (2,0,15), (2,15,30)]]
|
||||
low_coeffs = [fortFloat(lines[i][j:k])
|
||||
for i,j,k in [(2,30,45), (2,45,60), (2,60,75), (3,0,15),
|
||||
(3,15,30), (3,30,45), (3,45,60)]]
|
||||
for i,j,k in [(2,30,45), (2,45,60), (2,60,75), (3,0,15),
|
||||
(3,15,30), (3,30,45), (3,45,60)]]
|
||||
|
||||
# Cases where only one temperature range is needed
|
||||
if Tint == Tmin or Tint == Tmax or high_coeffs == low_coeffs:
|
||||
@@ -998,7 +998,15 @@ class Parser:
|
||||
used.update(entry_lines)
|
||||
self.current_entry = entry
|
||||
self.line_number = input_lineno
|
||||
name, thermo, comp = self.read_NASA7_entry(entry, TintDefault, comments)
|
||||
try:
|
||||
name, thermo, comp = self.read_NASA7_entry(entry, TintDefault,
|
||||
comments)
|
||||
except ValueError as err:
|
||||
logger.error(self.entry("thermo entry") + str(err))
|
||||
comments = []
|
||||
marker = '1'
|
||||
continue
|
||||
|
||||
if name not in self.species_dict:
|
||||
if self.skip_undeclared_species:
|
||||
logger.debug(f"Skipping unexpected species '{name}' while "
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
THERMO ALL
|
||||
300.000 1000.000 5000.000
|
||||
H2 TPIS78H 2 G 200.000 3500.000 1000.000 1
|
||||
3.33727920E+00-4.94024731E-05 4.99456778E-07-1.79566394E-10 2.00255376E-14 2
|
||||
-9.50158922E+02-3.20502331E+00 2.34433112E+00 7.98052075E-03-1.94781510E-05 3
|
||||
2.01572094E-08-7.37611761E-12-9.17935173E+02 6.83010238E-01 4
|
||||
C10H20QJDQB C 10H 21O 4 G 0300.00 5000.00 1000.00 1
|
||||
0.34605728E+02 0.51931810E-01-0.15951700E-04 0.23693092E-08-0.13905114E-12 2
|
||||
-0.52524566E+05-0.13525214E+03-0.35101023E+ 0.1490370200E+00-0.10659422E-03 3
|
||||
0.30515071E-07 0.18942989E-12-0.43008395E+05 0.44972477E+02 4
|
||||
H2O L 8/89H 2O 1 G 200.000 3500.000 1000.000 1
|
||||
3.03399249E+00 2.17691804E-03-1.64072518E-07-9.70419870E-11 1.68200992E-14 2
|
||||
-3.00042971E+04 4.96677010E+00 4.19864056E+00-2.03643410E-03 6.52040211E-06 3
|
||||
-5.48797062E-09 1.77197817E-12-3.02937267E+04-8.49032208E-01 4
|
||||
END
|
||||
@@ -168,6 +168,13 @@ class ck2yamlTest(utilities.CanteraTest):
|
||||
gas = ct.Solution(yaml=yaml)
|
||||
assert set(gas.species_names) == {"O", "H", "H2O"}
|
||||
|
||||
def test_bad_nasa7_float(self):
|
||||
with pytest.raises(ck2yaml.InputError):
|
||||
self.convert(None, thermo='bad-nasa7-float.dat')
|
||||
|
||||
captured = self._capsys.readouterr()
|
||||
assert "could not convert string to float: '-0.35101023e+ 0'" in captured.out
|
||||
|
||||
def test_bad_nasa9_temperature_ranges(self):
|
||||
with pytest.raises(ck2yaml.InputError,
|
||||
match="non-adjacent temperature ranges"):
|
||||
|
||||
Reference in New Issue
Block a user