def __run_find_kopt(self, case): system = molsturm.System(case.atom) system.multiplicity = case.multiplicity scfparams = molsturm.ScfParameters() scfparams.system = system basis_type = "sturmian/atomic/cs_reference_pc" if basis_type not in molsturm.available_basis_types: raise unittest.SkipTest("Skipped subtest " + case.atom + ", since basis type not available: " + basis_type) scfparams.basis = molsturm.construct_basis( basis_type, scfparams.system, k_exp=0.0, # dummy n_max=case.n_max, l_max=case.l_max) scfparams["scf/eigensolver/method"] = "lapack" scfparams["guess/eigensolver/method"] = "lapack" conv_tol = 1e-3 best = molsturm.sturmian.cs.find_kopt(scfparams, conv_tol=conv_tol) k = best["input_parameters"]["discretisation"]["k_exp"] self.assertAlmostEqual(k, case.ref_kexp, tol=conv_tol, prefix="optimal exponent kopt: ") self.assertAlmostEqual(best["energy_ground_state"], case.ref_energy, tol=conv_tol / 100, prefix="ground state energy: ")
def dump_integrals_gaussian(atoms, coords, electrons, basis_set_name, ifile=None): system = molsturm.System(atoms, coords, electrons) params = molsturm.ScfParameters() params.system = system params.basis = molsturm.construct_basis("gaussian", params.system, basis_set_name=basis_set_name) if ifile is None: latoms = [a.lower() for a in atoms] ifile = "integrals_{}_{}.hdf5".format("".join(latoms), basis_set_name) with h5py.File(ifile, "w") as h5f: write_integrals_to_hdf5(params, h5f) g_discr = h5f.create_group("discretisation") g_discr.create_dataset("basis_type", data="gaussian", dtype=h5py.special_dtype(vlen=str)) g_discr.create_dataset("basis_set_name", dtype=h5py.special_dtype(vlen=str), data=basis_set_name) g_discr.create_dataset("has_real_harmonics", data=1, dtype=np.uint8)
def run_matrix_free(system, basis, extra={}): params = molsturm.ScfParameters() params.system = system params.basis = basis params["guess/method"] = "random" params["guess/eigensolver/method"] = "arpack" params["scf/eigensolver/method"] = "arpack" params["scf/n_eigenpairs"] = 2 * (basis.size // 2) params.update(extra) res = molsturm.self_consistent_field(params) molsturm.print_convergence_summary(res) molsturm.print_energies(res) molsturm.print_mo_occupation(res) molsturm.print_quote(res) return res
def main(): carbon = molsturm.System("c") carbon.multiplicity = 3 params = molsturm.ScfParameters() params.system = carbon params.basis = molsturm.construct_basis("sturmian/atomic/cs_reference_pc", params.system, k_exp=3.3, n_max=4, l_max=3) params["scf/eigensolver/method"] = "lapack" params["scf/print_iterations"] = True params["guess/eigensolver/method"] = "lapack" res = molsturm.self_consistent_field(params) molsturm.print_convergence_summary(res) molsturm.print_energies(res) molsturm.print_mo_occupation(res) molsturm.print_quote(res) return res
def dump_integrals_sturmian(atoms, coords, electrons, k_exp, n_max, l_max, m_max, ifile=None): system = molsturm.System(atoms, coords, electrons) params = molsturm.ScfParameters() params.system = system basis = molsturm.construct_basis("sturmian/atomic", params.system, k_exp=k_exp, n_max=n_max, l_max=l_max, m_max=m_max) basis.backend = "cs_reference" params.basis = basis if ifile is None: latoms = [a.lower() for a in atoms] ifile = ("integrals_{}_{:02d}{:02d}{:02d}_{:.4f}.hdf5" "".format("".join(latoms), n_max, l_max, m_max, k_exp)) with h5py.File(ifile, "w") as h5f: write_integrals_to_hdf5(params, h5f) g_discr = h5f.create_group("discretisation") g_discr.create_dataset("basis_type", data="sturmian/atomic", dtype=h5py.special_dtype(vlen=str)) g_discr.create_dataset("nlm_basis", data=basis.functions) g_discr.create_dataset("k_exp", data=k_exp) g_discr.create_dataset("n_max", data=n_max) g_discr.create_dataset("l_max", data=l_max) g_discr.create_dataset("m_max", data=m_max) g_discr.create_dataset("has_real_harmonics", data=basis.has_real_harmonics, dtype=np.uint8)
## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with molsturm. If not, see <http://www.gnu.org/licenses/>. ## ## --------------------------------------------------------------------- import molsturm import molsturm.gaussian import numpy as np import matplotlib.pyplot as plt import warnings params = molsturm.ScfParameters() params.system = molsturm.MolecularSystem("Be") params["scf/print_iterations"] = True params.basis = molsturm.construct_basis("gaussian", params.system, basis_set_name="cc-pvdz") print("Running fit, please wait") with warnings.catch_warnings(): warnings.simplefilter("ignore") res = molsturm.gaussian.extrapolate_cbs_limit(params) # Print the result cov = res.cov print("Estimated parameters: value (stddev)") print(" E(CBS) == {0:16.14G} ({1: >9.4G})".format(res.cbs,