forked from cesmix-mit/LAMMPS.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update examples and docs (cesmix-mit#47)
- Loading branch information
Showing
4 changed files
with
64 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "LAMMPS" | ||
uuid = "ee2e13b9-eee9-4449-aafa-cfa6a2dbe14d" | ||
authors = ["Valentin Churavy <[email protected]>"] | ||
version = "0.4.0" | ||
version = "0.4.1" | ||
|
||
[deps] | ||
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" | ||
|
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 |
---|---|---|
@@ -1,37 +1,46 @@ | ||
using LAMMPS | ||
|
||
lmp = LMP() | ||
command(lmp, "units lj") | ||
command(lmp, "atom_style atomic") | ||
command(lmp, "atom_modify map array sort 0 0") | ||
command(lmp, "box tilt large") | ||
|
||
command(lmp, """ | ||
units lj | ||
atom_style atomic | ||
atom_modify map array sort 0 0 | ||
box tilt large | ||
""") | ||
|
||
# Setup box | ||
x_hi = 10.0 | ||
y_hi = 10.0 | ||
z_hi = 10.0 | ||
command(lmp, "boundary p p p") | ||
command(lmp, "region cell block 0 $x_hi 0 $y_hi 0 $z_hi units box") | ||
command(lmp, "create_box 1 cell") | ||
command(lmp, """ | ||
boundary p p p | ||
region cell block 0 $x_hi 0 $y_hi 0 $z_hi units box | ||
create_box 1 cell | ||
""") | ||
|
||
# Setup style | ||
command(lmp, "pair_style lj/cut 2.5") | ||
command(lmp, "pair_coeff * * 1 1") # TODO | ||
command(lmp, """ | ||
pair_style lj/cut 2.5 | ||
pair_coeff * * 1 1 | ||
""") | ||
|
||
# Setup atoms | ||
natoms = 10 | ||
command(lmp, "create_atoms 1 random $natoms 1 NULL") | ||
command(lmp, "mass 1 1.0") | ||
command(lmp, """ | ||
create_atoms 1 random $natoms 1 NULL | ||
mass 1 1.0 | ||
""") | ||
|
||
# (x,y,z), natoms | ||
positions = rand(3, 10) .* 5 | ||
LAMMPS.API.lammps_scatter_atoms(lmp, "x", 1, 3, positions) | ||
scatter!(lmp, "x", positions) | ||
|
||
# Compute pot_e | ||
command(lmp, "compute pot_e all pe") | ||
|
||
command(lmp, "run 0") | ||
|
||
# extract output | ||
forces = extract_atom(lmp, "f") | ||
energies = extract_compute(lmp, "pot_e", LAMMPS.API.LMP_STYLE_GLOBAL, LAMMPS.API.LMP_TYPE_SCALAR) | ||
forces = gather(lmp, "f") | ||
energies = gather(lmp, "pot_e") |
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