Skip to content

Commit

Permalink
lammps: triclinic cell
Browse files Browse the repository at this point in the history
  • Loading branch information
sozykinsa committed May 27, 2024
1 parent 9747673 commit 0316c0a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/program/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ def model_to_lammps_input(model: AtomicModel, charge=False):

text = "# Comment\n"
n_atoms = model.n_atoms()
text += "box tilt large\n"
text += "change_box all triclinic\n"
text += str(n_atoms) + " atoms\n"
types = model.types_of_atoms()
text += str(len(types)) + " atom types\n\n"
text += str(len(types)) + " atom types\n"
a, b, c, al, bt, gm = model.cell_params()
lx, ly, lz, xy, xz, yz = cellparams_to_lammps_cell(a, b, c, al, bt, gm)

text += "0.000000000000 " + str(a) + " xlo xhi\n"
text += "0.000000000000 " + str(b) + " ylo yhi\n"
text += "0.000000000000 " + str(c) + " zlo zhi\n\n"
text += "0.000000000000 " + str(lx) + " xlo xhi\n"
text += "0.000000000000 " + str(ly) + " ylo yhi\n"
text += "0.000000000000 " + str(lz) + " zlo zhi\n"
text += str(round(xy, 12)) + " " + str(round(xz, 12)) + " " + str(round(yz, 12)) + " xy xz yz\n\n"

text += "Masses\n\n"
for i in range(len(types)):
Expand All @@ -57,6 +61,16 @@ def model_to_lammps_input(model: AtomicModel, charge=False):
return text


def cellparams_to_lammps_cell(a, b, c, al, bt, gm):
lx = a
xy = b * np.cos(gm * np.pi / 180)
xz = c * np.cos(bt * np.pi / 180)
ly = np.sqrt(b * b - xy * xy)
yz = (b * c * np.cos(al * np.pi / 180) - xy * xz) / ly
lz = np.sqrt(c * c - xz * xz - yz * yz)
return lx, ly, lz, xy, xz, yz


def atoms_trajectory_step(f_name):
model = AtomicModel()
n_atoms = 0
Expand Down

0 comments on commit 0316c0a

Please sign in to comment.