### Install Pymatgen from source using pip Source: https://github.com/materialsproject/pymatgen/blob/main/docs/index.md Install the developmental version of pymatgen by cloning the GitHub repository and installing from the root. ```shell uv pip install . ``` -------------------------------- ### Example POTCAR Configuration Process Source: https://github.com/materialsproject/pymatgen/blob/main/docs/installation.md This example demonstrates the complete process of configuring POTCAR paths for both PBE and LDA functionals and adding the Pymatgen PSP directory to the configuration. ```bash pmg config -p /path/to/pseudos/potcar_PBE.54 /path/to/pseudos/pmg_potcars pmg config -p /path/to/pseudos/potcar_LDA.54 /path/to/pseudos/pmg_potcars pmg config --add PMG_VASP_PSP_DIR /path/to/pseudos/pmg_potcars ``` -------------------------------- ### Install Pymatgen Core Package Source: https://github.com/materialsproject/pymatgen/blob/main/README.md Installs only the core pymatgen objects and file I/O functionality, providing a minimal installation. ```sh pip install pymatgen-core ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/materialsproject/pymatgen/blob/main/docs/contributing.md Install the pre-commit hook for linters to ensure code quality before committing changes. ```sh uv run pre-commit install # Install pre-commit hook for linters. ``` -------------------------------- ### Text Transition Setup Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up a transition for the text content of an element. ```javascript ji.text=function(t){return Vi(this,"text",t,Hi)} ``` -------------------------------- ### Setup Painter in Mapbox GL JS Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Initializes the map's painter, which is responsible for rendering. It attempts to get a WebGL rendering context and creates a painter instance. ```javascript i.prototype._setupPainter=function(){var r=t.extend({},e.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),n=this._canvas.getContext("webgl",r)||this._canvas.getContext("experimental-webgl",r);n?(this.painter=new _n(n,this.transform),t.webpSupported.testSupport(n)):this.fire(new t.ErrorEvent(new Error("Failed ")))} ``` -------------------------------- ### Install Full Pymatgen Package Source: https://github.com/materialsproject/pymatgen/blob/main/README.md Installs the complete pymatgen package, including analyses, applications, and external integrations, along with core data objects and file I/O. ```sh pip install pymatgen ``` -------------------------------- ### Start a polygon Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets the point and line handlers for the start of a polygon. This prepares the projection for polygon rendering. ```javascript function Gt(){Bt.point=Wt} ``` -------------------------------- ### Install Pymatgen using pip Source: https://github.com/materialsproject/pymatgen/blob/main/docs/index.md Use this command to install the latest stable release of pymatgen from PyPI. ```shell uv pip install pymatgen ``` -------------------------------- ### Install Optional Libraries using pmg Source: https://github.com/materialsproject/pymatgen/blob/main/docs/installation.md Installs optional libraries like enumlib and bader using the pmg command-line tool. These are only for OSX and Linux. ```shell pmg config --install enumlib pmg config --install bader ``` -------------------------------- ### Install and Run Pymatgen Pre-commit Hooks Source: https://github.com/materialsproject/pymatgen/blob/main/docs/contributing.md Install pre-commit hooks to automatically check code style and quality before commits. Optionally, run pre-commit manually on specific files or the entire codebase. ```sh uv run pre-commit install # ensure linters are run prior to all future commits # (Optional) Run pre-commit manually uv run pre-commit run --files path/to/changed/files # ensure certain file don't offend linters # or uv run pre-commit run --all-files # ensure your entire codebase passes linters ``` -------------------------------- ### Style Tween Setup Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up a tween for style transitions, allowing custom interpolation. ```javascript ji.styleTween=function(t,e,r){function n(n,i){var a=e.call(this,n,i,o(this).getComputedStyle(this,null).getPropertyValue(t));return a&&function(e){this.style.setProperty(t,a(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,n)} ``` -------------------------------- ### Voronoi Edge Start and End Points Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Helper methods for a Voronoi edge to get its start and end sites based on the current site context. ```javascript $e.prototype={start:function(){return this.edge.l===this.site?this.edge.a:this.edge.b},end:function(){return this.edge.l===this.site?this.edge.b:this.edge.a}} ``` -------------------------------- ### Start and End Angle Accessors Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Functions to get and set the start and end angles for arc-based path generation. These define the portion of the circle or ellipse used. ```javascript function ei(t){return t.startAngle} function ri(t){return t.endAngle} ``` -------------------------------- ### Style Transition Setup Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up a transition for CSS properties. Handles property removal if the value is null. ```javascript ji.style=function(t,e,r){var n=arguments.length;if(n<3){if("string"!=typeof t){for(r in n<2&&(e=""),t)this.style(r,t\[r\],e);return this}r=""}function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var n,i=o(this).getComputedStyle(this,null).getPropertyValue(t);return i!==e&&(n=yr(i,e),function(e){this.style.setProperty(t,n(e),r)})})}return Vi(this,"style."+t,e,a)} ``` -------------------------------- ### Synchronize Dependencies with uv Source: https://github.com/materialsproject/pymatgen/blob/main/docs/contributing.md Set up your development environment by synchronizing dependencies using uv. You can install optional dependencies or all of them. ```sh uv sync # uv sync --extra optional # Install a specific optional dependency # uv sync --all-extras # Install all optional dependencies ``` -------------------------------- ### Deprecated Method Aliases Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Provides aliases for previously used method names, throwing an error to guide users to the current, renamed methods. For example, `radians2degrees` is now `radiansToDegrees`. ```javascript r.radians2degrees=function(){throw new Error("method has been renamed to \`radiansToDegrees`")},r.degrees2radians=function(){throw new Error("method has been renamed to \`degreesToRadians`")},r.distanceToDegrees=function(){throw new Error("method has been renamed to \`lengthToDegrees`")},r.distanceToRadians=function(){throw new Error("method has been renamed to \`lengthToRadians`")},r.radiansToDistance=function(){throw new Error("method has been renamed to \`radiansToLength`")},r.bearingToAngle=function(){throw new Error("method has been renamed to \`bearingToAzimuth`")},r.convertDistance=function(){throw new Error("method has been renamed to \`convertLength`")} ``` -------------------------------- ### Element and Composition Basics Source: https://github.com/materialsproject/pymatgen/blob/main/docs/index.md Demonstrates creating Element and Composition objects and accessing their properties like atomic mass, melting point, and weight. Composition objects allow for easy querying of atomic fractions. ```python from pymatgen.core import Composition, Element, Lattice, Molecule, Structure # Integrated symmetry analysis tools from spglib from pymatgen.symmetry.analyzer import SpacegroupAnalyzer si = Element("Si") si.atomic_mass # 28.0855 print(si.melting_point) # 1687.0 K comp = Composition("Fe2O3") comp.weight # 159.6882 # Note that Composition conveniently allows strings to be treated just like an Element object. comp["Fe"] # 2.0 comp.get_atomic_fraction("Fe") # 0.4 ``` -------------------------------- ### Rendering Engine Setup Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up various buffers and index buffers required for rendering tiles, debug information, raster bounds, and viewports. Also initializes an empty texture and stencil clear mode. ```javascript _n.prototype.setup=function(){var e=this.context,r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(r,Ge.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);var n=new t.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(t.EXTENT,0),n.emplaceBack(0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(n,Ge.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);var i=new t.StructArrayLayout4i8;i.emplaceBack(0,0,0,0),i.emplaceBack(t.EXTENT,0,t.EXTENT,0),i.emplaceBack(0,t.EXTENT,0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.rasterBoundsBuffer=e.createVertexBuffer(i,P.members),this.rasterBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);var a=new t.StructArrayLayout2i4;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(a,Ge.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);var o=new t.StructArrayLayout1ui2;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(o);var s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new t.Texture(e,{width:1,height:1,data:new Uint8Array([0,0,0,0])},e.gl.RGBA);var l=this.context.gl;this.stencilClearMode=new Mt({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}, ``` -------------------------------- ### Buffer Creation and Initialization Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Demonstrates how to allocate and initialize Buffer objects. Supports filling with a specific value or creating an unsafe buffer. ```javascript a.alloc=function(t,e,r){return function(t,e,r){return s(t),t<=0?i(t):void 0!==e?"string"==typeof r?i(t).fill(e,r):i(t).fill(e):i(t)}(t,e,r)}, ``` ```javascript a.allocUnsafe=function(t){return l(t)}, ``` ```javascript a.allocUnsafeSlow=function(t){return l(t)}, ``` -------------------------------- ### Initialize Clustering Utility Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up the clustering utility with provided options and initializes an array to hold Quadtrees for different zoom levels. ```javascript var U=function(t){this.options=X(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1)} ``` -------------------------------- ### Start Request Performance Measurement Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Starts performance measurement for a request by marking the start time. This is used to track the duration of various operations. ```javascript var gu=self.performance,mu=function(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},gu.mark(this._marks.start)};mu.prototype.finish=function(){gu.mark(this._marks.end);var t=gu.getEntriesByName(this._marks.measure);return 0===t.length&&(gu.measure(this._marks.measure,this._marks.start,this._marks.end),t=gu.getEntriesByName(this._marks.measure),gu.clearMarks(this._marks.start),gu.clearMarks(this._marks.end),gu.clearMeasures(this._marks.measure)),t} ``` -------------------------------- ### Install Pymatgen with Pip after Conda Dependencies Source: https://github.com/materialsproject/pymatgen/blob/main/docs/installation.md Use this method if the direct Conda installation fails. It installs critical dependencies via Conda first, then uses Pip for pymatgen. ```shell conda install --yes numpy scipy matplotlib pip install pymatgen ``` -------------------------------- ### Use Program Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Selects a rendering program (shader) for use. Initializes a cache if it doesn't exist. This is a fundamental step before issuing rendering commands. ```javascript t,e;this.cache=this.cache||{};var ``` -------------------------------- ### Geo Projection: Polygon Start Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Initializes polygon projection. Use when starting to draw a polygon. ```javascript V.polygonStart=function(){j.reset(),V.lineStart=H,V.lineEnd=q} ``` -------------------------------- ### Initialize Buffers and Textures Source: https://github.com/materialsproject/pymatgen/blob/main/docs/assets/team-map.html Sets up WebGL buffers and textures required for rendering. This includes creating dynamic buffers for attributes and a texture for the color palette. ```javascript var a = n(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]), o = t("./constants").maxDimensionCount, s = t("../../lib"), l = new Uint8Array(4), c = new Uint8Array(4), u = {shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"}; function f(t,e,r,n,i){var a=t._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,r,n,i),t.clear({color:[0,0,0,0],depth:1})} function h(t,e,r,n,i,a){var o=a.key;r.drawCompleted||(!function s(l){var c=Math.min(n,i-l*n);0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],f(t,a.scissorX,a.scissorY,a.scissorWidth,a.viewBoxSize[1])),r.clearOnly||(a.count=2*c,a.offset=2*l*n,e(a),l*n+c>>8*e)%256/255} function g(t,e,r){for(var n=new Array(8*e),i=0,a=0;a=1},p.isTransparent=function(){return this.opacity<1},p.pickSlots=1,p.setPickBase=function(t){this.pickId=t},p.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),void 0!==t.tubeScale&&(this.tubeScale=t.tubeScale),void 0!==t.vectorScale&&(this.vectorScale=t.vectorScale),void 0!==t.coneScale&&(this.coneScale=t.coneScale),void 0!==t.coneOffset&&(this.coneOffset=t.coneOffset),t.colormap&&(this.texture.shape=\[256,256\] ,this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(function(t){for(var e=u({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;n<256;++n){for(var i=e[n],a=0;a<3;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return c(r,[256,256,4],[4,0,1])}(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions,i=t.vectors;if(n&&r&&i){var a=\[\] ,o=\[\] ,s=\[\] ,l=\[\] ,f=\[\];this.cells=r,this.positions=n,this.vectors=i;var h=t.meshColor||\[1,1,1,1\] ,p=t.vertexIntensity,d=1/0,g=-1/0;if(p)if(t.vertexIntensityBounds)d=+t.vertexIntensityBounds[0],g=+t.vertexIntensityBounds[1];else for(var m=0;m1){ v=p[0];var x=p[1],b=v[0]-x[0],_=v[1]-x[1];a=b*b+_* o=[(o[0]+c[0])/2,(o[1]+c[1])/2], l=[(l[0]+u[0])/2,(l[1]+u[1])/2], k(g*e) } s=null,A(o,l),L(n) } function m(){ var o,l,c,u,f=t.touches(r); Di.call(r); for(var h=0,p=f.length;h