diff --git a/samples/python/onedim/diffusion_flame_batch.py b/samples/python/onedim/diffusion_flame_batch.py index 97f78b6d23..58dda388b1 100644 --- a/samples/python/onedim/diffusion_flame_batch.py +++ b/samples/python/onedim/diffusion_flame_batch.py @@ -98,7 +98,7 @@ def names(test): # Save to data directory file_name, entry = names("initial-solution") desc = "Initial hydrogen-oxygen counterflow flame at 1 bar and low strain rate" -f.save(file_name, name=entry, description=desc) +f.save(file_name, name=entry, description=desc, overwrite=True) # %% # Batch Pressure Loop @@ -148,7 +148,8 @@ def names(test): # Try solving the flame f.solve(loglevel=0) file_name, entry = names(f"pressure-loop/{p:05.1f}") - f.save(file_name, name=entry, description=f"pressure = {p} bar") + f.save(file_name, name=entry, description=f"pressure = {p} bar", + overwrite=True) p_previous = p except ct.CanteraError as e: print('Error occurred while solving:', e, 'Try next pressure level') @@ -201,7 +202,7 @@ def names(test): f.solve(loglevel=0) file_name, entry = names(f"strain-loop/{n:02d}") f.save(file_name, name=entry, - description=f"strain rate iteration {n}") + description=f"strain rate iteration {n}", overwrite=True) except FlameExtinguished: print('Flame extinguished') break @@ -238,9 +239,10 @@ def names(test): ax2.legend(loc=0) ax2.set_xlabel(r'$z/z_{max}$') ax2.set_ylabel(r'$u/u_f$') -fig1.savefig(output_path / "figure_u_p.png") +fig2.savefig(output_path / "figure_u_p.png") plt.show() +# %% fig3 = plt.figure() fig4 = plt.figure() ax3 = fig3.add_subplot(1, 1, 1) @@ -261,10 +263,10 @@ def names(test): ax3.legend(loc=0) ax3.set_xlabel(r'$z/z_{max}$') ax3.set_ylabel(r'$T$ [K]') -fig1.savefig(output_path / "figure_T_a.png") +fig3.savefig(output_path / "figure_T_a.png") ax4.legend(loc=0) ax4.set_xlabel(r'$z/z_{max}$') ax4.set_ylabel(r'$u/u_f$') -fig1.savefig(output_path / "figure_u_a.png") +fig4.savefig(output_path / "figure_u_a.png") plt.show() diff --git a/samples/python/onedim/diffusion_flame_extinction.py b/samples/python/onedim/diffusion_flame_extinction.py index 35683c3c09..43d09603b0 100644 --- a/samples/python/onedim/diffusion_flame_extinction.py +++ b/samples/python/onedim/diffusion_flame_extinction.py @@ -146,7 +146,8 @@ def names(test): # Flame is still burning, so proceed to next strain rate n_last_burning = n file_name, entry = names(f"extinction/{n:04d}") - f.save(file_name, name=entry, description=f"Solution at alpha = {alpha[-1]}") + f.save(file_name, name=entry, description=f"Solution at alpha = {alpha[-1]}", + overwrite=True) print('Flame burning at alpha = {:8.4F}. Proceeding to the next iteration, ' 'with delta_alpha = {}'.format(alpha[-1], delta_alpha)) @@ -155,7 +156,8 @@ def names(test): # strain rate increase is reached, save the last, non-burning, solution # to the output file and break the loop file_name, entry = names(f"extinction/{n:04d}") - f.save(file_name, name=entry, description=f"Flame extinguished at alpha={alpha[-1]}") + f.save(file_name, name=entry, overwrite=True, + description=f"Flame extinguished at alpha={alpha[-1]}") print('Flame extinguished at alpha = {0:8.4F}.'.format(alpha[-1]), 'Abortion criterion satisfied.') diff --git a/samples/python/onedim/flame_initial_guess.py b/samples/python/onedim/flame_initial_guess.py index 5e8d5f58cb..b1bbb4480f 100644 --- a/samples/python/onedim/flame_initial_guess.py +++ b/samples/python/onedim/flame_initial_guess.py @@ -64,7 +64,8 @@ def describe(flame): print("Save YAML") yaml_filepath = output_path / "flame.yaml" -f.save(yaml_filepath, name="solution", description="Initial methane flame") +f.save(yaml_filepath, name="solution", description="Initial methane flame", + overwrite=True) print("Save CSV") csv_filepath = output_path / "flame.csv" @@ -74,7 +75,8 @@ def describe(flame): # HDF is not a required dependency hdf_filepath = output_path / "flame.h5" hdf_filepath.unlink(missing_ok=True) - f.save(hdf_filepath, name="freeflame", description="Initial methane flame") + f.save(hdf_filepath, name="freeflame", description="Initial methane flame", + overwrite=True) print("Save HDF\n") else: print(f"Skipping HDF: Cantera compiled without HDF support\n")