-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from schrummy14/master
Commits to have LIGGGHTS work with Python3
- Loading branch information
Showing
4 changed files
with
160 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Simple example based on contactModels/in.newModels | ||
|
||
variable density equal 2500 | ||
|
||
# Contact model example | ||
atom_style granular | ||
atom_modify map array | ||
boundary f f f | ||
newton off | ||
|
||
communicate single vel yes | ||
|
||
units si | ||
|
||
region reg block -0.05 0.05 -0.05 0.05 0.0 0.15 units box | ||
create_box 1 reg | ||
|
||
neighbor 0.002 bin | ||
neigh_modify delay 0 | ||
|
||
# Material properties required for new pair styles | ||
fix m1 all property/global youngsModulus peratomtype 5.0e6 | ||
fix m2 all property/global poissonsRatio peratomtype 0.3 | ||
fix m3 all property/global coefficientRestitution peratomtypepair 1 0.95 | ||
fix m4 all property/global coefficientFriction peratomtypepair 1 0.05 | ||
fix m5 all property/global characteristicVelocity scalar 2.0 | ||
|
||
# Pair Style | ||
pair_style gran model hertz tangential history | ||
pair_coeff * * | ||
|
||
timestep 1.0e-5 | ||
|
||
fix grav all gravity 9.81 vector 0.0 0.0 -1.0 | ||
|
||
# Region for Particle Insertion | ||
region bc cylinder z 0.0 0.0 0.045 0.00 0.15 units box | ||
|
||
fix pts1 all particletemplate/sphere 15485863 atom_type 1 density constant ${density} radius constant 0.0025 | ||
fix pdd1 all particledistribution/discrete 15485867 1 pts1 1.0 | ||
fix ins all insert/pack seed 32452843 distributiontemplate pdd1 vel constant 0.0 0.0 -0.5 & | ||
insert_every once overlapcheck yes all_in yes particles_in_region 18 region bc | ||
|
||
fix integr all nve/sphere | ||
|
||
compute rke all erotate/sphere update_on_run_end yes | ||
thermo_style custom step time atoms ke c_rke cpu cpuremain | ||
thermo 1000 | ||
thermo_modify lost ignore norm no | ||
|
||
run 500 | ||
|
||
fix z0 all store/state 0 z |
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,60 @@ | ||
from liggghts import liggghts | ||
|
||
# Try loading in liggghts | ||
lmp = liggghts() | ||
|
||
# Try reading in an input file | ||
lmp.file("in.simpExample") | ||
|
||
|
||
# Try performing a command | ||
print("") | ||
print("Attempting to run simulation another 500 steps") | ||
lmp.command("run 500") | ||
|
||
# Try extracting a global value | ||
print("") | ||
print("Attempting to get the number of atoms in simulation") | ||
numAtoms = lmp.extract_global("natoms", 0) | ||
print("natoms =", numAtoms) | ||
|
||
# Try extracting atom's positions | ||
print("") | ||
print("Attempting to get the atom's positions") | ||
pos = lmp.extract_atom("x",3) | ||
for k in range(0,numAtoms): | ||
print("Pos[%i] = [%f, %f, %f]" % (k, pos[k][0], pos[k][1], pos[k][2])) | ||
|
||
# Try extracting a compute | ||
print("") | ||
print("Attempting to get the rotational KE") | ||
rke = lmp.extract_compute("rke",0,0) | ||
print("rke = %f" % rke) | ||
|
||
# Try extracting a fix | ||
print("") | ||
print("Attempting to get the pos_z before python ran another 500 steps") | ||
z0 = lmp.extract_fix("z0",1,1) | ||
print("z0[0] = %f" % z0[0]) | ||
|
||
# Try extracting a variable | ||
print("") | ||
print("Attempting to get the density variable used in simulation") | ||
density = lmp.extract_variable("density","all",0) | ||
print("density = %f" % density) | ||
|
||
# Testing get_natoms | ||
print("") | ||
print("Testing get_natoms") | ||
natoms = lmp.get_natoms() | ||
print("natoms = %i" % natoms) | ||
|
||
# Testing gather_atoms | ||
print("") | ||
print("Testing gather_atoms (NOTICE THAT IDS ARE DIFFERENT!!!)") | ||
x_gather_atoms = lmp.gather_atoms("x",1,3) | ||
for k in range(natoms): | ||
x = x_gather_atoms[3*k+0] | ||
y = x_gather_atoms[3*k+1] | ||
z = x_gather_atoms[3*k+2] | ||
print("x[%i] = [%f, %f, %f]" % (k, x, y, z)) |
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