|
2 | 2 |
|
3 | 3 | # AtomsBase.jl
|
4 | 4 |
|
5 |
| -Cclib.jl allows loading atom information into [AtomsBase.jl](https://github.com/JuliaMolSim/AtomsBase.jl) objects using `get_atom_objects` function: |
| 5 | +Cclib.jl provides interoperability with [AtomsBase.jl](https://github.com/JuliaMolSim/AtomsBase.jl) by allowing to create AtomsBase systems. |
| 6 | + |
| 7 | +The documentaiton below provides some essential functionality, such as creating and editing AtomsBase.jl systems. |
| 8 | + |
| 9 | +For a detailed overview, or if you want to know how AtomsBase.jl operates behind the scenes, refer to its official documentation. |
| 10 | + |
| 11 | +## Creating AtomsBase Systems |
| 12 | +We can load information contained in a Cclib.jl-supported file into a system by using the following functions: |
| 13 | +- `make_flexible_system` - for creating an AtomsBase `FlexibleSystem` |
6 | 14 |
|
7 | 15 | ```Julia
|
8 | 16 | # Input file can be found in the in the repo under "test" folder
|
9 | 17 | julia> using Cclib
|
| 18 | +julia> using Unitful |
| 19 | +julia> using AtomsBase |
| 20 | +julia> box = [[3.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]]u"Å" |
| 21 | +julia> boundary_conditions = [Periodic(), Periodic(), Periodic()] |
| 22 | +julia> system = make_flexible_system("./water_mp2.out", box, boundary_conditions) |
| 23 | + |
| 24 | +FlexibleSystem(H₂O, periodic = TTT): |
| 25 | + bounding_box : [ 3 0 0; |
| 26 | + 0 3 0; |
| 27 | + 0 0 3]u"Å" |
| 28 | + |
| 29 | + Atom(O, [ 0, 0, -0.0666785]u"Å") |
| 30 | + Atom(H, [ 0, -0.790649, 0.529118]u"Å") |
| 31 | + Atom(H, [ 0, 0.790649, 0.529118]u"Å") |
| 32 | + |
| 33 | + .------. |
| 34 | + /| | |
| 35 | + O | | |
| 36 | + | | | |
| 37 | + |H.------. |
| 38 | + |H / |
| 39 | + *------* |
| 40 | + |
| 41 | +``` |
| 42 | + |
| 43 | +- `make_isolated_system` - for creating an AtomsBase `isolated_system` |
| 44 | + |
| 45 | +```Julia |
| 46 | +julia> using Cclib |
| 47 | +julia> system = make_isolated_system("./water_mp2.out") |
| 48 | + |
| 49 | +FlexibleSystem(H₂O, infinite): |
| 50 | + Atom(O, [ 0, 0, -0.0666785]u"Å") |
| 51 | + Atom(H, [ 0, -0.790649, 0.529118]u"Å") |
| 52 | + Atom(H, [ 0, 0.790649, 0.529118]u"Å") |
| 53 | +``` |
| 54 | + |
| 55 | +- `get_atom_objects` - for getting an array of AtomsBase `Atom` objects in case you need more control. |
| 56 | + |
| 57 | +```Julia |
| 58 | +julia> using Cclib |
10 | 59 | julia> using AtomsBase
|
11 |
| -julia> mol = ccread("./Trp_polar.fchk") |
| 60 | +julia> mol = ccread("./water_mp2.out") |
12 | 61 | julia> atoms = get_atom_objects(mol)
|
13 | 62 | julia> atoms[1]
|
14 | 63 |
|
15 |
| -Atom(N, atomic_number = 7, atomic_mass = 14.007 u): |
16 |
| - position : [-0.069982688,0.33219872,0.28212832]u"Å" |
| 64 | +Atom(O, atomic_number = 8, atomic_mass = 15.999 u): |
| 65 | + position : [0,0,-0.066678532]u"Å" |
17 | 66 | ```
|
18 |
| - |
19 |
| -Like before, all the stored information for each atom is still accessible: |
| 67 | +## Accessing System Properties |
| 68 | +In case we need to look at what our system contains, we can use regular `keys` to see available system-level properties and `atomkeys` to see available atom-level properties |
20 | 69 |
|
21 | 70 | ```Julia
|
22 |
| -julia> keys(atoms[1]) |
| 71 | +julia> using Cclib |
| 72 | +julia> using AtomsBase |
| 73 | +julia> system = make_isolated_system("./water_mp2.out") |
| 74 | + |
| 75 | +julia> keys(system) |
| 76 | +(:bounding_box, :boundary_conditions) |
| 77 | + |
| 78 | +julia> atomkeys(system) |
23 | 79 | (:position, :velocity, :atomic_symbol, :atomic_number, :atomic_mass)
|
| 80 | + |
| 81 | +julia> bounding_box(system) |
| 82 | + [Inf a₀, 0.0 a₀, 0.0 a₀] |
| 83 | + [0.0 a₀, Inf a₀, 0.0 a₀] |
| 84 | + [0.0 a₀, 0.0 a₀, Inf a₀ |
| 85 | + |
| 86 | + julia> atomic_symbol(system) |
| 87 | + 3-element Vector{Symbol}: |
| 88 | + :O |
| 89 | + :H |
| 90 | + :H |
24 | 91 | ```
|
| 92 | +
|
| 93 | +## Updating and/or adding system properties |
| 94 | +We can also update and/or add system properties by using `update_system` function that accepts keywords arguments. Below is an example of adding data that was parsed using `ccread` to a system. |
| 95 | +```Julia |
| 96 | +julia> using Cclib |
| 97 | +julia> mol = ccread("./water_mp2.out") |
| 98 | +julia> system = make_isolated_system(mol); |
| 99 | +julia> system = update_system(system; nbasis=mol["nbasis"]) |
| 100 | +julia> system[:nbasis] |
| 101 | +7 |
| 102 | +``` |
| 103 | +
|
25 | 104 | # AtomsBase.jl-supported libraries
|
26 | 105 |
|
27 |
| -We can use data loaded with Cclib.jl to perform calculations using other libraries that use AtomsBase.jl, such as [InteratomicPotentials.jl](https://github.com/cesmix-mit/InteratomicPotentials.jl) |
| 106 | +We can use data loaded with Cclib.jl to perform calculations using other libraries that use AtomsBase.jl, such as [InteratomicPotentials.jl](https://github.com/cesmix-mit/InteratomicPotentials.jl) or [DFTK.jl](https://github.com/JuliaMolSim/DFTK.jl). |
28 | 107 |
|
29 |
| -First, we load the data and define the system: |
| 108 | +Let's first load some dependencies and make a system |
30 | 109 | ```Julia
|
31 | 110 | julia> using Cclib
|
32 | 111 | julia> using AtomsBase
|
33 | 112 | julia> using Unitful
|
34 | 113 | julia> using UnitfulAtomic
|
35 | 114 | julia> using InteratomicPotentials
|
| 115 | +julia> using DFTK |
36 | 116 |
|
37 |
| -julia> atoms = get_atom_objects("./Trp_polar.fchk") |
38 |
| -julia> boundaryconditions = [Periodic(), Periodic(), Periodic()] |
39 |
| -julia> box = [[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]u"Å" |
40 |
| -julia> system = FlexibleSystem(atoms, box, boundaryconditions) |
41 |
| - |
42 |
| -FlexibleSystem(C₁₁H₁₂N₂O₂, periodic = TTT): |
43 |
| - bounding_box : [ 10 0 0; |
44 |
| - 0 10 0; |
45 |
| - 0 0 10]u"Å" |
46 |
| - |
47 |
| - .------------------------. |
48 |
| - /| H | |
49 |
| - / | | |
50 |
| - / | | |
51 |
| - / | H C C H | |
52 |
| - / H | |
53 |
| - * C C C C H C H | |
54 |
| - | H | C HN H | |
55 |
| - | | | |
56 |
| - | | C C | |
57 |
| - | | C | |
58 |
| - | | O | |
59 |
| - | .----------------------H-. |
60 |
| - | / / |
61 |
| - | / / |
62 |
| - | H/O / |
63 |
| - | / H / |
64 |
| - |/ N/ |
65 |
| - *------------------------* |
| 117 | +julia> box = [[3.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]]u"Å" |
| 118 | +julia> boundary_conditions = [Periodic(), Periodic(), Periodic()] |
| 119 | +julia> system = make_flexible_system("./water_mp2.out", box, boundary_conditions); |
66 | 120 | ```
|
| 121 | +
|
67 | 122 | We can now perform calculate various properties of the system:
|
| 123 | +- using `InteratomicPotentials.jl` |
68 | 124 | ```Julia
|
69 | 125 | julia> ϵ = 1.0 * 1u"eV"
|
70 | 126 | julia> σ = 0.25 * 1u"Å"
|
71 | 127 | julia> rcutoff = 2.25 * 1u"Å"
|
72 | 128 | julia> lj = LennardJones(ϵ, σ, rcutoff, [:N, :C, :O, :H])
|
73 |
| -julia> potential_energy(system, lj). |
74 |
| --0.00039418327614247183 Eₕ |
| 129 | +julia> potential_energy(system, lj) |
| 130 | +-8.061904291397444e-5 Eₕ |
75 | 131 | ```
|
76 |
| -Refer to InteratomicPotentials.jl documentation for more details. |
| 132 | +
|
| 133 | +- using `DFTK.jl` |
| 134 | +```Julia |
| 135 | +model = model_LDA(system; temperature=1e-3) |
| 136 | +basis = PlaneWaveBasis(model; Ecut=15, kgrid=(3, 3, 3)) |
| 137 | +self_consistent_field(basis); |
| 138 | +n Energy log10(ΔE) log10(Δρ) Diag Δtime |
| 139 | +--- --------------- --------- --------- ---- ------ |
| 140 | + 1 -38.18166038243 0.81 5.2 |
| 141 | + 2 -45.38103756530 0.86 0.12 3.0 253ms |
| 142 | + 3 -45.54220597356 -0.79 -0.74 3.0 273ms |
| 143 | + 4 -45.55809718591 -1.80 -1.40 2.1 172ms |
| 144 | + 5 -45.55889514812 -3.10 -2.14 1.0 159ms |
| 145 | + 6 -45.55892123307 -4.58 -2.63 1.4 158ms |
| 146 | + 7 -45.55892315420 -5.72 -3.26 1.8 211ms |
| 147 | + 8 -45.55892314370 + -7.98 -3.57 1.2 113ms |
| 148 | + 9 -45.55892319258 -7.31 -3.92 2.0 189ms |
| 149 | + 10 -45.55892320440 -7.93 -4.94 1.1 142ms |
| 150 | + 11 -45.55892320464 -9.63 -4.96 2.0 185ms |
| 151 | + 12 -45.55892320468 -10.33 -5.44 1.0 134ms |
| 152 | + 13 -45.55892320469 -11.36 -6.15 2.0 158ms |
| 153 | +``` |
| 154 | +
|
| 155 | +For a full list of tools that support AtomsBase.jl, refer to its [official |
| 156 | +documentation](https://github.com/JuliaMolSim/AtomsBase.jl). |
77 | 157 |
|
78 | 158 | # Fermi.jl
|
79 | 159 |
|
|
0 commit comments