From 9bf573d9733cb0862e40a194473cc97030849f30 Mon Sep 17 00:00:00 2001 From: "Fattebert J.-L" Date: Mon, 3 Jun 2024 22:32:36 -0400 Subject: [PATCH 1/2] Add possible periodic dimensions to xyz2in.py --- util/xyz2in.py | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/util/xyz2in.py b/util/xyz2in.py index 3555e138..8877ea27 100644 --- a/util/xyz2in.py +++ b/util/xyz2in.py @@ -15,6 +15,16 @@ #read file ifile=open(sys.argv[1],'r') + +lx = 0. +ly = 0. +lz = 0. +if( len(sys.argv) > 2 ): + lx = eval(sys.argv[2]) + ly = eval(sys.argv[3]) + lz = eval(sys.argv[4]) + + lines=ifile.readlines() count=0 @@ -22,13 +32,31 @@ dummy=0 #unused flag set to 0 for line in lines: ## loop over lines of file - words=line.split() - if len(words)>1: - if words[0][0:1]!='#': - name=words[0]+str(count) + if count>1: + words=line.split() + if len(words)>1: + name=words[0]+str(count-2) x=eval(words[1])*ang2bohr y=eval(words[2])*ang2bohr z=eval(words[3])*ang2bohr - + + if lx > 0.: + if x<0: + x = x +lx + if x>lx: + x = x -lx + + if ly > 0.: + if y<0: + y = y +ly + if y>ly: + y = y -ly + + if lz > 0.: + if z<0: + z = z +lz + if z>lz: + z = z -lz + print(name,'\t',dummy,'\t',x,'\t',y,'\t',z,'\t',movable) - count=count+1 + count=count+1 From 07f6c4d7b382c42ed7796a51c1c62eafcd3662a9 Mon Sep 17 00:00:00 2001 From: Jean-Luc Fattebert Date: Tue, 4 Jun 2024 09:44:09 -0400 Subject: [PATCH 2/2] Update xyz2in.py --- util/xyz2in.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/xyz2in.py b/util/xyz2in.py index 8877ea27..bb2e022d 100644 --- a/util/xyz2in.py +++ b/util/xyz2in.py @@ -5,9 +5,11 @@ # This file is part of MGmol. For details, see https://github.com/llnl/mgmol. # Please also read this link https://github.com/llnl/mgmol/LICENSE # -# Python program to convert .xyz file into mgmol input +# Python program to convert .xyz file into mgmol input coordinates file +# Optional arguments: [lx ly lz] to define box size and map all atoms into +# box (0,0,0)-(lx,ly,lz) using periodic boundary conditions # -# use: python coords.xyz > coords.in +# use: python coords.xyz [lx ly lz] > coords.in #------------------------------------------------------------------------------- import sys, string