const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bkuhln3H.js","assets/index-DmbfXZZ1.css"])))=>i.map(i=>d[i]);
import{_}from"./index-Bkuhln3H.js";const w=["opt","scf","freq","dos","bader"],m=new Set(["ENCUT","EDIFF","EDIFFG","SIGMA","POTIM","AMIX","BMIX","AMIX_MAG","BMIX_MAG"]),S=new Set(["SYSTEM","PREC","GGA","ALGO","LREAL"]),N=t=>t.length?t[0].toUpperCase()+t.slice(1).toLowerCase():t;function R(t){if(Number.isInteger(t)&&Math.abs(t)<1e16)return`${t}.0`;const n=t===0?0:Math.floor(Math.log10(Math.abs(t)));if(t!==0&&(n<-4||n>=16)){const[s,a]=t.toExponential().split("e"),c=a[0]==="-"?"-":"+",e=a.replace(/[+-]/,"").padStart(2,"0");return`${s}e${c}${e}`}return String(t)}function h(t,n){return typeof n=="boolean"?n?"  .TRUE.":"  .FALSE.":typeof n=="string"?S.has(t)?N(n):n:m.has(t)?R(n):String(n)}const L=[["General",["SYSTEM","PREC","ENCUT","GGA","ALGO","LREAL","ISYM","ADDGRID"]],["Electronic convergence",["EDIFF","NELM","NELMIN","NELMDL","ICHARG","ISTART","AMIX","BMIX","AMIX_MAG","BMIX_MAG","LMAXMIX"]],["Smearing",["ISMEAR","SIGMA"]],["Spin",["ISPIN","MAGMOM"]],["Ionic relaxation / MD",["IBRION","NSW","ISIF","EDIFFG","POTIM","NFREE"]],["Output",["LWAVE","LCHARG","LORBIT","LELF","LAECHG","NWRITE","NEDOS","NBANDS"]],["vdW correction",["IVDW"]],["Parallelization",["NCORE","NPAR"]]];function G(t){const n={...t},s=[];for(const[c,e]of L){const i=e.filter(o=>o in n);if(i.length!==0){s.push(`# ${c}`);for(const o of i)s.push(`${o.padEnd(20)} = ${h(o,n[o])}`),delete n[o];s.push("")}}const a=Object.keys(n);if(a.length){s.push("# Other");for(const c of a)s.push(`${c.padEnd(20)} = ${h(c,n[c])}`);s.push("")}return s.join(`
`)}const d={ALGO:"Fast",LREAL:"Auto",NELM:150,NELMIN:6,ICHARG:1,ISYM:-1,IVDW:12,LORBIT:11};function g(t){const n=t.encut??450,s=t.prec??"Accurate",a=t.gga??"PE",c=t.ediff??1e-5,e=t.ispin??2,i={ALGO:"Fast",PREC:s,ENCUT:n,GGA:a,EDIFF:c,ISPIN:e};let o;t.calculation_type==="opt"?o={...i,ISMEAR:0,SIGMA:.05,IBRION:2,ISIF:3,NSW:100,EDIFFG:t.ediffg??-.05,LWAVE:!1,LCHARG:!0,NCORE:24}:t.calculation_type==="freq"?o={...i,ISMEAR:0,SIGMA:.05,IBRION:5,NFREE:2,POTIM:.015,NWRITE:3,NSW:0,LWAVE:!1,LCHARG:!0,NPAR:1}:t.calculation_type==="dos"?o={...i,ISMEAR:-5,SIGMA:.05,NSW:0,IBRION:-1,NEDOS:3001,LWAVE:!1,LCHARG:!0,NCORE:24}:t.calculation_type==="bader"?o={...i,ISMEAR:0,SIGMA:.05,NSW:0,IBRION:-1,LCHARG:!0,LAECHG:!0,LWAVE:!1,NCORE:24}:o={...i,ISMEAR:0,SIGMA:.05,NSW:0,IBRION:-1,LWAVE:!0,LCHARG:!0,NCORE:24};for(const[u,r]of Object.entries(d))u!=="NCORE"&&(o[u]=r);return t.ivdw!=null&&(o.IVDW=t.ivdw),t.magmom&&(o.MAGMOM=t.magmom),o}function v(t){return G(g(t))}const M=2*Math.PI;function O(t){return t[0][0]*(t[1][1]*t[2][2]-t[1][2]*t[2][1])-t[0][1]*(t[1][0]*t[2][2]-t[1][2]*t[2][0])+t[0][2]*(t[1][0]*t[2][1]-t[1][1]*t[2][0])}function l(t){return[Math.hypot(...t[0]),Math.hypot(...t[1]),Math.hypot(...t[2])]}function y(t){const n=l(t),s=(e,i)=>e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=e=>e*180/Math.PI,c=(e,i)=>a(Math.acos(Math.max(-1,Math.min(1,s(t[e],t[i])/(n[e]*n[i])))));return[c(1,2),c(0,2),c(0,1)]}function C(t,n=5,s=.01){const a=l(t),c=y(t),e=[0,1,2].filter(o=>Math.abs(c[o]-90)<n),i=[0,1,2].filter(o=>Math.abs(c[o]-60)<n||Math.abs(c[o]-120)<n);return e.length===2&&i.length===1&&Math.abs(a[e[0]]-a[e[1]])<s}function b(t,n,s,a={}){const c=M**3/Math.abs(O(t));let e=s*c*n;const i=`pymatgen with grid density = ${Math.round(e)} / number of atoms`;Math.abs(Math.floor(Math.cbrt(e)+.5)**3-e)<1&&(e+=e*.01);const o=l(t),r=(e/n*o[0]*o[1]*o[2])**(1/3),f=o.map(I=>{const E=Math.floor(Math.max(r/I,1));return Number.isFinite(E)&&E>=1?E:1}),p=f.some(I=>I%2===1)||(a.isHexagonal??C(t))||(a.isFaceCentered??!1)||(a.forceGamma??!1)?"Gamma":"Monkhorst";return`${i}
0
${p}
${f.join(" ")}
`}function A(t){return`Automatic kpoint scheme
0
Monkhorst
${t[0]} ${t[1]} ${t[2]}
`}function F(t){return`Automatic kpoint scheme
0
Gamma
${t[0]} ${t[1]} ${t[2]}
`}function T(t){const[n,s,a]=t[0],[c,e,i]=t[1],[o,u,r]=t[2],f=n*(e*r-i*u)-s*(c*r-i*o)+a*(c*u-e*o);return[[(e*r-i*u)/f,(a*u-s*r)/f,(s*i-a*e)/f],[(i*o-c*r)/f,(n*r-a*o)/f,(a*c-n*i)/f],[(c*u-e*o)/f,(s*o-n*u)/f,(n*e-s*c)/f]]}function D(t){const n=T(t),s=a=>Math.hypot(n[0][a],n[1][a],n[2][a]);return[M*s(0),M*s(1),M*s(2)]}function P(t){const n="lattice"in t?t.lattice:void 0;if(!n?.matrix||n.matrix.length<3)throw new Error("No lattice matrix for KPOINTS");const s=n.matrix,a=Math.hypot(...s[2]);return{matrix:s,natoms:t.sites?.length??0,cvec:a}}function H(t,n={calculation_type:"scf"},s={}){const{matrix:a,natoms:c,cvec:e}=P(t),i=e>15;if(n.kmesh){const u=n.kmesh.map(r=>Math.max(1,Math.round(r)||1));return i&&u[2]>1&&(u[2]=1),A(u)}if(n.kspacing!=null&&n.kspacing>0){const r=D(a).map(f=>Math.max(1,Math.ceil(f/n.kspacing)));return i&&r[2]>1&&(r[2]=1),F(r)}const o=b(a,c,1e3,s);if(i){const r=o.split(`
`)[3].split(/\s+/).map(Number);if(r.length===3&&r[2]>1)return r[2]=1,A(r)}return o}const W=new Set([196,202,203,209,210,216,219,225,226,227,228]);async function V(t){const{analyze_structure_symmetry:n}=await _(async()=>{const{analyze_structure_symmetry:c}=await import("./index-Bkuhln3H.js").then(e=>e.E);return{analyze_structure_symmetry:c}},__vite__mapDeps([0,1])),a=(await n(t,{})).number;return typeof a=="number"&&W.has(a)}export{w as SUPPORTED_CALC_TYPES,b as automatic_density_by_vol,g as build_incar_params,V as face_centered_from_symmetry,G as format_incar,v as generate_incar_str,H as generate_kpoints_str,C as is_hexagonal,R as py_float};
