When calling f.save('backup.yaml', name="solution", overwrite=True), the output file does not get overwritten. I may be using this feature incorrectly, but I thought theoverwrite=Truemeant that the contents of the file will be overwritten by the current state of the flame.
Minimal example to showcase the issue is below. backup.yaml should have the contents of the backup_2.yaml. Looking at the mass-flux entry shows that it has the values from backup_1.yaml. The first backup file (backup_1.yaml) is from the starting solution, and backup_2.yaml is the solution in the flame after increasing the boundary mass fluxes and re-calling solve().
I may be using this feature incorrectly and I haven't had time to look at the save() method, but it felt like it might be a bug.
import cantera as ct
p = 101325 # pressure [Pascals]
fuel_inlet_temp= 800.0 # fuel inlet temperature [Kelvin]
oxidizer_inlet_temp= 711.0 # oxidizer inlet temperature [Kelvin]
fuel_mdot= 0.5 # kg/m^2/s
width= 50.0e-3 # Distance between inlets [m]
oxidizer_composition= 'O2:1.0' # oxidizer composition (right)
fuel_composition= 'H2:1.0' # fuel composition (left)
# Reaction mechanism
mechanism= 'h2o2.yaml'
gas = ct.Solution(mechanism)
gas.TPY = fuel_inlet_temp, p, oxidizer_composition
density_f = gas.density
gas.TPY = oxidizer_inlet_temp, p, oxidizer_composition
density_o = gas.density
#Unity Lewis number testing
gas.transport_model = 'unity-Lewis-number'
f = ct.CounterflowDiffusionFlame(gas, width=width)
f.set_refine_criteria(ratio=15, slope= 0.15, curve= 0.08, prune= 0.04)
#Set the state of the two inlets
f.fuel_inlet.mdot = fuel_mdot
f.fuel_inlet.X = fuel_composition
f.fuel_inlet.T = fuel_inlet_temp
#Create a guestimate for what the oxidizer mdot would be
f.oxidizer_inlet.mdot = (fuel_mdot / density_f) * density_o*4
f.oxidizer_inlet.X = oxidizer_composition
f.oxidizer_inlet.T = oxidizer_inlet_temp
# Generate initial condition
f.solve(auto=True, loglevel=6)
f.save('backup_1.yaml', name="solution", overwrite=True)
f.save('backup.yaml', name="solution", overwrite=True)
print('mdot info:')
print('Fuel mdot: ' + str(f.fuel_inlet.mdot))
print('Oxidizer mdot: ' + str(f.oxidizer_inlet.mdot))
print('BC State:')
print('Left U: ' + str(f.velocity[0]))
print('Right U: ' + str(f.velocity[-1]))
# Now change the conditions, re-run the flame and overwrite the solution
f.fuel_inlet.mdot = f.fuel_inlet.mdot*2
f.oxidizer_inlet.mdot = f.oxidizer_inlet.mdot*2
f.solve()
f.save('backup_2.yaml', name="solution", overwrite=True)
f.save('backup.yaml', name="solution", overwrite=True)
I can reproduce a bug here. While part of the solution in backup.yaml is overwritten, the two inlets aren't modified. Further, the flame domain output is scrambled.
When calling
f.save('backup.yaml', name="solution", overwrite=True)
, the output file does not get overwritten. I may be using this feature incorrectly, but I thought theoverwrite=True
meant that the contents of the file will be overwritten by the current state of the flame.Minimal example to showcase the issue is below.
backup.yaml
should have the contents of thebackup_2.yaml
. Looking at themass-flux
entry shows that it has the values frombackup_1.yaml
. The first backup file (backup_1.yaml
) is from the starting solution, andbackup_2.yaml
is the solution in the flame after increasing the boundary mass fluxes and re-callingsolve()
.I may be using this feature incorrectly and I haven't had time to look at the save() method, but it felt like it might be a bug.