def main(): const = ConstantsClass() const.k_B = 1.38065e-26 #const.Temp = 298 #const.Temp = 303.15 const.Temp = 300.0 const.N_A = 6.002214e23 const.betainv = const.Temp * const.k_B * const.N_A # 1/beta (kJ / mol) const.beta = 1.0/const.betainv const.jobfilepath = "./jobfiles_all/" const.MarkovNetworkQ = True const.TSFEmax = 1.0e30 const.EQFEmax = 1.0e30 const.stateQN = 400 #const.Pmax = 1.0e30 const.Pmax = 36.0 #const.samePrange = 2.0 #const.EQFEmax_Prange = 20.0 const.samePrange = 0.0 const.EQFEmax_Prange = 1.0e30 #const.k_min = 1.0e-12 # cut off in order of second #const.k_min = 1.0e-16 # cut off in order of hour const.k_min = 1.0e-20 #const.stateNmin = 1.0e-20 # #const.deltak_th = 1.0e-16 const.deltak_th = 0.0 #const.stateNmin = 1.0e-10 const.stateNmin = 0.0 const.is_bilayer = True const.diffusionQ = False const.oneoutsideEQ = True const.asymmetricQ = True const.rm_disconnections = False const.sameEQthreshold = [0.2 for _ in range(4)] + [2.0] #const.sameEQthreshold = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 2.0] const.maxtime = 47.0 const.calc_mpiQ = True const.cythonQ = True const = mkconst.main(const) from mpi4py import MPI const.comm = MPI.COMM_WORLD const.rank = const.comm.Get_rank() const.size = const.comm.Get_size() const.root = 0 const.k_RCMC = 1.0 #const.ksim_Z = 30 const.t_delta = 1.0 / const.k_RCMC / 10 #kSimulation_oneZ.main(const) for const.ksim_Z in range(31): if const.ksim_Z % const.size != const.rank: continue kSimulation_oneZ.main(const)
def main(): const = ConstantsClass() const.k_B = 1.38065e-26 #const.Temp = 298 #const.Temp = 303.15 const.Temp = 300.0 const.N_A = 6.002214e23 const.betainv = const.Temp * const.k_B * const.N_A # 1/beta (kJ / mol) const.MarkovNetworkQ = False const.TSFEmax = 1.0e30 const.EQFEmax = 1.0e30 const.stateQN = 400 #const.Pmax = 1.0e30 const.Pmax = 35.0 #const.samePrange = 2.0 #const.EQFEmax_Prange = 20.0 const.samePrange = 0.0 const.EQFEmax_Prange = 1.0e30 #const.k_min = 1.0e-12 # cut off in order of second const.k_min = 1.0e-16 # cut off in order of hour #const.k_min = 1.0e-20 #const.stateNmin = 1.0e-20 # #const.deltak_th = 1.0e-16 const.deltak_th = 0.0 #const.stateNmin = 1.0e-10 const.stateNmin = 0.0 const.is_bilayer = False const.diffusionQ = False const.oneoutsideEQ = True const.asymmetricQ = True const.rm_disconnections = False const.sameEQthreshold = [0.2 for _ in range(4)] + [2.0] #const.sameEQthreshold = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 2.0] const.maxtime = 47.0 const.calc_mpiQ = True const.cythonQ = True const = mkconst.main(const) from mpi4py import MPI const.comm = MPI.COMM_WORLD const.rank = const.comm.Get_rank() const.size = const.comm.Get_size() const.root = 0 const.jobfilepath = "./" for i in range(36): os.chdir("./jobfiles_%s"%i) RCMC.main(const) os.chdir("../")
def main(): constC = constClass() constC.Temp = 300.0 # tempeture (K) k_B = 1.38065e-26 # Boltzmann constant (kJ / K) N_A = 6.002214e23 # Avogadro constant (mol^-1) constC.betainv = constC.Temp * k_B * N_A # 1/beta (kJ / mol) constC.beta = 1.0 / constC.betainv constC.initialpointN = 1000 #constC.initialpointN = 0 #constC.calc_cupyQ = True constC.cythonQ = True #constC.calc_mpiQ = True constC.calc_mpiQ = False constC.use_jacQ = True constC.sameEQthreshold = [0.2 for _ in range(4)] + [2.0] constC.IOEsphereA_initial = 0.10 constC.IOEsphereA_dist = 0.02 constC.deltas0 = 0.20 constC.deltas = 0.01 #constC.lADDnQ = True #constC.IOEl = 10 constC.coeffPickNlist = [] #! SET iteration 400000 #constC.coeffabsmin = 1.0e-3 constC.periodicQ = True constC.periodicmax = [np.pi for _ in range(4)] + [50.0] constC.periodicmin = [-np.pi for _ in range(4)] + [-50.0] constC.wallmax = [1.0e30 for _ in range(4)] + [50.0] constC.wallmin = [-1.0e30 for _ in range(4)] + [-50.0] #constC.EQwallmax = [ 1.0e30 for _ in range(4)] + [ 5.0] #constC.EQwallmin = [-1.0e30 for _ in range(4)] + [-5.0] #constC.EQwallmax = [ 1.0e30 for _ in range(4)] + [10.0] #constC.EQwallmin = [-1.0e30 for _ in range(4)] + [ 5.0] #constC.EQwallmax = [ 1.0e30 for _ in range(4)] + [20.0] #constC.EQwallmin = [-1.0e30 for _ in range(4)] + [10.0] #constC.EQwallmax = [ 1.0e30 for _ in range(4)] + [30.0] #constC.EQwallmin = [-1.0e30 for _ in range(4)] + [20.0] #constC.EQwallmax = [ 1.0e30 for _ in range(4)] + [40.0] #constC.EQwallmin = [-1.0e30 for _ in range(4)] + [30.0] constC.EQwallmax = [1.0e30 for _ in range(4)] + [35.0] constC.EQwallmin = [-1.0e30 for _ in range(4)] + [-35.0] constC.abslist = [False for _ in range(4)] + [True] #constC.x0randomQ = False #constC.chkBifurcationQ = True constC.x0randomQ = True constC.chkBifurcationQ = False constC.chkinitialTSQ = False constC.gridQ = True constC.grid_importQ = True constC.grid_min = [-np.pi for _ in range(4)] + [-50.0] constC.grid_max = [np.pi for _ in range(4)] + [50.0] constC.grid_bin = [100 for _ in range(4)] + [500] args = sys.argv currentpoint = sys.argv[2] #currentpoint = 35 constC.CVfixQ = True constC.fixlist = [(False, None)] * 4 + [(True, float(currentpoint))] constC.jobfilepath = "./jobfiles_%s/" % currentpoint if constC.calc_mpiQ: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() root = 0 else: comm = None rank = 0 root = 0 size = 1 if rank == root: if not os.path.exists(constC.jobfilepath): os.mkdir(constC.jobfilepath) constC = mkconst.main(constC) if rank == root: with open("./%s/constants.txt" % constC.jobfilepath, "w") as wf: wf.write(constC.writestr) plumedpath = './plumed.dat' VESclass = SHS4py.VESanalyzer.VESpotential(plumedpath, constC, rank, root, size, comm) initialpointlist = [] initialpointTSlist = [] initialpointlist, initialpointTSlist = importinitialpoint(constC) initialpointlist += importinitialpoint_random(constC) SHS4py.SHSearch(VESclass.f, VESclass.grad, VESclass.hessian, importinitialpointQ=False, initialpoints=initialpointlist, initialTSpoints=initialpointTSlist, SHSrank=rank, SHSroot=root, SHSsize=size, SHScomm=comm, const=constC)
def main(): """ template of the calculation of Metadynamics """ constC = constClass() Temp = 298.0 # tempeture (K) : must same with that of MD simulation k_B = 1.38065e-26 # Boltzmann constant (kJ / K) N_A = 6.002214e23 # Avogadro constant (mol^-1) constC.betainv = Temp * k_B * N_A # 1/beta (kJ / mol) constC.beta = 1.0 / constC.betainv constC.threshold = 0.1 constC.sameEQthreshold = 0.05 constC.IOEsphereA_initial = 0.02 constC.IOEsphereA_dist = 0.005 constC.deltas0 = 0.01 constC.deltas = 0.005 constC.initialpointN = 100 constC.periodicQ = False #If CVs have periodic(like as angles or dihedrals), periodicQ must be True and define periodicmin and periodicmax. #For example, if you use dihedrals as CVs: #constC.periodicQ = True #constC.periodicmin = -np.pi #constC.periodicmax = np.pi constC.calc_mpiQ = False # package mpi4py is necessary constC.calc_cupyQ = False # package cupy is necessary constC.cythonQ = False # package cython and previous compile are necessary #If the trajectory is long, I recommend you to use mpi4py & cupy & cython with GPGPU machine. constC.WellTempairedQ = True constC.WT_Biasfactor = 6 #BIASFACTOR of the PLUMED setting. constC.digThreshold = 5 height = 0.5 #HEIGHT of the PLUMED setting. digTH = -height * constC.digThreshold constC = mkconst.main(constC) if constC.calc_mpiQ: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() root = 0 else: comm = None rank = 0 root = 0 size = 1 metaD = SHS4py.metaDanalyzer.Metad_result("./HILLS", constC) if size != 1: hillD = len(metaD.hillCs) // (constC.initialpointN // size) else: hillD = len(metaD.hillCs) // (constC.initialpointN) initialpointlist = [] for hillC in metaD.hillCs[::hillD]: initialpointlist.append(hillC.s) if size != 1: initialpointlist = comm.gather(initialpointlist, root=0) if rank == root: initialpointlist_gather = [] for initialpointlist_chunk in initialpointlist: initialpointlist_gather.extend(initialpointlist_chunk) else: initialpointlist_gather = None initialpointlist_gather = comm.bcast(initialpointlist_gather, root=0) else: initialpointlist_gather = initialpointlist SHS4py.SHSearch(metaD.f, metaD.grad, metaD.hessian, importinitialpointQ=False, initialpoints=initialpointlist_gather, SHSrank=rank, SHSroot=root, SHScomm=comm, optdigTH=digTH, const=constC)
def main(): const = ConstantsClass() const.k_B = 1.38065e-26 #const.Temp = 298 #const.Temp = 303.15 const.Temp = 300.0 const.N_A = 6.002214e23 const.betainv = const.Temp * const.k_B * const.N_A # 1/beta (kJ / mol) const.MarkovNetworkQ = True const.TSFEmax = 1.0e30 const.EQFEmax = 1.0e30 const.stateQN = 400 #const.Pmax = 1.0e30 const.Pmax = 36.0 #const.samePrange = 2.0 #const.EQFEmax_Prange = 20.0 const.samePrange = 0.0 const.EQFEmax_Prange = 1.0e30 #const.k_min = 1.0e-12 # cut off in order of second #const.k_min = 1.0e-16 # cut off in order of hour const.k_min = 1.0e-20 #const.stateNmin = 1.0e-20 # #const.deltak_th = 1.0e-16 const.deltak_th = 0.0 #const.stateNmin = 1.0e-10 const.stateNmin = 0.0 const.is_bilayer = True const.diffusionQ = True const.oneoutsideEQ = True const.asymmetricQ = True const.rm_disconnections = False const.sameEQthreshold = [0.2 for _ in range(4)] + [2.0] #const.sameEQthreshold = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 2.0] const.maxtime = 47.0 const.calc_mpiQ = True const.cythonQ = True const = mkconst.main(const) from mpi4py import MPI const.comm = MPI.COMM_WORLD const.rank = const.comm.Get_rank() const.size = const.comm.Get_size() const.root = 0 const.periodicQ = True const.periodicmax = np.array([np.pi for _ in range(4)] + [50.0]) const.periodicmin = np.array([-np.pi for _ in range(4)] + [-50.0]) const.useZpozitionQ = True const.colvarpath = [ #"../VESMW_100ns/run*", #"../VESMW_200ns/run*", #"../VESMW_300ns/run*", #"../VESMW_400ns/run*", "../VESMW_500ns/run*" ] #for z in range(36): #const.zpozition = z args = sys.argv const.zpozition = int(sys.argv[1]) const.jobfilepath = "./jobfiles_%s/" % const.zpozition COV2Diff.main(const)
def main(): """ """ constC = constClass() constC = mkconst.main(constC) constC.Temp = 300.0 # tempeture (K) k_B = 1.38065e-26 # Boltzmann constant (kJ / K) N_A = 6.002214e23 # Avogadro constant (mol^-1) constC.betainv = constC.Temp * k_B * N_A # 1/beta (kJ / mol) constC.beta = 1.0 / constC.betainv comm = None rank = 0 root = 0 size = 1 plumedpath = './plumed.dat' VESclass = VESanalyzer.VESpotential(plumedpath, constC, rank, root, size, comm) felimit = 99999 zlist = range(36) eqlist_all = [] tslist_all = [] connections_all = {} exporteqstr = "" eqpointindex = 0 exporttsstr = "" tspointindex = 0 for line in open("./diff_inner.csv"): angdiff_inner = float(line) break for line in open("./diff_outer.csv"): angdiff_outer = float(line) break for z in zlist: eqlist, tslist, connections, fricdic = importpoints(z) #eqpoint_femin = eqlist[0] G = nx.Graph() #print(len(set([x[0] for x in connections]))) for name1, name2 in connections: if "EQ" in name1: eqname = name1 tsname = name2 else: eqname = name2 tsname = name1 eqpoint = [point for point in eqlist if point.name == eqname] if len(eqpoint) == 0: print("ERROR; there is not %s in eqlist.csv" % eqname) exit() eqpoint = eqpoint[0] #if felimit < eqpoint.fe - eqpoint_femin.fe: #continue G.add_edge(name1, name2) G.add_edge(name2, name1) for eqpoint in eqlist: if not eqpoint.name in G.nodes(): continue eqpoint_femin = eqpoint break #eqlist_connected = [] #for eqpoint in eqlist: #if not eqpoint.name in G.nodes(): #continue #if nx.has_path(G, eqpoint_femin.name, eqpoint.name): #eqlist_connected.append(eqpoint) #eqlist = eqlist_connected tslist_connected = [] for tspoint in tslist: if not tspoint.name in G.nodes(): continue if nx.has_path(G, eqpoint_femin.name, tspoint.name): tslist_connected.append(tspoint) tslist = tslist_connected #exit() for eqpoint in eqlist: eqpointindex += 1 eqpoint.networkname = "EQ%05d" % eqpointindex exporteqstr += eqpoint.networkname for x in eqpoint.point: exporteqstr += ", %s" % x exporteqstr += ", %s" % eqpoint.z exporteqstr += ", %s\n" % eqpoint.fe for tspoint in tslist: eqpoints = [x for x in G.neighbors(tspoint.name)] if len(eqpoints) == 1: continue if len(eqpoints) != 2: print("ERROR; eqpoints = %s" % eqpoints) exit() eqpoint1 = [ point for point in eqlist if point.name == eqpoints[0] ][0] eqpoint2 = [ point for point in eqlist if point.name == eqpoints[1] ][0] deltafe = tspoint.fe - eqpoint1.fe #print(tspoint) #print(fricdic.keys()) k = fricdic[(eqpoint1.name, tspoint.name)] * np.exp( -constC.beta * deltafe) #eqedge = (eqpoint1.name, eqpoint2.name) eqedge = (eqpoint1.networkname, eqpoint2.networkname) if eqedge in connections_all.keys(): connections_all[eqedge] += k else: connections_all[eqedge] = k deltafe = tspoint.fe - eqpoint2.fe k = fricdic[(eqpoint2.name, tspoint.name)] * np.exp( -constC.beta * deltafe) eqedge = (eqpoint2.networkname, eqpoint1.networkname) if eqedge in connections_all.keys(): connections_all[eqedge] += k else: connections_all[eqedge] = k tspointindex += 1 tspoint.networkname = "TS%05d" % tspointindex exporttsstr += tspoint.networkname for x in tspoint.point: exporttsstr += ", %s" % x exporttsstr += ", %s" % tspoint.z exporttsstr += ", %s\n" % tspoint.fe zfric = float(open("./jobfiles_%s/fric_z.csv" % z).readline()) z_before = z - 1.0 if z < 25.0: angfric = angdiff_inner else: angfric = angdiff_outer if z_before < 25.0: angfric_before = angdiff_inner else: angfric_before = angdiff_outer #if 0 <= z_before < 35: if z != 0: connections_all = calcMarcofFric(eqlist, z, zfric, eqlist_before, zfric_before, angfric, angfric_before, connections_all, constC, VESclass) eqlist_before = eqlist tslist_before = tslist connections_before = connections zfric_before = zfric print("z = %s" % z) print("connections_all//Len = %s" % len(connections_all.keys())) if not os.path.exists("./jobfiles_all"): os.mkdir("./jobfiles_all") with open("./jobfiles_all/eqlist.csv", "w") as wf: wf.write(exporteqstr) with open("./jobfiles_all/tslist.csv", "w") as wf: wf.write(exporttsstr) Kmatstr = "" for edge in connections_all.keys(): Kmatstr += "%s, %s, %s\n" % (edge[0], edge[1], connections_all[edge]) with open("./jobfiles_all/Kmatrix.csv", "w") as wf: wf.write(Kmatstr)
def main(): constC = constClass() #constC.initialpointN = 100 constC.initialpointN = 0 #constC.calc_cupyQ = True constC.cythonQ = True constC.calc_mpiQ = True constC.use_jacQ = True constC. IOEsphereA_initial = 0.02 constC.IOEsphereA_dist = 0.01 constC.deltas0 = 0.10 constC.deltas = 0.05 constC.lADDnQ = True constC.IOEl = 8 constC.coeffPickNlist = [300000] #constC.coeffabsmin = 1.0e-2 constC.periodicQ = True constC.periodicmax = [ np.pi for _ in range(20)] constC.periodicmin = [-np.pi for _ in range(20)] constC.x0randomQ = True #constC.x0randomQ = False if constC.calc_mpiQ: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() root = 0 else: comm = None rank = 0 root = 0 size = 1 if rank == root: if not os.path.exists("./jobfiles_meta"): os.mkdir("./jobfiles_meta") constC = mkconst.main(constC) if rank == root: with open("./jobfiles_meta/constants.txt", "w") as wf: wf.write(constC.writestr) plumedpath = './plumedVES.dat' VESclass = SHS4py.VESanalyzer.VESpotential(plumedpath, constC, rank, root, size, comm) initialpointlist = [] # for line in open('./COLVAR'): # if '#' in line: # continue # x = line.replace('\n','').split(' ') # #print(x) # initialpointlist.append(np.array(x[2:], dtype = float)) # initialpointlist = random.sample(initialpointlist, k = constC.initialpointN) #print(initialpointlist) #for line in open("../VES2D_200ns/jobfiles_meta/eqlist.csv"): #for line in open("./jobfiles_meta.back1/eqlist.csv"): #if "#" in line: #continue #line = line.split(",") #initialpointlist.append(np.array(line[1:-1], dtype = float)) #print(initialpointlist[0]) SHS4py.SHSearch(VESclass.f, VESclass.grad, VESclass.hessian, importinitialpointQ = False, initialpoints = initialpointlist, SHSrank = rank, SHSroot = root, SHSsize = size, SHScomm = comm, const = constC)
def main(): constC = constClass() constC.Temp = 300.0 # tempeture (K) k_B = 1.38065e-26 # Boltzmann constant (kJ / K) N_A = 6.002214e23 # Avogadro constant (mol^-1) constC.betainv = constC.Temp * k_B * N_A # 1/beta (kJ / mol) constC.beta = 1.0 / constC.betainv #constC.initialpointN = 100 constC.initialpointN = 0 #constC.calc_cupyQ = True constC.cythonQ = True constC.use_jacQ = True constC.threshold = 1.0 constC.sameEQthreshold = [0.2 for _ in range(4)] + [2.0] constC.IOEsphereA_initial = 0.05 constC.IOEsphereA_dist = 0.01 constC.deltas0 = 0.05 constC.deltas = 0.01 constC.coeffPickNlist = [] #! SET iteration 400000 #constC.coeffabsmin = 1.0e-3 constC.periodicQ = True constC.periodicmax = [np.pi for _ in range(4)] + [40.0] constC.periodicmin = [-np.pi for _ in range(4)] + [-40.0] constC.wallmax = [1.0e30 for _ in range(4)] + [40.0] constC.wallmin = [-1.0e30 for _ in range(4)] + [-40.0] constC.EQwallmax = [1.0e30 for _ in range(4)] + [35.0] constC.EQwallmin = [-1.0e30 for _ in range(4)] + [-35.0] constC.abslist = False constC.x0randomQ = False constC.chkBifurcationQ = False constC.chkinitialTSQ = True constC.gridQ = False constC.grid_importQ = False constC.CVfixQ = False constC.calc_mpiQ = False if constC.calc_mpiQ: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() root = 0 else: comm = None rank = 0 root = 0 size = 1 #if rank == root: #if not os.path.exists(constC.jobfilepath): #os.mkdir(constC.jobfilepath) constC = mkconst.main(constC) plumedpath = './plumed.dat' VESclass = SHS4py.VESanalyzer.VESpotential(plumedpath, constC, rank, root, size, comm) eqlist_all = [] for line in open("./jobfiles_all/eqlist.csv"): if "#" in line: continue eqpoint = EQclass(line) eqlist_all.append(eqpoint) for z in range(36): eqlist_z = [eqpoint for eqpoint in eqlist_all if eqpoint.z == z] femin = 1.0e30 for eqpoint in eqlist_z: if eqpoint.fe < femin: femin = eqpoint.fe targetpoint = eqpoint.cv writeline = "" for z_pmf in range(36): p = np.array(list(targetpoint) + [z_pmf]) print("p = %s" % p) fe = VESclass.f(p) writeline += "%s, %s\n" % (z_pmf, fe) #print(writeline) #exit() csvpath = "./jobfiles_all/PMF_%s.csv" % z with open(csvpath, "w") as wf: wf.write(writeline) print("%s is writen" % csvpath)