1- ************************************
2- HSD — Human-friendly Structured Data
3- ************************************
1+ **********************************************
2+ HSD — Make your structured data human friendly
3+ **********************************************
44
5- This Python package contains utilities to read and write files in
6- the Human-friendly Structured Data (HSD) format.
5+ This package contains utilities to read and write files in the Human-friendly
6+ Structured Data (HSD) format.
77
8- It is licensed under the *BSD 2-clause license *.
8+ The HSD-format is very similar to both JSON and YAML, but tries to minimize the
9+ effort for **humans ** to read and write it. It ommits special characters as much
10+ as possible (in contrast to JSON) and is not indentation dependent (in contrast
11+ to YAML). It was developed originally as the input format for the scientific
12+ simulation tool (`DFTB+ <https://github.com/dftbplus/dftbplus >`_), but is
13+ of general purpose. Data stored in HSD can be easily mapped to a subset of JSON
14+ or XML and vica versa.
15+
16+ Detailed `documentation <https://hsd-python.readthedocs.io/ >`_ can be found on
17+ `Read the Docs <https://hsd-python.readthedocs.io/ >`_.
918
1019
1120Installation
1221============
1322
14- To install the python package in development mode use
23+ The package can be installed via conda-forge::
1524
16- .. code ::
25+ conda install hsd-python
1726
18- pip install -e src
27+ Alternatively, the package can be downloaded and installed via pip into the
28+ active Python interpreter (preferably using a virtual python environment) by ::
1929
30+ pip install hsd
31+
32+ or into the user space issueing ::
33+
34+ pip install --user hsd
2035
21- The HSD format
22- ==============
2336
24- The HSD-format is very similar to both JSON and XML, but tries to minimize the
25- effort for humans to read and write it. It ommits special characters as much as
26- possible but (in contrast to YAML for example) is not indentation dependent.
37+ Quick tutorial
38+ ==============
2739
28- It was developed originally as the input format for a scientific simulation tool
29- (`DFTB+ <https://github.com/dftbplus/dftbplus >`_), but is absolutely general. A
30- typical input written in HSD looks like ::
40+ A typical, self-explaining input written in HSD looks like ::
3141
3242 driver {
3343 conjugate_gradients {
@@ -45,11 +55,13 @@ typical input written in HSD looks like ::
4555 }
4656 filling {
4757 fermi {
48- temperature [kelvin] = 1e-8
58+ # This is comment which will be ignored
59+ # Note the attribute (unit) of the field below
60+ temperature [kelvin] = 100
4961 }
5062 }
5163 k_points_and_weights {
52- supercell_folding = {
64+ supercell_folding {
5365 2 0 0
5466 0 2 0
5567 0 0 2
@@ -59,13 +71,56 @@ typical input written in HSD looks like ::
5971 }
6072 }
6173
62- Content in HSD format can be represented as JSON. Content in JSON format can
63- similarly be represented as HSD, provided it satisfies one restriction for
64- arrays: Either all elements of an array must be objects or none of them. (This
65- allows for a clear separation of structure and data and allows for the very
66- simple input format.)
74+ The above input can be parsed into a Python dictionary with::
75+
76+ import hsd
77+ hsdinput = hsd.load("test.hsd")
78+
79+ The dictionary ``hsdinput `` will then look as::
80+
81+ {
82+ "driver": {
83+ "conjugate_gradients" {
84+ "moved_atoms": [1, 2, "7:19"],
85+ "max_steps": 100
86+ }
87+ },
88+ "hamiltonian": {
89+ "dftb": {
90+ "scc": True,
91+ "scc_tolerance": 1e-10,
92+ "mixer": {
93+ "broyden": {}
94+ },
95+ "filling": {
96+ "fermi": {
97+ "temperature": 100,
98+ "temperature.attrib": "kelvin"
99+ }
100+ }
101+ "k_points_and_weights": {
102+ "supercell_folding": [
103+ [2, 0, 0],
104+ [0, 2, 0],
105+ [0, 0, 2],
106+ [0.5, 0.5, 0.5]
107+ ]
108+ }
109+ }
110+ }
111+ }
112+
113+ Being a simple Python dictionary, it can be easily queried and manipulated in
114+ Python ::
115+
116+ hsdinput["driver"]["conjugate_gradients"]["max_steps"] = 200
117+
118+ and then stored again in HSD format ::
119+
120+ hsd.dump(hsdinput, "test2.hsd")
121+
122+
123+ License
124+ ========
67125
68- Content in HSD format can be represented as XML (DOM-tree). Likewise content in
69- XML can be converted to HSD, provided it satisfies the restriction that every
70- child has either data (text) or further children, but never both of
71- them. (Again, this ensures the simplicity of the input format.)
126+ The hsd-python package is licensed under the `BSD 2-clause license <LICENSE >`_.
0 commit comments