maml icon indicating copy to clipboard operation
maml copied to clipboard

Question about radius in BOWSR readme example

Open janosh opened this issue 2 years ago • 7 comments

This might be a dumb question. In the BOWSR readme example, why the rounding? And is the 0.6 factor an approximation for getting the larger element's radius?

expected_radius() might be better named expected_diameter() since it gives the sum of 2 radii.

https://github.com/materialsvirtuallab/maml/blob/a37f78a090c338a79f4c0644e5e267c60c50a8d1/maml/apps/bowsr/README.md?plain=1#L75-L81

janosh avatar Sep 21 '22 20:09 janosh

@JiQi535 Pls fix and respond.

shyuep avatar Sep 21 '22 20:09 shyuep

@JiQi535 In case you rename the function, I think it can also be simplified from this:

def expected_radius(struct):
    element_list = struct.composition.chemical_system.split("-")
    element_list = [get_el_sp(e) for e in element_list]
    ele1, ele2 = sorted(element_list, key=lambda x: x.atomic_radius)[:2]
    return ele1.atomic_radius + ele2.atomic_radius

to this:

def expected_diameter(structure: Structure) -> float:
    elem_1, elem_2, *_ = sorted(structure.composition.elements, key=lambda x: x.atomic_radius)
    return elem_1.atomic_radius + elem_2.atomic_radius

janosh avatar Sep 21 '22 23:09 janosh

Btw, this function fails for unary structures.

ValueError: not enough values to unpack (expected at least 2, got 1)

janosh avatar Sep 22 '22 03:09 janosh

@JiQi535 I suggest you fix these problems and submit a PR. We shouldn't let this issue fester for so long. This is not a difficult fix.

shyuep avatar Dec 14 '22 20:12 shyuep

why the rounding? And is the 0.6 factor an approximation for getting the larger element's radius?

After checking through the codes, I believe this 0.6 factor is just a customizable factor to define the minimum allowed atomic distance in an optimized structure. It provides a reasonable guess of the shortest bond length in a structure that is not unphysical. As in the example of README, we provide a cutoff value for the minimum allowed atomic distance as argument to the method compressed_optimizer.get_optimized_structure_and_energy(radius=radius) . The returned optimized structure will have shortest bond length larger than this cutoff "radius".

To make it more clear, I can change the name of the "radius" variable to "cutoff_distance".

@YunxingZuo @shyuep Please kindly correct me if my understanding is not correct. Thanks!

JiQi535 avatar Dec 15 '22 13:12 JiQi535

@JiQi535 The bigger issue is the unary structure failure. That can be easily fixed?

shyuep avatar Dec 15 '22 15:12 shyuep

@shyuep The BOWSER optimizer doesn't have this kind of limitation. The previous example function expected_radius to get an estimated shortest allowed atomic distance in the README does have this limitation, and it has already been modified in the PR to work with unary structures.

JiQi535 avatar Dec 16 '22 01:12 JiQi535