Oxygen Displacement¶
©️ Copyright 2025 @ Liu Theory Lab
Author:
林子越 (Ziyue Lin) 📨
Date:2025-11-28
Lisence:This document is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.
This tutorial is used to calculate the displacement of each oxygen atom in HfO₂ systems relative to the geometric center of its neighboring regular tetrahedron, and to determine whether the structure has global polarization.
Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Tetrahedron-Displacement Algorithm Explanation¶
1. Determining "whether a point is inside a tetrahedron" — Signed Volume Criterion¶
Given a tetrahedron formed by four vertices A B C D, its signed volume is:
For any test point P, construct 4 "smaller" tetrahedra:
- If
V₁ … V₄have consistent signs withV₀, P is inside; - If some Vᵢ≈0, then P is on a face/edge;
- If signs are not all the same, P is outside.
The code uses a ±tol tolerance, considering five volumes to have the same sign if all are > −tol or < tol.
2. Finding 4 Coordinating Hf Atoms for O¶
- For each O atom, calculate minimum image distances to all Hf atoms;
- Sort distances in ascending order, always use the nearest 3;
- Try the 4th nearest Hf in sequence, accept only when all 6 edges of the 4 Hf atoms are < 5 Å;
- Centroid:
Displacement (polarization vector):
Write to O-disp.dat. Record as "not coordinated" if no suitable fourth vertex is found.
3. Interactive 3D Visualization¶
Save the following complete HTML as view_tetra.html to view in a browser:
- Left dropdown menu can select any O atom
- Scene elements:
- Gray spheres: all Hf
- Pink spheres: all O
- Red sphere: selected O
- Gold spheres: 4 Hf atoms forming the tetrahedron
- Yellow lines: 6 edges of tetrahedron
- Green sphere: centroid
- Blue arrow: polarization vector Δ⃗
- Supports drag rotation and zoom
🔗 Click to view interactive demo
The above content provides both algorithm explanation and visualization examples for further debugging or demonstration.