Commit a7ec2bec authored by Artem Pulkin's avatar Artem Pulkin

ml_util: make etas the same in default Behler choice

parent 2f09cad8
Pipeline #43954 passed with stage
in 2 minutes and 25 seconds
......@@ -87,7 +87,7 @@ def prepare_dataset(n, box_size, potentials=None, species=1, size=3, seed=None,
return cells
def default_behler_descriptors(arg, n, a, left=1):
def default_behler_descriptors(arg, n, a, left=1, common_eta=True):
"""
Default Behler descriptor choice.
......@@ -103,6 +103,8 @@ def default_behler_descriptors(arg, n, a, left=1):
The function cutoff.
left : float
Left boundary factor.
common_eta : bool
Pick common etas.
Returns
-------
......@@ -126,17 +128,24 @@ def default_behler_descriptors(arg, n, a, left=1):
for w in arg
), min)
descriptors_raw = {}
etas = {}
for k, d in arg.items():
d *= left
if d > a / 2:
raise ValueError(f"The minimal interatomic distance {d} for entity {k} "
f"is more than half-way to the cutoff {a}")
descriptors = []
descriptors_raw[k] = descriptors
etas[k] = _etas = []
for tp in np.linspace(d, a / 2, n):
eta = _eta_for_tp(tp)
descriptors.append(behler2_descriptor_family(a=a, eta=eta, r_sphere=0, tag=k))
_etas.append(_eta_for_tp(tp))
if common_eta:
_etas = np.mean(list(etas.values()), axis=0)
etas = {k: _etas for k in etas}
descriptors_raw = {
k: list(behler2_descriptor_family(a=a, eta=eta, r_sphere=0, tag=k) for eta in v)
for k, v in etas.items()
}
all_species = sorted(set(sum((i.split("-") for i in descriptors_raw), [])))
......@@ -159,7 +168,6 @@ def default_behler_descriptors(arg, n, a, left=1):
if s2 not in descriptors:
descriptors[s2] = []
descriptors[s2] += list(i.copy(tag=tags[1]) for i in d)
return descriptors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment