Skip to content

Commit caf8177

Browse files
Merge pull request #50 from kirstenwinther/master
Show additional calc info and improve loading speed
2 parents 3ee540f + 086233d commit caf8177

File tree

9 files changed

+118
-166
lines changed

9 files changed

+118
-166
lines changed

app/components/About/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@ class About extends React.Component { // eslint-disable-line react/prefer-statel
4747

4848
<Paper className={this.props.classes.paper}>
4949
<h2>License</h2>
50-
<img src={ccLogoBig} alt="ccLogoBig" />
5150
<div className={this.props.classes.text}>
5251
Except where otherwise noted, content on Catalysis-Hub is licensed under a
5352
{' '}
5453
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>
5554
.
5655
</div>
56+
<img src={ccLogoBig} alt="ccLogoBig" />
5757
</Paper>
5858

5959
<Paper className={this.props.classes.paper}>
60-
<h2>People</h2>
60+
<h2>People and Contact</h2>
61+
<div>The platform is developed at the SUNCAT Center for Interface Science and Catalysis, SLAC National Accelerator Laboratory, Stanford University. Contact information for the primary people involved is provided below. For technical support please contact postdoc Kirsten Winther at winther@stanford.edu.</div>
6162
<ul className={this.props.classes.peopleList}>
6263
{Object.keys(people).map((name, i) => (
6364
<li key={`person_${i}`}>

app/components/Apps/filteredApps.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ class FilteredApps extends React.Component { // eslint-disable-line react/prefer
4444
elevation={0}
4545
>
4646
<Tooltip title={app.tooltip} placement="top">
47-
<h3>
48-
{getAppIcon(app.title)}
49-
{'\u00A0'}{app.title}</h3>
47+
{(app.title === 'Activity Maps' || app.title === 'Scaling Relations' || app.title === 'Pourbaix Diagrams') ?
48+
<h3>
49+
{getAppIcon(app.title)}
50+
{'\u00A0'}{app.title}{' (Beta) '}
51+
</h3>
52+
:
53+
<h3>
54+
{getAppIcon(app.title)}
55+
{'\u00A0'}{app.title}
56+
</h3>
57+
}
5058
</Tooltip>
5159
<div className={this.props.classes.appHint}>{app.tooltip} <MdChevronRight /></div>
5260
</Paper>

app/components/Publications/index.js

Lines changed: 34 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -82,115 +82,48 @@ class Publications extends React.Component { // eslint-disable-line react/prefer
8282
this.clickPublication = this.clickPublication.bind(this);
8383
this.loadPreviewCif = this.loadPreviewCif.bind(this);
8484
this.backToList = this.backToList.bind(this);
85-
86-
if (_.get(props, 'routeParams.pubId', '') !== '') {
87-
const publicationQuery = {
88-
ttl: 300,
89-
query: `{publications(pubId: "${this.state.pubId}") {
90-
edges {
91-
node {
92-
id
93-
pubId
94-
title
95-
authors
96-
pages
97-
volume
98-
journal
99-
doi
100-
pubtextsearch
101-
}
102-
}
103-
}}` };
104-
105-
axios(newGraphQLRoot,
106-
{
107-
method: 'post',
108-
data: publicationQuery,
109-
}).then((response) => {
110-
this.setState({
111-
reference: _.get(response,
112-
'data.data.publications.edges[0].node',
113-
{}),
114-
});
115-
});
116-
}
11785
}
11886
componentDidMount() {
119-
const mtimeQuery = `{systems(first:50, keyValuePairs: "~", jsonkey: "pub_id", distinct: true) {
120-
totalCount
121-
edges {
122-
node {
123-
keyValuePairs
124-
mtime
125-
}
126-
}
127-
}}`;
87+
const yearQuery = '{publications { edges { node { year } } }}';
12888
axios.post(newGraphQLRoot, {
129-
query: mtimeQuery,
89+
query: yearQuery,
13090
})
131-
.then((mtimeResponse) => {
132-
const mtimes = mtimeResponse.data.data.systems.edges.map((n) => (n.node.mtime));
133-
const sortedMtimes = mtimes.slice().sort((a, b) => b - a);
134-
const systemPubIds = mtimeResponse.data.data.systems.edges.map((n) => (JSON.parse(n.node.keyValuePairs).pub_id));
135-
let orderedPubIds = sortedMtimes.map((sortedMtime) => systemPubIds[mtimes.indexOf(sortedMtime)]);
136-
orderedPubIds = Array.from(new Set(orderedPubIds));
137-
const yearQuery = '{publications { edges { node { year } } }}';
138-
axios.post(newGraphQLRoot, {
139-
query: yearQuery,
140-
})
141-
.then((response) => {
142-
let years = response.data.data.publications.edges.map((n) => n.node.year);
143-
years = [...new Set(years)].sort().reverse().filter((x) => x !== null);
144-
this.setState({
145-
years,
146-
});
147-
years.map((year) => {
148-
const query = `{publications (year: ${year}) { edges { node { doi title year authors journal pages pubId pubtextsearch } } }}`;
149-
return axios.post(newGraphQLRoot, {
150-
query,
151-
})
152-
.then((yearResponse) => {
153-
let references = yearResponse.data.data.publications.edges
91+
.then((response) => {
92+
let years = response.data.data.publications.edges.map((n) => n.node.year);
93+
years = [...new Set(years)].sort().reverse().filter((x) => x !== null);
94+
this.setState({
95+
years,
96+
});
97+
years.map((year) => {
98+
const query = `{publications (year: ${year}, order: "-stime") { edges { node { doi title year authors journal volume number pages pubId pubtextsearch } } }}`;
99+
return axios.post(newGraphQLRoot, {
100+
query,
101+
})
102+
.then((yearResponse) => {
103+
let references = yearResponse.data.data.publications.edges
154104
.map((n) => (n.node));
155-
references = [...new Set(references)];
156-
const dois = yearResponse.data.data.publications.edges.map((n) => (n.node.doi));
157-
const titles = yearResponse.data.data.publications.edges.map((n) => (n.node.title));
158-
const pubIds = yearResponse.data.data.publications.edges.map((n) => (n.node.pubId));
159-
const pubIndices = [];
160-
orderedPubIds.map((orderedPubId) => {
161-
if (pubIds.includes(orderedPubId)) {
162-
pubIndices.push(pubIds.indexOf(orderedPubId));
163-
}
164-
return pubIndices;
165-
});
166-
pubIds.map((pubId, index) => {
167-
if (!orderedPubIds.includes(pubId)) {
168-
pubIndices.push(index);
169-
}
170-
return pubIndices;
171-
});
172-
const allReferences = this.state.references;
173-
const allDois = this.state.dois;
174-
const allTitles = this.state.titles;
175-
const allPubIds = this.state.pubIds;
105+
references = [...new Set(references)];
106+
const dois = yearResponse.data.data.publications.edges.map((n) => (n.node.doi));
107+
const titles = yearResponse.data.data.publications.edges.map((n) => (n.node.title));
176108

177-
allReferences[year] = pubIndices.map((p) => references[p]);
178-
allDois[year] = pubIndices.map((p) => dois[p]);
179-
allTitles[year] = pubIndices.map((p) => titles[p]);
180-
allPubIds[year] = pubIndices.map((p) => pubIds[p]);
109+
const allReferences = this.state.references;
110+
const allDois = this.state.dois;
111+
const allTitles = this.state.titles;
181112

182-
this.setState({
183-
references: allReferences,
184-
dois: allDois,
185-
titles: allTitles,
186-
});
187-
})
188-
.catch(() => {
189-
})
190-
;
191-
});
113+
allReferences[year] = references;
114+
allDois[year] = dois;
115+
allTitles[year] = titles;
116+
117+
this.setState({
118+
references: allReferences,
119+
dois: allDois,
120+
titles: allTitles,
121+
});
122+
})
123+
.catch(() => {
124+
});
192125
});
193-
});
126+
});
194127
}
195128
backToList() {
196129
this.setState({
@@ -391,7 +324,6 @@ totalCount
391324
if (!notFound.every((x) => x)) {
392325
return null;
393326
}
394-
395327
if (this.state.titles[year][j] !== null) {
396328
return (
397329

app/components/SingleStructureView/index.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from 'utils/functions';
1818

1919
import GeometryCanvasWithOptions from 'components/GeometryCanvasWithOptions';
20+
import GraphQlbutton from 'components/GraphQlbutton';
2021

2122
const initialState = {
2223
Formula: '',
@@ -39,10 +40,31 @@ class SingleStructureView extends React.Component { // eslint-disable-line react
3940
constructor(props) {
4041
super(props);
4142
this.state = initialState;
43+
this.state.printquery = `query{systems( uniqueId: "${this.props.selectedSystem.aseId}" ) {
44+
edges {
45+
node {
46+
Formula
47+
energy
48+
numbers
49+
initialMagmoms
50+
magmoms
51+
magmom
52+
charges
53+
momenta
54+
calculator
55+
keyValuePairs
56+
calculatorParameters
57+
publication {
58+
title
59+
authors
60+
doi
61+
}
62+
}
63+
}
64+
}}`;
4265
}
4366
render() {
4467
const energy = this.props.selectedSystem.energy || this.state.energy || 0.0;
45-
4668
let x;
4769
let y;
4870
let z;
@@ -72,11 +94,11 @@ class SingleStructureView extends React.Component { // eslint-disable-line react
7294
<ul style={{ width: '50%' }}>
7395
<li>Formula: {this.props.selectedSystem.Formula}</li>
7496
<li>DFT Total Energy: {energy.toFixed(2)} eV</li>
97+
{this.props.selectedSystem.energyCorrection !== 0 &&
98+
<li> Energy correction: {this.props.selectedSystem.energyCorrection}</li>
99+
}
75100
<li>DFT Code: {this.props.selectedSystem.DFTCode}</li>
76101
<li>DFT Functional: {this.props.selectedSystem.DFTFunctional}</li>
77-
{_.isEmpty(this.props.selectedSystem.calculatorParameters) ? null :
78-
<li> DFT parameters: {this.props.selectedSystem.calculatorParameters}</li>
79-
}
80102
<li>Publication: {prettyPrintReference(this.props.selectedPublication)}</li>
81103
<div>
82104
{_.isEmpty(this.props.selectedPublication.doi) ? null :
@@ -98,6 +120,9 @@ class SingleStructureView extends React.Component { // eslint-disable-line react
98120
View all reactions in dataset
99121
</a>
100122
</li>
123+
<li>
124+
Open <GraphQlbutton query={this.state.printquery} newSchema /> to view calculational details.
125+
</li>
101126
</ul>
102127
</div>
103128
}

app/containers/EnergiesPage/Input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class EnergiesPageInput extends React.Component { // eslint-disable-line react/p
191191
chemicalComposition
192192
reactionSystems {
193193
name
194+
energyCorrection
194195
aseId
195196
}
196197
}
@@ -273,7 +274,7 @@ class EnergiesPageInput extends React.Component { // eslint-disable-line react/p
273274
<div> A quick guide: </div>
274275
<ul>
275276
<li> Leave fields blank if you {"don't"} want to impose any restrictions. </li>
276-
<li> For the <b>Reactants</b> and <b>Product</b> fields, choose the chemical species taking part in the left- and/or right hand side of the chemical reaction respectively. The phase of the molecules and elements can also be specified, such that {"'CO2gas'"} refers to CO<sub>2</sub> in the gas phase, whereas {"'CO2*'"} refers to CO<sub>2</sub> adsorbed on the surface. </li>
277+
<li> For the <b>Reactants</b> and <b>Products</b> fields, choose the chemical species taking part in the left- and/or right hand side of the chemical reaction respectively. The phase of the molecules and elements can also be specified, such that {"'CO2gas'"} refers to CO<sub>2</sub> in the gas phase, whereas {"'CO2*'"} refers to CO<sub>2</sub> adsorbed on the surface. </li>
277278
<li> In the <b>Surface</b> field, enter the (reduced) chemical composition of the surface, or a sum of elements that must be present, such as {"'Ag+'"} or {"'Ag+Sr'"}. </li>
278279
</ul>
279280
</div>

app/containers/EnergiesPage/MatchingReactions.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p
129129
loading: true,
130130
});
131131
this.props.saveLoading(true);
132-
let catappIds;
133-
let catappNames;
132+
let cathubIds;
133+
let cathubNames;
134+
let catenergyCorrections;
134135
if (typeof reaction.reactionSystems !== 'undefined' && reaction.reactionSystems !== null) {
135-
catappIds = (reaction.reactionSystems.map((x) => x.aseId));
136-
catappNames = (reaction.reactionSystems.map((x) => x.name));
136+
cathubIds = (reaction.reactionSystems.map((x) => x.aseId));
137+
cathubNames = (reaction.reactionSystems.map((x) => x.name));
138+
catenergyCorrections = (reaction.reactionSystems.map((x) => x.energyCorrection));
137139
} else {
138-
catappIds = {};
140+
cathubIds = {};
139141
snackbarActions.open('Scroll down for detailed structure.');
140142
}
141143

@@ -160,9 +162,10 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p
160162
});
161163

162164
this.props.clearSystems();
163-
catappIds.map((key, index) => {
165+
cathubIds.map((key, index) => {
164166
let aseId = key;
165-
const name = catappNames[index];
167+
const name = cathubNames[index];
168+
const energyCorrection = catenergyCorrections[index];
166169
if (typeof aseId === 'object') {
167170
aseId = aseId[1];
168171
}
@@ -189,6 +192,7 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p
189192
node.Facet = reaction.facet;
190193
node.publication = this.props.publication;
191194
node.aseId = aseId;
195+
node.energyCorrection = energyCorrection;
192196
node.key = name;
193197
node.full_key = node.Formula;
194198
const ads = name.replace('star', ' @');

0 commit comments

Comments
 (0)