-
Notifications
You must be signed in to change notification settings - Fork 54
Fix load_many crash on single-atom/single-step FCHK optimizations #404
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
Merged
+145
−16
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a5224cc
Fix load_many crash on single-atom/single-step FCHK optimizations
Ao-chuba 357d963
fix lint error E501 and TRY301
Ao-chuba c6a857d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ed69455
Refactor fchk.py to reduce redundancy in load_many
Ao-chuba 9b962ea
Merge remote changes and apply FCHK refactoring
Ao-chuba 177736b
Address PR feedback: move test case and add assertions
Ao-chuba d352053
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 74763cc
Delete iodata/test/test_fchk_single_atom.py
Ao-chuba 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
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| h_sto3g | ||
| FOpt UHF STO-3G | ||
| Number of atoms I 1 | ||
| Charge I 0 | ||
| Multiplicity I 2 | ||
| Number of electrons I 1 | ||
| Number of alpha electrons I 1 | ||
| Number of beta electrons I 0 | ||
| Number of basis functions I 1 | ||
| Number of contracted shells I 1 | ||
| Highest angular momentum I 0 | ||
| Largest degree of contraction I 3 | ||
| Number of primitive shells I 3 | ||
| Virial Ratio R 1.613897736040718E+00 | ||
| SCF Energy R -4.665818503844346E-01 | ||
| Total Energy R -4.665818503844346E-01 | ||
| Atomic numbers I N= 1 | ||
| 1 | ||
| Nuclear charges R N= 1 | ||
| 1.00000000E+00 | ||
| Current cartesian coordinates R N= 3 | ||
| 0.00000000E+00 0.00000000E+00 0.00000000E+00 | ||
| Integer atomic weights I N= 1 | ||
| 1 | ||
| Real atomic weights R N= 1 | ||
| 1.00782504E+00 | ||
| Shell types I N= 1 | ||
| 0 | ||
| Number of primitives per shell I N= 1 | ||
| 3 | ||
| Shell to atom map I N= 1 | ||
| 1 | ||
| Primitive exponents R N= 3 | ||
| 3.42525091E+00 6.23913730E-01 1.68855404E-01 | ||
| Contraction coefficients R N= 3 | ||
| 1.54328967E-01 5.35328142E-01 4.44634542E-01 | ||
| Coordinates of each shell R N= 3 | ||
| 0.00000000E+00 0.00000000E+00 0.00000000E+00 | ||
| Alpha Orbital Energies R N= 1 | ||
| -4.66581850E-01 | ||
| Beta Orbital Energies R N= 1 | ||
| 3.08024094E-01 | ||
| Alpha MO coefficients R N= 1 | ||
| 1.00000000E+00 | ||
| Beta MO coefficients R N= 1 | ||
| 1.00000000E+00 | ||
| Total SCF Density R N= 1 | ||
| 1.00000000E+00 | ||
| Spin SCF Density R N= 1 | ||
| 1.00000000E+00 | ||
| Dipole Moment R N= 3 | ||
| 0.00000000E+00 0.00000000E+00 0.00000000E+00 |
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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from importlib.resources import as_file, files | ||
|
|
||
| from numpy.testing import assert_allclose | ||
|
|
||
| from ..api import load_many | ||
|
|
||
|
|
||
| def load_fchk_trj_helper(fn_fchk): | ||
| """Load a trajectory from a testing fchk file with iodata.iodata.load_many.""" | ||
| with as_file(files("iodata.test.data").joinpath(fn_fchk)) as fn: | ||
| return list(load_many(fn)) | ||
|
|
||
|
|
||
| def test_load_fchk_single_atom_optimization(): | ||
| """Test loading a single-atom optimization (missing trajectory block).""" | ||
| trj = load_fchk_trj_helper("atom_opt.fchk") | ||
| # Should load exactly one frame | ||
| assert len(trj) == 1 | ||
| mol = trj[0] | ||
|
|
||
| # Check basic properties | ||
| assert mol.natom == 1 | ||
| assert mol.atnums[0] == 1 | ||
| assert mol.atcorenums[0] == 1.0 | ||
|
|
||
| # Check fallback values | ||
| assert mol.extra["ipoint"] == 0 | ||
| assert mol.extra["npoint"] == 1 | ||
| assert mol.extra["istep"] == 0 | ||
| assert mol.extra["nstep"] == 1 | ||
|
|
||
|
Ao-chuba marked this conversation as resolved.
Outdated
|
||
| # Check that properties were correctly loaded from the single frame | ||
| assert mol.energy is not None | ||
| assert_allclose(mol.energy, -4.665818503844346e-01) | ||
|
|
||
| # Check coordinates | ||
| assert_allclose(mol.atcoords, [[0.0, 0.0, 0.0]]) | ||
|
Ao-chuba marked this conversation as resolved.
Outdated
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.