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 andvica versa.
915
1016
1117Installation
1218============
1319
14- To install the python package in development mode use
20+ The package can be installed via conda-forge::
1521
16- .. code ::
22+ conda install hsd-python
1723
18- pip install -e src
24+ Alternatively, the package can be downloaded and installed via pip into the
25+ active Python interpreter (preferably using a virtual python environment) by ::
1926
27+ pip install hsd
2028
21- The HSD format
22- ==============
29+ or into the user space issueing ::
30+
31+ pip install --user hsd
2332
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.
2733
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 ::
34+ Quick tutorial
35+ ==============
36+
37+ A typical, self-explaining input written in HSD looks like ::
3138
3239 driver {
3340 conjugate_gradients {
@@ -45,11 +52,13 @@ typical input written in HSD looks like ::
4552 }
4653 filling {
4754 fermi {
48- temperature [kelvin] = 1e-8
55+ # This is comment which will be ignored
56+ # Note the attribute (unit) of the field below
57+ temperature [kelvin] = 100
4958 }
5059 }
5160 k_points_and_weights {
52- supercell_folding = {
61+ supercell_folding {
5362 2 0 0
5463 0 2 0
5564 0 0 2
@@ -59,13 +68,56 @@ typical input written in HSD looks like ::
5968 }
6069 }
6170
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.)
71+ The above input can be parsed into a Python dictionary with::
72+
73+ import hsd
74+ hsdinput = hsd.load_file("test.hsd")
75+
76+ The dictionary ``hsdinput `` will then look as::
77+
78+ {
79+ "driver": {
80+ "conjugate_gradients" {
81+ "moved_atoms": [1, 2, "7:19"],
82+ "max_steps": 100
83+ }
84+ },
85+ "hamiltonian": {
86+ "dftb": {
87+ "scc": True,
88+ "scc_tolerance": 1e-10,
89+ "mixer": {
90+ "broyden": {}
91+ },
92+ "filling": {
93+ "fermi": {
94+ "temperature": 100,
95+ "temperature.attrib": "kelvin"
96+ }
97+ }
98+ "k_points_and_weights": {
99+ "supercell_folding": [
100+ [2, 0, 0],
101+ [0, 2, 0],
102+ [0, 0, 2],
103+ [0.5, 0.5, 0.5]
104+ ]
105+ }
106+ }
107+ }
108+ }
109+
110+ Being a simple Python dictionary, it can be easily queried and manipulated in
111+ Python ::
112+
113+ hsdinput["driver"]["conjugate_gradients"]["max_steps"] = 200
114+
115+ and then stored again in HSD format ::
116+
117+ hsd.dump_file(hsdinput, "test2.hsd")
118+
119+
120+ License
121+ ========
67122
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.)
123+ The hsd-python package is licensed under the `BSD 2-clause license <LICENSE >`_.
0 commit comments