def read_and_calc(self, target, c_strain): uobj = UDFManager(target) time = [] temp = [] stress = [] strain = [] # データ読み込み prev_stress = 0. for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # time.append(uobj.get("Time")) temp.append(uobj.get('Statistics_Data.Temperature.Batch_Average')) # if self.mode == 'elong': strs = uobj.get("Statistics_Data.Stress.Total.Batch_Average") tmp_stress = strs[2] - (strs[0] + strs[1]) / 2. elif self.mode == 'shear': tmp_stress = uobj.get( 'Statistics_Data.Stress.Total.Batch_Average.xy' ) #- self.ave_xy if tmp_stress <= 0: tmp_stress = prev_stress # stress.append(tmp_stress) strain.append(c_strain) prev_stress = tmp_stress # stress_part = np.stack([time, stress, temp], 1) strain_part = np.stack([time, strain, temp], 1) return stress_part, strain_part
def read_and_calc(area_init, z_init, target): uobj = UDFManager(target) data = [] for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # cell = uobj.get("Structure.Unit_Cell.Cell_Size") # stress = uobj.get("Statistics_Data.Stress.Total.Batch_Average") t_stress = calc_stress(cell, stress, area_init) # bond_stress = uobj.get("Statistics_Data.Stress.Bond.Batch_Average") bond = calc_stress(cell, bond_stress, area_init) # non_bond_stress = uobj.get( "Statistics_Data.Stress.Non_Bond.Batch_Average") non_bond = calc_stress(cell, non_bond_stress, area_init) # strain = uobj.get("Structure.Unit_Cell.Cell_Size.c") / z_init # temp = uobj.get("Statistics_Data.Temperature.Batch_Average") # data.append([strain, t_stress, non_bond, bond, temp]) return data
def read_and_calc(self, target): uobj = UDFManager(target) time = [] g = [] temp = [] # データ読み込み prev_g = 0. for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # time.append(uobj.get("Time")) temp.append(uobj.get('Statistics_Data.Temperature.Batch_Average')) # if self.mode == 'elong': stress = uobj.get("Statistics_Data.Stress.Total.Batch_Average") tmp_g = (stress[2] - (stress[0] + stress[1]) / 2.) / (self.deform**2 - 1 / self.deform) elif self.mode == 'shear': tmp_stress = uobj.get( 'Statistics_Data.Stress.Total.Batch_Average.xy' ) - self.ave_xy tmp_g = tmp_stress / self.deform if tmp_g <= 0: tmp_g = prev_g g.append(tmp_g) prev_g = tmp_g # smoothing mod_g = signal.savgol_filter(g, 11, 3) # pack up data = np.stack([time, g, temp], 1) data_mod = np.stack([time, mod_g, temp], 1) return data, data_mod
def read_step_stress(self, t_udf): print("Readin file = ", t_udf) area_init, z_init = self.calc_init(t_udf) uobj = UDFManager(t_udf) time = [] strain = [] stress = [] temp = [] # データ読み込み prev_stress = 0. for rec in range(uobj.totalRecord()): print("Reading Rec.=", rec) uobj.jump(rec) # time.append(uobj.get("Time")) if self.mode == 'elong': tmp_strain = uobj.get( "Structure.Unit_Cell.Cell_Size.c") / z_init elif self.mode == 'shear': tmp_strain = uobj.get('Structure.Unit_Cell.Shear_Strain') strain.append(tmp_strain) # if rec == 0: tmp_stress = prev_stress temp.append(1.) else: temp.append( uobj.get('Statistics_Data.Temperature.Batch_Average')) if self.mode == 'elong': stress_list = uobj.get( "Statistics_Data.Stress.Total.Batch_Average") tmp_stress = stress_list[2] - (stress_list[0] + stress_list[1]) / 2. elif self.mode == 'shear': tmp_stress = uobj.get( 'Statistics_Data.Stress.Total.Batch_Average.xy' ) #- self.ave_xy if tmp_stress <= 0: tmp_stress = prev_stress stress.append(tmp_stress) # prev_stress = tmp_stress # stress_step = np.stack([time, stress, temp], 1) strain_step = np.stack([time, strain, temp], 1) ss = np.stack([strain, stress, temp], 1) self.plot(strain_step, 'strain_step.dat') self.plot(stress_step, 'stress_step.dat') self.plot(ss, 'ss.dat') return stress_step, strain_step
def read_and_calc(target): uobj = UDFManager(target) data = [] for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # stress = uobj.get('Statistics_Data.Stress.Total.Batch_Average.xy') # strain = uobj.get('Structure.Unit_Cell.Shear_Strain') # data.append([strain, stress]) return data
def make_base_udf(self, t_udf): if os.path.exists(self.calc_dir): print("Use existing dir of ", self.calc_dir) else: print("Make new dir of ", self.calc_dir) os.makedirs(self.calc_dir) # base = os.path.join(self.calc_dir, self.base_udf) print("Readin file = ", t_udf) u = UDFManager(t_udf) # u.jump(u.totalRecord() - 1) # ave_xy = u.get('Statistics_Data.Stress.Total.Total_Average.xy') u.eraseRecord(0, u.totalRecord() - 2) u.write(base) return base
def read_and_calc(target, c_strain, mode): # low = 1e-5 uobj = UDFManager(target) time = [] temp = [] stress = [] strain = [] gt = [] # データ読み込み prev_stress = 0. for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # time.append(uobj.get("Time")) temp.append(uobj.get('Statistics_Data.Temperature.Batch_Average')) # if mode == 'elong': strs = uobj.get("Statistics_Data.Stress.Total.Batch_Average") tmp_stress = strs[2] - (strs[0] + strs[1]) / 2. if tmp_stress <= 0.05 * prev_stress: tmp_stress = 4 * prev_stress / 5 if tmp_stress < 1e-4: tmp_stress = 1e-4 tmp_gt = tmp_stress / c_strain / 3. elif mode == 'shear': tmp_stress = uobj.get( 'Statistics_Data.Stress.Total.Batch_Average.xy' ) #- self.ave_xy if tmp_stress <= 0.05 * prev_stress: tmp_stress = 4 * prev_stress / 5 if tmp_stress < 1e-4: tmp_stress = 1e-4 tmp_gt = tmp_stress / c_strain # tmp_stress = low # stress.append(tmp_stress) strain.append(c_strain) gt.append(tmp_gt) prev_stress = tmp_stress # mod_stress = signal.savgol_filter(stress, 5, 3) stress_part = np.stack([time, mod_stress, temp], 1) strain_part = np.stack([time, strain, temp], 1) gt_part = np.stack([time, gt, temp], 1) return stress_part, strain_part, gt_part
def read_and_calc(target): if target.split('_')[0] == 'Cycle': sim_type = target.split('_')[4] else: sim_type = target.split('_')[3] uobj = UDFManager(target) if sim_type == 'forward': uobj.jump(0) cell = uobj.get("Structure.Unit_Cell.Cell_Size") area_init = cell[0] * cell[1] z_init = cell[2] data = [[1.0, 0, 0, 0]] elif sim_type == 'backward': uobj.jump(1) vol = uobj.get("Statistics_Data.Volume.Batch_Average") area_init = vol**(2. / 3.) z_init = vol**(1. / 3.) data = [] for i in range(1, uobj.totalRecord()): print("Reading Rec.=", i) uobj.jump(i) # cell = uobj.get("Structure.Unit_Cell.Cell_Size") # stress = uobj.get("Statistics_Data.Stress.Total.Batch_Average") t_stress = calc_stress(cell, stress, area_init) # bond_stress = uobj.get("Statistics_Data.Stress.Bond.Batch_Average") bond = calc_stress(cell, bond_stress, area_init) # non_bond_stress = uobj.get( "Statistics_Data.Stress.Non_Bond.Batch_Average") non_bond = calc_stress(cell, non_bond_stress, area_init) # strain = uobj.get("Structure.Unit_Cell.Cell_Size.c") / z_init # temp = uobj.get("Statistics_Data.Temperature.Batch_Average") # data.append([strain, t_stress, non_bond, bond, temp]) return data
print nnk,mxk rr=zeros(1001,float64) hist=zeros(1001,int32) for kkk in range(1, nnk): k1 = float(k01[kkk]) * pi2 / float(lx) k2 = float(k02[kkk]) * pi2 / float(ly) k3 = float(k03[kkk]) * pi2 / float(lz) kl = sqrt(k1*k1+k2*k2+k3*k3) bin = int(kl/delk) rr[bin] = rr[bin] + kl*dia hist[bin] = hist[bin] + 1 for ij in range(0, 1000): if hist[ij]>0: rr[ij]=rr[ij]/float(hist[ij]) print ij,rr[ij],hist[ij] nt=uobj.totalRecord() #print nt suma=zeros(1001,float64) for n in range(0,nt): uobj.jump(n) x = uobj.get("Particles[].R.x") y = uobj.get("Particles[].R.y") z = uobj.get("Particles[].R.z") for kkk in range(1,nnk): k1 = float(k01[kkk]) * pi2 / float(lx) k2 = float(k02[kkk]) * pi2 / float(ly) k3 = float(k03[kkk]) * pi2 / float(lz) kl = sqrt(k1*k1+k2*k2+k3*k3) bin = int(kl/delk) sa1 = 0.0 sa2 = 0.0
def read_step_stress(self, t_udf): print("Readin file = ", t_udf) area_init, z_init = self.calc_init(t_udf) uobj = UDFManager(t_udf) time = [] strain = [] g = [] stress = [] temp = [] # データ読み込み prev_stress = 0. prev_g = 0. for rec in range(uobj.totalRecord()): print("Reading Rec.=", rec) uobj.jump(rec) # time.append(uobj.get("Time")) if self.mode == 'elong': tmp_strain = uobj.get( "Structure.Unit_Cell.Cell_Size.c") / z_init elif self.mode == 'shear': tmp_strain = uobj.get('Structure.Unit_Cell.Shear_Strain') strain.append(tmp_strain) # if rec == 0: tmp_stress = prev_stress tmp_g = prev_g temp.append(1.) else: temp.append( uobj.get('Statistics_Data.Temperature.Batch_Average')) if self.mode == 'elong': stress_list = uobj.get( "Statistics_Data.Stress.Total.Batch_Average") tmp_stress = stress_list[2] - (stress_list[0] + stress_list[1]) / 2. tmp_g = tmp_stress / (tmp_strain**2 - 1 / tmp_strain) elif self.mode == 'shear': tmp_stress = uobj.get( 'Statistics_Data.Stress.Total.Batch_Average.xy' ) - self.ave_xy tmp_g = tmp_stress / tmp_strain if tmp_stress <= 0: tmp_stress = prev_stress tmp_g = prev_g stress.append(tmp_stress) g.append(tmp_g) # prev_stress = tmp_stress prev_g = tmp_g # mod_g = signal.savgol_filter(g, 11, 3) # gt_step_mod = np.stack([time, mod_g, temp], 1) gt_step = np.stack([time, g, temp], 1) ss_step = np.stack([strain, stress, temp], 1) self.save_data(ss_step, 'ss_step.dat') self.save_data(gt_step, 'gt_step.dat') self.save_data(gt_step_mod, 'gt_step_mod.dat') return gt_step, gt_step_mod