def atomicMobility(): multip = 1 fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() folder = o.props['folders'][0][:-6:1] pdStart = parseData(folder + 'co.' + str(50000) + '.data') pdFinish = parseData(folder + 'co.' + str(2500000) + '.data') masses = pdStart.masses atomsFullStart = pdStart.atomsFull atomsFullFinish = pdFinish.atomsFull lx = pdStart.xhi - pdStart.xlo ly = pdStart.yhi - pdStart.ylo lz = pdStart.zhi - pdStart.zlo mobilityProfile = [[0, 0] for i in range(300 * multip)] for i in range(len(atomsFullStart)): if masses[atomsFullStart[i][2] - 1] < 5: continue z = int(100 + multip * atomsFullStart[i][6]) dx = min(abs(atomsFullFinish[i][4] - atomsFullStart[i][4]), lx - abs(atomsFullFinish[i][4] - atomsFullStart[i][4])) dy = min(abs(atomsFullFinish[i][5] - atomsFullStart[i][5]), ly - abs(atomsFullFinish[i][5] - atomsFullStart[i][5])) dz = min(abs(atomsFullFinish[i][6] - atomsFullStart[i][6]), lz - abs(atomsFullFinish[i][6] - atomsFullStart[i][6])) mobilityProfile[z][0] += 1 mobilityProfile[z][1] += (dx**2 + dy**2 + dz**2)**0.5 f = open('log', 'w') for i in range(len(mobilityProfile)): if mobilityProfile[i][0] != 0: f.write( str((i - 100) / multip) + ' ' + str(mobilityProfile[i][0]) + ' ' + str(mobilityProfile[i][1] / mobilityProfile[i][0]) + '\n')
def main1A7L(): step = 100 filesNum = int(2500000 / step) + 1 fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() folder = o.props['folders'][folderNum] f = open('log', 'w') f.write(folder + '\n') f.write('LayerNum Period Magnitude Error\n') lx = o.props['xhi'] - o.props['xlo'] ly = o.props['yhi'] - o.props['ylo'] lz = o.props['zhi'] - o.props['zlo'] pressOneStep = [0 for j in range(uo.multip * uo.bigNumber)] pressures = [] for i in range(filesNum): print(i) fname = folder + 'ALLstress.' + str(i * step) pd = parseDump(fname) stp = stressToPressure(pd.stresses, lx, ly, lz) stp.pres1A() pressOneStep7L = [0 for i in range(500)] for i in range(59, len(pressOneStep)): pressOneStep7L[int((i - 59) / 4.5)] += stp.pressOneStep[i] pressures.append(pressOneStep7L) for k in range(15): period = len(pressures) for layerNum in range(len(pressures[0])): press = [] for step in range(len(pressures)): press.append(pressures[step][layerNum] / 4.5) pressTmp = [] for step in range(len(press)): pressTmp.append(press[step]) a = appro(pressTmp) a.error() if a.magnitude != 0: f.write( str(layerNum) + ' ' + str(period) + ' ' + str(a.magnitude) + ' +- ' + str(a.error) + '\n') for step in range(len(pressures) - 1): for layer in range(len(pressures[step])): pressures[step][layer] += pressures[step + 1][layer] pressures[step][layer] /= 2 firstelement = pressures[0] endelement = pressures[-1] pressures = pressures[1:-2:2] pressures.insert(0, firstelement) pressures.append(endelement) k += 1
def modifierDistribution(systemName='mixed'): """Change systemName, ParentFolders and Folders and start and end""" segregatedParentFolder = ( "/media/anton/Seagate Expansion Drive/Article-MMT/" + "Cluster calculations for article/1st conf/" + "segregated/500K/") segregatedFolders = [ "1332494 - 2.5ns/", "1338014 - 2.5ns more/", "1343289 - 2.5ns more/", "1352547 - 2.5 ns more/", "1388142 - 2.5 ns more/", "1404644/" ] mixedParentFolder = ("/media/anton/Seagate Expansion Drive/Article-MMT/" + "Cluster calculations for article/1st conf/" + "mixed ok/500K/") mixedFolders = [ "all/", "1388141/", "1393565/", "1397381/", "1400005/", "1404643/" ] fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() folder = o.props['folders'][len(o.props['folders']) - 1][:-6:1] [top, bottom] = returnCalyRanges(systemName) filenum = 0 f = open('log', 'w') for j in range(len(mixedFolders)): end = 51 start = 1 if j == 0: end = 24 if j == 2: end = 50 for i in range(start, end): filenum += 1 fname = (mixedParentFolder + mixedFolders[j] + 'co.' + str(i * 50000) + '.data') pd = parseData(fname) lz = pd.zhi - pd.zlo atomsFull = pd.atomsFull distanceSum = 0 atomsNum = 0 for atom in atomsFull: if definePhase(atom[0], systemName) == 2: atomsNum += 1 distance = min((atom[6] - top)**2, (lz + bottom - atom[6])**2) distanceSum += distance f.write( str(filenum) + ' ' + str((distanceSum / atomsNum)**0.5) + '\n')
def densityProfileMass(folderNum=1, systemName="mixed"): """Define the folder number, range for files""" fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() uo.multip = 10 folder = ('/media/anton/Seagate Expansion Drive/Article-MMT/Cluster' + ' calculations for article/1st conf/mixed ok/300K/' + 'npt after 6th cycle/1440224/') densityProfile = [[0, 0, 0, 0] for i in range(uo.multip * uo.bigNumber)] for i in range(1, 51): print(i) fname = folder + 'co.' + str(i * 50000) + '.data' pd = parseData(fname) masses = pd.masses atomsFull = pd.atomsFull lx = pd.xhi - pd.xlo ly = pd.yhi - pd.ylo for atom in atomsFull: atomNumber = atom[0] #z = int(9 + (atom[6] - int(pd.zlo)) * uo.multip) z = int((atom[6] + 150) * uo.multip) atomType = atom[2] mass = masses[atomType - 1] phase = definePhase(atomNumber, systemName) densityProfile[z][ 0] += mass * 1.66 # coefficient from units conversion densityProfile[z][phase] += mass * 1.66 f = open('log', 'w') for i in range(len(densityProfile)): if (densityProfile[i][0] > 0): f.write( str(i / uo.multip - 150) + ' ' + str(densityProfile[i][0] / 50 / (lx * ly) * uo.multip) + ' ' + str(densityProfile[i][1] / 50 / (lx * ly) * uo.multip) + ' ' + str(densityProfile[i][2] / 50 / (lx * ly) * uo.multip) + ' ' + str(densityProfile[i][3] / 50 / (lx * ly) * uo.multip) + '\n')
def __init__(self, stresses, lx, ly, lz): self.uo = universalOptions() self.stresses = stresses self.lx = lx self.ly = ly self.lz = lz
def rgyr(folderNum=6, systemName="10x20"): fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() r_xVSz = [[0, 0] for i in range(1500)] r_yVSz = [[0, 0] for i in range(1500)] r_zVSz = [[0, 0] for i in range(1500)] for i in range(len(o.props['folders'])): print(i) folder = o.props['folders'][i][:-6:1] fname = folder + 'co.' + str(1 * 50000) + '.data' pd = parseData(fname) masses = pd.masses atomsFull = pd.atomsFull lx = pd.xhi - pd.xlo ly = pd.yhi - pd.ylo lz = pd.zhi - pd.zlo for chainNum in range(int(o.props['polymerChainsNum'])): (moleculeStart, moleculeEnd) = computeChainRange(chainNum, systemName) groupOfAtoms = copy.deepcopy( atomsFull[moleculeStart:moleculeEnd:1]) groupOfAtoms = makeMolecule(groupOfAtoms, lx, ly, lz) (rx, ry, rz) = computeCM(groupOfAtoms) outputXYZ(groupOfAtoms, 'pics/' + systemName + str(chainNum) + '.xyz') (rGyr_x, rGyr_y, rGyr_z, ex, ey, ez) = computeRgyr(groupOfAtoms) z = int((550 + rz) * uo.multip) r_xVSz[z][0] += 1 r_xVSz[z][1] += rGyr_x r_yVSz[z][0] += 1 r_yVSz[z][1] += rGyr_y r_zVSz[z][0] += 1 r_zVSz[z][1] += rGyr_z f = open('log', 'w') for i in range(len(r_zVSz)): if r_zVSz[i][0] != 0: f.write( str(i / uo.multip - 150) + ' ' + str(r_zVSz[i][1] / r_zVSz[i][0]) + '\n') r_x_mean = 0 valuesNum = 0 for i in range(len(r_xVSz)): if r_xVSz[i][0] != 0: r_x_mean += r_xVSz[i][1] valuesNum += r_xVSz[i][0] print(r_x_mean / valuesNum) r_y_mean = 0 valuesNum = 0 for i in range(len(r_yVSz)): if r_yVSz[i][0] != 0: r_y_mean += r_yVSz[i][1] valuesNum += r_yVSz[i][0] print(r_y_mean / valuesNum) r_z_mean = 0 valuesNum = 0 for i in range(len(r_zVSz)): if r_zVSz[i][0] != 0: r_z_mean += r_zVSz[i][1] valuesNum += r_zVSz[i][0] print(r_z_mean / valuesNum) print(valuesNum)
def anglesOrientation(systemName="10x20"): multip = 1 fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() folder = o.props['folders'][0][:-6:1] orientations = [[0, 0] for i in range(500)] end = 51 if systemName == '5x20': end = 50 if systemName == '10x20': end = 51 for i in range(1, end): pd = parseData(folder + 'co.' + str(i * 50000) + '.data') lx = pd.xhi - pd.xlo ly = pd.yhi - pd.ylo lz = pd.zhi - pd.zlo atomsFull = pd.atomsFull angles = pd.angles for angle in angles: if systemName == 'mixed': if angle[1] not in [ 1, 2, 3, 7, 9, 10, 16, 19, 20, 21, 22, 25, 26, 28, 29 ]: continue elif systemName == 'segregated': if angle[1] not in [ 1, 2, 3, 7, 9, 10, 16, 19, 20, 21, 22, 25, 26, 28, 29 ]: continue elif systemName == 'long': if angle[1] not in [ 1, 2, 5, 7, 8, 9, 10, 13, 14, 16, 20, 22, 23, 24, 26 ]: continue elif systemName == '5x20': if angle[1] not in [ 1, 2, 3, 7, 9, 10, 16, 19, 20, 21, 22, 25, 26, 28, 29 ]: continue elif systemName == '10x20': if angle[1] not in [ 1, 2, 3, 7, 9, 10, 16, 19, 20, 21, 22, 25, 26, 28, 29 ]: continue atomOne = atomsFull[angle[2] - 1] atomMid = atomsFull[angle[3] - 1] atomTwo = atomsFull[angle[4] - 1] bondx = min(abs(atomOne[4] - atomTwo[4]), lx - abs(atomOne[4] - atomTwo[4])) bondy = min(abs(atomOne[5] - atomTwo[5]), lx - abs(atomOne[5] - atomTwo[5])) bondz = min(abs(atomOne[6] - atomTwo[6]), lx - abs(atomOne[6] - atomTwo[6])) cosTheta = bondz / (bondx**2 + bondy**2 + bondz**2)**0.5 parameter = (3 * cosTheta**2 - 1) / 2 z = int((100 + atomMid[6]) * multip) orientations[z][0] += 1 orientations[z][1] += parameter f = open('log', 'w') for i in range(len(orientations)): if orientations[i][0] != 0: f.write( str(i / multip - 100) + ' ' + str(orientations[i][1] / orientations[i][0]) + ' ' + str(orientations[i][0]) + '\n')
def bondsOrientation(systemName="mixed"): multip = 1 fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() orientations = [[0, 0] for i in range(1500)] end = 51 if systemName == '5x20': end = 50 if systemName == '10x20': end = 51 if systemName == 'long': folder = ( '/media/anton/Seagate Expansion Drive/Article-MMT/Cluster' + ' calculations for article/BiggerSystems/Comp/1chain (long)/' + '1845502 - wiggle1/') elif systemName == 'mixed': folder = ('/media/anton/Seagate Expansion Drive/Article-MMT/Cluster' + ' calculations for article/1st conf/mixed ok/300K/' + 'npt after 6th cycle/1440224/') for i in range(1, 51): print(i) pd = parseData(folder + 'co.' + str(i * 50000) + '.data') lx = pd.xhi - pd.xlo ly = pd.yhi - pd.ylo lz = pd.zhi - pd.zlo atomsFull = pd.atomsFull bonds = pd.bonds for bond in bonds: if systemName == 'mixed': if bond[1] not in [3, 4, 5, 7, 8, 11, 12, 13, 14, 16]: #if bond[1] not in [5, 8]: continue elif systemName == 'segregated': if bond[1] not in [3, 4, 5, 7, 8, 11, 12, 13, 14, 16]: continue elif systemName == 'long': if bond[1] not in [4, 5, 6, 7, 8, 9, 11, 12, 14, 15]: continue elif systemName == '5x20': if bond[1] not in [3, 4, 5, 7, 8, 11, 12, 13, 14, 16]: continue elif systemName == '10x20': if bond[1] not in [3, 4, 5, 7, 8, 11, 12, 13, 14, 16]: continue atomOne = atomsFull[bond[2] - 1] atomTwo = atomsFull[bond[3] - 1] bondx = min(abs(atomOne[4] - atomTwo[4]), abs(lx - abs(atomOne[4] - atomTwo[4]))) bondy = min(abs(atomOne[5] - atomTwo[5]), abs(ly - abs(atomOne[5] - atomTwo[5]))) bondz = min(abs(atomOne[6] - atomTwo[6]), abs(lz - abs(atomOne[6] - atomTwo[6]))) if bondx >= 3 or bondy >= 3 or bondz >= 3: print("Long bond ", bondx, bondy, bondz) cosTheta = bondz / ((bondx**2 + bondy**2 + bondz**2)**0.5) parameter = (3 * cosTheta**2 - 1) / 2 z = int((250 + atomOne[6]) * multip) orientations[z][0] += 1 orientations[z][1] += parameter f = open('log', 'w') for i in range(len(orientations)): if orientations[i][0] != 0: f.write( str(i / multip - 250) + ' ' + str(orientations[i][1] / orientations[i][0]) + ' ' + str(orientations[i][0]) + '\n')
def polymerChainsMobility(): fnameOptions = 'options/' + systemName + '.json' o = options(fnameOptions) uo = universalOptions() folder = o.props['folders'][len(o.props['folders']) - 1][:-6:1] cms = [[] for i in range(int(o.props['polymerChainsNum']))] #cms[molecule][filenum] = [x, y, z] for i in range(1, 51): print(i) fname = folder + 'co.' + str(i * 50000) + '.data' pd = parseData(fname) masses = pd.masses atomsFull = pd.atomsFull lx = pd.xhi - pd.xlo ly = pd.yhi - pd.ylo lz = pd.zhi - pd.zlo for chainNum in range(int(o.props['polymerChainsNum'])): (moleculeStart, moleculeEnd) = computeChainRange(chainNum, systemName) groupOfAtoms = copy.deepcopy( atomsFull[moleculeStart:moleculeEnd:1]) groupOfAtoms = makeMolecule(groupOfAtoms, lx, ly, lz) (x_cm, y_cm, z_cm) = computeCM(groupOfAtoms) cms[chainNum].append([x_cm, y_cm, z_cm]) for i in range(49): xOld = cms[1][i][0] yOld = cms[1][i][1] zOld = cms[1][i][2] xNew = cms[1][i + 1][0] yNew = cms[1][i + 1][1] zNew = cms[1][i + 1][2] xMin = 0 yMin = 0 zMin = 0 rMin = 10000 for x in [-1, 0, 1]: xNewTmp = xNew + x * lx r = xNewTmp - xOld if r < rMin: rMin = r xMin = x rMin = 10000 for y in [-1, 0, 1]: yNewTmp = yNew + y * ly r = yNewTmp - yOld if r < rMin: rMin = r yMin = y rMin = 10000 for z in [-1, 0, 1]: zNewTmp = zNew + z * lz r = zNewTmp - zOld if r < rMin: rMin = r zMin = z xNew += x * lx yNew += y * ly zNew += z * lz deltaCM = 0 for i in range(int(o.props['polymerChainsNum'])): deltaCM += (cms[i][49][0] - cms[i][0][0])**2 deltaCM += (cms[i][49][1] - cms[i][0][1])**2 deltaCM += (cms[i][49][2] - cms[i][0][2])**2 deltaCM = deltaCM**0.5 deltaCM /= int(o.props['polymerChainsNum']) print(deltaCM)