Skip to content
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

Default Grid Assesment #210

Merged
merged 25 commits into from
Jan 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0b0851b
Add default PowerRTransform params to utils
Ali-Tehrani Jan 4, 2024
2e9f063
Add default rgrid to from_preset in atomgrid
Ali-Tehrani Jan 4, 2024
b6524e7
Fix that default rgrid is in angstorm
Ali-Tehrani Jan 4, 2024
d270839
Add helper function to generate default rgrid
Ali-Tehrani Jan 4, 2024
61742b1
Add default rgrid to from_preset in molgrid
Ali-Tehrani Jan 4, 2024
04688cf
Add default rgrid to mol from_size and from_pruned
Ali-Tehrani Jan 4, 2024
9ade1d2
Fix bug in atomgrid with default rgrid
Ali-Tehrani Jan 4, 2024
0319c43
Decrease accuracy of ode test
Ali-Tehrani Jan 4, 2024
e1face4
Fix def rgrid in molgrid and add tests
Ali-Tehrani Jan 4, 2024
cffc3ea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 4, 2024
c4d3459
Fix linters issue
Ali-Tehrani Jan 4, 2024
67470d6
Change random test so that it passes in ode
Ali-Tehrani Jan 4, 2024
530fd8e
Add aim_weights default for Molgrid.from_preset
Ali-Tehrani Jan 4, 2024
837a007
Add default aim_weights to MolGrid.from_size
Ali-Tehrani Jan 4, 2024
c8637c9
Add default aim_weights to MolGrid.from_pruned
Ali-Tehrani Jan 4, 2024
1e7bf91
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 4, 2024
543d455
Fix ruff linter
Ali-Tehrani Jan 4, 2024
c6ff8f4
Clarification on converting A^o to a.u.
Ali-Tehrani Jan 4, 2024
eb813ed
Remove *_ from MolGrid.from_preset
Ali-Tehrani Jan 4, 2024
d3b46e9
Fix improt for scipy.constants
Ali-Tehrani Jan 4, 2024
cc61d59
Remove * from AtomicGrid class
FarnazH Jan 4, 2024
0b405c5
Add angstrom scipy conversion
Ali-Tehrani Jan 5, 2024
fe61a51
Remove sub-test where ode doesn't converge
Ali-Tehrani Jan 5, 2024
3dc9a72
Fix ruff linter
Ali-Tehrani Jan 5, 2024
078a98e
Define ang2bohr conversion factor
FarnazH Jan 5, 2024
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
Prev Previous commit
Next Next commit
Add default rgrid to mol from_size and from_pruned
- Change tests as well
  • Loading branch information
Ali-Tehrani committed Jan 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 04688cf7dcfbb0440f7f3c226571a65344ed8eb5
30 changes: 20 additions & 10 deletions src/grid/molgrid.py
Original file line number Diff line number Diff line change
@@ -449,9 +449,9 @@ def from_size(
cls,
atnums: np.ndarray,
atcoords: np.ndarray,
rgrid: OneDGrid,
size: int,
aim_weights: Union[callable, np.ndarray],
rgrid: OneDGrid = None,
rotate: int = 37,
store: bool = False,
):
@@ -463,20 +463,21 @@ def from_size(
>>> onedg = UniformInteger(100) # number of points, oned grid before TF.
>>> rgrid = ExpRTransform(1e-5, 2e1).generate_radial(onedg) # radial grid
>>> becke = BeckeWeights(order=3)
>>> molgrid = MolGrid.from_size(atnums, atcoords, rgrid, 110, becke)
>>> molgrid = MolGrid.from_size(atnums, atcoords, 110, becke, rgrid)

Parameters
----------
atnums : np.ndarray(M, 3)
Atomic number of :math:`M` atoms in molecule.
atcoords : np.ndarray(N, 3)
Cartesian coordinates for each atoms
rgrid : OneDGrid
one dimension grid to construct spherical grid
size : int
Num of points on each shell of angular grid
aim_weights : Callable or np.ndarray(K,)
Atoms in molecule weights.
rgrid : OneDGrid, optional
One-dimensional grid to construct the atomic grid. If none, then
default radial grid is generated based on atomic numbers.
rotate : bool or int , optional
Flag to set auto rotation for atomic grid, if given int, the number
will be used as a seed to generate rantom matrix.
@@ -491,18 +492,23 @@ def from_size(
"""
at_grids = []
for i in range(len(atcoords)):
at_grids.append(AtomGrid(rgrid, sizes=[size], center=atcoords[i], rotate=rotate))
if rgrid is None:
atnum = atnums[i]
rad_grid = _generate_default_rgrid(atnum)
else:
rad_grid = rgrid
at_grids.append(AtomGrid(rad_grid, sizes=[size], center=atcoords[i], rotate=rotate))
return cls(atnums, at_grids, aim_weights, store=store)

@classmethod
def from_pruned(
cls,
atnums: np.ndarray,
atcoords: np.ndarray,
rgrid: Union[OneDGrid, list],
radius: Union[float, list],
aim_weights: Union[callable, np.ndarray],
sectors_r: np.ndarray,
rgrid: Union[OneDGrid, list] = None,
sectors_degree: np.ndarray = None,
sectors_size: np.ndarray = None,
rotate: int = 37,
@@ -517,10 +523,6 @@ def from_pruned(
List of atomic numbers for each atom.
atcoords: np.ndarray(M, 3)
Cartesian coordinates for each atoms
rgrid : OneDGrid or List[OneDGrid] or Dict[int: OneDGrid]
One dimensional grid for the radial component. If a list is provided,then ith
grid correspond to the ith atom. If dictionary is provided, then the keys are
correspond to the `atnums[i]` attribute.
radius: float, List[float]
The atomic radius to be multiplied with `r_sectors` (to make them atom specific).
If float, then the same atomic radius is used for all atoms, else a list specifies
@@ -532,6 +534,11 @@ def from_pruned(
Each row is a sequence of boundary points specifying radial sectors of the pruned grid
for the `m`th atom. The first sector is ``[0, radius*sectors_r[0]]``, then
``[radius*sectors_r[0], radius*sectors_r[1]]``, and so on.
rgrid : OneDGrid or List[OneDGrid] or Dict[int: OneDGrid], optional
One dimensional grid for the radial component. If a list is provided,then ith
grid correspond to the ith atom. If dictionary is provided, then the keys are
correspond to the `atnums[i]` attribute. If None, then using atomic numbers it will
generate a default radial grid (PowerRTransform of UniformInteger grid).
sectors_degree: List[List], keyword-only argument
Each row is a sequence of Lebedev/angular degrees for each radial sector of the pruned
grid for the `m`th atom. If both `sectors_degree` and `sectors_size` are given,
@@ -571,6 +578,9 @@ def from_pruned(
rad = rgrid[i]
elif isinstance(rgrid, dict):
rad = rgrid[atnums[i]]
elif rgrid is None:
atnum = atnums[i]
rad = _generate_default_rgrid(atnum)
else:
raise TypeError(f"not supported radial grid input; got input type: {type(rgrid)}")

2 changes: 1 addition & 1 deletion src/grid/tests/test_molgrid.py
Original file line number Diff line number Diff line change
@@ -578,10 +578,10 @@ def test_from_pruned(self):
mol_grid = MolGrid.from_pruned(
nums,
coors,
self.rgrid,
radius,
becke,
sectors_r=sectors_r,
rgrid=self.rgrid,
sectors_degree=sectors_deg,
rotate=False,
)