Skip to content

Commit

Permalink
auto
Browse files Browse the repository at this point in the history
  • Loading branch information
dimonaks committed Apr 3, 2018
1 parent 267e42b commit b8c11db
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
7 changes: 5 additions & 2 deletions calc_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,14 +1846,17 @@ def inherit_icalc(inherit_type, it_new, ver_new, id_base, calc = None, st_base =

new.len_units = 'Angstrom' #! Because from VASP


# print(id_base_st_type)
# sys.exit()

new.version = ver_new

if id_base_st_type == 'init':
st = new.init
elif id_base_st_type == 'end':
st = new.end
if not hasattr(st, 'znucl'):
printlog('Error! end structure of', new.id, 'is empty! Use either init or finish calculation!')

# print(st.typat)

Expand Down Expand Up @@ -2194,7 +2197,7 @@ def inherit_icalc(inherit_type, it_new, ver_new, id_base, calc = None, st_base =


def res_loop(it, setlist, verlist, calc = None, varset = None, analys_type = 'no', b_id = None,
typconv='', up = "", imp1 = None, imp2 = None, matr = None, voronoi = False, r_id = None, readfiles = True, plot = True, show = '',
typconv='', up = "", imp1 = None, imp2 = None, matr = None, voronoi = False, r_id = None, readfiles = True, plot = True, show = 'fo',
comment = None, input_geo_format = None, savefile = None, energy_ref = 0, ifolder = None, bulk_mul = 1, inherit_option = None,
calc_method = None, u_ramping_region = None, input_geo_file = None, corenum = None, run = None, input_st= None,
ortho = None, mat_proj_cell = None,
Expand Down
21 changes: 20 additions & 1 deletion classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@
"""


class cd:
"""Context manager for changing the current working directory"""
def __init__(self, newPath):
self.newPath = os.path.expanduser(newPath)

def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)

def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)






class Description():
"""
Objects of this class include just folder and description of specific calculation.
Expand Down Expand Up @@ -2446,7 +2463,9 @@ def actualize_set(self, curset = None):
ns = len(spec_mom_is);
number_of_ord = int(math.factorial(ns) / math.factorial(0.5 * ns)**2)

if 1:
if number_of_ord > 10000:
printlog('Attention! Too much orderings (1000), skipping ...')
else:
nords = 10
use_each = number_of_ord // nords # spin() should be improved to find the AFM state based on the number of configuration
if use_each == 0:
Expand Down
2 changes: 1 addition & 1 deletion geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def ortho_vec(rprim, ortho_sizes = None):



def create_supercell(st, mul_matrix, test_overlap = False, mp = 2, bound = 0.01):
def create_supercell(st, mul_matrix, test_overlap = False, mp = 4, bound = 0.01):
"""
st (Structure) -
mul_matrix (3x3 ndarray of int) - for example created by *ortho_ vec()*
Expand Down
18 changes: 17 additions & 1 deletion header.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def runBash(cmd, env = None, detached = False):
printlog('running in BASH:', cmd)
my_env = os.environ.copy()
# my_env["PATH"] = "/opt/local/bin:/opt/local/sbin:" + my_env["PATH"]
p = subprocess.Popen(cmd, executable='/bin/bash', shell=True, stdout=stdout, stderr = stderr, stdin = None, env = my_env)
p = subprocess.Popen(cmd,
# executable='/bin/bash',
shell=True, stdout=stdout, stderr = stderr, stdin = None, env = my_env)
# print (cmd)
# print 'Bash output is\n'+out
# print ( str(out, 'utf-8') )
Expand All @@ -286,3 +288,17 @@ def runBash(cmd, env = None, detached = False):



def run_win_cmd(cmd):
#example for windows
result = []
process = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in process.stdout:
result.append(line)
errcode = process.returncode
for line in result:
print(line)
if errcode is not None:
raise Exception('cmd %s failed, see above for details', cmd)
23 changes: 18 additions & 5 deletions neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import copy, sys, os
import numpy as np
from operator import itemgetter

import shutil

from header import print_and_log, printlog, runBash
import header
from calc_manage import add_loop, res_loop, add_des, inherit_ngkpt
from functions import return_atoms_to_cell, push_to_server, invert
from inout import write_xyz

from small_functions import is_list_like
from classes import CalculationVasp
from small_functions import is_list_like, makedir
from classes import CalculationVasp, cd
from impurity import find_pores
from tabulate import tabulate
from geo import xcart2xred, xred2xcart, local_surrounding, replic, determine_symmetry_positions
Expand Down Expand Up @@ -735,9 +735,22 @@ def unique_by_key(elements, key=None):

st1s.write_poscar('xyz/POSCAR1')
st2s.write_poscar('xyz/POSCAR2')
a = runBash('cd xyz; '+header.PATH2NEBMAKE+' POSCAR1 POSCAR2 3')
# print(a)
runBash('cd xyz; mkdir '+it_new+'_all;'+"""for i in {00..04}; do cp $i/POSCAR """+ it_new+'_all/POSCAR$i; done; rm -r 00 01 02 03 04')
# runBash('cd xyz; mkdir '+it_new+'_all;'+"""for i in {00..04}; do cp $i/POSCAR """+ it_new+'_all/POSCAR$i; done; rm -r 00 01 02 03 04')

with cd('xyz'):
a = runBash(header.PATH2NEBMAKE+' POSCAR1 POSCAR2 3')

dst = it_new+'_all'
makedir(dst)
for f in ['00', '01', '02', '03', '04']:
shutil.move(f+'/POSCAR', dst+'/POSCAR'+f)
shutil.rmtree(f)





#prepare calculations
# sys.exit()

Expand Down

0 comments on commit b8c11db

Please sign in to comment.