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

Gamma surface & stacking fault tools #178

Merged
merged 80 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
26d46bf
ENH: GammaSurface class
thomas-rocke Sep 1, 2023
11ddefe
ENH: StackingFault class
thomas-rocke Sep 1, 2023
f4854af
BUG: Gamma Surface Bug Fixes
thomas-rocke Sep 5, 2023
7076a6b
BUG: Gamma Surface Bugfixes
thomas-rocke Sep 25, 2023
a54fb20
BUG: Remove GammaSurface compression, as not functional
thomas-rocke Sep 26, 2023
1349682
ENH: Gamma Surface Vacuum layers
thomas-rocke Oct 5, 2023
4977379
TST: Gamma Surface tests
thomas-rocke Oct 5, 2023
cbc3bcb
Add depreciation warning on gamma_line
thomas-rocke Oct 6, 2023
ea5713f
BUG: Fix error in gamma surface si unit conversions
thomas-rocke Oct 20, 2023
f504009
Shift matplotlib import to plotting functions
thomas-rocke Oct 31, 2023
c6c83d4
Merge branch 'DislocRefactor' into gamma-surface
thomas-rocke Nov 4, 2023
8fd61e1
WIP: Initial stages of integration w disloc tools
thomas-rocke Nov 6, 2023
e25caff
Merge remote-tracking branch 'upstream/master' into gamma-surface
thomas-rocke Nov 8, 2023
dd5b5b8
ENH: GammaSurface called using dislocation class
thomas-rocke Nov 8, 2023
22f3ae8
BUG: Pass crystalstructure and symbol through to bulk generator
thomas-rocke Nov 8, 2023
834f1e3
DOC: First parts of stacking fault docs
thomas-rocke Nov 8, 2023
c59094b
DOC: Switch to using Carbon Brenner model
thomas-rocke Nov 9, 2023
4a16774
ENH: Set glide distance automatically based on dislocation glide dist…
thomas-rocke Nov 9, 2023
0d80d59
DOC: Docs on gamma surface + multispecies sf
thomas-rocke Nov 9, 2023
06f56e8
DOC: Switch to FCC Al to show change of basis
thomas-rocke Nov 9, 2023
a67cbcb
DOC: Speed up relaxations using smaller systems
thomas-rocke Nov 9, 2023
357fb71
MAINT: Add verbosity arg to get_elastic_constants
thomas-rocke Nov 9, 2023
23da21d
MAINT: Disable strainfilter print if verbose=False
thomas-rocke Nov 9, 2023
a78494f
DOC: Set verbose=False for all get_elastic_constants
thomas-rocke Nov 9, 2023
d5f5d44
CI: Add sphinx-build -j auto
thomas-rocke Nov 10, 2023
dc2b678
DOC: Adjustments to show_stacking_fault function
thomas-rocke Nov 10, 2023
bc8fac3
DOC: switched to ase plots for SF visualisation
pgrigorev Nov 11, 2023
2c4ba8c
ENH: Stacking fault attached calculator, more docs
thomas-rocke Nov 14, 2023
f5a3e18
Merge pull request #3 from pgrigorev/gamma_surface
thomas-rocke Nov 14, 2023
53f4042
ENH: Gamma Surface Formatting
thomas-rocke Nov 15, 2023
67fbfbb
ENH: Package generate_images to new private function
thomas-rocke Nov 15, 2023
8fccf86
ENH: Togglable compression mode for gamma surface images
thomas-rocke Nov 15, 2023
55dd566
MAINT: Initialise 'Es'
thomas-rocke Nov 15, 2023
1fe44f1
ENH: Allow Es to be directly passed to plotting
thomas-rocke Nov 15, 2023
0d61636
DOC: Add Es docs to stacking fault plot numpydoc
thomas-rocke Nov 15, 2023
9f23d04
TST: Fix Tests
thomas-rocke Nov 16, 2023
87d504b
DOC: Start of Gamma Surface Docs rework
thomas-rocke Nov 16, 2023
7fa8fcf
ENH: atom offset for dislocs relative to core position
thomas-rocke Nov 16, 2023
0c7034c
MAINT: Rename y_dir to glide_direction
thomas-rocke Nov 17, 2023
33efaba
ENH: complete_basis function in utils.py
thomas-rocke Nov 17, 2023
1daac47
MAINT: get_surface_energies -> get_energy_densities
thomas-rocke Nov 17, 2023
3ebc245
TST: Remove quippy import
thomas-rocke Nov 17, 2023
b59324e
MAINT: Switch FIRE optimiser to PreconLBFGS
thomas-rocke Nov 17, 2023
2859eec
ENH: Port stacking fault plotting to class method
thomas-rocke Nov 17, 2023
6cf424e
BUG: Fixes to uncompressed structure generation
thomas-rocke Nov 17, 2023
432c37c
ENH: Add manual rotation to stacking fault show
thomas-rocke Nov 17, 2023
e264a38
ENH: Stacking fault plots beased on glide distance
thomas-rocke Nov 17, 2023
0eb87d0
ENH: Gamma Surface show() function
thomas-rocke Nov 17, 2023
b30d31a
ENH: _vec_to_miller function
thomas-rocke Nov 17, 2023
68b29e3
ENH: Add miller directions to .show() methods
thomas-rocke Nov 17, 2023
a163a32
MAINT: Rename plot_gamma_surface -> plot_energy_densities
thomas-rocke Nov 18, 2023
63bcc40
MAINT: Fix basis sometimes having wrong handedness
thomas-rocke Nov 18, 2023
455a34b
ENH: Expose interpolation scheme for gamma surface plot
thomas-rocke Nov 18, 2023
f6b6040
MAINT: Remove show_stacking_fault from visualisation.py, as not needed
thomas-rocke Nov 18, 2023
b0c9e13
DOC: New docs on gamma surface basics
thomas-rocke Nov 18, 2023
f84f321
ENH: Allow passing of CubicCrystalDislocation, not just Dissociated
thomas-rocke Nov 18, 2023
9330c22
DOC: Advanced gamma surface features
thomas-rocke Nov 18, 2023
7d9912e
MAINT: Delete old gamma surface docs
thomas-rocke Nov 18, 2023
7e68e70
DOC: Add note on SF/GSF similarity
thomas-rocke Nov 18, 2023
2f1640a
MAINT: Enforce right-handed chirality
thomas-rocke Nov 20, 2023
9e2541f
MAINT: Variable renaming, formatting
thomas-rocke Nov 22, 2023
da5cade
ENH: Add failure if relaxation does not converge, add steps limit
thomas-rocke Nov 22, 2023
c0c47e5
BUG: Carry renamed variables through to unittests
thomas-rocke Nov 22, 2023
72101e1
MAINT: Replace if statement with one-liner
thomas-rocke Nov 22, 2023
882dc46
DOC: minor text formatting
pgrigorev Nov 23, 2023
529ad28
DOC: added execution timout tag to metadata
pgrigorev Nov 23, 2023
03844bd
ENH: added `save_count` to suppress warning
pgrigorev Nov 23, 2023
529f181
DOC: reduce length of text lines to avoid scrolbar
pgrigorev Nov 23, 2023
69c5e4f
DOCs: fixed typos
pgrigorev Nov 23, 2023
7fcca93
ENH: enable 'colon_fence` for admonitions (note!)
pgrigorev Nov 23, 2023
2fbc5b3
DOCL add number of images for SF/note -> Caution
pgrigorev Nov 23, 2023
a7c02d6
DOC: shorter lines to avoid scrolbars
pgrigorev Nov 23, 2023
baeb623
DOC: few typos and note as admonition
pgrigorev Nov 23, 2023
c93bd1b
DOC: odd number of images/minor text corrections
pgrigorev Nov 23, 2023
b41f8f9
MAINT: lots of flakes!
pgrigorev Nov 23, 2023
917f589
Merge pull request #4 from pgrigorev/gamma_surface
thomas-rocke Nov 24, 2023
790cb69
MAINT: Move show_HTML to visualisation.py
thomas-rocke Nov 24, 2023
cd8acb1
BUG: Re-add x and ylims to image gen path
thomas-rocke Nov 24, 2023
53f504d
MAINT: Remove unused import of warnings
thomas-rocke Nov 24, 2023
6984748
MAINT: Docs gen now fails if notebook crashes
thomas-rocke Nov 24, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: build_doc
run: |
cd docs
make html
make html SPHINXOPTS="-j auto"
cd ..

# Publish built docs to gh-pages branch.
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS ?=
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
Expand Down
6 changes: 3 additions & 3 deletions docs/applications/cylinder_configurations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"eam_calc = EAM(\"../../tests/w_eam4.fs\")\n",
"\n",
"# the function accepts any ASE type of calculator\n",
"alat, C11, C12, C44 = get_elastic_constants(calculator=eam_calc, symbol=\"W\")"
"alat, C11, C12, C44 = get_elastic_constants(calculator=eam_calc, symbol=\"W\", verbose=False)"
]
},
{
Expand Down Expand Up @@ -855,7 +855,7 @@
"eam_calc = EAM(\"../../tests/FeCuNi.eam.alloy\")\n",
"\n",
"# the function accepts any ASE type of calculator\n",
"alat, C11, C12, C44 = get_elastic_constants(calculator=eam_calc, symbol=\"Ni\")"
"alat, C11, C12, C44 = get_elastic_constants(calculator=eam_calc, symbol=\"Ni\", verbose=False)"
]
},
{
Expand Down Expand Up @@ -1291,7 +1291,7 @@
"calc = Manybody(**StillingerWeber(Holland_Marder_PRL_80_746_Si))\n",
"\n",
"# the function accepts any ASE type of calculator\n",
"alat, C11, C12, C44 = get_elastic_constants(calculator=calc, symbol=\"Si\")"
"alat, C11, C12, C44 = get_elastic_constants(calculator=calc, symbol=\"Si\", verbose=False)"
]
},
{
Expand Down
146 changes: 146 additions & 0 deletions docs/applications/gamma_surface_advanced.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advanced Features of `gamma_surface.py`\n",
"\n",
"## Stacking Faults of Specific Dislocations\n",
"A feature of dislocations which make them challenging to model is that some dislocation systems can dissociate, creating two partial dislocations connected by a finite-length stacking fault. In some contexts such as in the development of Machine Learning Interatomic Potentials (MLIPs), it may be desirable to model the stacking fault in isolation.\n",
"\n",
"The classes `GammaSurface` and `StackingFault` offer parameterisation based on the specific classes of `matscipy.dislocation`. Instead of passing a miller index to `surface_direction`, we can instead pass a class or instance of a class that subclasses `CubicCrystalDislocation` or `CubicCrystalDissociatedDislocation` (e.g. classes like `DiamondGlideScrew`, `BCCEdge100Dislocation` or `FCCEdge110Dislocation`).\n",
"\n",
"As an example, the `DiamondGlideScrew` class allows the user to model the Glide Screw dislocation in diamond, which dissociates into two $30^\\circ$ partial dislocations connected by a stacking fault defined by the `surface_direction` (111) and the `glide_direction` (11-2)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from matscipy.dislocation import DiamondGlideScrew, get_elastic_constants\n",
"from matscipy.gamma_surface import StackingFault\n",
"from matscipy.calculators.manybody.explicit_forms.tersoff_brenner import \\\n",
" TersoffBrenner, Brenner_PRB_42_9458_C_I\n",
"from matscipy.calculators.manybody import Manybody\n",
"from visualisation import show_dislocation\n",
"\n",
"calc = Manybody(**TersoffBrenner(Brenner_PRB_42_9458_C_I))\n",
"\n",
"# the function accepts any ASE type of calculator\n",
"alat, C11, C12, C44 = get_elastic_constants(calculator=calc, symbol=\"C\", verbose=False)\n",
"print(f\"alat = {alat}\")\n",
"C_screw = DiamondGlideScrew(alat, C11, C12, C44, symbol=\"C\")\n",
"\n",
"C_screw_bulk, C_screw_dislo = C_screw.build_cylinder(radius=25, partial_distance=20)\n",
"\n",
"view = show_dislocation(C_screw_dislo, \n",
" diamond_structure=True, \n",
" scale=0.6, \n",
" partial_distance=20 * C_screw.glide_distance, \n",
" d_name=\"1/6<112> 30 degree partial screw\") \n",
"\n",
"view.control.spin([0, 1, 0], np.math.pi) # flip along y-axis to align with SF visualisation\n",
"view.control.zoom(0.7)\n",
"view"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will use the `StackingFault` class to try and model the stacking fault we see in the above dissociated dislocation plot. The plot made use of [Common Neighbour Analysis (CNA)](https://www.ovito.org/docs/current/reference/pipelines/modifiers/common_neighbor_analysis.html) to provide useful colours for the atoms according to the identified crystal structure. This is also available in the `.show()` methods of the `StackingFault` and `GammaSurface` classes, using the `CNA_color=True` argument."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from visualisation import show_HTML\n",
"fault = StackingFault(alat, DiamondGlideScrew, symbol=\"C\")\n",
"fault.generate_images(n=9, cell_move=False, z_reps=2, vacuum=True)\n",
"anim = fault.show(CNA_color=True)\n",
"show_HTML(anim)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see that CNA gives the same orange colour we see in the dislocation part way through the stacking fault sweep. With nine total images along the path, the middle image number five corresponds to the perfect stacking fault structure. It can be seen that atomic stacking of image five is exactly the same as the stacking fault region between two partial dislocations. This helps to confirm that we have generated a similar local structure.\n",
"\n",
"## Accessing Different Stacking Fault Planes\n",
"The Diamond (111) surface is interesting, as it has two distinct planes, called \"glide\" and \"shuffle\", with the same (111) normal direction. Selection of which plane you are modelling depends on which z ordinate in the crystal basis you choose to cut at. Because in the previous example we parameterised the stacking fault with `DiamondGlideScrew` (which is a dislocation along the glide plane, as the name would suggest), we achieved a stacking fault on the glide plane. To achieve the related stacking fault on the shuffle plane, we can use the argument `z_offset` to add an offset (in Angstrom) and shift to the different plane. For this carbon crystal, an offset of 0.84 Angstrom gets us to the shuffle plane."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fault = StackingFault(alat, DiamondGlideScrew, symbol=\"C\")\n",
"fault.generate_images(n=9, cell_move=False, z_reps=2, z_offset=0.84, vacuum=True)\n",
"anim = fault.show(CNA_color=True)\n",
"show_HTML(anim)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Stacking Faults in more complex systems\n",
"`GammaSurface` and `StackingFault` generate a base structure from the input arguments in a very similar manner to the dislocation classes in `matscipy.dislocation`. This means that instead of supplying a lattice constant + symbol + crystalstructure, we can instead pass an atoms object. As an example, let's revisit GaAs from the multispecies dislocation docs:\n",
"\n",
":::{note}\n",
"As with the dislocation classes, `GammaSurface` and `StackingFault` are only guaranteed to work when passed cubic bulk crystals, and cannot themselves model chemical disorder. Any disorder effects should be applied after `generate_images()` is called.\n",
":::"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from ase.build import bulk\n",
"\n",
"# Data from https://doi.org/10.1080/08927022.2011.602975\n",
"alat = 11.2402/2\n",
"\n",
"GaAs = bulk(\"GaAs\", crystalstructure=\"zincblende\", cubic=True, a=alat)\n",
"\n",
"fault = StackingFault(GaAs, DiamondGlideScrew)\n",
"fault.generate_images(n=9, cell_move=False, z_reps=2, vacuum=True)\n",
"anim = fault.show(CNA_color=False)\n",
"show_HTML(anim)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading