-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add i-PI server calculator and update i-PI driver to AB v0.4 (#31)
* driver update * initial server draft * AtomsCalculators interface and some fixes * ipi server working * fixes * tests * update tests * fix unixsocket * add doc string for server * fix
- Loading branch information
1 parent
d56e6b1
commit f3b130e
Showing
3 changed files
with
241 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using AtomsBase | ||
using AtomsCalculators | ||
using AtomsCalculators.Testing | ||
using AtomsCalculatorsUtilities.IPI | ||
using AtomsCalculatorsUtilities.PairPotentials | ||
using Unitful | ||
using Base.Threads | ||
|
||
|
||
hydrogen = isolated_system([ | ||
:H => [0.1, 0, 0.]u"Å", | ||
:H => [0, 0, 1.]u"Å", | ||
:H => [4., 0, 0.]u"Å", | ||
:H => [4., 1., 0.]u"Å" | ||
]) | ||
|
||
box = ( | ||
[10.0, 0., 0.]u"Å", | ||
[0.0, 10., 0.]u"Å", | ||
[0.0, 0., 10.]u"Å", | ||
) | ||
|
||
pbc = (false, false, false) | ||
|
||
hydrogen = FlexibleSystem(hydrogen[:], bounding_box=box, periodicity=pbc) | ||
|
||
|
||
V = SimplePairPotential( | ||
x-> (x-0.9)^2-1, | ||
1, | ||
1, | ||
2.0u"Å" | ||
) | ||
|
||
|
||
ipi_future = @spawn IPIcalculator(port=33415) | ||
sleep(1) # we need to yeald to start the server | ||
|
||
ipi_driver = @spawn run_driver("127.0.0.1", V, hydrogen; port=33415) | ||
sleep(1) # we need to yeald to connect to the server | ||
|
||
calc = fetch(ipi_future) | ||
|
||
## | ||
|
||
test_energy_forces_virial(hydrogen, calc) | ||
|
||
@test AtomsCalculators.potential_energy(hydrogen, V) ≈ AtomsCalculators.potential_energy(hydrogen, calc) | ||
f_v = AtomsCalculators.forces(hydrogen, V) | ||
f_ipi = AtomsCalculators.forces(hydrogen, calc) | ||
@test all( isapprox.(f_v, f_ipi) ) | ||
@test AtomsCalculators.virial(hydrogen, V) ≈ AtomsCalculators.virial(hydrogen, calc) |