|
11 | 11 | import numpy as np |
12 | 12 | from atomdb import load |
13 | 13 |
|
14 | | -from bfit.density import SlaterAtoms |
15 | | -from bfit.fit import KLDivergenceFPI, ScipyFit |
| 14 | +from bfit.fit import KLDivergenceFPI |
16 | 15 | from bfit.grid import ClenshawRadialGrid |
17 | | -from bfit.measure import KLDivergence |
18 | 16 | from bfit.model import AtomicGaussianDensity |
19 | 17 | from bfit.parse_ugbs import get_ugbs_exponents |
20 | 18 |
|
| 19 | +# change the path to the location of the AtomDB data as needed |
| 20 | +DATAPATH = ("/home/ali-tehrani/SoftwareProjects/AtomDBdata",) |
| 21 | + |
21 | 22 | results_final = {} |
22 | 23 | atoms = ["H", "C", "N", "O", "F", "P", "S", "Cl"] |
23 | | -atomic_numbs = [1, 6, 7, 8, 9, 15, 16, 17] #[1 + i for i in range(0, len(atoms))] |
| 24 | +atomic_numbs = [1, 6, 7, 8, 9, 15, 16, 17] # [1 + i for i in range(0, len(atoms))] |
24 | 25 | mult = [2, 3, 4, 3, 2, 4, 3, 2] |
25 | 26 | for k, element in enumerate(atoms): |
26 | 27 | print("Start Atom %s" % element) |
27 | 28 |
|
28 | 29 | # Construct a integration grid |
29 | 30 | atomic_numb = atomic_numbs[k] |
30 | 31 | grid = ClenshawRadialGrid( |
31 | | - atomic_numb, num_core_pts=10000, num_diffuse_pts=899, include_origin=True#, extra_pts=[50,75,100], |
| 32 | + atomic_numb, |
| 33 | + num_core_pts=10000, |
| 34 | + num_diffuse_pts=899, |
| 35 | + include_origin=True, |
| 36 | + # extra_pts=[50,75,100], |
32 | 37 | ) |
33 | 38 |
|
34 | 39 | # Initial Guess constructed from UGBS |
|
41 | 46 | e_0 = np.array(exps_s + exps_p) * 2.0 |
42 | 47 |
|
43 | 48 | # Construct Atomic Density and Fitting Object |
44 | | - #density = SlaterAtoms(element=element).atomic_density(grid.points) |
| 49 | + # density = SlaterAtoms(element=element).atomic_density(grid.points) |
45 | 50 | # Use AtomDB to calculate the density |
46 | | - atom = load(elem=element, charge=0, mult=mult[k], dataset="hci", datapath="/home/ali-tehrani/SoftwareProjects/AtomDBdata") |
| 51 | + atom = load( |
| 52 | + elem=element, |
| 53 | + charge=0, |
| 54 | + mult=mult[k], |
| 55 | + dataset="hci", |
| 56 | + datapath=DATAPATH, |
| 57 | + ) |
47 | 58 |
|
48 | 59 | dens = atom.dens_func() |
49 | 60 | density = dens(grid.points) |
50 | 61 |
|
51 | | - import matplotlib.pyplot as plt |
52 | | - |
53 | 62 | # plt.plot(grid.points, density, "bo-") |
54 | 63 | # plt.show() |
55 | 64 | print(density[-1], grid.points[-1], grid.points[0:3]) |
|
69 | 78 | # measure = KLDivergence(mask_value=1e-18) |
70 | 79 | # fit_KL_slsqp = ScipyFit(grid, density, model, measure=measure, method="SLSQP", spherical=True) |
71 | 80 | # # Run the SLSQP optimization algorithm |
72 | | - # results = fit_KL_slsqp.run(coeffs, e_0, maxiter=10000, disp=True, with_constraint=True, tol=1e-14) |
| 81 | + # results = fit_KL_slsqp.run( |
| 82 | + # coeffs, e_0, maxiter=10000, disp=True, with_constraint=True, tol=1e-14 |
| 83 | + # ) |
73 | 84 |
|
74 | 85 | print("KL-FPI INFO") |
75 | 86 | print("-----------") |
|
0 commit comments