with open(filename, 'rb') as flow: HoomdFlow = gsd.pygsd.GSDFile(flow) hoomdTraj = gsd.hoomd.HOOMDTrajectory(HoomdFlow) boxParams = (hoomdTraj.read_frame(0)).configuration.box Lx = boxParams[0] if boxParams[0] != boxParams[1] or boxParams[1] != boxParams[ 2] or boxParams[0] != boxParams[2]: print 'box dimensions are : ', boxParams[0] print 'and are not supported (only isotropic systems supported)' raise SystemExit size_factor = (int(Lx / 9.3)) # size_factor = (int(Lx/(9.3/2))) ## debug only Nframes = len(hoomdTraj) print 'there are Nframes=', Nframes, 'in the file, but we only use trajDuration=', Nframes / every_forMemory, ' of them.' Natoms = int( float(module_filenamesHandler.filename_parser(filename[:-4], 'N'))) expectedDensity = 1.2 selectedAtoms, Nselected, expectedDensity = module_filenamesHandler.selectAtoms_function( hoomdTraj[0].particles.typeid, kind, Lx, expectedDensity, hoomdTraj[0].particles.position) trajDuration = Nframes / every_forMemory trajectory = np.zeros((trajDuration, Natoms, 3)) for time in range(0, trajDuration, 1): ## we only look 1 frame every "every_forMemory" frame, to save memory: trajectory[time] = (hoomdTraj[time * every_forMemory].particles.position ) # [selectedAtoms] HoomdFlow.close() print 'shape of your trajectory array:', np.shape(trajectory) ## "trajectory" is now the full array of all positions of all atoms (over time)
hoomdTraj = gsd.hoomd.HOOMDTrajectory(HoomdFlow); dim = hoomdTraj.read_frame(0).configuration.dimensions Nframes = hoomdTraj.file.nframes boxParams = hoomdTraj.read_frame(0).configuration.box Natoms = hoomdTraj[0].particles.N atomIds = np.arange(Natoms, dtype=int).transpose() ## XXX to be added ? atomTypes = np.array(hoomdTraj[0].particles.typeid, dtype=int).transpose() Lx=boxParams[0] if boxParams[0] != boxParams[1] or boxParams[1]!= boxParams[2] or boxParams[0]!= boxParams[2]: print( 'box dimensions are : ', boxParams[0]) print( 'and are not supported (only isotropic systems supported)') raise SystemExit ## TODO: use this time unit in the outputs ?? dt=0.00025 recPeriod = int(float(module_filenamesHandler.filename_parser(filename[:-4], 'rP'))) curStep = int(float(module_filenamesHandler.filename_parser(filename[:-4], 'cst'))) time_per_index = recPeriod*dt * frameSkipEvery # time_per_frame = recPeriod * dt Nframes = len(hoomdTraj)/frameSkipEvery Nframes_max = int(6e8/Natoms/3) trajDuration = min(Nframes_max, Nframes) ## trajDuration should be related to the actual time observed in the simu, ## or at least the number of steps seen, indpeenent of number of atoms in the simulation... print('there are Nframes=', Nframes, 'in the file, but we only use trajDuration=', trajDuration, ' of them.') # print('TODO: if you need longer time sequences, you can split the atoms instead of splitting time, and do separate chuncks of the system using a mask, like selectedAtoms') ## for tests and/or RAM limitations: selectedAtoms = np.arange(Natoms, dtype=int) #[:50] additional_tag='-' if slidingWindow:
plotting = 1 debug_or_choose_parameters = True debug_or_choose_parameters = False # above: from phop.py,may be useless. ## le read de decorated: issu de la partie plots de phop ## ensuite: issu de la partie eventsData de phop, analyse qui a sa place ici. ## ensuite:partie defintion med soft hard de construct, qui doit etre ici et non la bas. ################################################################################################################################################################ if "deco" in filename: # read the decorated file produced before # if p_threshold_low == -1: p_threshold_low = float( module_filenamesHandler.filename_parser(filename[:-4], 'pLow')) print('reading that the file has a p_threshold_low=', p_threshold_low, ' ...') if p_threshold_low == 0.0: p_threshold_low = 1e-7 print("correcting its threshold to :", p_threshold_low) decoratedFlowRead = gsd.fl.GSDFile( name=filename, mode='rb') # TODO : use with as instead of close() atomTypes = decoratedFlowRead.read_chunk(frame=0, name='atomTypes') boxParams = decoratedFlowRead.read_chunk(frame=0, name='configuration.box') Lx = boxParams[0] Ninitial = int( float(module_filenamesHandler.filename_parser(filename[:-4], 'N'))) expectedDensity = float( module_filenamesHandler.filename_parser(filename[:-4], 'rho'))
###### print('usage:') print( 'run build_hyperwall.py [filename with "AVA=descriptors..."] [mode=1,2] ' ) filename = sys.argv[1] rootname = module_filenamesHandler.get_rootname(filename) suffix = module_filenamesHandler.get_suffix(filename) mode = int(sys.argv[2]) cv_cross = 2 cv_cross = int(sys.argv[3]) Natoms = int(float(module_filenamesHandler.filename_parser(filename[:-4], 'N'))) seed = 4242 if "AVA=descriptors" in filename: X_all_descriptors_array = np.loadtxt(filename) else: print( "no way. Use correct file conttaing the ddescriptors (prodcued with B1)." ) raise SystemExit Nsamples = len(X_all_descriptors_array[:, 0]) / 2 print("found ", Nsamples, " samples (hard, soft)") #hard_descriptors = X_all_descriptors_array[0:Nsamples,:] #soft_descriptors = X_all_descriptors_array[Nsamples: ,:] y_correct_labels = np.zeros(2 * Nsamples) - 1 y_correct_labels[Nsamples:] += 2
plt.rcParams['text.latex.unicode']=True plt.rcParams.update(module_importPlotParams.fparams()) plt.ion() ## optional ###### print('usage:') print('run '+sys.argv[0]+' [filename] [kind]') filename = sys.argv[1] kind = sys.argv[2] # kind = module_filenamesHandler.filename_parser(filename[:-4], 'kind') if "softness-R" in filename : # read the decorated file produced before # p_threshold_low = float(module_filenamesHandler.filename_parser(filename[:-4], 'pLow')) # print('reading that the file has a p_threshold_low=', p_threshold_low, ' ...') # if p_threshold_low ==0 : # p_threshold_low= 1e-7 # print("correcting its threshold to :",p_threshold_low) # Natoms = int(float(module_filenamesHandler.filename_parser(filename[:-4], 'N')) ) # selectedAtoms = np.arange(Natoms, dtype=int) # if 'tagBonusNum' in filename : # Natoms = int(module_filenamesHandler.filename_parser(filename[:-4], 'tagBonusNum')) # selectedAtoms = selectedAtoms[:Natoms] decoratedFlowRead = gsd.fl.GSDFile(name=filename, mode='rb') # TODO : use with as instead of close() atomTypes = decoratedFlowRead.read_chunk(frame=0, name='atomTypes')
print('run ' + sys.argv[0] + ' [rootname_AVA] [Nexamples] ') verbose = True verbose = False rootname_AVA = sys.argv[1] Nexamples = int(sys.argv[2]) throwBoundaries_steps = 10 soft_delay = 2 ## time frames, which is not a well controlled unit ### parameters to define hard and soft instants ### #hard_factor = 2 Natoms = int( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'N'))) p_threshold_low = max( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'pl')), float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'pLow'))) p_threshold_high = float( module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'ph')) slowWindow = int( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'sW'))) fastWindow = int( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'fW'))) kind = module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'kind') curStep = int( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'cst')) / 1e6) recPeriod = int( float(module_filenamesHandler.filename_parser(rootname_AVA[:-4], 'rP')))
import sys import module_filenamesHandler import module_descriptors import module_dist_compute print('usage:') print('run '+sys.argv[0]+' [deco-traj.gsd] [hyperplane_name.dat??] ') # run B3-assign-softness.py KA_rho=12e-1_N=1e3_T=43e-2_type=FIRE-traj-deco_cst=91e6_rP=1000_LL=60000_SLID_pLow=0.002_rec=100.gsd KA_rho=12e-1_N=1e3_T=43e-2_type=FIRE-traj-deco_cst=91e6_rP=1000_LL=60000_SLID_pLow=0.002_rec=100_kind=A_pl=0.002_ph=0.08_sW=500_fW=2_AVA=descriptors_fam=1_Nex=10000_hyperplane.dat filename = sys.argv[1] hyperplane_name = sys.argv[2] outputName_softness_R=filename[:-4]+"_SOFT=softness-R.gsd" Natoms = int(float(module_filenamesHandler.filename_parser(filename[:-4], 'N'))) kind = module_filenamesHandler.filename_parser(hyperplane_name[:-4], 'kind') descriptor_family_parameters = np.loadtxt("B0_fam=1_type=radial.dat") descriptor_family_name=1 # hyperplane_name = filename[:-4]+"_hyperplane.dat" hyperplane = np.loadtxt(hyperplane_name) descriptor_averages = hyperplane[:,0] descriptor_stdDevs = hyperplane[:,1] a_hyperplane = hyperplane[:,2] with open(hyperplane_name, 'r') as flow: flow.readline() b_intercept = float((flow.readline()).split()[-1])
analyzer_period = 4e3 if len(sys.argv) > 7: analyzer_period = int(float(sys.argv[7])) tauT = 1 # float(sys.argv[2]) if len(sys.argv) > 8: tauT = float(sys.argv[8]) rootname = module_filenamesHandler.get_rootname(filename) dt = 0.0025 if len(sys.argv) > 9: dt = float(sys.argv[9]) if dt != 0.0025: if 'dt=' not in filename: rootname += "_dt=" + str(dt) else: dt = float( module_filenamesHandler.filename_parser(filename[:-4], 'dt')) #rootname+="_dt="+str(dt) #print "accepting, for once, the incoming" module_filenamesHandler.log_action(rootname, '\n\n' + str(sys.argv) + '\n') TemperatureGoal = float( module_filenamesHandler.filename_parser(filename[:-4], 'T')) #TemperatureGoal = 0.23 #45 notice_level = 1 thermostat = 'NVT' if len(sys.argv) > 10: thermostat = str(sys.argv[10]) if thermostat == 'MB': notice_level = 0 interactionType = "LJ" if len(sys.argv) > 11: interactionType = sys.argv[11]