sgbaird / latticeplane Goto Github PK
View Code? Open in Web Editor NEWCalculate atomic lattice plane densities in arbitrary crystal structures (CIF input) for arbitrary lattice planes (HKL indices).
License: MIT License
Calculate atomic lattice plane densities in arbitrary crystal structures (CIF input) for arbitrary lattice planes (HKL indices).
License: MIT License
PlaneIntersection[\[ScriptCapitalP]_, \[ScriptCapitalU]_] :=
Module[{\[ScriptCapitalP]1, \[ScriptCapitalB], \[ScriptCapitalM], \
\[ScriptCapitalP]crop, \[ScriptCapitalP]int, shapes, bmesh, d, order,
coords, TF},
If[Head@\[ScriptCapitalP] ===
InfinitePlane, \[ScriptCapitalP]1 = {\[ScriptCapitalP]}, \
\[ScriptCapitalP]1 = \[ScriptCapitalP]];
\[ScriptCapitalB] =
RegionResize[BoundingRegion[\[ScriptCapitalU]],
Scaled@Rationalize[
1.1(*100$MachineEpsilon*)]];(*for cropping the plane*)
\[ScriptCapitalP]crop =
RegionIntersection[#, \[ScriptCapitalB]] & /@ \[ScriptCapitalP]1;
\[ScriptCapitalP]crop =
CanonicalizePolygon /@ N[\[ScriptCapitalP]crop];
\[ScriptCapitalP]int =
RegionIntersection[#, N@\[ScriptCapitalU]] & /@
N[\[ScriptCapitalP]crop];
shapes = OpenCascadeShape[#] & /@ \[ScriptCapitalP]int;
bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[#] & /@ shapes;
coords = #["Coordinates"] & /@ bmesh;
TF = CoplanarPoints /@ coords;
coords =
MapThread[
If[#1, #2,
DimensionReduction[#2, 2][#2, "ReconstructedData"]] &, {TF,
coords}];
{d, order} = (FindShortestTour[#] & /@ coords)\[Transpose];
\[ScriptCapitalP]int =
MapThread[Polygon[#1[[#2[[;; -2]]]]] &, {coords, order}]
]
Without CanonicalizePolygon
(which is how it was before I tried resolving a bug #1):
Message[CoplanarPoints::pts, $Failed["Coordinates"]] "\!\($Failed[\"Coordinates\"]\) should be a non-empty list of points."
Upon further inspection, this was due to the intersection being incorrectly determined as a line instead of a plane AFAIK. Adding CanonicalizePolygon
seemed to resolve this issue for mp-134
(Al), but now the results for mp-510623
(Fe3C) are off (maybe they're off for mp-134
since I didn't do manual verification of the values). The PlotSymmetrizedFullHKL
function isn't even working because all of the intersection areas were determined to be zero for Fe.
This is running on Mathematica 13.0.1.0 on Microsoft Windows 64-bit.
Getting the plane intersection functions to be robust across a variety of use-cases has been very difficult, and if I'm not mistaken, somewhere between 12.2 and 13.0 there's a bug that has been introduced. Haven't verified by reverting to 12.2.
The issue might also be with how the intersections between the bounded plane and the atom hard spheres are being computed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.