- eqtk.solveNG(x0, N, G, tol=1e-07, tol_zero=1e-12, max_iters=1000, delta_bar=1000.0, eta=0.125, min_delta=1e-12, max_trials=100, perturb_scale=100.0)¶
Solve for equilibrium concentrations of all species in a dilute solution.
x0 (Contiguous Numpy array in C order, shape (n_points, n_compounds)) – Array containing the total “initial” dimensionless concentration of all compounds in solution.
N (Contiguous Numpy array in C order, shape (n_reactions, n_compounds)) – N[r, j] = the stoichiometric coefficient of compound j in chemical reaction r.
G (Contiguous Numpy array in C order, shape (n_compounds,)) – G[j] is the free energy of compound j in units of kT.
tol (float, default 1e-7) – Tolerance for convergence. The absolute tolerance for a given initial concentration c0 (a one-dimensional array) for the conservation conditions are tol * np.dot(A, c0) except when an entry in np.dot(A, c0) is zero. If that is the case for entry i, then the absolute tolerance is tol * np.max(A[i] * c0). If all entries in A[i] * c0 are zero, which only happens with c0 = 0, the absolute tolerance is tol_zero.
tol_zero (float, default 1e-12) – Absolute tolerance for convergence when the initial concentrations are all zero. This cannot really be set a priori; it depends on the scale of the dimensionless concentrations. By default, assume an absolute tolerance consistent with tol and millimolar mole fractions.
max_iters (int, default 1000) – Maximum number of iterations allowed in trust region method.
delta_bar (float, default 1000.0) – Maximum step size allowed in the trust region method.
eta (float, default 0.125) – Value for eta in the trust region method. eta must satisfy 0 < eta < 0.25.
min_delta (float, default 1e-12) – Minimal allowed radius of the trust region. When the trust region radius gets below min_delta, the trust region iterations stop, and a final set of Newton steps is attempted.
max_trials (int, default 100) – In the event that an attempt to solve does not converge, the solver tries again with different initial guesses. This continues until max_trials failures.
perturb_scale (float, default 100.0) – Multiplier on random perturbations to the initial guesses as new ones are generated.
logx – logx[i, j] = natural log of the dimensionless equilibrium concentration of compound j for calculation i.
- Return type
Numpy array, shape (n_points, n_compounds)
N must have full row rank, i.e., all rows must be linearly independent.
All values in x0 must be non-negative and finite.