Skip to content

Commit

Permalink
Merge pull request #22 from XT-Lee/master6
Browse files Browse the repository at this point in the history
cuda
  • Loading branch information
XT-Lee authored May 5, 2023
2 parents d817bc5 + 3547b3c commit 98fb799
Show file tree
Hide file tree
Showing 15 changed files with 3,390 additions and 493 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@
- and has a library to proceed trajectories of particles in 2D and get their structural or dynamic properties

## log:
- 20230504 add file_for_CUDA.test_cuda
- 20230424 edit workflow_analysis.show_disp_field.get_bicolor_disp.
- 20230423 add workflow_part.saveIndexCN346PCairoSeed.
- 20230422 add workflow_analysis.show_cairo_order_parameter.
- 20230420 add proceed_file to operate files and make directories.
- 20230420 fix get_conditional_bonds_and_simplices, return count_polygon_relative
- 20230410 edit get_conditional_bonds_and_simplices, return count_polygon_relative
- 20230408 edit bond_plot_module init(ax=none)
- 20230404 add points_analysis_2d.count_polygon_n
- 20230329 add workflow_analysis.show_waiting_time_interstitial_motion
add points_analysis_2d.dynamical_facilitation_module.scan_displacement_t
- 20230328 add workflow_analysis.optimize_polyfit
add workflow_analysis.show_waiting_time_brownian
add workflow_analysis.show_waiting_time_dynamical_facilitation
- 20230324 add workflow_analysis.show_tuned_image to add line over image.
add bond_plot_module_for_image in points_analysis_2d
- 20230320 add workflow_uniform_continue in symmetry_transformation.simple_simulation
add workflow_analysis.get_msd_from_gsd()
add workflow_analysis.get_displacement_field_normal()
- 20230314 add workflow_analysis to record codes.
- 20230306 plot scatter vacancy and occupation in dynamical_facilitation_module.plot_reference_occupation
add dynamical_facilitation_module.plot_reference_positions_waiting_time_colored
- 20230225 set honeycomb3-8-12 as facilitation reference, part1 as traps.
- 20230223 add probability distribution of dynamical facilitation(ongoing)
add get_displacement_1D_overlap in data_analysis_cycle
add dynamical_facilitation_module in points_analysis_2d
- 20230222 add function_plot including example_plot and unit_transform
- 20230216 add workflow_mysql_to_data_pin_hex_to_honeycomb_part_klt_2m_random_oop
add mysql_data_processor in getDataAndScatter
add get_string_like_motion_rank in data_analysis_workflow,
Expand Down
3 changes: 2 additions & 1 deletion computeTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def getTimeCost(t1,t2):
else:
print("start",t1.tm_hour,":",t1.tm_min,":",t1.tm_sec)
print("end ",t2.tm_hour,":",t2.tm_min,":",t2.tm_sec)
print("cost ",dt_h,":",dt_m,":",dt_s)
print("cost ",dt_h,":",dt_m,":",dt_s)

58 changes: 5 additions & 53 deletions control_table.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,20 @@
#import threading
import time
import computeTime as ct
tm1=time.localtime(time.time())


R"""
select * from pin_hex_to_honeycomb_part_klt_2m where HarmonicK = 700;
| SimuIndex | HarmonicK | LinearCompressionRatio | kT | Psi3 | Psi6 | RandomSeed |
| 4302 | 700 | 0.81 | 1 | 0.927068 | 0.123686 | 9 |
select * from pin_hex_to_honeycomb_klt_2m where HarmonicK = 900;
+-----------+-----------+------------------------+------+----------+----------+------------+
| SimuIndex | HarmonicK | LinearCompressionRatio | kT | Psi3 | Psi6 | RandomSeed |
| 4634 | 900 | 0.79 | 1 | 0.862018 | 0.159095 | 9 |
select * from pin_hex_to_honeycomb_klt_2m where SimuIndex = 5238;
+-----------+-----------+------------------------+------+----------+----------+------------+
| SimuIndex | HarmonicK | LinearCompressionRatio | kT | Psi3 | Psi6 | RandomSeed |
+-----------+-----------+------------------------+------+----------+----------+------------+
| 5238 | 60 | 0.79 | 1 | 0.885731 | 0.196146 | 9 |
+-----------+-----------+------------------------+------+----------+----------+------------+
"""
#import getDataAndScatter as scatt
#scatt.workflow_mysql_to_data_pin_hex_to_honeycomb_klt_2m(account='remote')

import data_analysis_cycle as da
get_traj = da.data_analysis()
directory,data_name = get_traj.gsd_to_txyz('remote',5238,9)
get_traj.txyz_to_bond_plot(directory,data_name)
"""
import data_analysis_cycle as da
import points_analysis_2D as pa
import numpy as np
path_to_results = '/home/remote/xiaotian_file/data/20221129/video_7'
txyz_npy_filename = path_to_results+'/'+'txyz_stable.npy'
txyz_stable = np.load(txyz_npy_filename)
msds = pa.dynamic_points_analysis_2d(txyz_stable,mode='exp')
msds.plot_trajectory_single_particle(path_to_results+'/traj_stable/')#trajectory_stable.png
#txyz_stable[:] = txyz_stable[:]/2.0
"""
"""
msds.compute_atmsd_t_chips(0.95)
time_log_file = path_to_results+'/'+'DefaultVideo_7.txt'
time_log = np.loadtxt(time_log_file)
png_filename=path_to_results+'/'+'msd_scantchips_loglog_um_95%.png'
msds.plot_msd(time_log,png_filename)
"""





"""
ts_id_dxy['particle']
#pa.compute_atmsd_t_chips(interval_max=0.9,msd_per_particle=True)
path_to_folder = '/home/remote/xiaotian_file/data/20221129/video5/'
time_log = path_to_folder+'DefaultVideo_5.txt'
png_filename = path_to_folder+'particle_'+str(id)+'_'+'msds_loglog.png'
pa.plot_msd_uniform(m_msd=1,time_log=time_log,png_filename=png_filename)
"""
import file_for_CUDA.test_cuda as tc
tcc = tc.comapre_speed_cpu_vs_gpu()
t1,t2,r2 = tcc.calculate_cpu(tcc.rm1)
t1,t2,r2c = tcc.calculate_gpu(tcc.rm1)


#time.sleep(1)
tm2=time.localtime(time.time())
#calculate the time cost
import computeTime as ct
ct.getTimeCost(tm1,tm2)

14 changes: 14 additions & 0 deletions control_table2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sys import prefix
import time
tm1=time.localtime(time.time())

import function_plot.example_plot as ep
fpm = ep.functions_plot_module()

#fpm.generate_compare()
t,y = fpm.generate_glass_list()#(b=1,m=0.99)
fpm.plot_function_glass(t,y)
tm2=time.localtime(time.time())
#calculate the time cost
import computeTime as ct
ct.getTimeCost(tm1,tm2)
136 changes: 131 additions & 5 deletions data_analysis_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy
import matplotlib.pyplot as plt
import os
import proceed_file as pf

def saveIndexPsi3Psi6(start_index,end_index,k1,step,linear_compression_ratio):
R"""
Expand Down Expand Up @@ -241,6 +242,51 @@ def saveIndexCN346Seed(start_index,end_index,k1,step,linear_compression_ratio,ra



save_file_name=prefix+str(start_index)+'-'+str(end_index)+'klcn346'
numpy.savetxt(save_file_name,record)
#print(record)
return save_file_name

def saveIndexCN346PCairoSeed(start_index,end_index,k1,step,linear_compression_ratio,randomseed):
R"""
This function will save a txt file named 'start index - end index kl', which contains
n rows of data
[ simu_index | HarmonicK | LinearCompressionRatio |
CoordinationNum3Rate | CoordinationNum4Rate |
CoordinationNum6Rate | PCairo | RandomSeed ]
"""
diference_index=end_index-start_index+1
prefix='/home/tplab/Downloads/'
record=numpy.zeros((diference_index,8))

for index in numpy.linspace(start_index,end_index,diference_index):
data_filename=prefix+'index'+str(index.astype(int))
obj_of_simu_index = pa.static_points_analysis_2d(filename=data_filename)


record[(index-start_index).astype(int),0]=index

record[(index-start_index).astype(int),1]=k1+step*(index-start_index)

record[(index-start_index).astype(int),2]=linear_compression_ratio


obj_of_simu_index.get_coordination_number_conditional()
ccn=obj_of_simu_index.count_coordination_ratio
record[(index-start_index).astype(int),3]=ccn[3]

record[(index-start_index).astype(int),4]=ccn[4]

record[(index-start_index).astype(int),5]=ccn[6]

import workflow_analysis as wa
cp = wa.show_cairo_order_parameter()
record[(index-start_index).astype(int),6]=cp.compute_cairo_order_parameter(ccn[3],ccn[4])

record[(index-start_index).astype(int),7]=randomseed



save_file_name=prefix+str(start_index)+'-'+str(end_index)+'klcn346'
numpy.savetxt(save_file_name,record)
#print(record)
Expand Down Expand Up @@ -730,7 +776,6 @@ def save_exp_20230113_6(i,stable=True):
xy_adjust = center+trap_locate
pos,trap_filename = spe.get_trap_positions(tsf_filename,xy_adjust,1,90)#

import points_analysis_2D as pa
directory = spe.path_to_results+'/'
dataname = video_name
if stable:
Expand Down Expand Up @@ -790,7 +835,7 @@ def save_exp_20230113_8(i,stable=True):
xy_adjust = center+trap_locate
pos,trap_filename = spe.get_trap_positions(tsf_filename,xy_adjust,1,90)#

import points_analysis_2D as pa

directory = spe.path_to_results+'/'
dataname = video_name
if stable:
Expand Down Expand Up @@ -1040,11 +1085,11 @@ def save_from_gsd(simu_index=None,seed=None,frame_cut=0,
#load time steps
if seed is None:
str_index=str(int(simu_index))
gsd_data = pa.proceed_gsd_file(simu_index=simu_index)
gsd_data = pf.proceed_gsd_file(simu_index=simu_index)
else:
str_index=str(int(simu_index))+'_'+str(seed)
file_gsd = log_prefix+'trajectory_auto'+str_index+'.gsd'#+'_'+str(seed)
gsd_data = pa.proceed_gsd_file(filename_gsd_seed=file_gsd,account=account)
gsd_data = pf.proceed_gsd_file(filename_gsd_seed=file_gsd,account=account)

file_log=log_prefix+'log-output_auto'+str_index+'.log'#+'_'+str(seed)
log_data = numpy.genfromtxt(fname=file_log, skip_header=True)
Expand Down Expand Up @@ -1308,6 +1353,8 @@ def save_from_gsd(simu_index=None,seed=None,frame_cut=0,
plt.savefig(png_filename)
plt.close()
if coordination_number:
#txt_filename = prefix +'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.txt'
#numpy.savetxt(txt_filename,record_cn)
plt.figure()
if frame_cut == 0:#frame_cut is set to abstract a part of the process to watch in detail
#plt.plot(record_cn[:,0],record_cn[:,1],label='CN_0')
Expand Down Expand Up @@ -1510,6 +1557,7 @@ def get_bond_plot(self,directory,data_name=None,trap_filename=None,trap_lcr=None
dpa.draw_bonds.plot_neighbor_change(txyz_stable,nb_change)
dpa.draw_bonds.plot_traps(trap_filename,LinearCompressionRatio)
"""

def get_defect_motion(self,directory,data_name=None,trap_filename=None,trap_lcr=None):
file_txyz_stable = directory + 'txyz_stable.npy'
txyz_stable = numpy.load(file_txyz_stable)
Expand Down Expand Up @@ -1599,8 +1647,85 @@ def get_a_frame(self,directory,frame_index):
dpa = pa.dynamic_points_analysis_2d(txyz_stable,mode='simu')
dpa.plot_a_frame_of_points(frame_index,directory+str(frame_index)+'.png')

def get_displacement_1D(self,directory,data_name=None):#,id=0
R"""
example:
import data_analysis_cycle as dac
daw = dac.data_analysis_workflow()
directory,data_name = daw.gsd_to_txyz(simu_index=4302,io_only=True)
daw.get_displacement_1D(directory,data_name)
"""
file_txyz_stable = directory + 'txyz_stable.npy'
txyz_stable = numpy.load(file_txyz_stable)
sz = numpy.shape(txyz_stable)
#print(sz)
"""
prefix = directory
folder_name = ''
isExists=os.path.exists(prefix+folder_name)
if not isExists:
os.makedirs(prefix+folder_name)
prefix = prefix+folder_name
"""

#dpa = pa.dynamic_points_analysis_2d(txyz_stable,mode='simu')
#import points_analysis_2D as pa
#dp = pa.dynamic_points_analysis_2d(txyz_stable)
df = pa.dynamical_facilitation_module()
for id in range(sz[1]):
ax = df.plot_displacement_t(txyz_stable[:,id,:2])
png_filename = directory+data_name+'_'+str(int(id))+'.png'
ax.set_title(data_name+'_'+str(int(id)))
plt.savefig(png_filename)
plt.close()

def get_displacement_1D_overlap(self,directory,data_name=None):#,id=0
file_txyz_stable = directory + 'txyz_stable.npy'
txyz_stable = numpy.load(file_txyz_stable)
sz = numpy.shape(txyz_stable)
df = pa.dynamical_facilitation_module()
fig,ax = plt.subplots()
for id in range(sz[1]):#
df.plot_displacement_t(txyz_stable[:,id,:2],ax)
ax.set_xlabel('t (k steps)')
ax.set_ylabel('$\delta$r ($\sigma$)')
ax.set_title(data_name+'_'+str(int(id)))
png_filename = directory+data_name+'_dr_abs'+'.png'
plt.savefig(png_filename)
plt.close()

def scan_displacement_1D_overlap(self,directory,data_name=None):#,id=0
file_txyz_stable = directory + 'txyz_stable.npy'
txyz_stable = numpy.load(file_txyz_stable)
sz = numpy.shape(txyz_stable)
df = pa.dynamical_facilitation_module()
fig,ax = plt.subplots()
for id in range(sz[1]):#
df.plot_displacement_t(txyz_stable[:,id,:2],ax)
df.plot_scan_displacement_t(txyz_stable[:,id,:2],ax)
ax.set_xlabel('t (k steps)')
ax.set_ylabel('$\delta$r ($\sigma$)')
ax.set_title(data_name+'_'+str(int(id)))
png_filename = directory+data_name+'_dr_abs'+'.png'
plt.savefig(png_filename)
plt.close()

def get_displacement_1D_data(self,directory,data_name=None):
file_txyz_stable = directory + 'txyz_stable.npy'
txyz_stable = numpy.load(file_txyz_stable)
sz = numpy.shape(txyz_stable)
df = pa.dynamical_facilitation_module()

for id in range(sz[1]):#
df.plot_displacement_t(txyz_stable[:,id,:2])


class transfer_txt_to_array:
R"""
introduction:
to draw traps on bond_plot in exp,
I have to transfer txt/tsf file into array
example:
import numpy as np
import data_analysis_cycle as dac
Expand Down Expand Up @@ -1660,4 +1785,5 @@ def get_scatter(self,account,data):
plt.colorbar()
png_filename=prefix+'K_VS_T_Psi6_as_value'+postfix
plt.savefig(png_filename)
plt.close()
plt.close()

File renamed without changes.
Loading

0 comments on commit 98fb799

Please sign in to comment.