Skip to content

Commit

Permalink
Update documentation for changes in NQCBase#11 (#351)
Browse files Browse the repository at this point in the history
* Update documentation for changes in NQCBase#11

* Version bump. Compat bump for NQCModels.jl

* Replaced PyCall with PythonCall in CI test

* Forgot to switch Project.toml to PythonCall
  • Loading branch information
Alexsp32 authored Aug 16, 2024
1 parent 2fa4709 commit d853f7f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 21 deletions.
24 changes: 20 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NQCDynamics"
uuid = "36248dfb-79eb-4f4d-ab9c-e29ea5f33e14"
authors = ["James <james.gardner1421@gmail.com>"]
version = "0.13.7"
version = "0.14.0"

[deps]
AdvancedHMC = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d"
Expand Down Expand Up @@ -62,7 +62,7 @@ MKL_jll = "2023"
MuladdMacro = "0.2"
NQCBase = "0.2"
NQCDistributions = "0.1"
NQCModels = "0.8"
NQCModels = "0.9"
Optim = "1"
OrdinaryDiffEq = "5, 6"
Parameters = "0.12"
Expand Down Expand Up @@ -99,11 +99,27 @@ JuLIP = "945c410c-986d-556a-acb1-167a618e0462"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "SafeTestsets", "CSV", "DataFrames", "DiffEqNoiseProcess", "FiniteDiff", "DiffEqDevTools", "Logging", "MKL", "PyCall", "JuLIP", "Symbolics", "Statistics", "Plots", "JLD2"]
test = [
"Test",
"SafeTestsets",
"CSV",
"DataFrames",
"DiffEqNoiseProcess",
"FiniteDiff",
"DiffEqDevTools",
"Logging",
"MKL",
"PythonCall",
"JuLIP",
"Symbolics",
"Statistics",
"Plots",
"JLD2",
]
40 changes: 24 additions & 16 deletions docs/src/atoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ start_time = time()
```
# [Handling Atoms](@id atoms)

This package makes the choice to separate the atomic parameters from their positions and
velocities for ease of use with the differential equations solvers.
This contrasts somewhat with most other software packages where these would be usually
by joined together into a single object.
!!! tip "Tip: NQCDynamics.jl handles atoms differently to `ase`"
This package makes the choice to separate the atomic parameters from their positions and
velocities for ease of use with the differential equations solvers.
This contrasts somewhat with most other software packages where these would be usually
be joined together into a single object.

The atomic parameters here are contained within the
[`Atoms`](@ref) type introduced earlier
Expand Down Expand Up @@ -40,32 +41,39 @@ When working with NQCDynamics, the most useful packages are [AtomsIO](https://gi
for reading and writing structures and trajectories, and [ASEconvert](https://github.com/mfherbst/ASEconvert.jl)
for working with [ASE](https://wiki.fysik.dtu.dk/ase/index.html) from within Julia.

## Using ASE with ASEconvert.jl
## Using Python's `ase` package from Julia

This example shows how ASEconvert can be used to build a structure, then convert
from the ASE format into an AtomsBase compatible system:
Julia provides multiple options to run Python-based code from Julia scripts. The NQCD packages
provide compatibility with [**PythonCall.jl**](https://github.com/JuliaPy/PythonCall.jl), and some deprecated interfaces for [**PyCall.jl**](https://github.com/JuliaPy/PyCall.jl) exist as well.
While both of these packages function similarly, PythonCall forces you as a user to think more about when data is copied in memory between Python and Julia, enabling more efficient code.

This example shows how `ase.build` can be used to build a structure from within Julia, then convert
from the ASE format into the required objects for atoms, positions and unit cell for an NQCD simulation:

```julia
using ASEconvert
using PythonCall
using NQCBase

# Make a silicon supercell using ASE
atoms_ase = ase.build.bulk("Si") * pytuple((4, 1, 1))
ase_build = pyimport("ase.build")

# Convert to an AtomsBase-compatible structure
atoms_ab = pyconvert(AbstractSystem, atoms_ase)
# Make a silicon supercell using ASE
atoms_ase = ase_build.bulk("Si") * pytuple((4, 1, 1))
```

It is currently not possible to use an AtomsBase system directly with NQCDynamics, but can
be quickly converted to the correct format:

```julia
using NQCDynamics
atoms_nqcd = Atoms(atoms_ab)
r = Position(atoms_ab)
v = Velocity(atoms_ab)
c = Cell(atoms_ab)

atoms_nqcd, positions_nqcd, cell_nqcd = convert_from_ase_atoms(atoms_ase)

println(atoms_nqcd)
println(positions_nqcd)
println(cell_nqcd)
```


## Saving and loading with AtomsIO.jl

After running a simulation it often desirable to save the trajectory in a standard format for visualization.
Expand Down
2 changes: 1 addition & 1 deletion test/Analysis/diatomic.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Test
using NQCDynamics
using Unitful, UnitfulAtomic
using PyCall
using PythonCall
using NQCModels
using JLD2

Expand Down

0 comments on commit d853f7f

Please sign in to comment.