mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Python] Fix unordered SolutionArray append
This commit is contained in:
parent
10d775495d
commit
e647b9de63
@ -815,14 +815,14 @@ class SolutionArray(SolutionArrayBase):
|
||||
"the thermodynamic state".format(tuple(kwargs))
|
||||
) from None
|
||||
if normalize or attr.endswith("Q"):
|
||||
setattr(self._phase, attr, list(kwargs.values()))
|
||||
setattr(self._phase, attr, [kwargs[a] for a in attr])
|
||||
else:
|
||||
if attr.endswith("X"):
|
||||
self._phase.set_unnormalized_mole_fractions(kwargs.pop("X"))
|
||||
elif attr.endswith("Y"):
|
||||
self._phase.set_unnormalized_mass_fractions(kwargs.pop("Y"))
|
||||
attr = attr[:-1]
|
||||
setattr(self._phase, attr, list(kwargs.values()))
|
||||
setattr(self._phase, attr, [kwargs[a] for a in attr])
|
||||
|
||||
self._append(self._phase.state, extra_temp)
|
||||
self._indices.append(len(self._indices))
|
||||
|
@ -475,6 +475,16 @@ class TestSolutionArrayIO:
|
||||
assert states[0].P == gas.P
|
||||
assert states[0].Y == approx(gas.Y)
|
||||
|
||||
def test_append_scrambled_input(self):
|
||||
gas = ct.Solution("h2o2.yaml")
|
||||
gas.TP = 300, ct.one_atm
|
||||
gas.set_unnormalized_mass_fractions(np.full(gas.n_species, 0.3))
|
||||
states = ct.SolutionArray(gas)
|
||||
states.append(Y=gas.Y, P=gas.P, normalize=False, T=gas.T)
|
||||
assert states[0].T == gas.T
|
||||
assert states[0].P == gas.P
|
||||
assert states[0].Y == approx(gas.Y)
|
||||
|
||||
@pytest.mark.skipif("native" not in ct.hdf_support(),
|
||||
reason="Cantera compiled without HDF support")
|
||||
def test_import_no_norm_data(self):
|
||||
|
Loading…
Reference in New Issue
Block a user