diff --git a/Makefile b/Makefile index d2af1bbc..d90121f6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ -default: +default: data hugo -serve: +serve: data hugo -D server clean: rm -rf public + +data: + python3 tools/generate_data.py diff --git a/README.md b/README.md index da5a79ca..6a76d654 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ ## Introduction The QUEST website has been designed to gather and analyze the highly-accurate vertical excitation energies produced by the [QUEST project](https://doi.org/10.1021/acs.jpclett.0c00014). -The QUEST database contains more than 470 accurate vertical excitation energies of various natures ($\pi \to \pis$, $n \to \pis$, double excitation, Rydberg, singlet, doublet, triplet, etc) for small- and medium-sized molecules. +The QUEST database contains more than 470 accurate vertical excitation energies of various natures ($\pi \to \pi^{*}$, $n \to \pi^{*}$, double excitation, Rydberg, singlet, doublet, triplet, etc) for small- and medium-sized molecules. These values have been obtained using a combination of high-order coupled cluster and selected configuration interaction calculations using increasingly large diffuse basis sets. One of the key aspect of the QUEST dataset is that it does not rely on any experimental values, avoiding potential biases inherently linked to experiments and facilitating in the process theoretical cross comparisons. -Following this composite protocol, we have been able to produce theoretical best estimate (TBEs) with the aug-cc-pVTZ basis set, as well as basis set corrected TBEs (i.e., near the complete basis set limit) for each of these transitions. +Following this composite protocol, we have been able to produce theoretical best estimates (TBEs) with the aug-cc-pVTZ basis set, as well as basis set corrected TBEs (i.e., near the complete basis set limit) for each of these transitions. Thanks to the present website, one can easily test and compare the accuracy of a given method with respect to various variables such as the molecule size or its family, the nature of the excited states, the size of the basis set, etc. ## Quick start @@ -19,13 +19,13 @@ cd QUESTDB_website hugo serve ``` -Now you car use your favorite browser to navigate to the website using the URL showed by Hugo in your terminal (normally ) +Now you can use your favorite browser to navigate to the website using the URL showed by Hugo in your terminal (normally http://localhost:1313) ## Repository content ### The website -The main part of this repository is the website. It is build using the [hugo](https://gohugo.io/) static website generator with the [beautifulhugo](https://themes.gohugo.io/beautifulhugo/) theme. +The main part of this repository is the website. It is built using the [hugo](https://gohugo.io/) static website generator with the [beautifulhugo](https://themes.gohugo.io/beautifulhugo/) theme. All the data are stored in the [data](static/data) directory. @@ -44,5 +44,5 @@ So you can remove a data file to regenerate it from a LaTeX input file with `dat #### ADC25generator -The `ADC25generator` is used to build `ADC(2.5)` data files from `ADC(2)` and `ADC(3)` data files +The `ADC25generator` is used to build `ADC(2.5)` data files from `ADC(2)` and `ADC(3)` data files. diff --git a/static/js/data.js b/static/js/data.js index 910cc579..f711d035 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -232,7 +232,8 @@ class dataFileBase { return /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/; } async getGeometryAsync(state = null) { - var text = await getTextFromFileUrlAsync(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`) + // var text = await getTextFromFileUrlAsync(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`) + var text = getTextFromFileUrl(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`) var lines = text.split("\n") var indexes = lines.findAllIndexes((line) => { return line.match(/^\d+$/) @@ -279,7 +280,8 @@ class dataFileBase { case String.name: file = getFullDataPath(file) const maxAge= (DebugMode.Enabled,0,600) - var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) + // var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) + var str = await getTextFromFileUrl(file) break; case File.name: var str = await getTextFromUploadedFileAsync(file) @@ -413,4 +415,4 @@ class VertDataFile extends dataFileBase { ex.VertExcitationKind = kind return ex } -} \ No newline at end of file +} diff --git a/static/js/getTextFromFile.js b/static/js/getTextFromFile.js index a2da778b..447d7148 100644 --- a/static/js/getTextFromFile.js +++ b/static/js/getTextFromFile.js @@ -1,3 +1,18 @@ +var fileCache = function () { + var json_url = "/data/database.json"; + var req = new XMLHttpRequest(); + req.open("GET",json_url, false); + req.send(); + return JSON.parse(req.responseText); +} + + +_cache = fileCache(); +function getTextFromFileUrl(url,header={}) { + return _cache[url]; +} + + async function getTextFromFileUrlAsync(url,header={}) { return new Promise(function (resolve, reject) { var req = new XMLHttpRequest(); @@ -21,7 +36,6 @@ async function getTextFromFileUrlAsync(url,header={}) { req.send(); }); } - async function getTextFromUploadedFileAsync(inputFile){ const temporaryFileReader = new FileReader(); @@ -36,4 +50,4 @@ async function getTextFromUploadedFileAsync(inputFile){ }; temporaryFileReader.readAsText(inputFile); }); -}; \ No newline at end of file +}; diff --git a/tools/generate_data.py b/tools/generate_data.py new file mode 100755 index 00000000..cd29320e --- /dev/null +++ b/tools/generate_data.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import os +import os.path +import json + + +def main(): + + d = {} + os.chdir("static") + try: + os.remove(os.path.join("data","database.json")) + except FileNotFoundError: + pass + for root, dirs, files in os.walk('data'): + for name in files: + filename = os.path.join(root,name) + with open(filename,'r',encoding="utf8") as f: + try: + d["/"+filename] = f.read() + except UnicodeDecodeError: + pass + + with open(os.path.join("data","database.json"),'w') as f: + f.write(json.dumps(d,indent=1)) + + +if __name__ == "__main__": + main()