Skip to content

Commit cd16ffa

Browse files
authored
Run index example automatically (#25)
1 parent 09913fb commit cd16ffa

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ julia = "1.10"
3838
[extras]
3939
ASEconvert = "3da9722f-58c2-4165-81be-b4d7253e8fd2"
4040
AtomsBuilder = "f5cc8831-eeb7-4288-8d9f-d6c1ddb77004"
41+
EmpiricalPotentials = "38527215-9240-4c91-a638-d4250620c9e2"
4142
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
4243
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4344
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
4445

4546
[targets]
46-
test = ["ASEconvert", "AtomsBuilder", "PythonCall", "Test", "TestItemRunner"]
47+
test = ["ASEconvert", "AtomsBuilder", "EmpiricalPotentials", "PythonCall", "Test", "TestItemRunner"]

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMolSim.github.io/GeometryOptimization.jl/stable/)
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaMolSim.github.io/GeometryOptimization.jl/dev/)
55
[![Build Status](https://github.com/JuliaMolSim/GeometryOptimization.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaMolSim/GeometryOptimization.jl/actions/workflows/CI.yml?query=branch%3Amain)
6-
[![Coverage](https://codecov.io/gh/JuliaMolSim/GeometryOptimization.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaMolSim/GeometryOptimization.jl)
6+
[![Coverage](https://codecov.io/gh/JuliaMolSim/GeometryOptimization.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaMolSim/GeometryOptimization.jl)
77

88
A package for optimising the structural parameters of an atomistic system,
99
i.e. the step usually referred to as
@@ -29,22 +29,24 @@ molecule using a simple Lennard Jones potential:
2929
using AtomsBase
3030
using EmpiricalPotentials
3131
using GeometryOptimization
32+
using LinearAlgebra
3233
using Unitful
3334
using UnitfulAtomic
3435

3536
# Setup system and calculator
36-
system = isolated_system([:H => [0, 0, 0.0]u"bohr",
37-
:H => [0, 0, 1.9]u"bohr"])
38-
37+
cell_vectors = ([10.0, 0.0, 0.0]u"Å", [0.0, 10.0, 0.0]u"Å", [0.0, 0.0, 10.0]u"Å")
38+
system = periodic_system([:H => [0, 0, 0.0]u"bohr",
39+
:H => [0, 0, 1.9]u"bohr"],
40+
cell_vectors)
3941
zH = 1
4042
emins = Dict((zH, zH) => -1.17u"hartree", )
41-
rmins = Dict((zH, zH) => 0.743u"Å", )
43+
rmins = Dict((zH, zH) => 0.743u"Å", )
4244
calc = LennardJones(emins, rmins, 5.0u"Å")
4345

4446
# Run the geometry optimisation
4547
results = minimize_energy!(system, calc)
4648

4749
# Inspect the results
48-
optimised = results.system
49-
bondlength = norm(position(optimised[1]) - position(optimised[2]))
50+
optsystem = results.system
51+
optimised_bondlength = norm(position(optsystem[1]) - position(optsystem[2]))
5052
```

docs/src/examples/tial_lj.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using AtomsIO
88
using EmpiricalPotentials
99
1010
system = load_system(joinpath(pkgdir(EmpiricalPotentials), "data/TiAl-1024.xyz"))
11-
nothing
11+
nothing # hide
1212
```
1313

1414
Setup calculator:
@@ -28,7 +28,7 @@ rmins = Dict( (zAl, zAl) => 2.7u"Å",
2828
(zAl, zTi) => 3.2u"Å",
2929
(zTi, zTi) => 3.0u"Å" )
3030
calc = LennardJones(emins, rmins, rcut)
31-
nothing
31+
nothing # hide
3232
```
3333

3434
Minimise energy:
@@ -37,7 +37,7 @@ using GeometryOptimization
3737
GO = GeometryOptimization
3838
3939
results = minimize_energy!(system, calc, GO.OptimCG(); maxiters=10, verbosity=1)
40-
results.energy
40+
nothing # hide
4141
```
4242

4343
Final structure:

docs/src/index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,31 @@ The source code can be found [on github](https://github.com/JuliaMolSim/Geometry
1414
We consider the optimisation of the bondlength of a hydrogen
1515
molecule using a simple Lennard Jones potential:
1616

17-
```julia
18-
## TODO: Should run as @example once EmpiricalPotentials is compatible
17+
```@example
1918
using AtomsBase
2019
using EmpiricalPotentials
2120
using GeometryOptimization
21+
using LinearAlgebra
2222
using Unitful
2323
using UnitfulAtomic
2424
2525
# Setup system and calculator
26-
system = isolated_system([:H => [0, 0, 0.0]u"bohr",
27-
:H => [0, 0, 1.9]u"bohr"])
26+
cell_vectors = ([10.0, 0.0, 0.0]u"Å", [0.0, 10.0, 0.0]u"Å", [0.0, 0.0, 10.0]u"Å")
27+
system = periodic_system([:H => [0, 0, 0.0]u"bohr",
28+
:H => [0, 0, 1.9]u"bohr"],
29+
cell_vectors)
2830
zH = 1
2931
emins = Dict((zH, zH) => -1.17u"hartree", )
30-
rmins = Dict((zH, zH) => 0.743u"Å", )
32+
rmins = Dict((zH, zH) => 0.743u"Å", )
3133
calc = LennardJones(emins, rmins, 5.0u"Å")
3234
3335
# Run the geometry optimisation (using verbosity=1 to print the progress)
3436
results = minimize_energy!(system, calc; verbosity=1)
3537
3638
# Inspect the results
37-
optimised_system = results.system
39+
optsystem = results.system
3840
optimised_bondlength = norm(position(optsystem[1]) - position(optsystem[2]))
41+
nothing # hide
3942
```
4043

4144
The idea is that

0 commit comments

Comments
 (0)