diff --git a/Project.toml b/Project.toml index e82f350..3b531cd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ACEmd" uuid = "69e0c927-b120-467d-b2b3-5b6842148cf4" authors = ["Teemu Järvinen and contributors"] -version = "0.1.7" +version = "0.1.8-DEV" [deps] ACE1 = "e3f9bc04-086e-409a-ba78-e9769fe067bb" diff --git a/docs/src/index.md b/docs/src/index.md index 922a437..5ec18e4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -6,7 +6,7 @@ CurrentModule = ACEmd [ACEmd](https://github.com/acesuit/ACEmd.jl) is molecular dynamics interface for Julia ACE. All MD use cases should use this package. -ACEmd is fully [AtomsBase](https://github.com/JuliaMolSim/AtomsBase.jl) compatable and you should use AtomsBase over older JuLIP. You can still use JuLIP `Atoms` type as an input, while in a long run JuLIP will be decomissioned. +ACEmd is fully [AtomsBase](https://github.com/JuliaMolSim/AtomsBase.jl) compatible and you should use AtomsBase over older JuLIP. You can still use JuLIP `Atoms` type as an input, while in a long run JuLIP will be decommissioned. ## Example use case @@ -50,7 +50,7 @@ pot_ev = load_ace_model(fname_ace; ace_energy(pot_ev, data) ``` -Alternatively you can overload the default unit by giving it explicitely +Alternatively you can overload the default unit by giving it explicitly ```@repl 1 ace_energy(pot_ev, data; energy_unit=u"hartree") @@ -78,5 +78,5 @@ ace_atom_energies(pot, data) ``` ```@autodocs -Modules = [ACEmd] +Modules = [ACEmd, ACEmd.IPIprotocol] ``` diff --git a/src/submodules/IPIprotocol.jl b/src/submodules/IPIprotocol.jl index 8600967..092bd0a 100644 --- a/src/submodules/IPIprotocol.jl +++ b/src/submodules/IPIprotocol.jl @@ -1,9 +1,13 @@ module IPIprotocol +# This is AtomsCalculators implementation for i-PI protocol. +# For reference see https://github.com/i-pi/i-pi/blob/master/drivers/py/driver.py -using ..ACEmd +using AtomsBase +using AtomsCalculators using Sockets using StaticArrays -# i-PI example https://github.com/i-pi/i-pi/blob/master/drivers/py/driver.py +using Unitful +using UnitfulAtomic export run_driver @@ -78,8 +82,18 @@ function sendforce(comm, e::Number, forces::AbstractVector, virial::AbstractMatr write(comm, zero(UInt8) ) end +""" + run_driver(address, potential, init_structure; port=31415, unixsocket=false ) -function run_driver(address, pot::ACEmd.ACEpotential, init_structure; port=31415, unixsocket=false ) +Connect I-PI driver to server at given `address`. Use kword `port` (default 31415) to +specify port. If kword `unixsocket` is true, `address` is understood to be the name of the socket +and `port` option is ignored. + +You need to give initial structure as I-PI protocol does not transfer atom symbols. +This means that, if you want to change the number of atoms or their symbols, you need +to lauch a new driver. +""" +function run_driver(address, potential, init_structure; port=31415, unixsocket=false ) if unixsocket comm = connect("/tmp/ipi_"*address) else @@ -119,10 +133,10 @@ function run_driver(address, pot::ACEmd.ACEpotential, init_structure; port=31415 cell = pos[:cell] @assert length(symbols) == length(positions) "received amount of position data does no match the atomic symbol data" system = FastSystem(cell, pbc, positions, symbols, anumbers, masses) - data = ace_energy_forces_virial(pot, system) + data = AtomsCalculators.energy_forces_virial(system, potential) has_data = true elseif header == "GETFORCE" - sendforce(comm, data["energy"], data["forces"], data["virial"]) + sendforce(comm, data[:energy], data[:forces], data[:virial]) has_data = false elseif header == "EXIT" @info "Exiting calculator"