Skip to content

Commit af35964

Browse files
committed
update bond determination
1 parent 43f9c44 commit af35964

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

src/App.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import StructureVisualizer from "./StructureVisualizer";
66
async function fetchCif3D() {
77
// Fetch a cif file from the Materials Cloud AiiDA rest api
88
const aiidaRestEndpoint = "https://aiida.materialscloud.org/mc3d/api/v4";
9-
const uuid = "85260507-9cb4-4849-a10d-703f32697dd7";
10-
//const uuid = "07e48338-e639-485c-bed0-5f23bf6cfae2"; // Ag
11-
//const uuid = "e36f52ac-0f64-47eb-86eb-550608c8672c"; // BN mc3d-66325/pbe
12-
//const uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
13-
//const uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
9+
let uuid = "85260507-9cb4-4849-a10d-703f32697dd7";
10+
11+
// potentially problematic cases w.r.t. bond lengths
12+
// uuid = "07e48338-e639-485c-bed0-5f23bf6cfae2"; // Ag
13+
// uuid = "e36f52ac-0f64-47eb-86eb-550608c8672c"; // BN mc3d-66325/pbe
14+
// uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
15+
// uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
16+
// uuid = "74046bff-82f1-4ced-b33e-54c09db90b78"; // "bizarre" graphite mc3d-19759/pbe
17+
// uuid = "f5e7395f-ecad-4227-9789-21e7e4d21124"; // Al2H4Li2O14Si4 (water molecule) mc3d-12502/pbe
1418

1519
const responseAiiDACif = await fetch(
1620
`${aiidaRestEndpoint}/nodes/${uuid}/download?download_format=cif&download=false`,
@@ -23,7 +27,11 @@ async function fetchCif3D() {
2327
async function fetchCif2D() {
2428
// Fetch a cif file from the Materials Cloud AiiDA rest api
2529
const aiidaRestEndpoint = "https://aiida.materialscloud.org/mc2d/api/v4";
26-
const uuid = "42744ae7-0c30-43df-8136-ab625b4f8425"; // graphene
30+
31+
let uuid = "42744ae7-0c30-43df-8136-ab625b4f8425"; // graphene
32+
33+
// potentially problematic cases w.r.t. bond lengths
34+
uuid = "89a8e9ec-d89b-47bb-a85e-8f1b6734a69c"; // Bi
2735

2836
const responseAiiDACif = await fetch(
2937
`${aiidaRestEndpoint}/nodes/${uuid}/download?download_format=cif&download=false`,

src/StructureVisualizer/StructureWindow/3dmol/Visualizer3dmol.jsx

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React from "react";
22

33
import * as $3Dmol from "3dmol";
44

5-
import * as math from "mathjs";
6-
75
import { covalentRadii } from "./bondLengths";
86

97
import "./Visualizer3dmol.css";
@@ -12,32 +10,17 @@ function mod(n, m) {
1210
return ((n % m) + m) % m;
1311
}
1412

15-
// override the covalent bond detection based on examples in MC3D
16-
const overrideBondLengths = {
17-
// uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
18-
Ba: 0.92 * covalentRadii["Ba"],
19-
Ti: 0.94 * covalentRadii["Ti"],
20-
// uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
21-
I: 1.05 * covalentRadii["I"],
22-
Eu: 1.05 * covalentRadii["Eu"],
23-
};
24-
2513
function setCustomBondLengths() {
2614
function setCustomBondLength(elem, len) {
2715
// 3dmol adds 0.25 to the total bond length as a "fudge_factor"
28-
let fudgeCorrection = 0.125;
29-
$3Dmol.setBondLength(elem, len - fudgeCorrection);
16+
// to correct for this, one could here subtract 0.125 from each atom's
17+
// bond length but it seems it's better to keep the "fudge factor".
18+
$3Dmol.setBondLength(elem, len);
3019
}
31-
3220
// override the default bond lengths with covalentRadii
3321
Object.keys(covalentRadii).forEach((elem) => {
3422
setCustomBondLength(elem, covalentRadii[elem]);
3523
});
36-
37-
// override further based on custom-defined lengths
38-
Object.keys(overrideBondLengths).forEach((elem) => {
39-
setCustomBondLength(elem, overrideBondLengths[elem]);
40-
});
4124
}
4225

4326
class Visualizer3dmol extends React.Component {
@@ -93,16 +76,6 @@ class Visualizer3dmol extends React.Component {
9376

9477
let final_atoms = [];
9578

96-
// console.log("loadedAtoms", loadedAtoms);
97-
// loadedAtoms = [
98-
// {
99-
// elem: "C",
100-
// x: 0.1,
101-
// y: 0.1,
102-
// z: 50.0,
103-
// },
104-
// ];
105-
10679
// in case of packed cell, make sure all the initially specified atoms
10780
// are folded back to the unit cell
10881
let atoms = [];
@@ -198,7 +171,7 @@ class Visualizer3dmol extends React.Component {
198171
style.sphere.scale = 1.0;
199172
}
200173
if (this.props.viewerParams.bonds) {
201-
style.stick = { radius: 0.2, colorscheme: "Jmol" };
174+
style.stick = { radius: 0.15, colorscheme: "Jmol" };
202175
}
203176

204177
this.viewer.setStyle(style);

0 commit comments

Comments
 (0)