-
Notifications
You must be signed in to change notification settings - Fork 4
Fix for freezing exponents #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deyanmihaylov
wants to merge
1
commit into
HPQC-LABS:main
Choose a base branch
from
deyanmihaylov:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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] | ||
| 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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
|
@@ -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) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!