pymatgen.util.convergence module

exception SplineInputError(msg)[source]

Bases: Exception

determine_convergence(xs, ys, name, tol=0.0001, extra='', verbose=False, mode='extra', plots=True)[source]

test it and at which x_value dy(x)/dx < tol for all x >= x_value, conv is true is such a x_value exists.

exponential(x, a, b, n)[source]

exponential function base n to fit convergence data

extrapolate_reciprocal(xs, ys, n, noise)[source]

return the parameters such that a + b / x^n hits the last two data points

extrapolate_simple_reciprocal(xs, ys)[source]
get_derivatives(xs, ys, fd=False)[source]

return the derivatives of y(x) at the points x if scipy is available a spline is generated to calculate the derivatives if scipy is not available the left and right slopes are calculated, if both exist the average is returned putting fd to zero always returns the finite difference slopes

get_weights(xs, ys, mode=2)[source]
id_generator(size=8, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')[source]
measure(function, xs, ys, popt, weights)[source]

measure the quality of a fit

multi_curve_fit(xs, ys, verbose)[source]

fit multiple functions to the x, y data, return the best fit

multi_reciprocal_extra(xs, ys, noise=False)[source]

Calculates for a series of powers ns the parameters for which the last two points are at the curve. With these parameters measure how well the other data points fit. return the best fit.

p0_exponential(xs, ys)[source]
p0_reciprocal(xs, ys)[source]

predictor for first guess for reciprocal

p0_simple_2reciprocal(xs, ys)[source]
p0_simple_4reciprocal(xs, ys)[source]
p0_simple_5reciprocal(xs, ys)[source]
p0_simple_reciprocal(xs, ys)[source]
p0_single_reciprocal(xs, ys)[source]
print_and_raise_error(xs, ys, name)[source]
print_plot_line(function, popt, xs, ys, name, tol=0.05, extra='')[source]

print the gnuplot command line to plot the x, y data with the fitted function using the popt parameters

reciprocal(x, a, b, n)[source]

reciprocal function to the power n to fit convergence data

simple_2reciprocal(x, a, b)[source]

reciprocal function to fit convergence data

simple_4reciprocal(x, a, b)[source]

reciprocal function to fit convergence data

simple_5reciprocal(x, a, b)[source]

reciprocal function to fit convergence data

simple_reciprocal(x, a, b)[source]

reciprocal function to fit convergence data

single_reciprocal(x, a, b, c)[source]

reciprocal function to fit convergence data