You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Fortran library providing unified molecular structure data handling and geometry file format I/O for computational chemistry applications.
10
+
The library supports reading and writing of molecular structures in more than twelve different geometry formats and provides element data and coordination number utilities.
11
+
12
+
13
+
## Features
14
+
15
+
-**Unified structure representation**: A common [``structure_type``](https://grimme-lab.github.io/mctc-lib/type/structure_type.html) for handling molecular and periodic systems
16
+
-**Multi-format I/O**: Read and write structures in 12+ geometry formats
17
+
-**Element data**: Access to atomic/covalent/vdW radii and Pauling electronegativities
To read an input file using the IO library use the ``read_structure`` routine.
179
239
The final geometry data is stored in a ``structure_type``:
180
240
181
-
```fortran
241
+
```f90
182
242
use mctc_io
183
243
use mctc_env
184
244
type(structure_type) :: mol
@@ -197,7 +257,7 @@ Alternatively, the ``filetype`` enumerator provides the identifiers of all suppo
197
257
198
258
In a similar way the ``write_structure`` routine allows to write a ``structure_type`` to a file or unit:
199
259
200
-
```fortran
260
+
```f90
201
261
use mctc_io
202
262
use mctc_env
203
263
type(structure_type) :: mol
@@ -214,6 +274,120 @@ The [``mctc-convert``](man/mctc-convert.1.adoc) program provides a chained reade
214
274
Checkout the implementation in [``app/main.f90``](app/main.f90).
215
275
216
276
277
+
## Working with the Structure Type
278
+
279
+
The [``structure_type``](https://grimme-lab.github.io/mctc-lib/type/structure_type.html) is the central data structure for representing molecular systems:
280
+
281
+
```f90
282
+
type(structure_type) :: mol
283
+
284
+
! Basic properties
285
+
mol%nat ! Number of atoms
286
+
mol%nid ! Number of unique species
287
+
mol%charge ! Total molecular charge
288
+
mol%uhf ! Number of unpaired electrons
289
+
290
+
! Atomic data (arrays)
291
+
mol%xyz(:, :) ! Cartesian coordinates (3, nat) in Bohr
292
+
mol%id(:) ! Species index for each atom (nat)
293
+
mol%num(:) ! Atomic numbers for each species (nid)
294
+
mol%sym(:) ! Element symbols for each species (nid)
295
+
296
+
! Periodic systems
297
+
mol%lattice(:, :) ! Lattice vectors (3, 3) in Bohr
298
+
mol%periodic(:) ! Periodic directions (3)
299
+
300
+
! Optional data
301
+
mol%bond(:, :) ! Bond connectivity
302
+
mol%comment ! Structure title/comment
303
+
```
304
+
305
+
### Creating Structures Programmatically
306
+
307
+
All inputs use atomic units. Coordinates must be provided in Bohr (1 Bohr ≈ 0.529 Å).
308
+
309
+
```f90
310
+
use mctc_io
311
+
use mctc_env, only : wp
312
+
implicit none
313
+
type(structure_type) :: mol
314
+
integer :: num(3)
315
+
real(wp) :: xyz(3, 3)
316
+
317
+
! Water molecule (coordinates in Bohr)
318
+
num = [8, 1, 1] ! O, H, H
319
+
xyz = reshape([ &
320
+
& 0.0_wp, 0.0_wp, 0.2372_wp, &
321
+
& 0.0_wp, 1.4939_wp, -0.9487_wp, &
322
+
& 0.0_wp, -1.4939_wp, -0.9487_wp], [3, 3])
323
+
324
+
call new(mol, num, xyz, charge=0.0_wp, uhf=0)
325
+
```
326
+
327
+
328
+
## Using Element Data
329
+
330
+
Access element-specific properties from the [``mctc_data``](https://grimme-lab.github.io/mctc-lib/module/mctc_data.html) module:
331
+
332
+
```f90
333
+
use mctc_data
334
+
use mctc_env, only : wp
335
+
implicit none
336
+
real(wp) :: radius
337
+
338
+
! Get covalent radius for carbon (atomic number 6)
Chemical JSON files are identified by the extension ``cjson`` or ``json`` and parsed following the format implemented in Avogadro 2.
10
-
The entries *name*, *atoms.elements.number*, *atoms.coords.3d*, *atoms.coords.3d fractional*, *unit cell*, *atoms.formalCharges*, *bonds.connections.index*, and *bonds.order* are recognized by the reader.
21
+
Chemical JSON is a JSON-based format developed for Avogadro 2.
22
+
It provides a structured way to represent molecular data including geometry, bonds, and properties.
0 commit comments