1
- ************************************
2
- HSD — Human-friendly Structured Data
3
- ************************************
1
+ **********************************************
2
+ HSD — Make your structured data human friendly
3
+ **********************************************
4
4
5
- This Python package contains utilities to write (and soon also to read) files in
6
- the Human-friendly Structured Data (HSD) format.
5
+ Utilities to read and write files in the Human-friendly Structured Data (HSD)
6
+ format.
7
7
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.
9
15
16
+ Detailed `documentation <https://hsd-python.readthedocs.io/ >`_ can be found on
17
+ `Read the Docs <https://hsd-python.readthedocs.io/ >`_.
10
18
11
- The HSD format
12
- ==============
13
19
14
- The HSD-format is very similar to both JSON and XML, but tries to minimize the
15
- effort for humans to read and write it. It ommits special characters as much as
16
- possible but (in contrast to YAML for example) is not indentation dependent.
20
+ Installation
21
+ ============
22
+
23
+ The package can be installed via conda-forge::
24
+
25
+ conda install --channel "conda-forge" hsd-python
26
+
27
+ Alternatively, the package can be downloaded and installed via pip into the
28
+ active Python interpreter (preferably using a virtual python environment) by ::
29
+
30
+ pip install hsd
31
+
32
+ or into the user space issueing ::
17
33
18
- It was developed originally developed as the input format for a scientific
19
- simulation tool (DFTB+), but is absolutely general. A typical input written in
20
- HSD would look like ::
34
+ pip install --user hsd
35
+
36
+
37
+ Quick tutorial
38
+ ==============
39
+
40
+ A typical, self-explaining input written in HSD looks like ::
21
41
22
42
driver {
23
43
conjugate_gradients {
@@ -35,11 +55,13 @@ HSD would look like ::
35
55
}
36
56
filling {
37
57
fermi {
38
- 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
39
61
}
40
62
}
41
63
k_points_and_weights {
42
- supercell_folding = {
64
+ supercell_folding {
43
65
2 0 0
44
66
0 2 0
45
67
0 0 2
@@ -49,12 +71,56 @@ HSD would look like ::
49
71
}
50
72
}
51
73
52
- Content in HSD format can be represented as JSON. Content in JSON format can be
53
- represented as HSD, provided it satisfies a restriction for arrays: Either all
54
- elements of an array must be objects or none of them. (This allows for a clear
55
- separation of structure and data and allows for the very 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
+ ========
56
125
57
- Content in HSD format can be represented as XML (DOM-tree). Content in XML can
58
- be converted to HSD, provided it satisfies the restriction that every child has
59
- either data (text) or further children, but never both of them. (Again, this
60
- ensures the simplicity of the input format.)
126
+ The hsd-python package is licensed under the `BSD 2-clause license <LICENSE >`_.
0 commit comments