[1D/Examples] eliminate unnecessary setting of tolerances

For most problems, these new default tolerances for both time stepping and
steady state solves are more likely to converge than tighter tolerances, but
still give well-resolved results. Tighter tolerances are required in some cases,
e.g. when evaluating sensitivity coefficients by finite difference.
This commit is contained in:
Ray Speth 2016-03-25 15:03:44 -04:00
parent 059e657fe4
commit b56094b183
13 changed files with 5 additions and 86 deletions

View file

@ -146,10 +146,11 @@ public:
m_name.resize(m_nv,"");
m_max.resize(m_nv, 0.0);
m_min.resize(m_nv, 0.0);
m_rtol_ss.resize(m_nv, 1.0e-8);
m_atol_ss.resize(m_nv, 1.0e-15);
m_rtol_ts.resize(m_nv, 1.0e-8);
m_atol_ts.resize(m_nv, 1.0e-15);
// Default error tolerances for all domains
m_rtol_ss.resize(m_nv, 1.0e-4);
m_atol_ss.resize(m_nv, 1.0e-9);
m_rtol_ts.resize(m_nv, 1.0e-4);
m_atol_ts.resize(m_nv, 1.0e-11);
m_points = np;
m_z.resize(np, 0.0);
m_slast.resize(m_nv * m_points, 0.0);

View file

@ -63,10 +63,6 @@ def solve_flame(gas):
sim.reactants.mdot = 0.12 # kg/m^2/s
sim.products.mdot = 0.06 # kg/m^2/s
sim.flame.set_steady_tolerances(default=[1.0e-7, 1.0e-13])
sim.flame.set_transient_tolerances(default=[1.0e-7, 1.0e-11])
sim.set_initial_guess()
sim.energy_enabled = False
sim.solve(0, refine_grid=False)
sim.set_refine_criteria(ratio=3, slope=0.1, curve=0.2)

View file

@ -12,8 +12,6 @@ Tin = 300.0 # unburned gas temperature [K]
reactants = 'H2:1.1, O2:1, AR:5' # premixed gas composition
width = 0.03 # m
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-4, 1.0e-13] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 8)
refine_grid = True # 'True' to enable refinement, 'False' to disable
@ -24,9 +22,6 @@ gas.TPX = Tin, p, reactants
# Flame object
f = ct.FreeFlame(gas, width=width)
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)
f.show_solution()
# Solve with the energy equation disabled

View file

@ -11,8 +11,6 @@ mdot = 0.06
reactants = 'H2:1.5, O2:1, AR:7' # premixed gas composition
width = 0.5 # m
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-4, 1.0e-10] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
refine_grid = 1 # 1 to enable refinement, 0 to disable
@ -23,8 +21,6 @@ f = ct.BurnerFlame(gas, width=width)
f.burner.mdot = mdot
f.set_initial_guess()
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)
f.show_solution()
f.energy_enabled = False

View file

@ -18,9 +18,6 @@ comp_f = 'C2H6:1' # fuel composition
width = 0.02 # Distance between inlets is 2 cm
tol_ss = [1.0e-5, 1.0e-12] # [rtol, atol] for steady-state problem
tol_ts = [5.0e-4, 1.0e-11] # [rtol, atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
refine_grid = 1 # 1 to enable refinement, 0 to disable
@ -43,10 +40,6 @@ f.oxidizer_inlet.mdot = mdot_o
f.oxidizer_inlet.X = comp_o
f.oxidizer_inlet.T = tin_o
# Set error tolerances
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)
# Set the boundary emissivities
f.set_boundary_emissivities(0.0, 0.0)
# Turn radiation off

View file

@ -50,13 +50,8 @@ f.oxidizer_inlet.mdot = 3.0 # kg/m^2/s
f.oxidizer_inlet.X = 'O2:1'
f.oxidizer_inlet.T = 300 # K
# Define relative and absolute error tolerances
f.flame.set_steady_tolerances(default=[1.0e-5, 1.0e-12])
f.flame.set_transient_tolerances(default=[5.0e-4, 1.0e-11])
# Set refinement parameters, if used
f.set_refine_criteria(ratio=3.0, slope=0.1, curve=0.2, prune=0.03)
f.set_grid_min(1e-20)
# Define a limit for the maximum temperature below which the flame is
# considered as extinguished and the computation is aborted

View file

@ -43,15 +43,10 @@ f.oxidizer_inlet.mdot = 3.0 # kg/m^2/s
f.oxidizer_inlet.X = 'O2:1'
f.oxidizer_inlet.T = 500 # K
# Define relative and absolute error tolerances
f.flame.set_steady_tolerances(default=[1.0e-5, 1.0e-12])
f.flame.set_transient_tolerances(default=[5.0e-4, 1.0e-11])
# Enable refinement
refine = True
# Set refinement parameters
f.set_refine_criteria(ratio=3.0, slope=0.1, curve=0.2, prune=0.03)
f.set_grid_min(1e-20)
# Define a limit for the maximum temperature below which the flame is
# considered as extinguished and the computation is aborted

View file

@ -16,8 +16,6 @@ comp = 'CH4:0.65, O2:1, N2:3.76' # premixed gas composition
# The solution domain is chosen to be 1 cm
width = 0.01 # m
tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state problem
tol_ts = [1.0e-5, 1.0e-4] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
refine_grid = True # 'True' to enable refinement
@ -46,9 +44,6 @@ zloc /= max(zloc)
# set the temperature profile to the values read in
f.flame.set_fixed_temp_profile(zloc, tvalues)
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)
# show the initial estimate for the solution
f.show_solution()

View file

@ -18,8 +18,6 @@ rxnmech = 'h2o2.cti' # reaction mechanism file
comp = 'H2:1.6, O2:1, AR:7' # premixed gas composition
width = 0.2 # m
tol_ss = [1.0e-7, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-7, 1.0e-11] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
# Grid refinement parameters
@ -41,8 +39,6 @@ sim = ct.CounterflowPremixedFlame(gas=gas, width=width)
sim.reactants.mdot = mdot_reactants
sim.products.mdot = mdot_products
sim.flame.set_steady_tolerances(default=tol_ss)
sim.flame.set_transient_tolerances(default=tol_ts)
sim.set_initial_guess() # assume adiabatic equilibrium products
sim.show_solution()

View file

@ -34,8 +34,6 @@ comp = 'H2:1.8, O2:1, AR:7' # premixed gas composition
# The solution domain is chosen to be 20 cm
width = 0.2 # m
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-4, 1.0e-9] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
refine_grid = True
@ -62,8 +60,6 @@ sim.inlet.mdot = mdot[0]
# set the surface state
sim.surface.T = tsurf
sim.flame.set_steady_tolerances(default=tol_ss)
sim.flame.set_transient_tolerances(default=tol_ts)
sim.set_grid_min(1e-4)
sim.energy_enabled = False

View file

@ -33,10 +33,6 @@ comp2 = 'CH4:0.095, O2:0.21, N2:0.78, AR:0.01'
# The inlet/surface separation is 10 cm.
width = 0.1 # m
# numerical parameters
tol_ss = [1.0e-5, 1.0e-9] # [rtol, atol] for steady-state problem
tol_ts = [1.0e-4, 1.0e-9] # [rtol, atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
refine_grid = True # enable or disable refinement
@ -74,10 +70,6 @@ sim.inlet.T = tinlet
sim.inlet.X = comp1
sim.surface.T = tsurf
# Set error tolerances
sim.flame.set_steady_tolerances(default=tol_ss)
sim.flame.set_transient_tolerances(default=tol_ts)
# Show the initial solution estimate
sim.show_solution()

View file

@ -74,10 +74,6 @@ StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
setBounds(4+k, -1.0e-7, 1.0e5);
}
//-------------------- default error tolerances ----------------
setTransientTolerances(1.0e-8, 1.0e-15);
setSteadyTolerances(1.0e-8, 1.0e-15);
//-------------------- grid refinement -------------------------
m_refiner->setActive(0, false);
m_refiner->setActive(1, false);

View file

@ -112,10 +112,6 @@ void Inlet1D::init()
setBounds(0, -1e5, 1e5); // mdot
setBounds(1, 200.0, 1e5); // T
// set tolerances
setSteadyTolerances(1e-4, 1e-5);
setTransientTolerances(1e-4, 1e-5);
// if a flow domain is present on the left, then this must be a right inlet.
// Note that an inlet object can only be a terminal object - it cannot have
// flows on both the left and right
@ -265,10 +261,6 @@ string Empty1D::componentName(size_t n) const
void Empty1D::init()
{
setBounds(0, -1.0, 1.0);
// set tolerances
setSteadyTolerances(1e-4, 1e-4);
setTransientTolerances(1e-4, 1e-4);
}
void Empty1D::eval(size_t jg, doublereal* xg, doublereal* rg,
@ -317,10 +309,6 @@ void Symm1D::init()
{
_init(1);
setBounds(0, -1.0, 1.0);
// set tolerances
setSteadyTolerances(1e-4, 1e-4);
setTransientTolerances(1e-4, 1e-4);
}
void Symm1D::eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg,
@ -395,9 +383,6 @@ void Outlet1D::init()
_init(1);
setBounds(0, -1.0, 1.0);
// set tolerances
setSteadyTolerances(1e-4, 1e-4);
setTransientTolerances(1e-4, 1e-4);
if (m_flow_right) {
m_flow_right->setViscosityFlag(false);
}
@ -509,10 +494,6 @@ void OutletRes1D::init()
// set bounds (dummy)
setBounds(0, -1.0, 1.0);
// set tolerances
setSteadyTolerances(1e-4, 1e-4);
setTransientTolerances(1e-4, 1e-4);
if (m_flow_left) {
m_flow = m_flow_left;
} else if (m_flow_right) {
@ -639,10 +620,6 @@ void Surf1D::init()
_init(1);
// set bounds (T)
setBounds(0, 200.0, 1e5);
// set tolerances
setSteadyTolerances(1e-4, 1e-4);
setTransientTolerances(1e-4, 1e-4);
}
void Surf1D::eval(size_t jg, doublereal* xg, doublereal* rg,
@ -719,10 +696,6 @@ void ReactingSurf1D::init()
for (size_t n = 0; n < m_nsp; n++) {
setBounds(n+1, -1.0e-5, 2.0);
}
setSteadyTolerances(1.0e-5, 1.0e-9);
setTransientTolerances(1.0e-5, 1.0e-9);
setSteadyTolerances(1.0e-5, 1.0e-4, 0);
setTransientTolerances(1.0e-5, 1.0e-4, 0);
}
void ReactingSurf1D::resetBadValues(double* xg) {