Skip to content

Commit

Permalink
Merge branch 'master' of github.com:3dmol/3Dmol.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoes committed Sep 4, 2024
2 parents 26796fc + d9efe75 commit a25f7d3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# so ignore any failure here
run: npm run cover
continue-on-error: true

timeout-minutes: 60
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

22 changes: 10 additions & 12 deletions src/parsers/VASP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Matrix3 } from "../WebGL";

import { assignBonds } from "./utils/assignBonds";
import { ParserOptionsSpec } from "./ParserOptionsSpec";
import { AtomSpec } from "specs";

/**
* @param {string}
Expand Down Expand Up @@ -58,26 +59,23 @@ export function VASP(str: string, options: ParserOptionsSpec = {}) {

matrix.multiplyScalar(lattice.length);
atoms.modelData = [{ symmetries: [], cryst: { matrix: matrix } }];
var atomSymbols = lines[5]
.replace(/\s+/, "")
.replace(/\s+$/, "")
.split(/\s+/);
var atomSymbols = lines[5].trim().split(/\s+/);
var atomSpeciesNumber = new Int16Array(
(lines[6] as any).replace(/^\s+/, "").split(/\s+/)
lines[6].trim().split(/\s+/) as any
);
var vaspMode = lines[7].replace(/\s+/, "");
var vaspMode = lines[7].trim();

var selective = false
if (vaspMode.match(/S/)) {
selective = true
vaspMode = lines[8].replace(/\s+/, "");
vaspMode = lines[8].trim();
}

if (vaspMode.match(/C/)) {
if (vaspMode.toLowerCase()[0] == "c") {
vaspMode = "cartesian";
} else if (vaspMode.match(/D/)) {
} else if (vaspMode.toLowerCase()[0] == "d") {
vaspMode = "direct";
} else {
} else {
console.log(
"Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"
);
Expand All @@ -104,10 +102,10 @@ export function VASP(str: string, options: ParserOptionsSpec = {}) {
var atomSymbol = atomSymbols[i];
for (var j = 0, atomLen = atomSpeciesNumber[i]; j < atomLen; j++) {
var coords = new Float32Array(
(lines[atomCounter + j] as any).replace(/^\s+/, "").split(/\s+/)
lines[atomCounter + j].trim().split(/\s+/) as any
);

var atom: Record<string, number | []> = {};
var atom: AtomSpec = {};
(atom.elem as any) = atomSymbol;
if (vaspMode == "cartesian") {
atom.x = lattice.length * coords[0];
Expand Down
10 changes: 10 additions & 0 deletions tests/auto/data/mg.vasp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MgO Fm-3m (No. 225)
1.0
2.606553 0.000000 1.504894
0.868851 2.457482 1.504894
0.000000 0.000000 3.009789
Mg O
1 1
direct
0.000000 0.000000 0.000000 Mg
0.500000 0.500000 0.500000 O
10 changes: 10 additions & 0 deletions tests/auto/tests/vaspex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


$.get('data/mg.vasp', function(v) {
let m = viewer.addModel(v, 'vasp');

viewer.addStyle('sphere');

viewer.zoomTo();
viewer.render();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a25f7d3

Please sign in to comment.