Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michele Nottoli
gext
Commits
831490c2
Commit
831490c2
authored
1 year ago
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Work in progress.
parent
55c3f32b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
Options
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gext/descriptors.py
+23
-6
23 additions, 6 deletions
gext/descriptors.py
gext/main.py
+40
-15
40 additions, 15 deletions
gext/main.py
with
63 additions
and
21 deletions
gext/descriptors.py
+
23
−
6
View file @
831490c2
...
@@ -3,10 +3,27 @@
...
@@ -3,10 +3,27 @@
import
numpy
as
np
import
numpy
as
np
from
scipy.spatial.distance
import
pdist
from
scipy.spatial.distance
import
pdist
def
distance
(
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
class
Distance
():
"""
Compute the distance matric as a descriptor.
"""
return
pdist
(
coords
,
metric
=
"
euclidean
"
)
def
coulomb
(
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Distance matrix descriptors.
"""
"""
Compute the Coulomb matrix as a descriptor.
"""
return
1.0
/
distance
(
coords
)
def
__init__
(
self
,
**
kwargs
):
self
.
set_options
(
**
kwargs
)
def
set_options
(
self
,
kwargs
):
"""
Given an option dictionary set the valid options and
raise an error if there are invalid ones.
"""
if
len
(
kwargs
)
>
0
:
raise
ValueError
(
"
Invalid arguments given to the descriptor class.
"
)
def
compute
(
self
,
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Compute the distance matric as a descriptor.
"""
return
pdist
(
coords
,
metric
=
"
euclidean
"
)
class
Coulomb
(
Distance
):
"""
Coulomb matrix descriptors.
"""
def
compute
(
self
,
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Compute the Coulomb matrix as a descriptor.
"""
return
1.0
/
super
().
compute
(
coords
)
This diff is collapsed.
Click to expand it.
gext/main.py
+
40
−
15
View file @
831490c2
...
@@ -14,24 +14,56 @@ class Extrapolator:
...
@@ -14,24 +14,56 @@ class Extrapolator:
it requires the number of electrons, the number of basis functions
it requires the number of electrons, the number of basis functions
and the number of atoms of the molecule. The number of previous
and the number of atoms of the molecule. The number of previous
steps used by the extrapolator is an optional argument with default
steps used by the extrapolator is an optional argument with default
value of
10
.
"""
value of
6
.
"""
def
__init__
(
self
,
nelectrons
:
int
,
nbasis
:
int
,
natoms
:
int
,
def
_update_docstring
(
self
):
nsteps
:
int
=
6
,
**
kwargs
):
options_str
=
"
\n
"
.
join
(
f
"
-
'
{
key
}
'
:
{
value
}
"
for
key
,
value
in
self
.
supported_options
.
items
())
self
.
__doc__
=
self
.
__doc__
.
format
(
options
=
options_str
)
def
__init__
(
self
,
nelectrons
:
int
,
nbasis
:
int
,
natoms
:
int
,
**
kwargs
):
self
.
supported_options
=
{
"
verbose
"
:
False
,
"
nsteps
"
:
6
}
self
.
_update_docstring
()
self
.
nelectrons
=
nelectrons
self
.
nelectrons
=
nelectrons
self
.
nbasis
=
nbasis
self
.
nbasis
=
nbasis
self
.
natoms
=
natoms
self
.
natoms
=
natoms
self
.
nsteps
=
nsteps
self
.
gammas
=
CircularBuffer
(
self
.
nsteps
,
(
self
.
nelectrons
//
2
,
self
.
nbasis
))
self
.
gammas
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
]
,
(
self
.
nelectrons
//
2
,
self
.
nbasis
))
self
.
overlaps
=
CircularBuffer
(
self
.
nsteps
,
(
self
.
nbasis
,
self
.
nbasis
))
self
.
overlaps
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
]
,
(
self
.
nbasis
,
self
.
nbasis
))
self
.
descriptors
=
CircularBuffer
(
self
.
nsteps
,
self
.
descriptors
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
]
,
((
self
.
natoms
-
1
)
*
self
.
natoms
//
2
,
))
((
self
.
natoms
-
1
)
*
self
.
natoms
//
2
,
))
self
.
tangent
:
Optional
[
np
.
ndarray
]
=
None
self
.
tangent
:
Optional
[
np
.
ndarray
]
=
None
self
.
_set_options
(
**
kwargs
)
self
.
set_options
(
**
kwargs
)
def
set_options
(
self
,
**
kwargs
):
"""
Given an arbitrary amount of keyword arguments, parse them if
specified, set default values if not specified and raise an error
if invalid arguments are passed.
"""
self
.
options
=
{}
descriptor_options
=
{}
fitting_options
=
{}
for
key
,
value
in
kwargs
.
items
():
if
key
in
self
.
supported_options
:
self
.
options
[
key
]
=
value
elif
key
.
startswith
(
"
descriptor_
"
):
descriptor_options
[
key
[
11
:]]
=
value
elif
key
.
startswith
(
"
fitting_
"
):
fitting_options
[
key
[
8
:]]
=
value
else
:
raise
ValueError
(
f
"
Unsupported option:
{
key
}
"
)
for
option
,
default_value
in
self
.
supported_options
.
items
():
if
not
hasattr
(
self
.
options
,
option
):
setattr
(
self
.
options
,
option
,
default_value
)
def
load_data
(
self
,
coords
:
np
.
ndarray
,
coeff
:
np
.
ndarray
,
def
load_data
(
self
,
coords
:
np
.
ndarray
,
coeff
:
np
.
ndarray
,
overlap
:
np
.
ndarray
):
overlap
:
np
.
ndarray
):
...
@@ -73,13 +105,6 @@ class Extrapolator:
...
@@ -73,13 +105,6 @@ class Extrapolator:
return
c_guess
@
c_guess
.
T
return
c_guess
@
c_guess
.
T
def
_set_options
(
self
,
**
kwargs
):
"""
Parse additional options from the additional keyword arguments.
"""
self
.
options
=
{}
if
"
verbose
"
in
kwargs
:
self
.
options
[
"
verbose
"
]
=
kwargs
[
"
verbose
"
]
else
:
self
.
options
[
"
verbose
"
]
=
False
def
_get_tangent
(
self
)
->
np
.
ndarray
:
def
_get_tangent
(
self
)
->
np
.
ndarray
:
"""
Get the tangent point.
"""
"""
Get the tangent point.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment