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.
Files changed (2) hide show
  1. package/dist/main.js +270 -159
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,24 +1,24 @@
1
- class S {
2
- constructor(e, t, o = {}) {
3
- this.speciesIndex = e, this.cart = t, this.props = o;
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, t) {
9
- this.props[e] = t;
8
+ setProp(e, s) {
9
+ this.props[e] = s;
10
10
  }
11
11
  }
12
- function I(n) {
13
- return n.sites.some((e) => Array.isArray(e.props.selectiveDynamics));
12
+ function A(t) {
13
+ return t.sites.some((e) => Array.isArray(e.props.selectiveDynamics));
14
14
  }
15
- class x {
15
+ class S {
16
16
  constructor({
17
17
  lattice: e,
18
- species: t,
19
- sites: o
18
+ species: s,
19
+ sites: i
20
20
  }) {
21
- this.lattice = this._validateLattice(e), this.species = this._validateSpecies(t), this.sites = this._validateSites(o);
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, t) {
40
- this._validateSpeciesIndex(e), this.sites.push(new S(e, t));
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((t) => {
50
- if (!Array.isArray(t) || t.length !== 3)
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((t) => {
57
- if (typeof t != "string")
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((t) => {
64
- if (t instanceof S) return t;
65
- if (typeof t == "object" && typeof t.speciesIndex == "number" && Array.isArray(t.cart) && t.cart.length === 3)
66
- return this._validateSpeciesIndex(t.speciesIndex), new S(
67
- t.speciesIndex,
68
- t.cart,
69
- t.props ?? {}
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 A(n) {
82
- const e = [], t = I(n);
83
- e.push("Generated by CrystalStructure"), e.push("1.0"), n.lattice.forEach((s) => {
84
- e.push(s.map((p) => p.toFixed(10)).join(" "));
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 o = Array.from(
87
- new Set(n.sites.map((s) => n.species[s.speciesIndex]))
88
- ), i = o.map(
89
- (s) => n.sites.filter((p) => n.species[p.speciesIndex] === s).length
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(o.join(" ")), e.push(i.join(" ")), t && e.push("Selective dynamics"), e.push("Cartesian"), o.forEach((s) => {
92
- n.sites.filter((p) => n.species[p.speciesIndex] === s).forEach((p) => {
93
- const a = p.cart.map((h) => h.toFixed(10)).join(" ");
94
- if (t) {
95
- const d = (Array.isArray(p.props?.selectiveDynamics) ? p.props.selectiveDynamics : [!0, !0, !0]).map((u) => u ? "T" : "F").join(" ");
96
- e.push(`${a} ${d}`);
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(a);
101
+ e.push(l);
99
102
  });
100
103
  }), e.join(`
101
104
  `);
102
105
  }
103
- function j(n) {
104
- const e = n.trim().split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
105
- let t = 0;
106
- t++;
107
- const o = parseFloat(e[t++]), i = [];
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[t++].split(/\s+/).map((y) => parseFloat(y) * o)
112
+ t[e++].split(/\s+/).map((f) => parseFloat(f) * s)
111
113
  );
112
- let s = e[t].trim(), p;
113
- /^[A-Za-z]/.test(s) && (p = s.split(/\s+/), t++);
114
- const a = e[t++].split(/\s+/).map(Number);
115
- p || (p = a.map((l, y) => `X${y + 1}`));
116
- let h = !1;
117
- e[t]?.toLowerCase().startsWith("s") && (h = !0, t++);
118
- const u = e[t++].toLowerCase().startsWith("d"), m = [];
119
- return p.forEach((l, y) => {
120
- for (let r = 0; r < a[y]; r++) {
121
- const c = e[t++].split(/\s+/).map(Number);
122
- let f;
123
- u ? f = [
124
- c[0] * i[0][0] + c[1] * i[1][0] + c[2] * i[2][0],
125
- c[0] * i[0][1] + c[1] * i[1][1] + c[2] * i[2][1],
126
- c[0] * i[0][2] + c[1] * i[1][2] + c[2] * i[2][2]
127
- ] : f = c.slice(0, 3);
128
- let w = {};
129
- if (h) {
130
- const g = e[t - 1].split(/\s+/).slice(3, 6).map((v) => v.toUpperCase() === "T");
131
- g.length === 3 && (w.selectiveDynamics = g);
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
- m.push(new S(y, f, w));
135
+ p.push(new y(f, d, g));
134
136
  }
135
- }), new x({
136
- lattice: i,
137
- species: p,
138
- sites: m
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 C(n) {
146
+ function R(t) {
142
147
  const e = [];
143
- return e.push("CRYSTAL"), e.push("PRIMVEC"), n.lattice.forEach((t) => {
144
- e.push(t.map((o) => o.toFixed(10)).join(" "));
145
- }), e.push("PRIMCOORD"), e.push(`${n.numSites} 1`), n.sites.forEach((t) => {
146
- const o = n.species[t.speciesIndex];
147
- e.push(`${o} ${t.cart.map((i) => i.toFixed(10)).join(" ")}`);
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 D(n) {
152
- const e = n.trim().split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0), t = [], o = [], i = [];
153
- let s = 0;
154
- for (; s < e.length && e[s].toUpperCase() !== "PRIMVEC"; ) s++;
155
- if (s === e.length) throw new Error("PRIMVEC block not found in XSF");
156
- s++;
157
- for (let a = 0; a < 3; a++)
158
- t.push(e[s++].split(/\s+/).map(Number));
159
- for (; s < e.length && e[s].toUpperCase() !== "PRIMCOORD"; ) s++;
160
- if (s === e.length) throw new Error("PRIMCOORD block not found in XSF");
161
- s++;
162
- const [p] = e[s++].split(/\s+/).map(Number);
163
- for (let a = 0; a < p; a++) {
164
- const h = e[s++].split(/\s+/), d = h[0], u = h.slice(1, 4).map(Number);
165
- let m = o.indexOf(d);
166
- m === -1 && (o.push(d), m = o.length - 1), i.push(new S(m, u));
167
- }
168
- return new x({ lattice: t, species: o, sites: i });
169
- }
170
- function F(n) {
171
- const e = [], t = n.sites.length;
172
- e.push(String(t));
173
- const o = I(n), i = n.lattice, s = [
174
- i[0][0],
175
- i[1][0],
176
- i[2][0],
177
- i[0][1],
178
- i[1][1],
179
- i[2][1],
180
- i[0][2],
181
- i[1][2],
182
- i[2][2]
183
- ].join(" "), p = [
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
- o ? "selectiveDynamics:L:3" : null
191
+ i ? "selectiveDynamics:L:3" : null
187
192
  ].filter(Boolean).join(":");
188
- e.push(`Lattice="${s}" Properties=${p}`);
189
- for (const a of n.sites) {
190
- const h = n.species[a.speciesIndex], [d, u, m] = a.cart;
191
- let l = `${h} ${d.toFixed(10)} ${u.toFixed(10)} ${m.toFixed(10)}`;
192
- if (o) {
193
- const y = Array.isArray(a.props?.selectiveDynamics) ? a.props.selectiveDynamics : [!0, !0, !0];
194
- l += " " + y.map((r) => r ? "T" : "F").join(" ");
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(l);
201
+ e.push(f);
197
202
  }
198
203
  return e.join(`
199
204
  `);
200
205
  }
201
- function L(n) {
202
- const e = n.trim().split(/\r?\n/).map((r) => r.trim()).filter((r) => r.length > 0);
203
- let t = 0;
204
- const o = parseInt(e[t++], 10);
205
- if (!Number.isFinite(o))
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 i = e[t++], s = {}, p = /(\w+)=(".*?"|\S+)/g;
208
- for (const r of i.matchAll(p)) {
209
- let c = r[2];
210
- c.startsWith('"') && (c = c.slice(1, -1)), s[r[1]] = c;
211
- }
212
- let a;
213
- if (s.Lattice) {
214
- const r = s.Lattice.split(/\s+/).map(Number);
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
- a = [
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 h = 0, d = 1, u = null;
224
- if (s.Properties) {
225
- const r = s.Properties.split(":");
226
- let c = 0;
227
- for (let f = 0; f < r.length; f += 3) {
228
- const w = r[f], g = parseInt(r[f + 2], 10);
229
- w === "species" && (h = c), w === "pos" && (d = c), w === "selectiveDynamics" && (u = c), c += g;
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 m = [], l = /* @__PURE__ */ new Map(), y = [];
233
- for (let r = 0; r < o; r++) {
234
- const c = e[t++].split(/\s+/), f = c[h];
235
- l.has(f) || (l.set(f, m.length), m.push(f));
236
- const w = l.get(f), g = c.slice(d, d + 3).map(Number), v = {};
237
- if (u !== null) {
238
- const E = c.slice(u, u + 3).map((b) => b.toUpperCase() === "T");
239
- E.length === 3 && (v.selectiveDynamics = E);
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
- y.push(new S(w, g, v));
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 x({ lattice: a, species: m, sites: y });
352
+ return new S({ lattice: h, species: f, sites: _ });
244
353
  }
245
354
  export {
246
- x as CrystalStructure,
247
- S as Site,
248
- j as poscarToStructure,
249
- A as structureToPoscar,
250
- C as structureToXsf,
251
- F as structureToXyz,
252
- D as xsfToStructure,
253
- L as xyzToStructure
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matsci-parse",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.js",