Dice Processes
This commit creates and fixes the Dice process: NVT.ter, NPT.ter, NPT.eq Signed-off-by: Vitor Hideyoshi <vitor.h.n.batista@gmail.com>
This commit is contained in:
BIN
.control.in.swp
BIN
.control.in.swp
Binary file not shown.
527
DPpack/Dice.py
527
DPpack/Dice.py
@@ -1,527 +0,0 @@
|
||||
import sys, os, time
|
||||
import subprocess
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from numpy import random
|
||||
|
||||
from DPpack.PTable import *
|
||||
from DPpack.SetGlobals import *
|
||||
from DPpack.Misc import *
|
||||
|
||||
####################################### functions ######################################
|
||||
|
||||
def make_inputs(cycle, proc):
|
||||
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
|
||||
num = time.time() ## Take the decimal places 7 to 12 of the
|
||||
num = (num - int(num)) * 1e6 ## time in seconds as a floating point
|
||||
num = int((num - int(num)) * 1e6) ## to make an integer in the range 1-1e6
|
||||
random.seed( (os.getpid() * num) % (max_seed + 1) )
|
||||
|
||||
if not dice['randominit']:
|
||||
xyzfile = dice['outname'] + ".xyz.last-" + "p{:02d}".format(proc)
|
||||
make_init_file(path, xyzfile)
|
||||
|
||||
if len(dice['nstep']) == 2: ## Means NVT simulation
|
||||
|
||||
make_nvt_ter(path)
|
||||
make_nvt_eq(path)
|
||||
|
||||
elif len(dice['nstep']) == 3: ## Means NPT simulation
|
||||
|
||||
if dice['randominit']:
|
||||
make_nvt_ter(path)
|
||||
else:
|
||||
dice['dens'] = new_density(proc)
|
||||
|
||||
make_npt_ter(path)
|
||||
make_npt_eq(path)
|
||||
|
||||
else:
|
||||
sys.exit("Error: bad number of entries for 'nstep'")
|
||||
|
||||
make_potential(path)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_nvt_ter(path):
|
||||
|
||||
file = path + os.sep + "NVT.ter"
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
fh.write("title = {} - NVT Thermalization\n".format(dice['title']))
|
||||
fh.write("ncores = {}\n".format(dice['ncores']))
|
||||
fh.write("ljname = {}\n".format(dice['ljname']))
|
||||
fh.write("outname = {}\n".format(dice['outname']))
|
||||
|
||||
string = " ".join(str(x) for x in dice['nmol'])
|
||||
fh.write("nmol = {}\n".format(string))
|
||||
|
||||
fh.write("dens = {}\n".format(dice['dens']))
|
||||
fh.write("temp = {}\n".format(dice['temp']))
|
||||
|
||||
if dice['randominit']:
|
||||
fh.write("init = yes\n")
|
||||
fh.write("nstep = {}\n".format(dice['nstep'][0]))
|
||||
else:
|
||||
fh.write("init = yesreadxyz\n")
|
||||
fh.write("nstep = {}\n".format(player['altsteps']))
|
||||
|
||||
fh.write("vstep = 0\n")
|
||||
fh.write("mstop = 1\n")
|
||||
fh.write("accum = no\n")
|
||||
fh.write("iprint = 1\n")
|
||||
fh.write("isave = 0\n")
|
||||
fh.write("irdf = 0\n")
|
||||
|
||||
seed = int(1e6 * random.random())
|
||||
fh.write("seed = {}\n".format(seed))
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_nvt_eq(path):
|
||||
|
||||
file = path + os.sep + "NVT.eq"
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
fh.write("title = {} - NVT Production\n".format(dice['title']))
|
||||
fh.write("ncores = {}\n".format(dice['ncores']))
|
||||
fh.write("ljname = {}\n".format(dice['ljname']))
|
||||
fh.write("outname = {}\n".format(dice['outname']))
|
||||
|
||||
string = " ".join(str(x) for x in dice['nmol'])
|
||||
fh.write("nmol = {}\n".format(string))
|
||||
|
||||
fh.write("dens = {}\n".format(dice['dens']))
|
||||
fh.write("temp = {}\n".format(dice['temp']))
|
||||
fh.write("init = no\n")
|
||||
fh.write("nstep = {}\n".format(dice['nstep'][1]))
|
||||
fh.write("vstep = 0\n")
|
||||
fh.write("mstop = 1\n")
|
||||
fh.write("accum = no\n")
|
||||
fh.write("iprint = 1\n")
|
||||
fh.write("isave = {}\n".format(dice['isave']))
|
||||
fh.write("irdf = {}\n".format(10 * player['nprocs']))
|
||||
|
||||
seed = int(1e6 * random.random())
|
||||
fh.write("seed = {}\n".format(seed))
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_npt_ter(path):
|
||||
|
||||
file = path + os.sep + "NPT.ter"
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
fh.write("title = {} - NPT Thermalization\n".format(dice['title']))
|
||||
fh.write("ncores = {}\n".format(dice['ncores']))
|
||||
fh.write("ljname = {}\n".format(dice['ljname']))
|
||||
fh.write("outname = {}\n".format(dice['outname']))
|
||||
|
||||
string = " ".join(str(x) for x in dice['nmol'])
|
||||
fh.write("nmol = {}\n".format(string))
|
||||
|
||||
fh.write("press = {}\n".format(dice['press']))
|
||||
fh.write("temp = {}\n".format(dice['temp']))
|
||||
|
||||
if dice['randominit']:
|
||||
fh.write("init = no\n") ## Because there will be a previous NVT simulation
|
||||
fh.write("vstep = {}\n".format(int(dice['nstep'][1] / 5)))
|
||||
else:
|
||||
fh.write("init = yesreadxyz\n")
|
||||
fh.write("dens = {:<8.4f}\n".format(dice['dens']))
|
||||
fh.write("vstep = {}\n".format(int(player['altsteps'] / 5)))
|
||||
|
||||
fh.write("nstep = 5\n")
|
||||
fh.write("mstop = 1\n")
|
||||
fh.write("accum = no\n")
|
||||
fh.write("iprint = 1\n")
|
||||
fh.write("isave = 0\n")
|
||||
fh.write("irdf = 0\n")
|
||||
|
||||
seed = int(1e6 * random.random())
|
||||
fh.write("seed = {}\n".format(seed))
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_npt_eq(path):
|
||||
|
||||
file = path + os.sep + "NPT.eq"
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
fh.write("title = {} - NPT Production\n".format(dice['title']))
|
||||
fh.write("ncores = {}\n".format(dice['ncores']))
|
||||
fh.write("ljname = {}\n".format(dice['ljname']))
|
||||
fh.write("outname = {}\n".format(dice['outname']))
|
||||
|
||||
string = " ".join(str(x) for x in dice['nmol'])
|
||||
fh.write("nmol = {}\n".format(string))
|
||||
|
||||
fh.write("press = {}\n".format(dice['press']))
|
||||
fh.write("temp = {}\n".format(dice['temp']))
|
||||
|
||||
fh.write("nstep = 5\n")
|
||||
|
||||
fh.write("vstep = {}\n".format(int(dice['nstep'][2] / 5)))
|
||||
fh.write("init = no\n")
|
||||
fh.write("mstop = 1\n")
|
||||
fh.write("accum = no\n")
|
||||
fh.write("iprint = 1\n")
|
||||
fh.write("isave = {}\n".format(dice['isave']))
|
||||
fh.write("irdf = {}\n".format(10 * player['nprocs']))
|
||||
|
||||
seed = int(1e6 * random.random())
|
||||
fh.write("seed = {}\n".format(seed))
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_init_file(path, file):
|
||||
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find the xyz file {} in main directory".format(file))
|
||||
try:
|
||||
with open(file) as fh:
|
||||
xyzfile = fh.readlines()
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
nsites_mm = 0
|
||||
for i in range(1, len(dice['nmol'])):
|
||||
nsites_mm += dice['nmol'][i] * len(molecules[i])
|
||||
|
||||
nsites_mm *= -1 ## Become an index to count from the end of xyzfile (list)
|
||||
xyzfile = xyzfile[nsites_mm :] ## Only the MM atoms of the last configuration remains
|
||||
|
||||
file = path + os.sep + dice['outname'] + ".xy"
|
||||
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
for atom in molecules[0]:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(atom['rx'], atom['ry'],
|
||||
atom['rz']))
|
||||
|
||||
for ghost in ghost_atoms:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(ghost['rx'], ghost['ry'],
|
||||
ghost['rz']))
|
||||
|
||||
for lps in lp_atoms:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(lps['rx'], lps['ry'],
|
||||
lps['rz']))
|
||||
|
||||
for line in xyzfile:
|
||||
atom = line.split()
|
||||
rx = float(atom[1])
|
||||
ry = float(atom[2])
|
||||
rz = float(atom[3])
|
||||
fh.write("{:>10.5f} {:>10.5f} {:>10.5f}\n".format(rx, ry, rz))
|
||||
|
||||
fh.write("$end")
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_potential(path):
|
||||
|
||||
fstr = "{:<3d} {:>3d} {:>10.5f} {:>10.5f} {:>10.5f} {:>10.6f} {:>9.5f} {:>7.4f}\n"
|
||||
|
||||
file = path + os.sep + dice['ljname']
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
fh.write("{}\n".format(dice['combrule']))
|
||||
fh.write("{}\n".format(len(dice['nmol'])))
|
||||
|
||||
nsites_qm = len(molecules[0]) + len(ghost_atoms) + len(lp_atoms)
|
||||
|
||||
## Print the sites of the QM molecule
|
||||
fh.write("{}\n".format(nsites_qm))
|
||||
for atom in molecules[0]:
|
||||
fh.write(fstr.format(atom['lbl'], atom['na'], atom['rx'], atom['ry'], atom['rz'],
|
||||
atom['chg'], atom['eps'], atom['sig']))
|
||||
|
||||
ghost_label = molecules[0][-1]['lbl'] + 1
|
||||
for ghost in ghost_atoms:
|
||||
fh.write(fstr.format(ghost_label, ghost_number, ghost['rx'], ghost['ry'],
|
||||
ghost['rz'], ghost['chg'], 0, 0))
|
||||
|
||||
ghost_label += 1
|
||||
for lp in lp_atoms:
|
||||
fh.write(fstr.format(ghost_label, ghost_number, lp['rx'], lp['ry'], lp['rz'],
|
||||
lp['chg'], 0, 0))
|
||||
|
||||
## Print the sites of the other molecules
|
||||
for mol in molecules[1:]:
|
||||
fh.write("{}\n".format(len(mol)))
|
||||
for atom in mol:
|
||||
fh.write(fstr.format(atom['lbl'], atom['na'], atom['rx'], atom['ry'],
|
||||
atom['rz'], atom['chg'], atom['eps'], atom['sig']))
|
||||
|
||||
return
|
||||
|
||||
|
||||
def make_proc_dir(cycle, proc):
|
||||
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(path))
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def run_dice(cycle, proc, fh):
|
||||
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
working_dir = os.getcwd()
|
||||
os.chdir(path)
|
||||
|
||||
fh.write("Simulation process {} initiated with pid {}\n".format(proc_dir, os.getpid()))
|
||||
|
||||
if len(dice['nstep']) == 2: ## Means NVT simulation
|
||||
|
||||
## NVT thermalization
|
||||
string = "(from " + ("random" if dice['randominit'] else "previous") + " configuration)"
|
||||
fh.write("p{:02d}> NVT thermalization initiated {} on {}\n".format(proc, string,
|
||||
date_time()))
|
||||
|
||||
infh = open("NVT.ter")
|
||||
outfh = open("NVT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(dice['progname'], stdin=infh, stdout=outfh)
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
if os.getppid() == 1: ## Parent process is dead
|
||||
sys.exit()
|
||||
|
||||
if exit_status != 0:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
else:
|
||||
outfh = open("NVT.ter.out") ## Open again to seek the normal end flag
|
||||
flag = outfh.readlines()[dice_flag_line].strip()
|
||||
outfh.close()
|
||||
if flag != dice_end_flag:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
## NVT production
|
||||
fh.write("p{:02d}> NVT production initiated on {}\n".format(proc, date_time()))
|
||||
|
||||
infh = open("NVT.eq")
|
||||
outfh = open("NVT.eq.out", "w")
|
||||
|
||||
exit_status = subprocess.call(dice['progname'], stdin=infh, stdout=outfh)
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
if os.getppid() == 1: ## Parent process is dead
|
||||
sys.exit()
|
||||
|
||||
if exit_status != 0:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
else:
|
||||
outfh = open("NVT.eq.out") ## Open again to seek the normal end flag
|
||||
flag = outfh.readlines()[dice_flag_line].strip()
|
||||
outfh.close()
|
||||
if flag != dice_end_flag:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
fh.write("p{:02d}> ----- NVT production finished on {}\n".format(proc,
|
||||
date_time()))
|
||||
|
||||
elif len(dice['nstep']) == 3: ## Means NPT simulation
|
||||
|
||||
## NVT thermalization if randominit
|
||||
if dice['randominit']:
|
||||
string = "(from random configuration)"
|
||||
fh.write("p{:02d}> NVT thermalization initiated {} on {}\n".format(proc,
|
||||
string, date_time()))
|
||||
infh = open("NVT.ter")
|
||||
outfh = open("NVT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(dice['progname'], stdin=infh, stdout=outfh)
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
if os.getppid() == 1: ## Parent process is dead
|
||||
sys.exit()
|
||||
|
||||
if exit_status != 0:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
else:
|
||||
outfh = open("NVT.ter.out") ## Open again to seek the normal end flag
|
||||
flag = outfh.readlines()[dice_flag_line].strip()
|
||||
outfh.close()
|
||||
if flag != dice_end_flag:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
## NPT thermalization
|
||||
string = (" (from previous configuration) " if not dice['randominit'] else " ")
|
||||
fh.write("p{:02d}> NPT thermalization initiated{}on {}\n".format(proc, string,
|
||||
date_time()))
|
||||
infh = open("NPT.ter")
|
||||
outfh = open("NPT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(dice['progname'], stdin=infh, stdout=outfh)
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
if os.getppid() == 1: ## Parent process is dead
|
||||
sys.exit()
|
||||
|
||||
if exit_status != 0:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
else:
|
||||
outfh = open("NPT.ter.out") ## Open again to seek the normal end flag
|
||||
flag = outfh.readlines()[dice_flag_line].strip()
|
||||
outfh.close()
|
||||
if flag != dice_end_flag:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
## NPT production
|
||||
fh.write("p{:02d}> NPT production initiated on {}\n".format(proc, date_time()))
|
||||
|
||||
infh = open("NPT.eq")
|
||||
outfh = open("NPT.eq.out", "w")
|
||||
|
||||
exit_status = subprocess.call(dice['progname'], stdin=infh, stdout=outfh)
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
if os.getppid() == 1: ## Parent process is dead
|
||||
sys.exit()
|
||||
|
||||
if exit_status != 0:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
else:
|
||||
outfh = open("NPT.eq.out") ## Open again to seek the normal end flag
|
||||
flag = outfh.readlines()[dice_flag_line].strip()
|
||||
outfh.close()
|
||||
if flag != dice_end_flag:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
fh.write("p{:02d}> ----- NPT production finished on {}\n".format(proc,
|
||||
date_time()))
|
||||
|
||||
os.chdir(working_dir)
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def print_last_config(cycle, proc):
|
||||
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
file = path + os.sep + dice['outname'] + ".xyz"
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find the xyz file {}".format(file))
|
||||
try:
|
||||
with open(file) as fh:
|
||||
xyzfile = fh.readlines()
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
nsites = ( len(molecules[0]) + len(ghost_atoms) + len(lp_atoms) ) * dice['nmol'][0]
|
||||
for i in range(1, len(dice['nmol'])):
|
||||
nsites += dice['nmol'][i] * len(molecules[i])
|
||||
|
||||
nsites += 2 ## To include the comment line and the number of atoms (xyz file format)
|
||||
|
||||
nsites *= -1 ## Become an index to count from the end of xyzfile (list)
|
||||
xyzfile = xyzfile[nsites :] ## Take the last configuration
|
||||
|
||||
|
||||
file = dice['outname'] + ".xyz.last-" + proc_dir
|
||||
fh = open(file, "w")
|
||||
for line in xyzfile:
|
||||
fh.write(line)
|
||||
|
||||
fh.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def new_density(proc):
|
||||
|
||||
file = dice['outname'] + ".xyz.last-" + "p{:02d}".format(proc)
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find the xyz file {} in main directory".format(file))
|
||||
try:
|
||||
with open(file) as fh:
|
||||
xyzfile = fh.readlines()
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
box = xyzfile[1].split()
|
||||
volume = float(box[-3]) * float(box[-2]) * float(box[-1])
|
||||
|
||||
total_mass = 0
|
||||
for i in range(len(molecules)):
|
||||
mol_mass = 0
|
||||
for atom in molecules[i]:
|
||||
mol_mass += atom['mass']
|
||||
total_mass += mol_mass * dice['nmol'][i]
|
||||
|
||||
density = (total_mass / volume) * umaAng3_to_gcm3
|
||||
|
||||
return density
|
||||
|
||||
|
||||
|
||||
def simulation_process(cycle, proc, logfh):
|
||||
|
||||
try:
|
||||
make_proc_dir(cycle, proc)
|
||||
make_inputs(cycle, proc)
|
||||
run_dice(cycle, proc, logfh)
|
||||
except Exception as err:
|
||||
sys.exit(err)
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os, sys, time
|
||||
from posixpath import sep
|
||||
import shutil, gzip
|
||||
|
||||
####################################### functions ######################################
|
||||
@@ -33,31 +34,34 @@ def compress_files_1mb(path):
|
||||
|
||||
return
|
||||
|
||||
def make_simulation_dir():
|
||||
|
||||
sim_dir = "simfiles"
|
||||
if os.path.exists(sim_dir):
|
||||
sys.exit("Error: a file or a directory {} already exists, move or delete de simfiles directory to continue.".format(sim_dir))
|
||||
try:
|
||||
os.makedirs(sim_dir)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(sim_dir))
|
||||
|
||||
def make_step_dir(cycle):
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
if os.path.exists(step_dir):
|
||||
path = sim_dir + os.sep + step_dir
|
||||
if os.path.exists(path):
|
||||
sys.exit("Error: a file or directory {} already exists".format(step_dir))
|
||||
try:
|
||||
os.makedirs(step_dir)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(step_dir))
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
def make_qm_dir(cycle):
|
||||
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
path = step_dir + os.sep + "qm"
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(path))
|
||||
|
||||
return
|
||||
|
||||
sys.exit("Error: cannot make directory {}".format(step_dir))
|
||||
|
||||
def make_qm_dir(cycle):
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
path = sim_dir + os.sep + step_dir + os.sep + "qm"
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(path))
|
||||
@@ -375,16 +375,22 @@ class Molecule:
|
||||
evals, evecs = self.principal_axes()
|
||||
|
||||
if round(linalg.det(evecs)) == -1:
|
||||
|
||||
evecs[0,2] *= -1
|
||||
evecs[1,2] *= -1
|
||||
evecs[2,2] *= -1
|
||||
|
||||
if round(linalg.det(evecs)) != 1:
|
||||
|
||||
sys.exit("Error: could not make a rotation matrix while adopting the standard orientation")
|
||||
|
||||
rot_matrix = evecs.T
|
||||
|
||||
for atom in self.atom:
|
||||
|
||||
position = np.array([ atom.rx, atom.ry, atom.rz ])
|
||||
new_position = np.matmul(rot_matrix, position.T).T
|
||||
|
||||
atom.rx = new_position[0]
|
||||
atom.ry = new_position[1]
|
||||
atom.rz = new_position[2]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import setproctitle
|
||||
import os, sys
|
||||
import shutil
|
||||
import textwrap
|
||||
@@ -19,11 +20,11 @@ umaAng3_to_gcm3 = 1.6605 ## Conversion between uma/Ang3 to g/cm3
|
||||
|
||||
max_seed = 4294967295 ## Maximum allowed value for a seed (numpy)
|
||||
|
||||
|
||||
class Internal:
|
||||
|
||||
def __init__(self, infile, outfile):
|
||||
|
||||
self.cyc = 1
|
||||
self.infile = infile
|
||||
self.outfile = outfile
|
||||
|
||||
@@ -51,7 +52,6 @@ class Internal:
|
||||
|
||||
## Dice:
|
||||
self.combrule = None
|
||||
self.randominit = True
|
||||
|
||||
def read_keywords(self):
|
||||
|
||||
@@ -126,6 +126,10 @@ class Internal:
|
||||
|
||||
elif key in ('ljname', 'outname', 'progname'):
|
||||
setattr(self.dice, key, value[0])
|
||||
|
||||
elif key == 'randominit':
|
||||
if value in ('always','first'):
|
||||
setattr(self.dice,key,value)
|
||||
|
||||
elif key in ('ncores', 'isave'):
|
||||
err = "Error: expected a positive integer for keyword {} in file {}".format(key, self.infile)
|
||||
@@ -414,6 +418,9 @@ class Internal:
|
||||
if not nsites.isdigit():
|
||||
sys.exit("Error: expected an integer in line {} of file {}".format(line, self.dice.ljname))
|
||||
|
||||
if molname is None:
|
||||
sys.exit("Error: expected a molecule name in line {} of file {}".format(line, self.dice.ljname))
|
||||
|
||||
nsites = int(nsites)
|
||||
|
||||
self.system.add_type(nsites, Molecule(molname))
|
||||
@@ -679,7 +686,8 @@ class Internal:
|
||||
|
||||
for proc in range(1, self.player.nprocs + 1): ## Run over folders
|
||||
|
||||
path = "step{:02d}".format(cycle) + os.sep + "p{:02d}".format(proc)
|
||||
simdir = "simfiles"
|
||||
path = simdir + os.sep + "step{:02d}".format(cycle) + os.sep + "p{:02d}".format(proc)
|
||||
file = path + os.sep + self.dice.outname + ".xyz"
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find file {}".format(file))
|
||||
@@ -795,10 +803,11 @@ class Internal:
|
||||
## Dice related Upper fuctions
|
||||
|
||||
def print_last_config(self, cycle, proc):
|
||||
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
file = path + os.sep + self.dice.outname + ".xyz"
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find the xyz file {}".format(file))
|
||||
@@ -818,14 +827,18 @@ class Internal:
|
||||
xyzfile = xyzfile[nsites :] ## Take the last configuration
|
||||
|
||||
|
||||
file = self.dice.outname + ".xyz.last-" + proc_dir
|
||||
file = path + os.sep + "last.xyz"
|
||||
fh = open(file, "w")
|
||||
for line in xyzfile:
|
||||
fh.write(line)
|
||||
|
||||
def new_density(self, proc):
|
||||
def new_density(self, cycle, proc):
|
||||
|
||||
file = self.dice.outname + ".xyz.last-" + "p{:02d}".format(proc)
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle-1)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
file = path + os.sep + "last.xyz"
|
||||
if not os.path.isfile(file):
|
||||
sys.exit("Error: cannot find the xyz file {} in main directory".format(file))
|
||||
try:
|
||||
@@ -847,6 +860,8 @@ class Internal:
|
||||
return density
|
||||
|
||||
def simulation_process(self, cycle, proc):
|
||||
|
||||
setproctitle.setproctitle("diceplayer-step{:0d}-p{:0d}".format(cycle,proc))
|
||||
|
||||
try:
|
||||
self.dice.make_proc_dir(cycle, proc)
|
||||
@@ -857,40 +872,49 @@ class Internal:
|
||||
|
||||
def make_inputs(self, cycle, proc):
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
|
||||
num = time.time() ## Take the decimal places 7 to 12 of the
|
||||
num = (num - int(num)) * 1e6 ## time in seconds as a floating point
|
||||
num = int((num - int(num)) * 1e6) ## to make an integer in the range 1-1e6
|
||||
random.seed( (os.getpid() * num) % (max_seed + 1) )
|
||||
|
||||
if self.randominit == False or self.player.cyc > 1:
|
||||
xyzfile = self.dice.outname + ".xyz.last-" + "p{:02d}".format(proc)
|
||||
if self.dice.randominit == 'first' and cycle > 1:
|
||||
step_dir = "step{:02d}".format(cycle-1)
|
||||
last_path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
xyzfile = last_path + os.sep + "last.xyz"
|
||||
self.make_init_file(path, xyzfile)
|
||||
|
||||
if len(self.dice.nstep) == 2: ## Means NVT simulation
|
||||
|
||||
self.make_nvt_ter(path)
|
||||
self.make_nvt_ter(cycle, path)
|
||||
self.make_nvt_eq(path)
|
||||
|
||||
elif len(self.dice.nstep) == 3: ## Means NPT simulation
|
||||
|
||||
if self.randominit:
|
||||
self.make_nvt_ter(path)
|
||||
if self.dice.randominit == 'first' and cycle > 1:
|
||||
self.dens = self.new_density(cycle, proc)
|
||||
else:
|
||||
self.dens = self.new_density(proc)
|
||||
self.make_nvt_ter(cycle, path)
|
||||
|
||||
self.make_npt_ter(path)
|
||||
self.make_npt_ter(cycle, path)
|
||||
self.make_npt_eq(path)
|
||||
|
||||
else:
|
||||
sys.exit("Error: bad number of entries for 'nstep'")
|
||||
|
||||
|
||||
self.make_potential(path)
|
||||
|
||||
def make_nvt_ter(self,path):
|
||||
# if (self.dice.randominit == 'first' and cycle > 1):
|
||||
|
||||
# last_path = sim_dir + os.sep + "step{:02d}".format(cycle-1) + os.sep + proc_dir
|
||||
# shutil.copyfile(last_path + os.sep + "phb.dat", path + os.sep + "phb.dat")
|
||||
|
||||
|
||||
def make_nvt_ter(self,cycle, path):
|
||||
|
||||
file = path + os.sep + "NVT.ter"
|
||||
try:
|
||||
@@ -909,12 +933,12 @@ class Internal:
|
||||
fh.write("dens = {}\n".format(self.dice.dens))
|
||||
fh.write("temp = {}\n".format(self.dice.temp))
|
||||
|
||||
if self.randominit:
|
||||
fh.write("init = yes\n")
|
||||
fh.write("nstep = {}\n".format(self.dice.nstep[0]))
|
||||
else:
|
||||
if self.dice.randominit == 'first' and cycle > 1:
|
||||
fh.write("init = yesreadxyz\n")
|
||||
fh.write("nstep = {}\n".format(self.player.altsteps))
|
||||
else:
|
||||
fh.write("init = yes\n")
|
||||
fh.write("nstep = {}\n".format(self.dice.nstep[0]))
|
||||
|
||||
fh.write("vstep = 0\n")
|
||||
fh.write("mstop = 1\n")
|
||||
@@ -962,7 +986,7 @@ class Internal:
|
||||
|
||||
fh.close()
|
||||
|
||||
def make_npt_ter(self,path):
|
||||
def make_npt_ter(self, cycle, path):
|
||||
|
||||
file = path + os.sep + "NPT.ter"
|
||||
try:
|
||||
@@ -981,13 +1005,14 @@ class Internal:
|
||||
fh.write("press = {}\n".format(self.dice.press))
|
||||
fh.write("temp = {}\n".format(self.dice.temp))
|
||||
|
||||
if self.dice.randominit == True:
|
||||
fh.write("init = no\n") ## Because there will be a previous NVT simulation
|
||||
fh.write("vstep = {}\n".format(int(self.dice.nstep[1] / 5)))
|
||||
else:
|
||||
|
||||
if self.dice.randominit == 'first' and cycle > 1:
|
||||
fh.write("init = yesreadxyz\n")
|
||||
fh.write("dens = {:<8.4f}\n".format(self.dice.dens))
|
||||
fh.write("vstep = {}\n".format(int(self.player.altsteps / 5)))
|
||||
else:
|
||||
fh.write("init = no\n") ## Because there will be a previous NVT simulation
|
||||
fh.write("vstep = {}\n".format(int(self.dice.nstep[1] / 5)))
|
||||
|
||||
fh.write("nstep = 5\n")
|
||||
fh.write("mstop = 1\n")
|
||||
@@ -1055,27 +1080,27 @@ class Internal:
|
||||
file = path + os.sep + self.dice.outname + ".xy"
|
||||
|
||||
try:
|
||||
fh = open(file, "w")
|
||||
fh = open(file, "w", 1)
|
||||
except:
|
||||
sys.exit("Error: cannot open file {}".format(file))
|
||||
|
||||
for atom in self.system.molecule[0].atom:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(atom.rx, atom.ry, atom.rz))
|
||||
|
||||
for i in self.system.molecule[0].ghost_atoms:
|
||||
with self.system.molecule[0].atom[i] as ghost:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(ghost.rx, ghost.ry, ghost.rz))
|
||||
# for i in self.system.molecule[0].ghost_atoms:
|
||||
# with self.system.molecule[0].atom[i] as ghost:
|
||||
# fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(ghost.rx, ghost.ry, ghost.rz))
|
||||
|
||||
for i in self.system.molecule[0].lp_atoms:
|
||||
with self.system.molecule[0].atom[i] as lp:
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(lp.rx, lp.ry, lp.rz))
|
||||
# for i in self.system.molecule[0].lp_atoms:
|
||||
# with self.system.molecule[0].atom[i] as lp:
|
||||
# fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(lp.rx, lp.ry, lp.rz))
|
||||
|
||||
for line in xyzfile:
|
||||
atom = line.split()
|
||||
rx = float(atom[1])
|
||||
ry = float(atom[2])
|
||||
rz = float(atom[3])
|
||||
fh.write("{:>10.5f} {:>10.5f} {:>10.5f}\n".format(rx, ry, rz))
|
||||
fh.write("{:>10.6f} {:>10.6f} {:>10.6f}\n".format(rx, ry, rz))
|
||||
|
||||
fh.write("$end")
|
||||
|
||||
@@ -1137,7 +1162,7 @@ class Internal:
|
||||
self.tol_factor = 1.2
|
||||
self.qmprog = "g16"
|
||||
|
||||
self.cyc = 1
|
||||
self.initcyc = 1
|
||||
|
||||
class Dice:
|
||||
|
||||
@@ -1147,7 +1172,8 @@ class Internal:
|
||||
self.progname = "dice"
|
||||
self.path = None
|
||||
|
||||
self.init = "yes"
|
||||
|
||||
self.randominit = 'first'
|
||||
self.temp = 300.0
|
||||
self.press = 1.0
|
||||
self.isave = 1000 # ASEC construction will take this into account
|
||||
@@ -1167,42 +1193,51 @@ class Internal:
|
||||
|
||||
def make_proc_dir(self, cycle, proc):
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
path = step_dir + os.sep + proc_dir
|
||||
path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
sys.exit("Error: cannot make directory {}".format(path))
|
||||
|
||||
return
|
||||
|
||||
def run_dice(self, cycle, proc, fh):
|
||||
|
||||
sim_dir = "simfiles"
|
||||
step_dir = "step{:02d}".format(cycle)
|
||||
proc_dir = "p{:02d}".format(proc)
|
||||
|
||||
try:
|
||||
fh.write("Simulation process {} initiated with pid {}\n".format(step_dir+'/'+proc_dir, os.getpid()))
|
||||
fh.flush()
|
||||
fh.write("Simulation process {} initiated with pid {}\n".format(sim_dir + os.sep + step_dir + os.sep + proc_dir, os.getpid()))
|
||||
|
||||
except Exception as err:
|
||||
print("I/O error({0}): {1}".format(err))
|
||||
|
||||
path = step_dir + os.sep + proc_dir
|
||||
path = sim_dir + os.sep + step_dir + os.sep + proc_dir
|
||||
working_dir = os.getcwd()
|
||||
os.chdir(path)
|
||||
|
||||
if len(self.nstep) == 2: ## Means NVT simulation
|
||||
|
||||
if self.randominit == 'no' or (self.randominit == 'first' and cycle > 1):
|
||||
string_tmp = 'previous'
|
||||
else:
|
||||
string_tmp = 'random'
|
||||
|
||||
## NVT thermalization
|
||||
string = "(from " + ("random" if self.randominit else "previous") + " configuration)"
|
||||
fh.write("p{:02d}> NVT thermalization initiated {} on {}\n".format(proc, string,
|
||||
string = "(from " + string_tmp + " configuration)"
|
||||
fh.write("p{:02d}> NVT thermalization finished {} on {}\n".format(proc, string,
|
||||
date_time()))
|
||||
|
||||
infh = open("NVT.ter")
|
||||
outfh = open("NVT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(self.progname, stdin=infh, stdout=outfh)
|
||||
if shutil.which("bash") != None:
|
||||
exit_status = subprocess.call(["bash","-c","exec -a dice-step{}-p{} {} < {} > {}".format(cycle, proc, self.progname, infh.name, outfh.name)])
|
||||
else:
|
||||
exit_status = subprocess.call(self.progname, stin=infh.name, stout=outfh.name)
|
||||
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
@@ -1224,7 +1259,11 @@ class Internal:
|
||||
infh = open("NVT.eq")
|
||||
outfh = open("NVT.eq.out", "w")
|
||||
|
||||
exit_status = subprocess.call(self.progname, stdin=infh, stdout=outfh)
|
||||
if shutil.which("bash") != None:
|
||||
exit_status = subprocess.call(["bash","-c","exec -a dice-step{}-p{} {} < {} > {}".format(cycle, proc, self.progname, infh.name, outfh.name)])
|
||||
else:
|
||||
exit_status = subprocess.call(self.progname, stin=infh.name, stout=outfh.name)
|
||||
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
@@ -1246,14 +1285,18 @@ class Internal:
|
||||
elif len(self.nstep) == 3: ## Means NPT simulation
|
||||
|
||||
## NVT thermalization if randominit
|
||||
if self.randominit:
|
||||
if self.randominit == 'always' or (self.randominit == 'first' and cycle == 1):
|
||||
string = "(from random configuration)"
|
||||
fh.write("p{:02d}> NVT thermalization initiated {} on {}\n".format(proc,
|
||||
string, date_time()))
|
||||
infh = open("NVT.ter")
|
||||
outfh = open("NVT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(self.progname, stdin=infh, stdout=outfh)
|
||||
if shutil.which("bash") != None:
|
||||
exit_status = subprocess.call(["bash","-c","exec -a dice-step{}-p{} {} < {} > {}".format(cycle, proc, self.progname, infh.name, outfh.name)])
|
||||
else:
|
||||
exit_status = subprocess.call(self.progname, stin=infh.name, stout=outfh.name)
|
||||
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
@@ -1270,14 +1313,21 @@ class Internal:
|
||||
sys.exit("Dice process p{:02d} did not exit properly".format(proc))
|
||||
|
||||
## NPT thermalization
|
||||
string = (" (from previous configuration) " if not self.randominit else " ")
|
||||
fh.write("p{:02d}> NPT thermalization initiated{}on {}\n".format(proc, string,
|
||||
if not self.randominit == 'always' or (self.randominit == 'first' and cycle == 1):
|
||||
string = " (from previous configuration) "
|
||||
else:
|
||||
string = " "
|
||||
fh.write("p{:02d}> NPT thermalization finished {} on {}\n".format(proc, string,
|
||||
date_time()))
|
||||
fh.flush()
|
||||
|
||||
infh = open("NPT.ter")
|
||||
outfh = open("NPT.ter.out", "w")
|
||||
|
||||
exit_status = subprocess.call(self.progname, stdin=infh, stdout=outfh)
|
||||
if shutil.which("bash") != None:
|
||||
exit_status = subprocess.call(["bash","-c","exec -a dice-step{}-p{} {} < {} > {}".format(cycle, proc, self.progname, infh.name, outfh.name)])
|
||||
else:
|
||||
exit_status = subprocess.call(self.progname, stin=infh.name, stout=outfh.name)
|
||||
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
@@ -1299,7 +1349,11 @@ class Internal:
|
||||
infh = open("NPT.eq")
|
||||
outfh = open("NPT.eq.out", "w")
|
||||
|
||||
exit_status = subprocess.call(self.progname, stdin=infh, stdout=outfh)
|
||||
if shutil.which("bash") != None:
|
||||
exit_status = subprocess.call(["bash","-c","exec -a dice-step{}-p{} {} < {} > {}".format(cycle, proc, self.progname, infh.name, outfh.name)])
|
||||
else:
|
||||
exit_status = subprocess.call(self.progname, stin=infh.name, stout=outfh.name)
|
||||
|
||||
infh.close()
|
||||
outfh.close()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# diceplayer
|
||||
initcyc = 1
|
||||
maxcyc = 3
|
||||
opt = NO
|
||||
nprocs = 4
|
||||
@@ -10,13 +9,13 @@ altsteps = 20000
|
||||
|
||||
# dice
|
||||
ncores = 3
|
||||
nmol = 1 100
|
||||
nmol = 1 50
|
||||
dens = 0.75
|
||||
nstep = 40000 60000 50000
|
||||
isave = 1000
|
||||
ljname = phb.pot
|
||||
ljname = phb.ljc
|
||||
outname = phb
|
||||
init = yes
|
||||
randominit = first
|
||||
|
||||
# Gaussian
|
||||
level = MP2/aug-cc-pVTZ
|
||||
level = MP2/aug-cc-pVTZ
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/export/apps/python/361/bin/python3
|
||||
|
||||
import os, sys, time, signal
|
||||
import setproctitle
|
||||
import argparse
|
||||
import shutil
|
||||
from multiprocessing import Process, connection
|
||||
|
||||
import DPpack.Dice as Dice
|
||||
import DPpack.Gaussian as Gaussian
|
||||
from DPpack.PTable import *
|
||||
from DPpack.SetGlobals import *
|
||||
@@ -17,6 +17,8 @@ if __name__ == '__main__':
|
||||
#### Read and store the arguments passed to the program ####
|
||||
#### and set the usage and help messages ####
|
||||
|
||||
setproctitle.setproctitle("diceplayer-current")
|
||||
|
||||
parser = argparse.ArgumentParser(prog='Diceplayer')
|
||||
parser.add_argument('--continue', dest='opt_continue' , default=False, action='store_true')
|
||||
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
|
||||
@@ -37,21 +39,28 @@ if __name__ == '__main__':
|
||||
outfile = open(args.outfile,'r')
|
||||
run_file = outfile.readlines()
|
||||
control_sequence = ' Step # '
|
||||
sucessfull_sequence = '+----------------------------------------------------------------------------------------+'
|
||||
|
||||
for line in run_file:
|
||||
if control_sequence in line:
|
||||
cyc = int(line[-2]) + 1
|
||||
cyc = int(line[-2])
|
||||
if sucessfull_sequence in line:
|
||||
cyc += 1
|
||||
|
||||
|
||||
outfile.close()
|
||||
os.rename(os.path.abspath(args.outfile),os.path.abspath(args.outfile)+".backup")
|
||||
outfile = open(args.outfile,'w')
|
||||
|
||||
if os.path.isfile(args.outfile+".backup"):
|
||||
os.remove(args.outfile+".backup")
|
||||
|
||||
if os.path.exists(args.outfile):
|
||||
os.rename(os.path.abspath(args.outfile),os.path.abspath(args.outfile)+".backup")
|
||||
outfile = open(args.outfile,'w')
|
||||
os.rename(args.outfile,args.outfile+".backup")
|
||||
outfile = open(args.outfile,'w',1)
|
||||
|
||||
elif os.path.exists(args.outfile):
|
||||
os.rename(args.outfile, args.outfile+".backup")
|
||||
outfile = open(args.outfile,'w',1)
|
||||
else:
|
||||
outfile = open(args.outfile,"w")
|
||||
outfile = open(args.outfile,"w",1)
|
||||
|
||||
except EnvironmentError as err:
|
||||
sys.exit(err)
|
||||
@@ -71,7 +80,10 @@ if __name__ == '__main__':
|
||||
internal.read_keywords()
|
||||
|
||||
if args.opt_continue:
|
||||
internal.player.cyc = cyc
|
||||
try:
|
||||
internal.player.initcyc = cyc
|
||||
except:
|
||||
sys.exit("Error: There is no sutable run.log file to continue the previous process")
|
||||
|
||||
internal.check_keywords()
|
||||
internal.print_keywords()
|
||||
@@ -106,17 +118,27 @@ if __name__ == '__main__':
|
||||
internal.outfile.write(90 * "=")
|
||||
internal.outfile.write("\n")
|
||||
|
||||
if not args.opt_continue:
|
||||
make_simulation_dir()
|
||||
else:
|
||||
simdir = "simfiles"
|
||||
stepdir = "step{:02d}".format(internal.player.initcyc)
|
||||
if os.path.exists(simdir+os.sep+stepdir):
|
||||
shutil.rmtree(simdir+os.sep+stepdir)
|
||||
|
||||
#### Open the geoms.xyz file and prints the initial geometry if starting from zero
|
||||
|
||||
if internal.player.cyc == 1:
|
||||
if internal.player.initcyc == 1:
|
||||
try:
|
||||
geomsfh = open("geoms.xyz", "w", 1)
|
||||
path = "geoms.xyz"
|
||||
geomsfh = open(path, "w", 1)
|
||||
except EnvironmentError as err:
|
||||
sys.exit(err)
|
||||
internal.system.print_geom(0, geomsfh)
|
||||
else:
|
||||
try:
|
||||
geomsfh = open("geoms.xyz", "A", 1)
|
||||
path = "geoms.xyz"
|
||||
geomsfh = open(path, "a", 1)
|
||||
except EnvironmentError as err:
|
||||
sys.exit(err)
|
||||
|
||||
@@ -126,10 +148,10 @@ if __name__ == '__main__':
|
||||
position = internal.system.molecule[0].read_position()
|
||||
|
||||
## If restarting, read the last gradient and hessian
|
||||
if internal.player.cyc > 1:
|
||||
if internal.player.qmprog in ("g03", "g09", "g16"):
|
||||
Gaussian.read_forces("grad_hessian.dat")
|
||||
Gaussian.read_hessian_fchk("grad_hessian.dat")
|
||||
# if internal.player.initcyc > 1:
|
||||
# if internal.player.qmprog in ("g03", "g09", "g16"):
|
||||
# Gaussian.read_forces("grad_hessian.dat")
|
||||
# Gaussian.read_hessian_fchk("grad_hessian.dat")
|
||||
|
||||
#if player['qmprog'] == "molcas":
|
||||
#Molcas.read_forces("grad_hessian.dat")
|
||||
@@ -138,21 +160,16 @@ if __name__ == '__main__':
|
||||
###
|
||||
### Start the iterative process
|
||||
###
|
||||
|
||||
internal.outfile.write("\n" + 90 * "-" + "\n")
|
||||
|
||||
for cycle in range(internal.player.cyc, internal.player.cyc + internal.player.maxcyc):
|
||||
for cycle in range(internal.player.initcyc, internal.player.initcyc + internal.player.maxcyc):
|
||||
|
||||
internal.outfile.write("\n" + 90 * "-" + "\n")
|
||||
internal.outfile.write("{} Step # {}\n".format(40 * " ", cycle))
|
||||
internal.outfile.write(90 * "-" + "\n\n")
|
||||
internal.outfile.flush()
|
||||
|
||||
|
||||
make_step_dir(cycle)
|
||||
|
||||
if internal.player.altsteps == 0 or internal.player.cyc == 1:
|
||||
internal.dice.randominit = True
|
||||
else:
|
||||
internal.dice.randominit = False
|
||||
|
||||
####
|
||||
#### Start block of parallel simulations
|
||||
####
|
||||
@@ -180,6 +197,8 @@ if __name__ == '__main__':
|
||||
|
||||
for proc in range(1, internal.player.nprocs + 1):
|
||||
internal.print_last_config(cycle, proc)
|
||||
|
||||
internal.outfile.write("\n+" + 88 * "-" + "+\n")
|
||||
|
||||
####
|
||||
#### End of parallel simulations block
|
||||
@@ -326,4 +345,4 @@ if __name__ == '__main__':
|
||||
# internal.outfile.close()
|
||||
# ####
|
||||
# #### End of the program
|
||||
# ####
|
||||
# ####
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
G 2 4 6 8 10 12 13 15 17 20
|
||||
M 2 3 4 5 6 7 8 19 20 22
|
||||
Z 23 25 26 27 28 29
|
||||
|
||||
1602
new_cyclo.xyz
1602
new_cyclo.xyz
File diff suppressed because it is too large
Load Diff
1602
new_cyclo.xyz.new
1602
new_cyclo.xyz.new
File diff suppressed because it is too large
Load Diff
1782
new_cyclo.xyz.new2
1782
new_cyclo.xyz.new2
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
initcyc = -4 pode?
|
||||
maxcyc = 1
|
||||
forces = yes
|
||||
nprocs = 2
|
||||
|
||||
# dice
|
||||
#nmol = aslkj 1 20 slkdfj
|
||||
dens = 0.75
|
||||
nsteps = 7000 2500 3876
|
||||
isave = 1340
|
||||
ljname = phb.pot
|
||||
51
phb.pot
51
phb.pot
@@ -1,51 +0,0 @@
|
||||
*
|
||||
2
|
||||
31 PHENOL BLUE geom/chg MP2/aug-cc-pVTZ Charge MK LJ OPLSAA
|
||||
1 6 -4.400337 0.665513 0.414312 -0.38759300 0.0700 3.5500
|
||||
1 6 -4.499567 -0.672788 -0.153273 0.80400100 0.0700 3.5500
|
||||
1 6 -3.256300 -1.289216 -0.613514 -0.33849100 0.0700 3.5500
|
||||
1 6 -2.058491 -0.668069 -0.486739 -0.22078300 0.0700 3.5500
|
||||
1 6 -1.971143 0.651479 0.105111 0.56352700 0.0700 3.5500
|
||||
1 6 -3.206008 1.296843 0.497122 -0.14537200 0.0700 3.5500
|
||||
2 8 -5.594533 -1.253085 -0.287655 -0.71446100 0.2100 2.9600
|
||||
3 7 -0.874044 1.358704 0.276359 -0.72179200 0.1700 3.2500
|
||||
4 6 0.387854 0.815120 0.144104 0.60712300 0.0700 3.5500
|
||||
4 6 1.407755 1.658002 -0.332615 -0.29547600 0.0700 3.5500
|
||||
4 6 0.759497 -0.468150 0.587914 -0.34666100 0.0700 3.5500
|
||||
4 6 2.710211 1.215186 -0.461194 -0.29854600 0.0700 3.5500
|
||||
4 6 2.073539 -0.898835 0.508310 -0.23428400 0.0700 3.5500
|
||||
4 6 3.080760 -0.089365 -0.061116 0.29465100 0.0700 3.5500
|
||||
5 7 4.372382 -0.539792 -0.201825 -0.19049700 0.1700 3.2500
|
||||
6 6 5.419802 0.438244 -0.438362 -0.21318300 0.0660 3.5000
|
||||
6 6 4.763609 -1.735216 0.522254 -0.22542000 0.0660 3.5000
|
||||
7 1 6.366998 -0.085365 -0.519616 0.10984000 0.0300 2.5000
|
||||
7 1 5.251961 0.966123 -1.374211 0.07714000 0.0300 2.5000
|
||||
7 1 5.495169 1.174115 0.367485 0.12575800 0.0300 2.5000
|
||||
7 1 4.158375 -2.584419 0.214461 0.08322900 0.0300 2.5000
|
||||
7 1 5.796953 -1.962538 0.280411 0.11536100 0.0300 2.5000
|
||||
7 1 4.674161 -1.617074 1.606614 0.12144000 0.0300 2.5000
|
||||
7 1 0.028134 -1.095538 1.080074 0.17943400 0.0300 2.4200
|
||||
7 1 2.318762 -1.865762 0.919126 0.17725000 0.0300 2.4200
|
||||
7 1 3.451018 1.898797 -0.846692 0.19884400 0.0300 2.4200
|
||||
7 1 1.147588 2.669090 -0.614979 0.17338800 0.0300 2.4200
|
||||
7 1 -3.119300 2.296790 0.900595 0.15153400 0.0300 2.4200
|
||||
7 1 -5.315819 1.136106 0.744794 0.20528900 0.0300 2.4200
|
||||
7 1 -3.338131 -2.250367 -1.102310 0.18436700 0.0300 2.4200
|
||||
7 1 -1.163740 -1.117915 -0.893805 0.16038200 0.0300 2.4200
|
||||
16 PLACEHOLDER
|
||||
1 6 0.672026 -2.823446 0.002631 -0.11500000 0.0700 3.5500
|
||||
1 6 2.072026 -2.823446 0.002631 -0.11500000 0.0700 3.5500
|
||||
1 6 2.768235 -1.617645 0.002633 -0.11500000 0.0700 3.5500
|
||||
1 6 2.068235 -0.405210 0.002635 -0.11500000 0.0700 3.5500
|
||||
1 14 0.675894 -0.405219 0.002635 0.15000000 0.0700 3.5500
|
||||
1 104 -0.024198 -1.617602 0.002633 -0.11500000 0.0700 3.5500
|
||||
2 1 0.132026 -3.758753 0.002629 0.11500000 0.0300 2.4200
|
||||
2 1 2.612026 -3.758753 0.002629 0.11500000 0.0300 2.4200
|
||||
2 1 2.608235 0.530098 0.002636 0.11500000 0.0300 2.4200
|
||||
2 1 -1.104198 -1.617602 0.002633 0.11500000 0.0300 2.4200
|
||||
3 8 -0.004114 0.772571 0.002637 -0.58500000 0.1700 3.0700
|
||||
3 1 0.619778 1.502200 0.002638 0.43500000 0.0000 0.0000
|
||||
4 6 4.278235 -1.617645 0.002633 0.11500000 0.1700 3.8000
|
||||
4 1 4.634902 -0.743994 0.507036 0.00000000 0.0000 0.0000
|
||||
4 1 4.634902 -2.491297 0.507036 0.00000000 0.0000 0.0000
|
||||
4 1 4.634902 -1.617645 -1.006173 0.00000000 0.0000 0.0000
|
||||
108
run.log
108
run.log
@@ -5,7 +5,7 @@
|
||||
Your python version is 3.6.9 (default, Jan 26 2021, 15:33:00)
|
||||
[GCC 8.4.0]
|
||||
|
||||
Program started on Friday, 05 Nov 2021 at 04:36:09
|
||||
Program started on Saturday, 20 Nov 2021 at 14:52:20
|
||||
|
||||
Environment variables:
|
||||
OMP_STACKSIZE = Not set
|
||||
@@ -15,9 +15,9 @@ OMP_STACKSIZE = Not set
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
altsteps = 20000
|
||||
cyc = 1
|
||||
freq = no
|
||||
ghosts = no
|
||||
initcyc = 1
|
||||
lps = no
|
||||
maxcyc = 3
|
||||
maxstep = 0.3
|
||||
@@ -35,15 +35,15 @@ vdwforces = no
|
||||
|
||||
combrule = *
|
||||
dens = 0.75
|
||||
init = yes
|
||||
isave = 1000
|
||||
ljname = phb.pot
|
||||
ljname = phb.ljc
|
||||
ncores = 3
|
||||
nmol = 1 100
|
||||
nmol = 1 50
|
||||
nstep = 40000 60000 50000
|
||||
outname = phb
|
||||
press = 1.0
|
||||
progname = dice
|
||||
randominit = first
|
||||
temp = 300.0
|
||||
title = Diceplayer run
|
||||
upbuf = 360
|
||||
@@ -65,7 +65,7 @@ Program g16 found at /usr/local/g16/g16
|
||||
Program formchk found at /usr/local/g16/formchk
|
||||
|
||||
==========================================================================================
|
||||
Potential parameters from file phb.pot:
|
||||
Potential parameters from file phb.ljc:
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Combination rule: *
|
||||
@@ -131,7 +131,7 @@ Lbl AN X Y Z Charge Epsilon Sigma Mass
|
||||
|
||||
==========================================================================================
|
||||
|
||||
Molecule type 1 - PHENOL:
|
||||
Molecule type 1 - PHENOL_BLUE:
|
||||
|
||||
Center of mass = ( -0.0000 , 0.0000 , 0.0000 )
|
||||
Moments of inertia = 3.144054E+02 2.801666E+03 3.027366E+03
|
||||
@@ -190,49 +190,67 @@ Starting the iterative process.
|
||||
Step # 1
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Simulation process step01/p01 initiated with pid 7039
|
||||
Simulation process step01/p02 initiated with pid 7040
|
||||
Simulation process step01/p03 initiated with pid 7041
|
||||
Simulation process step01/p04 initiated with pid 7042
|
||||
p03> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 04:36:09
|
||||
p03> NPT thermalization initiated on 05 Nov 2021 at 04:42:40
|
||||
p01> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 04:36:09
|
||||
p01> NPT thermalization initiated on 05 Nov 2021 at 04:42:40
|
||||
p04> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 04:36:09
|
||||
p04> NPT thermalization initiated on 05 Nov 2021 at 04:42:52
|
||||
p02> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 04:36:09
|
||||
p02> NPT thermalization initiated on 05 Nov 2021 at 04:42:54
|
||||
Simulation process simfiles/step01/p02 initiated with pid 15516
|
||||
p02> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 14:52:20
|
||||
Simulation process simfiles/step01/p01 initiated with pid 15515
|
||||
p01> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 14:52:20
|
||||
Simulation process simfiles/step01/p03 initiated with pid 15517
|
||||
p03> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 14:52:20
|
||||
Simulation process simfiles/step01/p04 initiated with pid 15518
|
||||
p04> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 14:52:20
|
||||
p03> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 14:54:12
|
||||
p04> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 14:54:13
|
||||
p02> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 14:54:13
|
||||
p01> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 14:54:13
|
||||
p03> NPT production initiated on 20 Nov 2021 at 14:57:16
|
||||
p02> NPT production initiated on 20 Nov 2021 at 14:57:19
|
||||
p04> NPT production initiated on 20 Nov 2021 at 14:57:20
|
||||
p01> NPT production initiated on 20 Nov 2021 at 14:57:21
|
||||
p03> ----- NPT production finished on 20 Nov 2021 at 15:00:16
|
||||
p02> ----- NPT production finished on 20 Nov 2021 at 15:00:21
|
||||
p04> ----- NPT production finished on 20 Nov 2021 at 15:00:23
|
||||
p01> ----- NPT production finished on 20 Nov 2021 at 15:00:27
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
+----------------------------------------------------------------------------------------+
|
||||
Step # 2
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Simulation process step02/p01 initiated with pid 7127
|
||||
Simulation process step02/p02 initiated with pid 7128
|
||||
Simulation process step02/p03 initiated with pid 7129
|
||||
Simulation process step02/p04 initiated with pid 7130
|
||||
p02> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:04:04
|
||||
p02> NPT thermalization initiated on 05 Nov 2021 at 05:10:41
|
||||
p01> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:04:04
|
||||
p01> NPT thermalization initiated on 05 Nov 2021 at 05:10:49
|
||||
p03> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:04:04
|
||||
p03> NPT thermalization initiated on 05 Nov 2021 at 05:10:51
|
||||
p04> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:04:04
|
||||
p04> NPT thermalization initiated on 05 Nov 2021 at 05:10:57
|
||||
Simulation process simfiles/step02/p02 initiated with pid 15559
|
||||
p02> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:00:27
|
||||
Simulation process simfiles/step02/p01 initiated with pid 15558
|
||||
p01> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:00:27
|
||||
Simulation process simfiles/step02/p03 initiated with pid 15560
|
||||
p03> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:00:27
|
||||
Simulation process simfiles/step02/p04 initiated with pid 15561
|
||||
p04> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:00:27
|
||||
p03> NPT production initiated on 20 Nov 2021 at 15:01:30
|
||||
p01> NPT production initiated on 20 Nov 2021 at 15:01:30
|
||||
p02> NPT production initiated on 20 Nov 2021 at 15:01:31
|
||||
p04> NPT production initiated on 20 Nov 2021 at 15:01:31
|
||||
p03> ----- NPT production finished on 20 Nov 2021 at 15:04:29
|
||||
p02> ----- NPT production finished on 20 Nov 2021 at 15:04:33
|
||||
p01> ----- NPT production finished on 20 Nov 2021 at 15:04:34
|
||||
p04> ----- NPT production finished on 20 Nov 2021 at 15:04:37
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
+----------------------------------------------------------------------------------------+
|
||||
Step # 3
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Simulation process step03/p01 initiated with pid 7182
|
||||
Simulation process step03/p02 initiated with pid 7183
|
||||
Simulation process step03/p03 initiated with pid 7184
|
||||
Simulation process step03/p04 initiated with pid 7185
|
||||
p04> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:32:04
|
||||
p04> NPT thermalization initiated on 05 Nov 2021 at 05:38:40
|
||||
p01> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:32:04
|
||||
p01> NPT thermalization initiated on 05 Nov 2021 at 05:38:46
|
||||
p03> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:32:04
|
||||
p03> NPT thermalization initiated on 05 Nov 2021 at 05:38:51
|
||||
p02> NVT thermalization initiated (from random configuration) on 05 Nov 2021 at 05:32:04
|
||||
p02> NPT thermalization initiated on 05 Nov 2021 at 05:38:51
|
||||
Simulation process simfiles/step03/p01 initiated with pid 15661
|
||||
p01> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:04:37
|
||||
Simulation process simfiles/step03/p02 initiated with pid 15662
|
||||
p02> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:04:37
|
||||
Simulation process simfiles/step03/p04 initiated with pid 15664
|
||||
p04> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:04:37
|
||||
Simulation process simfiles/step03/p03 initiated with pid 15663
|
||||
p03> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 15:04:37
|
||||
p03> NPT production initiated on 20 Nov 2021 at 15:05:41
|
||||
p01> NPT production initiated on 20 Nov 2021 at 15:05:42
|
||||
p04> NPT production initiated on 20 Nov 2021 at 15:05:42
|
||||
p02> NPT production initiated on 20 Nov 2021 at 15:05:44
|
||||
p01> ----- NPT production finished on 20 Nov 2021 at 15:08:44
|
||||
p03> ----- NPT production finished on 20 Nov 2021 at 15:08:45
|
||||
p04> ----- NPT production finished on 20 Nov 2021 at 15:08:48
|
||||
p02> ----- NPT production finished on 20 Nov 2021 at 15:08:51
|
||||
|
||||
+----------------------------------------------------------------------------------------+
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Your python version is 3.6.9 (default, Jan 26 2021, 15:33:00)
|
||||
[GCC 8.4.0]
|
||||
|
||||
Program started on Friday, 05 Nov 2021 at 04:35:58
|
||||
Program started on Saturday, 20 Nov 2021 at 13:29:59
|
||||
|
||||
Environment variables:
|
||||
OMP_STACKSIZE = Not set
|
||||
@@ -15,11 +15,11 @@ OMP_STACKSIZE = Not set
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
altsteps = 20000
|
||||
cyc = 1
|
||||
freq = no
|
||||
ghosts = no
|
||||
initcyc = 1
|
||||
lps = no
|
||||
maxcyc = 3
|
||||
maxcyc = 4
|
||||
maxstep = 0.3
|
||||
nprocs = 4
|
||||
opt = no
|
||||
@@ -35,15 +35,15 @@ vdwforces = no
|
||||
|
||||
combrule = *
|
||||
dens = 0.75
|
||||
init = yes
|
||||
isave = 1000
|
||||
ljname = phb.pot
|
||||
ljname = phb.ljc
|
||||
ncores = 3
|
||||
nmol = 1 100
|
||||
nmol = 1 50
|
||||
nstep = 40000 60000 50000
|
||||
outname = phb
|
||||
press = 1.0
|
||||
progname = dice
|
||||
randominit = first
|
||||
temp = 300.0
|
||||
title = Diceplayer run
|
||||
upbuf = 360
|
||||
@@ -65,7 +65,7 @@ Program g16 found at /usr/local/g16/g16
|
||||
Program formchk found at /usr/local/g16/formchk
|
||||
|
||||
==========================================================================================
|
||||
Potential parameters from file phb.pot:
|
||||
Potential parameters from file phb.ljc:
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Combination rule: *
|
||||
@@ -131,7 +131,7 @@ Lbl AN X Y Z Charge Epsilon Sigma Mass
|
||||
|
||||
==========================================================================================
|
||||
|
||||
Molecule type 1 - PHENOL:
|
||||
Molecule type 1 - PHENOL_BLUE:
|
||||
|
||||
Center of mass = ( -0.0000 , 0.0000 , 0.0000 )
|
||||
Moments of inertia = 3.144054E+02 2.801666E+03 3.027366E+03
|
||||
@@ -190,3 +190,19 @@ Starting the iterative process.
|
||||
Step # 1
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Simulation process simfiles/step01/p01 initiated with pid 14014
|
||||
p01> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 13:29:59
|
||||
Simulation process simfiles/step01/p02 initiated with pid 14015
|
||||
p02> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 13:29:59
|
||||
Simulation process simfiles/step01/p03 initiated with pid 14016
|
||||
p03> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 13:29:59
|
||||
Simulation process simfiles/step01/p04 initiated with pid 14017
|
||||
p04> NVT thermalization initiated (from random configuration) on 20 Nov 2021 at 13:29:59
|
||||
p03> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 13:31:50
|
||||
p01> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 13:31:51
|
||||
p04> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 13:31:52
|
||||
p02> NPT thermalization finished (from previous configuration) on 20 Nov 2021 at 13:31:52
|
||||
p03> NPT production initiated on 20 Nov 2021 at 13:34:53
|
||||
p02> NPT production initiated on 20 Nov 2021 at 13:34:57
|
||||
p01> NPT production initiated on 20 Nov 2021 at 13:34:58
|
||||
p04> NPT production initiated on 20 Nov 2021 at 13:35:00
|
||||
|
||||
64
test4.py
64
test4.py
@@ -1,64 +0,0 @@
|
||||
#!/opt/local/bin/python3
|
||||
|
||||
import sys, math
|
||||
from math import pi
|
||||
import numpy as np
|
||||
from numpy import linalg
|
||||
from numpy.random import rand, random
|
||||
from copy import deepcopy
|
||||
|
||||
from DPpack.MolHandling import *
|
||||
from DPpack.PTable import *
|
||||
|
||||
|
||||
natoms = input("# of atoms: ")
|
||||
natoms = int(natoms)
|
||||
file = input("xyz file: ")
|
||||
|
||||
molecules=[]
|
||||
|
||||
with open(file) as fh:
|
||||
xyzfile = fh.readlines()
|
||||
|
||||
file += ".new"
|
||||
file2 = file + "2"
|
||||
fh = open(file, "w")
|
||||
fh2 = open(file2, "w")
|
||||
|
||||
total_atoms = int(xyzfile.pop(0).split()[0])
|
||||
fh.write("{}\n".format(total_atoms))
|
||||
comment = xyzfile.pop(0)
|
||||
fh.write("{}".format(comment))
|
||||
|
||||
nmols = round(total_atoms/natoms)
|
||||
for i in range(nmols):
|
||||
molecules.append([])
|
||||
for j in range(natoms):
|
||||
molecules[i].append({})
|
||||
line = xyzfile.pop(0).split()
|
||||
molecules[i][j]['na'] = int(line[0])
|
||||
molecules[i][j]['rx'] = float(line[1])
|
||||
molecules[i][j]['ry'] = float(line[2])
|
||||
molecules[i][j]['rz'] = float(line[3])
|
||||
molecules[i][j]['mass'] = atommass[molecules[0][j]['na']]
|
||||
|
||||
for atom in molecules[0]:
|
||||
fh.write("{:>4s} {:>11.5f} {:>11.5f} {:>11.5f}\n".format(atomsymb[atom['na']],
|
||||
atom['rx'], atom['ry'], atom['rz']))
|
||||
fh2.write("{:>4s} {:>11.5f} {:>11.5f} {:>11.5f}\n".format(atomsymb[atom['na']],
|
||||
atom['rx'], atom['ry'], atom['rz']))
|
||||
|
||||
for i in range(1, nmols):
|
||||
fh2.write("{}\n".format(natoms))
|
||||
fh2.write("{}".format(comment))
|
||||
rmsd, projected_mol = rmsd_fit(molecules[i], molecules[0])
|
||||
print("{:>9.5f}".format(rmsd))
|
||||
for atom in projected_mol:
|
||||
fh.write("{:>4s} {:>11.5f} {:>11.5f} {:>11.5f}\n".format(atomsymb[atom['na']],
|
||||
atom['rx'], atom['ry'], atom['rz']))
|
||||
fh2.write("{:>4s} {:>11.5f} {:>11.5f} {:>11.5f}\n".format(atomsymb[atom['na']],
|
||||
atom['rx'], atom['ry'], atom['rz']))
|
||||
|
||||
fh.close()
|
||||
fh2.close()
|
||||
|
||||
Reference in New Issue
Block a user