diff --git a/leap/multistep/__init__.py b/leap/multistep/__init__.py index e357a47d6742adf5a4e2029487861d0743215a6f..4674cf6faf2340419c5a967f7bd20684e5e184df 100644 --- a/leap/multistep/__init__.py +++ b/leap/multistep/__init__.py @@ -49,7 +49,7 @@ def _linear_comb(coefficients, vectors): zip(coefficients, vectors))) -class ABIntegrationFunctionFamily(object): +class AdamsIntegrationFunctionFamily(object): def __len__(self): raise NotImplementedError() @@ -60,7 +60,7 @@ class ABIntegrationFunctionFamily(object): raise NotImplementedError() -class ABMonomialIntegrationFunctionFamily(ABIntegrationFunctionFamily): +class AdamsMonomialIntegrationFunctionFamily(AdamsIntegrationFunctionFamily): def __init__(self, order): self.order = order @@ -89,7 +89,7 @@ def _emit_func_family_operation(cb, name_gen, transpose = var("transpose") # use: - # Vandermonde^T * ab_coeffs = integrate(t_start, t_end, monomials) + # Vandermonde^T * a_coeffs = integrate(t_start, t_end, monomials) vdmt = var(name_gen("vdm_transpose")) cb(vdmt, array(nfunctions*hist_len)) @@ -106,10 +106,10 @@ def _emit_func_family_operation(cb, name_gen, for i in range(len(function_family)): cb(coeff_rhs[i], rhs_func(i)) - ab_coeffs = var(name_gen("ab_coeffs")) + a_coeffs = var(name_gen("a_coeffs")) if hist_len == nfunctions: - cb(ab_coeffs, linear_solve(vdmt, coeff_rhs, nfunctions, 1)) + cb(a_coeffs, linear_solve(vdmt, coeff_rhs, nfunctions, 1)) else: # Least squares with SVD builtin u = var(name_gen("u")) @@ -140,10 +140,10 @@ def _emit_func_family_operation(cb, name_gen, cb(intermed, matmul(v, sig_array, nfunctions, nfunctions)) cb(ainv, matmul(intermed, ut, nfunctions, nfunctions)) - cb(ab_coeffs, matmul(ainv, coeff_rhs, nfunctions, 1)) + cb(a_coeffs, matmul(ainv, coeff_rhs, nfunctions, 1)) return _linear_comb( - [ab_coeffs[ii] for ii in range(hist_len)], + [a_coeffs[ii] for ii in range(hist_len)], hist_vars) # }}} @@ -164,20 +164,20 @@ def _emit_func_family_operation(cb, name_gen, coeff_rhs[i] = rhs_func(i) if hist_len == nfunctions: - ab_coeffs = la.solve(vdm_t, coeff_rhs) + a_coeffs = la.solve(vdm_t, coeff_rhs) else: # SVD-based least squares solve u, sigma, v = la.svd(vdm_t, full_matrices=False) ainv = np.dot(v.transpose(), np.dot(la.inv(np.diag(sigma)), u.transpose())) - ab_coeffs = np.dot(ainv, coeff_rhs) + a_coeffs = np.dot(ainv, coeff_rhs) - return _linear_comb(ab_coeffs, hist_vars) + return _linear_comb(a_coeffs, hist_vars) # }}} -def emit_ab_integration(cb, name_gen, +def emit_adams_integration(cb, name_gen, function_family, time_values, hist_vars, t_start, t_end): return _emit_func_family_operation( cb, name_gen, function_family, time_values, hist_vars, @@ -186,7 +186,7 @@ def emit_ab_integration(cb, name_gen, - function_family.antiderivative(i, t_start))) -def emit_ab_extrapolation(cb, name_gen, +def emit_adams_extrapolation(cb, name_gen, function_family, time_values, hist_vars, t_eval): return _emit_func_family_operation( cb, name_gen, function_family, time_values, hist_vars, @@ -211,7 +211,7 @@ class AdamsBashforthMethodBuilder(MethodBuilder): hist_length=None, static_dt=False, order=None): """ :arg function_family: Accepts an instance of - :class:`ABIntegrationFunctionFamily` + :class:`AdamsIntegrationFunctionFamily` or an integer, in which case the classical monomial function family with the order given by the integer is used. :arg static_dt: If *True*, changing the timestep during time integration @@ -226,7 +226,7 @@ class AdamsBashforthMethodBuilder(MethodBuilder): del order if isinstance(function_family, int): - function_family = ABMonomialIntegrationFunctionFamily(function_family) + function_family = AdamsMonomialIntegrationFunctionFamily(function_family) super(AdamsBashforthMethodBuilder, self).__init__() self.function_family = function_family @@ -297,7 +297,7 @@ class AdamsBashforthMethodBuilder(MethodBuilder): cb_primary(rhs_var, self.eval_rhs(self.t, self.state)) history = self.history + [rhs_var] - ab_sum = emit_ab_integration( + ab_sum = emit_adams_integration( cb_primary, name_gen, self.function_family, time_hist, history, diff --git a/leap/multistep/multirate/__init__.py b/leap/multistep/multirate/__init__.py index a8481f19e6db212dc5ae81a666a7098eb29b0310..d35268254ce13e32aaabefd7b30295586bdbace3 100644 --- a/leap/multistep/multirate/__init__.py +++ b/leap/multistep/multirate/__init__.py @@ -1,4 +1,4 @@ -"""Multirate-AB ODE method.""" +"""Multirate Adams ODE method.""" from __future__ import division @@ -76,14 +76,14 @@ class MultiRateHistory(Record): :arg arguments: A tuple of component names (see :class:`MultiRateMultiStepMethodBuilder`) which are passed to this right-hand side function. - :arg order: The AB approximation order to be used for this + :arg order: The Adams approximation order to be used for this history, or None if the method default is to be used. :arg rhs_policy: One of the constants in :class:`rhs_policy` :arg invalidate_dependent_state: Whether evaluating this right-hand side should force a recomputation of any state that depended upon now-superseded state. :arg hist_length: history length. If greater than order, we use a - least-squares solve rather than a linear solve to obtain the AB + least-squares solve rather than a linear solve to obtain the Adams coefficients for this history """ super(MultiRateHistory, self).__init__( @@ -724,7 +724,7 @@ class MultiRateMultiStepMethodBuilder(MethodBuilder): # {{{ main method generation - def emit_ab_method(self, cb, explainer): + def emit_adams_method(self, cb, explainer): from pytools import UniqueNameGenerator name_gen = UniqueNameGenerator() @@ -828,21 +828,21 @@ class MultiRateMultiStepMethodBuilder(MethodBuilder): dt_factor = self.dt from leap.multistep import ( - ABMonomialIntegrationFunctionFamily, - emit_ab_integration, - emit_ab_extrapolation) + AdamsMonomialIntegrationFunctionFamily, + emit_adams_integration, + emit_adams_extrapolation) if self.is_ode_component[comp_name]: - contrib = dt_factor*emit_ab_integration( + contrib = dt_factor*emit_adams_integration( cb, name_gen, - ABMonomialIntegrationFunctionFamily(rhs.order), + AdamsMonomialIntegrationFunctionFamily(rhs.order), time_hist, relv_hist_vars, t_start, t_end) else: - contrib = emit_ab_extrapolation( + contrib = emit_adams_extrapolation( cb, name_gen, - ABMonomialIntegrationFunctionFamily(rhs.order), + AdamsMonomialIntegrationFunctionFamily(rhs.order), time_hist, relv_hist_vars, t_end) @@ -1011,12 +1011,12 @@ class MultiRateMultiStepMethodBuilder(MethodBuilder): self.early_hist_consistency_threshold): cb((), "print(rel_rhs_error)") cb.raise_(InconsistentHistoryError, - "MRAB: top-of-history for RHS '%s' is not " - "consistent with current state" + "MRAdams: top-of-history for RHS '%s' is not" + " consistent with current state" % rhs.func_name) else: cb.raise_(InconsistentHistoryError, - "MRAB: RHS '%s' has early policy " + "MRAdams: RHS '%s' has early policy " "and requires relaxed threshold input" % rhs.func_name) @@ -1025,7 +1025,7 @@ class MultiRateMultiStepMethodBuilder(MethodBuilder): with cb.if_("rel_rhs_error", ">=", self.hist_consistency_threshold): cb.raise_(InconsistentHistoryError, - "MRAB: top-of-history for RHS '%s' is not " + "MRAdams: top-of-history for RHS '%s' is not " "consistent with current state" % rhs.func_name) # {{{ run_substep_loop @@ -1129,7 +1129,7 @@ class MultiRateMultiStepMethodBuilder(MethodBuilder): self.emit_initialization(cb_init) with CodeBuilder(name="primary") as cb_primary: - self.emit_ab_method(cb_primary, explainer) + self.emit_adams_method(cb_primary, explainer) with CodeBuilder(name="bootstrap") as cb_bootstrap: self.emit_rk_bootstrap(cb_bootstrap)