[Cython] Fix format strings for compatibility with Python 2.6
This commit is contained in:
parent
988f300e6b
commit
3fe2cd9bbb
9 changed files with 16 additions and 16 deletions
|
|
@ -71,7 +71,7 @@ for i in range(npoints):
|
|||
mix.equilibrate('HP', solver='gibbs', max_steps=1000)
|
||||
|
||||
tad[i] = mix.T
|
||||
print('At phi = {:12.4g}, Tad = {:12.4g}'.format(phi[i], tad[i]))
|
||||
print('At phi = {0:12.4g}, Tad = {1:12.4g}'.format(phi[i], tad[i]))
|
||||
xeq[:,i] = mix.species_moles
|
||||
|
||||
# write output CSV file for importing into Excel
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ f.solve(loglevel=loglevel, refine_grid=refine_grid)
|
|||
f.save('h2_adiabatic.xml', 'energy',
|
||||
'solution with mixture-averaged transport')
|
||||
f.show_solution()
|
||||
print('mixture-averaged flamespeed = {:7f} m/s'.format(f.u[0]))
|
||||
print('mixture-averaged flamespeed = {0:7f} m/s'.format(f.u[0]))
|
||||
|
||||
# Solve with multi-component transport properties
|
||||
f.transport_model = 'Multi'
|
||||
f.solve(loglevel, refine_grid)
|
||||
f.show_solution()
|
||||
print('multicomponent flamespeed = {:7f} m/s'.format(f.u[0]))
|
||||
print('multicomponent flamespeed = {0:7f} m/s'.format(f.u[0]))
|
||||
f.save('h2_adiabatic.xml','energy_multi',
|
||||
'solution with multicomponent transport')
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ sim = ct.ReactorNet([mixer])
|
|||
|
||||
# Since the mixer is a reactor, we need to integrate in time to reach steady
|
||||
# state. A few residence times should be enough.
|
||||
print('{:>14s} {:>14s} {:>14s} {:>14s} {:>14s}'.format(
|
||||
print('{0:>14s} {1:>14s} {2:>14s} {3:>14s} {4:>14s}'.format(
|
||||
't [s]', 'T [K]', 'h [J/kg]', 'P [Pa]', 'X_CH4'))
|
||||
|
||||
t = 0.0
|
||||
|
|
@ -65,7 +65,7 @@ for n in range(30):
|
|||
tres = mixer.mass/(mfc1.mdot(t) + mfc2.mdot(t))
|
||||
t += 0.5*tres
|
||||
sim.advance(t)
|
||||
print('{:14.5g} {:14.5g} {:14.5g} {:14.5g} {:14.5g}'.format(
|
||||
print('{0:14.5g} {1:14.5g} {2:14.5g} {3:14.5g} {4:14.5g}'.format(
|
||||
t, mixer.T, mixer.thermo.h, mixer.thermo.P, mixer.thermo['CH4'].X[0]))
|
||||
|
||||
# view the state of the gas in the mixer
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ mass_flow_rate = velocity * gas.density * area
|
|||
TDY = gas.TDY
|
||||
cov = surf.coverages
|
||||
|
||||
print((' {:>10s}'*4).format('distance', 'X_CH4', 'X_H2', 'X_CO'))
|
||||
print(' distance X_CH4 X_H2 X_CO')
|
||||
|
||||
for n in range(NReactors):
|
||||
surf.TP = TDY[0], ct.one_atm
|
||||
|
|
@ -148,7 +148,7 @@ for n in range(NReactors):
|
|||
dist = n * rlen * 1.0e3 # distance in mm
|
||||
|
||||
if not n % 10:
|
||||
print((' {:10f}'*4).format(dist, *gas['CH4','H2','CO'].X))
|
||||
print(' {0:10f} {1:10f} {2:10f} {3:10f}'.format(dist, *gas['CH4','H2','CO'].X))
|
||||
|
||||
# write the gas mole fractions and surface coverages vs. distance
|
||||
writer.writerow([dist, r.T - 273.15, r.thermo.P/ct.one_atm] +
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def show_coverages(s):
|
|||
cov = s.coverages
|
||||
names = s.species_names
|
||||
for n in range(s.n_species):
|
||||
print('{:16s} {:13.4g}'.format(names[n], cov[n]))
|
||||
print('{0:16s} {1:13.4g}'.format(names[n], cov[n]))
|
||||
|
||||
|
||||
def equil_OCV(gas1, gas2):
|
||||
|
|
|
|||
|
|
@ -50,15 +50,15 @@ cdef class Kinetics(_SolutionBase):
|
|||
|
||||
def _check_phase_index(self, n):
|
||||
if not 0 <= n < self.n_phases:
|
||||
raise ValueError("Phase index ({}) out of range".format(n))
|
||||
raise ValueError("Phase index ({0}) out of range".format(n))
|
||||
|
||||
def _check_reaction_index(self, n):
|
||||
if not 0 <= n < self.n_reactions:
|
||||
raise ValueError("Reaction index ({}) out of range".format(n))
|
||||
raise ValueError("Reaction index ({0}) out of range".format(n))
|
||||
|
||||
def _check_kinetics_species_index(self, n):
|
||||
if not 0 <= n < self.n_total_species:
|
||||
raise ValueError("Kinetics Species index ({}) out of range".format(n))
|
||||
raise ValueError("Kinetics Species index ({0}) out of range".format(n))
|
||||
|
||||
def kinetics_species_index(self, int species, int phase):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ cdef class Mixture:
|
|||
4.0
|
||||
"""
|
||||
if not 0 <= k < self.n_species:
|
||||
raise IndexError('Species index ({}) out of range (0 < {})'.format(k, self.n_species))
|
||||
raise IndexError('Species index ({0}) out of range (0 < {1})'.format(k, self.n_species))
|
||||
return self.mix.nAtoms(k, self.element_index(m))
|
||||
|
||||
property n_phases:
|
||||
|
|
@ -332,7 +332,7 @@ cdef class Mixture:
|
|||
iSolver = 1
|
||||
else:
|
||||
raise ValueError('Unrecognized equilibrium solver '
|
||||
'specified: "{}"'.format(solver))
|
||||
'specified: "{0}"'.format(solver))
|
||||
|
||||
vcs_equilibrate(deref(self.mix), stringify(XY).c_str(), estimate_equil,
|
||||
print_level, iSolver, rtol, max_steps, max_iter,
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ cdef class Sim1D:
|
|||
idom = i
|
||||
dom = d
|
||||
if idom is None:
|
||||
raise KeyError('Domain named "{}" not found.'.format(dom))
|
||||
raise KeyError('Domain named "{0}" not found.'.format(dom))
|
||||
|
||||
assert 0 <= idom < len(self.domains)
|
||||
return idom
|
||||
|
|
@ -933,7 +933,7 @@ class FlameBase(Sim1D):
|
|||
list(getattr(self.gas, species)))
|
||||
csvfile.close()
|
||||
if not quiet:
|
||||
print("Solution saved to '{}'.".format(filename))
|
||||
print("Solution saved to '{0}'.".format(filename))
|
||||
|
||||
|
||||
def _trim(docstring):
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ def compareTextFiles(env, file1, file2):
|
|||
abserr = abs(num1-num2)
|
||||
relerr = abserr / (0.5 * abs(num1 + num2) + atol)
|
||||
if abserr > (1.1*delta + atol) and relerr > rtol:
|
||||
print 'Values differ: {: 14g} {: 14g}; rel. err = {:.3e}; abs. err = {:.3e}'.format(num1, num2, relerr, abserr)
|
||||
print 'Values differ: {0: 14g} {1: 14g}; rel. err = {2:.3e}; abs. err = {3:.3e}'.format(num1, num2, relerr, abserr)
|
||||
allMatch = False
|
||||
break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue