-
Notifications
You must be signed in to change notification settings - Fork 3
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
feature/SOF-7427 feat: ASE distance norm calculator #160
Conversation
VsevolodX
commented
Sep 2, 2024
•
edited
Loading
edited
- feat: add ASE calculator
- add docstrings explaining
- add required forces defintions and calculations
@@ -167,3 +167,100 @@ def calculate_norm_of_distances(material: Material, shadowing_radius: float = 2. | |||
substrate_coordinates_values = np.array(substrate_atoms_surface_coordinates.values) | |||
|
|||
return get_norm_of_distances_between_coordinates(film_coordinates_values, substrate_coordinates_values) | |||
|
|||
|
|||
class SurfaceDistanceCalculator(ASECalculator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FixedZ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, we pass this as a paramter: whether to fix_z, fix_substrate or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FilmSubstrateDistanceCalculator
|
||
ASECalculator.calculate(self, atoms, properties, system_changes) | ||
material = Material(from_ase(atoms)) | ||
norm = calculate_norm_of_distances(material, self.shadowing_radius) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
energies
atoms.set_constraint(constraints) | ||
return atoms | ||
|
||
def _calculate_forces(self, atoms: ASEAtoms, norm: float) -> np.ndarray: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove this
Args: | ||
shadowing_radius (float): The radius for atom to shadow underlying from being considered surface, in Angstroms. | ||
force_constant (float): The force constant for the finite difference approximation of the forces. | ||
fix_substrate (bool): Whether to fix the substrate atoms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_substrate_fixed, is_z_axis_fixed
force_constant (float): The force constant for the finite difference approximation of the forces. | ||
fix_substrate (bool): Whether to fix the substrate atoms. | ||
fix_z (bool): Whether to fix atoms movement in the z direction. | ||
symprec (float): The symmetry precision for the ASE calculator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is that - let's put a link to the original explanation
|
||
ASECalculator.calculate(self, atoms, properties, system_changes) | ||
material = Material(from_ase(atoms)) | ||
energy = calculate_film_substrate_interaction_metric(material, self.shadowing_radius) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be MaterialCalculator.get_energy(material, calculator_parameters**)
shadowing_radius (float): Radius for atoms shadowing underlying from being treated as a surface, in Angstroms. | ||
force_constant (float): The force constant for the finite difference approximation of the | ||
Note: | ||
Built following: https://wiki.fysik.dtu.dk/ase/development/calculators.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove :
atoms = self._add_constraints(atoms) | ||
constraints = atoms.constraints | ||
|
||
ASECalculator.calculate(self, atoms, properties, system_changes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use super
|
||
return forces | ||
|
||
@decorator_convert_material_args_kwargs_to_atoms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point of having this
implemented_properties = ["energy", "forces"] | ||
|
||
def __init__( | ||
self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should have material_calculator as parameter
|
||
Args: | ||
shadowing_radius (float): The radius for atom to shadow underlying from being considered surface, in Angstroms. | ||
force_constant (float): The force constant for the finite difference approximation of the forces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove, this can be in interaction_function
@@ -120,3 +122,174 @@ def get_energy( | |||
substrate_coordinates_values = np.array(substrate_surface_atom_coordinates.values) | |||
|
|||
return interaction_function(film_coordinates_values, substrate_coordinates_values) | |||
|
|||
|
|||
class FixFilmRigidXY(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class InterfaceConstraint
class RigidFilmXYConstraint(InterfaceConstraint)
def _add_constraints(self, atoms: ASEAtoms) -> ASEAtoms: | ||
constraints: List[Union[ASEFixAtoms, ASEFixedPlane, RigidFilmXYConstraint]] = [] | ||
if self.fix_substrate: | ||
substrate_indices = [i for i, tag in enumerate(atoms.get_tags()) if tag == 0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should abstract this into get_interface_part_indices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but locally. Since it's ASE atoms, not Material
all_indices = list(range(len(atoms))) | ||
constraints.append(ASEFixedPlane(indices=all_indices, direction=[0, 0, 1])) | ||
|
||
film_indices = [i for i, tag in enumerate(atoms.get_tags()) if tag == 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -120,3 +123,112 @@ def get_energy( | |||
substrate_coordinates_values = np.array(substrate_surface_atom_coordinates.values) | |||
|
|||
return interaction_function(film_coordinates_values, substrate_coordinates_values) | |||
|
|||
|
|||
class FilmSubstrateDistanceASECalculator(ASECalculator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put in ase
subfolder for this and constraints into it
raise NotImplementedError | ||
|
||
|
||
class RigidFilmXYConstraint(InterfaceConstraint): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InterfaceConstraint