Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def get_basis_string(basis_str, exponents, exp_array=None):
if exp_array is None:
exp_array = np.zeros((exponents.size, 2))

exp_array[np.where(exp_array[:, 1] == 0), 0] = exponents[np.where(exp_array[:, 1] == 0)]
exp_array[np.where(exp_array[:, 1] == 0), 0] = exponents[:]

print(exp_array[:, 0])
basis_string = ''.join([''.join([
get_basis_substring(exp_array[i, 0], orbital) if j == 0 else
get_basis_substring(exp_array[i + basis_cum_nums[j-1], 0], orbital)
Expand Down Expand Up @@ -64,18 +65,18 @@ def atomic_energy(
if return_J is True:
jac = mf.energy_grad()
grad_E = np.array(jac.exp)
grad_E = grad_E[np.where(exp_array[:, 1] == 0)]
return e, grad_E

def minimize_energy(mol, basis_str, exp_array=None, use_Jacobian=True):
x0 = exp_array[:, 0]
print(x0)
bnds = ((1e-9, None) for _ in range(exp_array.shape[0]))
def minimize_energy(mol, basis_str, exp_array=None, use_Jacobian=False):
x0 = exp_array[np.where(exp_array[:, 1] == 0), 0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, so it is meant to check that the exponent's freeze/free flag is ==0 before sending it to the optimizer. I will check to see if it works soon!

bnds = ((1e-9, None) for _ in range(x0.size))

res = optimize.minimize(
atomic_energy,
x0,
args=(mol, basis_str, exp_array, use_Jacobian),
method="SLSQP",
method="Nelder-Mead",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SLSQP changed to Nelder-Mead? Please always remember to "pull" the latest version of a code before pushing any commits!

jac=use_Jacobian,
hess=None,
hessp=None,
Expand Down Expand Up @@ -117,4 +118,7 @@ def minimize_energy(mol, basis_str, exp_array=None, use_Jacobian=True):
exps = np.zeros((N, 2))
exps[:, 0] = np.array([0.5 * (N - i) for i in range(N)])

# freeze exponent 1
exps[0, 1] = 1

minimize_energy(mol, basis, exps)