matsci-parse 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +270 -159
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
class
|
|
2
|
-
constructor(e,
|
|
3
|
-
this.speciesIndex = e, this.cart =
|
|
1
|
+
class y {
|
|
2
|
+
constructor(e, s, i = {}) {
|
|
3
|
+
this.speciesIndex = e, this.cart = s, this.props = i;
|
|
4
4
|
}
|
|
5
5
|
getProp(e) {
|
|
6
6
|
return this.props[e];
|
|
7
7
|
}
|
|
8
|
-
setProp(e,
|
|
9
|
-
this.props[e] =
|
|
8
|
+
setProp(e, s) {
|
|
9
|
+
this.props[e] = s;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
12
|
+
function A(t) {
|
|
13
|
+
return t.sites.some((e) => Array.isArray(e.props.selectiveDynamics));
|
|
14
14
|
}
|
|
15
|
-
class
|
|
15
|
+
class S {
|
|
16
16
|
constructor({
|
|
17
17
|
lattice: e,
|
|
18
|
-
species:
|
|
19
|
-
sites:
|
|
18
|
+
species: s,
|
|
19
|
+
sites: i
|
|
20
20
|
}) {
|
|
21
|
-
this.lattice = this._validateLattice(e), this.species = this._validateSpecies(
|
|
21
|
+
this.lattice = this._validateLattice(e), this.species = this._validateSpecies(s), this.sites = this._validateSites(i);
|
|
22
22
|
}
|
|
23
23
|
// ---------- Simple methods ----------
|
|
24
24
|
get numSites() {
|
|
@@ -36,8 +36,8 @@ class x {
|
|
|
36
36
|
get elements() {
|
|
37
37
|
return this.species;
|
|
38
38
|
}
|
|
39
|
-
addSite(e,
|
|
40
|
-
this._validateSpeciesIndex(e), this.sites.push(new
|
|
39
|
+
addSite(e, s) {
|
|
40
|
+
this._validateSpeciesIndex(e), this.sites.push(new y(e, s));
|
|
41
41
|
}
|
|
42
42
|
removeSite(e) {
|
|
43
43
|
this.sites.splice(e, 1);
|
|
@@ -46,27 +46,27 @@ class x {
|
|
|
46
46
|
_validateLattice(e) {
|
|
47
47
|
if (!Array.isArray(e) || e.length !== 3)
|
|
48
48
|
throw new Error("Lattice must be a 3x3 matrix");
|
|
49
|
-
return e.forEach((
|
|
50
|
-
if (!Array.isArray(
|
|
49
|
+
return e.forEach((s) => {
|
|
50
|
+
if (!Array.isArray(s) || s.length !== 3)
|
|
51
51
|
throw new Error("Lattice vectors must be length 3");
|
|
52
52
|
}), e;
|
|
53
53
|
}
|
|
54
54
|
_validateSpecies(e) {
|
|
55
55
|
if (!Array.isArray(e)) throw new Error("Species must be an array");
|
|
56
|
-
return e.forEach((
|
|
57
|
-
if (typeof
|
|
56
|
+
return e.forEach((s) => {
|
|
57
|
+
if (typeof s != "string")
|
|
58
58
|
throw new Error("Species entries must be strings");
|
|
59
59
|
}), e;
|
|
60
60
|
}
|
|
61
61
|
_validateSites(e) {
|
|
62
62
|
if (!Array.isArray(e)) throw new Error("Sites must be an array");
|
|
63
|
-
return e.map((
|
|
64
|
-
if (
|
|
65
|
-
if (typeof
|
|
66
|
-
return this._validateSpeciesIndex(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
return e.map((s) => {
|
|
64
|
+
if (s instanceof y) return s;
|
|
65
|
+
if (typeof s == "object" && typeof s.speciesIndex == "number" && Array.isArray(s.cart) && s.cart.length === 3)
|
|
66
|
+
return this._validateSpeciesIndex(s.speciesIndex), new y(
|
|
67
|
+
s.speciesIndex,
|
|
68
|
+
s.cart,
|
|
69
|
+
s.props ?? {}
|
|
70
70
|
);
|
|
71
71
|
throw new Error(
|
|
72
72
|
"Each site must be a Site instance or a valid site object"
|
|
@@ -78,177 +78,288 @@ class x {
|
|
|
78
78
|
throw new Error("speciesIndex out of bounds");
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
function I(t) {
|
|
82
|
+
return t.split(/\r?\n/).map((e) => e.trim()).filter(Boolean);
|
|
83
|
+
}
|
|
84
|
+
function D(t) {
|
|
85
|
+
const e = [], s = A(t);
|
|
86
|
+
e.push("Generated by matsci-parse"), e.push("1.0"), t.lattice.forEach((n) => {
|
|
87
|
+
e.push(n.map((c) => c.toFixed(10)).join(" "));
|
|
85
88
|
});
|
|
86
|
-
const
|
|
87
|
-
new Set(
|
|
88
|
-
),
|
|
89
|
-
(
|
|
89
|
+
const i = Array.from(
|
|
90
|
+
new Set(t.sites.map((n) => t.species[n.speciesIndex]))
|
|
91
|
+
), o = i.map(
|
|
92
|
+
(n) => t.sites.filter((c) => t.species[c.speciesIndex] === n).length
|
|
90
93
|
);
|
|
91
|
-
return e.push(
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
e.push(`${
|
|
94
|
+
return e.push(i.join(" ")), e.push(o.join(" ")), s && e.push("Selective dynamics"), e.push("Cartesian"), i.forEach((n) => {
|
|
95
|
+
t.sites.filter((c) => t.species[c.speciesIndex] === n).forEach((c) => {
|
|
96
|
+
const l = c.cart.map((u) => u.toFixed(10)).join(" ");
|
|
97
|
+
if (s) {
|
|
98
|
+
const m = (Array.isArray(c.props?.selectiveDynamics) ? c.props.selectiveDynamics : [!0, !0, !0]).map((p) => p ? "T" : "F").join(" ");
|
|
99
|
+
e.push(`${l} ${m}`);
|
|
97
100
|
} else
|
|
98
|
-
e.push(
|
|
101
|
+
e.push(l);
|
|
99
102
|
});
|
|
100
103
|
}), e.join(`
|
|
101
104
|
`);
|
|
102
105
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
t
|
|
107
|
-
|
|
108
|
-
for (let l = 0; l < 3; l++)
|
|
106
|
+
function T(t) {
|
|
107
|
+
let e = 0;
|
|
108
|
+
e++;
|
|
109
|
+
const s = parseFloat(t[e++]), i = [];
|
|
110
|
+
for (let h = 0; h < 3; h++)
|
|
109
111
|
i.push(
|
|
110
|
-
e
|
|
112
|
+
t[e++].split(/\s+/).map((f) => parseFloat(f) * s)
|
|
111
113
|
);
|
|
112
|
-
let
|
|
113
|
-
/^[A-Za-z]/.test(
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
let
|
|
117
|
-
e
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
for (let
|
|
121
|
-
const
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
] :
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
|
|
114
|
+
let o = t[e].trim(), n;
|
|
115
|
+
/^[A-Za-z]/.test(o) && (n = o.split(/\s+/), e++);
|
|
116
|
+
const c = t[e++].split(/\s+/).map(Number);
|
|
117
|
+
n || (n = c.map((h, f) => `X${f + 1}`));
|
|
118
|
+
let l = !1;
|
|
119
|
+
t[e]?.toLowerCase().startsWith("s") && (l = !0, e++);
|
|
120
|
+
const m = t[e++].toLowerCase().startsWith("d"), p = [];
|
|
121
|
+
return n.forEach((h, f) => {
|
|
122
|
+
for (let _ = 0; _ < c[f]; _++) {
|
|
123
|
+
const r = t[e++].split(/\s+/).map(Number);
|
|
124
|
+
let d;
|
|
125
|
+
m ? d = [
|
|
126
|
+
r[0] * i[0][0] + r[1] * i[1][0] + r[2] * i[2][0],
|
|
127
|
+
r[0] * i[0][1] + r[1] * i[1][1] + r[2] * i[2][1],
|
|
128
|
+
r[0] * i[0][2] + r[1] * i[1][2] + r[2] * i[2][2]
|
|
129
|
+
] : d = r.slice(0, 3);
|
|
130
|
+
const g = {};
|
|
131
|
+
if (l) {
|
|
132
|
+
const x = r.slice(3, 6).map((a) => a === 1);
|
|
133
|
+
x.length === 3 && (g.selectiveDynamics = x);
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
p.push(new y(f, d, g));
|
|
134
136
|
}
|
|
135
|
-
}),
|
|
136
|
-
lattice: i,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
}), {
|
|
138
|
+
structure: new S({ lattice: i, species: n, sites: p }),
|
|
139
|
+
linesConsumed: e
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function P(t) {
|
|
143
|
+
const e = I(t);
|
|
144
|
+
return T(e).structure;
|
|
140
145
|
}
|
|
141
|
-
function
|
|
146
|
+
function R(t) {
|
|
142
147
|
const e = [];
|
|
143
|
-
return e.push("CRYSTAL"), e.push("PRIMVEC"),
|
|
144
|
-
e.push(
|
|
145
|
-
}), e.push("PRIMCOORD"), e.push(`${
|
|
146
|
-
const
|
|
147
|
-
e.push(`${
|
|
148
|
+
return e.push("CRYSTAL"), e.push("PRIMVEC"), t.lattice.forEach((s) => {
|
|
149
|
+
e.push(s.map((i) => i.toFixed(10)).join(" "));
|
|
150
|
+
}), e.push("PRIMCOORD"), e.push(`${t.numSites} 1`), t.sites.forEach((s) => {
|
|
151
|
+
const i = t.species[s.speciesIndex];
|
|
152
|
+
e.push(`${i} ${s.cart.map((o) => o.toFixed(10)).join(" ")}`);
|
|
148
153
|
}), e.join(`
|
|
149
154
|
`);
|
|
150
155
|
}
|
|
151
|
-
function
|
|
152
|
-
const e =
|
|
153
|
-
let
|
|
154
|
-
for (;
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
for (let
|
|
158
|
-
|
|
159
|
-
for (;
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
const [
|
|
163
|
-
for (let
|
|
164
|
-
const
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
return new
|
|
169
|
-
}
|
|
170
|
-
function
|
|
171
|
-
const e = [],
|
|
172
|
-
e.push(String(
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
].join(" "),
|
|
156
|
+
function W(t) {
|
|
157
|
+
const e = I(t), s = [], i = [], o = [];
|
|
158
|
+
let n = 0;
|
|
159
|
+
for (; n < e.length && e[n].toUpperCase() !== "PRIMVEC"; ) n++;
|
|
160
|
+
if (n === e.length) throw new Error("PRIMVEC block not found in XSF");
|
|
161
|
+
n++;
|
|
162
|
+
for (let l = 0; l < 3; l++)
|
|
163
|
+
s.push(e[n++].split(/\s+/).map(Number));
|
|
164
|
+
for (; n < e.length && e[n].toUpperCase() !== "PRIMCOORD"; ) n++;
|
|
165
|
+
if (n === e.length) throw new Error("PRIMCOORD block not found in XSF");
|
|
166
|
+
n++;
|
|
167
|
+
const [c] = e[n++].split(/\s+/).map(Number);
|
|
168
|
+
for (let l = 0; l < c; l++) {
|
|
169
|
+
const u = e[n++].split(/\s+/), m = u[0], p = u.slice(1, 4).map(Number);
|
|
170
|
+
let h = i.indexOf(m);
|
|
171
|
+
h === -1 && (i.push(m), h = i.length - 1), o.push(new y(h, p));
|
|
172
|
+
}
|
|
173
|
+
return new S({ lattice: s, species: i, sites: o });
|
|
174
|
+
}
|
|
175
|
+
function O(t) {
|
|
176
|
+
const e = [], s = t.sites.length;
|
|
177
|
+
e.push(String(s));
|
|
178
|
+
const i = A(t), o = t.lattice, n = [
|
|
179
|
+
o[0][0],
|
|
180
|
+
o[1][0],
|
|
181
|
+
o[2][0],
|
|
182
|
+
o[0][1],
|
|
183
|
+
o[1][1],
|
|
184
|
+
o[2][1],
|
|
185
|
+
o[0][2],
|
|
186
|
+
o[1][2],
|
|
187
|
+
o[2][2]
|
|
188
|
+
].join(" "), c = [
|
|
184
189
|
"species:S:1",
|
|
185
190
|
"pos:R:3",
|
|
186
|
-
|
|
191
|
+
i ? "selectiveDynamics:L:3" : null
|
|
187
192
|
].filter(Boolean).join(":");
|
|
188
|
-
e.push(`Lattice="${
|
|
189
|
-
for (const
|
|
190
|
-
const
|
|
191
|
-
let
|
|
192
|
-
if (
|
|
193
|
-
const
|
|
194
|
-
|
|
193
|
+
e.push(`Lattice="${n}" Properties=${c}`);
|
|
194
|
+
for (const l of t.sites) {
|
|
195
|
+
const u = t.species[l.speciesIndex], [m, p, h] = l.cart;
|
|
196
|
+
let f = `${u} ${m.toFixed(10)} ${p.toFixed(10)} ${h.toFixed(10)}`;
|
|
197
|
+
if (i) {
|
|
198
|
+
const _ = Array.isArray(l.props?.selectiveDynamics) ? l.props.selectiveDynamics : [!0, !0, !0];
|
|
199
|
+
f += " " + _.map((r) => r ? "T" : "F").join(" ");
|
|
195
200
|
}
|
|
196
|
-
e.push(
|
|
201
|
+
e.push(f);
|
|
197
202
|
}
|
|
198
203
|
return e.join(`
|
|
199
204
|
`);
|
|
200
205
|
}
|
|
201
|
-
function
|
|
202
|
-
const e =
|
|
203
|
-
let
|
|
204
|
-
const
|
|
205
|
-
if (!Number.isFinite(
|
|
206
|
+
function X(t) {
|
|
207
|
+
const e = I(t);
|
|
208
|
+
let s = 0;
|
|
209
|
+
const i = parseInt(e[s++], 10);
|
|
210
|
+
if (!Number.isFinite(i))
|
|
206
211
|
throw new Error("Invalid XYZ: first line must be atom count");
|
|
207
|
-
const
|
|
208
|
-
for (const r of
|
|
209
|
-
let
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
let
|
|
213
|
-
if (
|
|
214
|
-
const r =
|
|
212
|
+
const o = e[s++], n = {}, c = /(\w+)=(".*?"|\S+)/g;
|
|
213
|
+
for (const r of o.matchAll(c)) {
|
|
214
|
+
let d = r[2];
|
|
215
|
+
d.startsWith('"') && (d = d.slice(1, -1)), n[r[1]] = d;
|
|
216
|
+
}
|
|
217
|
+
let l;
|
|
218
|
+
if (n.Lattice) {
|
|
219
|
+
const r = n.Lattice.split(/\s+/).map(Number);
|
|
215
220
|
if (r.length !== 9) throw new Error("Invalid Lattice in extended XYZ");
|
|
216
|
-
|
|
221
|
+
l = [
|
|
217
222
|
[r[0], r[3], r[6]],
|
|
218
223
|
[r[1], r[4], r[7]],
|
|
219
224
|
[r[2], r[5], r[8]]
|
|
220
225
|
];
|
|
221
226
|
} else
|
|
222
227
|
throw new Error("Lattice must be present in extended XYZ format");
|
|
223
|
-
let
|
|
224
|
-
if (
|
|
225
|
-
const r =
|
|
226
|
-
let
|
|
227
|
-
for (let
|
|
228
|
-
const
|
|
229
|
-
|
|
228
|
+
let u = 0, m = 1, p = null;
|
|
229
|
+
if (n.Properties) {
|
|
230
|
+
const r = n.Properties.split(":");
|
|
231
|
+
let d = 0;
|
|
232
|
+
for (let g = 0; g < r.length; g += 3) {
|
|
233
|
+
const x = r[g], a = parseInt(r[g + 2], 10);
|
|
234
|
+
x === "species" && (u = d), x === "pos" && (m = d), x === "selectiveDynamics" && (p = d), d += a;
|
|
230
235
|
}
|
|
231
236
|
}
|
|
232
|
-
const
|
|
233
|
-
for (let r = 0; r <
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
239
|
-
|
|
237
|
+
const h = [], f = /* @__PURE__ */ new Map(), _ = [];
|
|
238
|
+
for (let r = 0; r < i; r++) {
|
|
239
|
+
const d = e[s++].split(/\s+/), g = d[u];
|
|
240
|
+
f.has(g) || (f.set(g, h.length), h.push(g));
|
|
241
|
+
const x = f.get(g), a = d.slice(m, m + 3).map(Number), b = {};
|
|
242
|
+
if (p !== null) {
|
|
243
|
+
const v = d.slice(p, p + 3).map((w) => w.toUpperCase() === "T");
|
|
244
|
+
v.length === 3 && (b.selectiveDynamics = v);
|
|
240
245
|
}
|
|
241
|
-
|
|
246
|
+
_.push(new y(x, a, b));
|
|
247
|
+
}
|
|
248
|
+
return new S({ lattice: l, species: h, sites: _ });
|
|
249
|
+
}
|
|
250
|
+
function E(t) {
|
|
251
|
+
return t * Math.PI / 180;
|
|
252
|
+
}
|
|
253
|
+
function C(t, e, s, i, o, n) {
|
|
254
|
+
const c = E(i), l = E(o), u = E(n), m = [t, 0, 0], p = [
|
|
255
|
+
e * Math.cos(u),
|
|
256
|
+
e * Math.sin(u),
|
|
257
|
+
0
|
|
258
|
+
], h = s * Math.cos(l), f = s * (Math.cos(c) - Math.cos(l) * Math.cos(u)) / Math.sin(u), _ = Math.sqrt(s * s - h * h - f * f);
|
|
259
|
+
return [m, p, [h, f, _]];
|
|
260
|
+
}
|
|
261
|
+
function j(t, e) {
|
|
262
|
+
const [s, i, o] = e;
|
|
263
|
+
return [
|
|
264
|
+
t[0] * s[0] + t[1] * i[0] + t[2] * o[0],
|
|
265
|
+
t[0] * s[1] + t[1] * i[1] + t[2] * o[1],
|
|
266
|
+
t[0] * s[2] + t[1] * i[2] + t[2] * o[2]
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
function F(t, e) {
|
|
270
|
+
return t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
|
|
271
|
+
}
|
|
272
|
+
function M(t) {
|
|
273
|
+
return Math.sqrt(F(t, t));
|
|
274
|
+
}
|
|
275
|
+
function $(t) {
|
|
276
|
+
return t * 180 / Math.PI;
|
|
277
|
+
}
|
|
278
|
+
function L(t, e) {
|
|
279
|
+
const [s, i, o] = e, n = s[0] * (i[1] * o[2] - i[2] * o[1]) - s[1] * (i[0] * o[2] - i[2] * o[0]) + s[2] * (i[0] * o[1] - i[1] * o[0]);
|
|
280
|
+
if (Math.abs(n) < 1e-12)
|
|
281
|
+
throw new Error("Singular lattice matrix");
|
|
282
|
+
const c = [
|
|
283
|
+
[
|
|
284
|
+
(i[1] * o[2] - i[2] * o[1]) / n,
|
|
285
|
+
(s[2] * o[1] - s[1] * o[2]) / n,
|
|
286
|
+
(s[1] * i[2] - s[2] * i[1]) / n
|
|
287
|
+
],
|
|
288
|
+
[
|
|
289
|
+
(i[2] * o[0] - i[0] * o[2]) / n,
|
|
290
|
+
(s[0] * o[2] - s[2] * o[0]) / n,
|
|
291
|
+
(s[2] * i[0] - s[0] * i[2]) / n
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
(i[0] * o[1] - i[1] * o[0]) / n,
|
|
295
|
+
(s[1] * o[0] - s[0] * o[1]) / n,
|
|
296
|
+
(s[0] * i[1] - s[1] * i[0]) / n
|
|
297
|
+
]
|
|
298
|
+
];
|
|
299
|
+
return [
|
|
300
|
+
t[0] * c[0][0] + t[1] * c[1][0] + t[2] * c[2][0],
|
|
301
|
+
t[0] * c[0][1] + t[1] * c[1][1] + t[2] * c[2][1],
|
|
302
|
+
t[0] * c[0][2] + t[1] * c[1][2] + t[2] * c[2][2]
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
function N(t) {
|
|
306
|
+
const [e, s, i] = t.lattice, o = M(e), n = M(s), c = M(i), l = $(Math.acos(F(s, i) / (n * c))), u = $(Math.acos(F(e, i) / (o * c))), m = $(Math.acos(F(e, s) / (o * n)));
|
|
307
|
+
let p = `data_made_with_matsci-parse
|
|
308
|
+
_symmetry_space_group_name_H-M 'P 1'
|
|
309
|
+
_symmetry_Int_Tables_number 1
|
|
310
|
+
|
|
311
|
+
_cell_length_a ${o.toFixed(6)}
|
|
312
|
+
_cell_length_b ${n.toFixed(6)}
|
|
313
|
+
_cell_length_c ${c.toFixed(6)}
|
|
314
|
+
_cell_angle_alpha ${l.toFixed(6)}
|
|
315
|
+
_cell_angle_beta ${u.toFixed(6)}
|
|
316
|
+
_cell_angle_gamma ${m.toFixed(6)}
|
|
317
|
+
|
|
318
|
+
loop_
|
|
319
|
+
_atom_site_label
|
|
320
|
+
_atom_site_type_symbol
|
|
321
|
+
_atom_site_fract_x
|
|
322
|
+
_atom_site_fract_y
|
|
323
|
+
_atom_site_fract_z
|
|
324
|
+
`;
|
|
325
|
+
return t.sites.forEach((h, f) => {
|
|
326
|
+
const _ = t.species[h.speciesIndex], r = L(h.cart, t.lattice);
|
|
327
|
+
p += `${_}${f + 1} ${_} ${r[0].toFixed(6)} ${r[1].toFixed(
|
|
328
|
+
6
|
|
329
|
+
)} ${r[2].toFixed(6)}
|
|
330
|
+
`;
|
|
331
|
+
}), p;
|
|
332
|
+
}
|
|
333
|
+
function z(t) {
|
|
334
|
+
const e = I(t);
|
|
335
|
+
let s = 0, i = 0, o = 0, n = 0, c = 0, l = 0;
|
|
336
|
+
const u = [];
|
|
337
|
+
let m = !1, p = [];
|
|
338
|
+
for (const a of e)
|
|
339
|
+
a.startsWith("_cell_length_a") ? s = parseFloat(a.split(/\s+/)[1]) : a.startsWith("_cell_length_b") ? i = parseFloat(a.split(/\s+/)[1]) : a.startsWith("_cell_length_c") ? o = parseFloat(a.split(/\s+/)[1]) : a.startsWith("_cell_angle_alpha") ? n = parseFloat(a.split(/\s+/)[1]) : a.startsWith("_cell_angle_beta") ? c = parseFloat(a.split(/\s+/)[1]) : a.startsWith("_cell_angle_gamma") ? l = parseFloat(a.split(/\s+/)[1]) : a.startsWith("loop_") ? (m = !0, p = []) : m && a.startsWith("_") ? p.push(a) : m && a && !a.startsWith("_") && u.push(a.split(/\s+/));
|
|
340
|
+
const h = C(s, i, o, n, c, l), f = [], _ = [], r = p.findIndex((a) => a.includes("fract_x")), d = p.findIndex((a) => a.includes("fract_y")), g = p.findIndex((a) => a.includes("fract_z")), x = p.findIndex((a) => a.includes("type_symbol"));
|
|
341
|
+
if (r < 0 || d < 0 || g < 0 || x < 0)
|
|
342
|
+
throw new Error("CIF missing required _atom_site columns");
|
|
343
|
+
for (const a of u) {
|
|
344
|
+
const b = [
|
|
345
|
+
parseFloat(a[r]),
|
|
346
|
+
parseFloat(a[d]),
|
|
347
|
+
parseFloat(a[g])
|
|
348
|
+
], v = j(b, h);
|
|
349
|
+
let w = f.indexOf(a[x]);
|
|
350
|
+
w === -1 && (w = f.length, f.push(a[x])), _.push(new y(w, v));
|
|
242
351
|
}
|
|
243
|
-
return new
|
|
352
|
+
return new S({ lattice: h, species: f, sites: _ });
|
|
244
353
|
}
|
|
245
354
|
export {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
355
|
+
S as CrystalStructure,
|
|
356
|
+
y as Site,
|
|
357
|
+
z as cifToStructure,
|
|
358
|
+
P as poscarToStructure,
|
|
359
|
+
N as structureToCif,
|
|
360
|
+
D as structureToPoscar,
|
|
361
|
+
R as structureToXsf,
|
|
362
|
+
O as structureToXyz,
|
|
363
|
+
W as xsfToStructure,
|
|
364
|
+
X as xyzToStructure
|
|
254
365
|
};
|