extended the test_results_cantera
This commit is contained in:
parent
681e356451
commit
6f8eb2914c
|
|
@ -28,14 +28,14 @@ def test_equilibrium_cantera():
|
||||||
|
|
||||||
flow1 = ct.Solution('gri30.yaml') # type: ignore
|
flow1 = ct.Solution('gri30.yaml') # type: ignore
|
||||||
ct_results = []
|
ct_results = []
|
||||||
comp = (composition.array_fractions[i, j] for i in range(composition.shape[0]) for j in range(composition.shape[1]))
|
comp = [composition.array_fractions[i, j] for i in range(composition.shape[0]) for j in range(composition.shape[1])]
|
||||||
for c in comp:
|
for c in comp:
|
||||||
comp_dict = {s: v for s, v in zip(fs.species, c)}
|
comp_dict = {s: v for s, v in zip(fs.species, c)}
|
||||||
|
|
||||||
flow1.TP = t, p
|
flow1.TP = t, p
|
||||||
flow1.X = comp_dict
|
flow1.X = comp_dict
|
||||||
flow1.equilibrate('TP') # type: ignore
|
flow1.equilibrate('TP') # type: ignore
|
||||||
indeces = [i for flsn in fs.active_species for i, sn in enumerate(flow1.species_names) if flsn == sn] # type: ignore
|
indeces = [i for flsn in fs.species for i, sn in enumerate(flow1.species_names) if flsn == sn] # type: ignore
|
||||||
ct_results.append(flow1.X[indeces]) # type: ignore
|
ct_results.append(flow1.X[indeces]) # type: ignore
|
||||||
|
|
||||||
#if flow1.X[indeces][0] > 0.01:
|
#if flow1.X[indeces][0] > 0.01:
|
||||||
|
|
@ -45,8 +45,33 @@ def test_equilibrium_cantera():
|
||||||
|
|
||||||
deviations = np.abs(gp_result_array - ct_result_array)
|
deviations = np.abs(gp_result_array - ct_result_array)
|
||||||
|
|
||||||
for dev, gp_comp_result, ct_comp_result in zip(deviations, gp_result_array, ct_result_array):
|
for dev, gp_comp_result, ct_comp_result, c in zip(deviations, gp_result_array, ct_result_array, comp):
|
||||||
print(f"Composition: {gp_comp_result} / {ct_comp_result}")
|
comp_dict = {s: v for s, v in zip(fs.species, c)}
|
||||||
|
print(f"Inp. Composition: {comp_dict}")
|
||||||
|
print(f"Res. Composition: {gp_comp_result}")
|
||||||
|
print(f"Ref. Composition: {ct_comp_result}")
|
||||||
|
print(f"---")
|
||||||
assert np.all(dev < 0.04), f"Deviateion: {dev}"
|
assert np.all(dev < 0.04), f"Deviateion: {dev}"
|
||||||
|
|
||||||
assert np.mean(deviations) < 2e-4
|
assert np.mean(deviations) < 2e-4
|
||||||
|
|
||||||
|
|
||||||
|
def test_cantera():
|
||||||
|
|
||||||
|
t = 1495 + 273.15 # K
|
||||||
|
p = 1e5 # Pa
|
||||||
|
|
||||||
|
flow1 = ct.Solution('gri30.yaml') # type: ignore
|
||||||
|
flow1.TP = t, p
|
||||||
|
inp_comp = {'CH4': 0.0, 'H2O': 0.0, 'H2': 0.9508196721311476, 'CO2': 0.0, 'CO': 0.0, 'O2': 0.04918032786885246}
|
||||||
|
flow1.X = inp_comp
|
||||||
|
flow1.equilibrate('TP') # type: ignore
|
||||||
|
|
||||||
|
results: dict[str, float] = {sn: float(flow1.X[i]) for flsn in inp_comp for i, sn in enumerate(flow1.species_names) if flsn == sn} # type: ignore
|
||||||
|
|
||||||
|
print(inp_comp)
|
||||||
|
print(results)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_cantera()
|
||||||
Loading…
Reference in New Issue