def run_measurment(self, steps, sample): assert not self.filament.attributes.magnetize, "you are running with the non-spara run funct !!!!!" sys.integrator.run(steps=0) dict_of_god = dict() prop_dict = self.filter_part_properties() for timestep in range(steps): logging.info('integrating step: ' + str(timestep)) sys.integrator.run(steps=sample) dict_of_god['timestep_%s' % timestep] = { 'pid_%s' % x.id: {y: getattr(x, y) for y in prop_dict} for x in sys.part[self.filament.attributes.realz_indices] } vtf.writevcf(sys, measurments_trj) measurments_trj.flush() pickle.dump(dict_of_god, gzip.open(path_to_custom_data, 'wb'), pickle.HIGHEST_PROTOCOL)
def setUpClass(cls): """Prepare a testsystem.""" cls.types_to_write = [2, 23] with tempfile.TemporaryFile(mode='w+') as fp: vtf.writevcf(cls.system, fp, types=cls.types_to_write) fp.flush() fp.seek(0) cls.written_pos = np.loadtxt(fp, comments="t") with tempfile.TemporaryFile(mode='w+') as fp: vtf.writevsf(cls.system, fp, types=cls.types_to_write) fp.flush() fp.seek(0) cls.written_bonds = np.loadtxt( fp, skiprows=1, comments="a", delimiter=":", usecols=[1]) # just the second bonded member fp.seek(0) cls.written_atoms = np.loadtxt( fp, skiprows=1, comments="b", usecols=[1, 7]) # just the part_ID and type_ID
def run_measurment_spara(self, steps, sample): assert self.filament.attributes.magnetize, "you are running with the spara run funct but you shouldnt!!!!!" sys.integrator.run(steps=0) dict_of_god = dict() prop_dict = self.filter_part_properties() for timestep in range(steps): logging.info('integrating step: ' + str(timestep)) for bla in range(sample): self.filament.magnetize() sys.integrator.run(0, recalc_forces=True) sys.integrator.run(steps=1, reuse_forces=True) dict_of_god['timestep_%s' % timestep] = { 'pid_%s' % x.id: {y: getattr(x, y) for y in prop_dict} for x in sys.part.select(lambda p: p.type == self.filament. attributes.type_to_be_magnetized) } vtf.writevcf(sys, measurments_trj) measurments_trj.flush() pickle.dump(dict_of_god, gzip.open(path_to_custom_data, 'wb'), pickle.HIGHEST_PROTOCOL)
############################################################# # Warmup # ############################################################# warm_steps = 10 lj_cap = 1 system.force_cap = lj_cap i = 0 act_min_dist = system.analysis.min_dist() # warmp with zero temperature to remove overlaps system.thermostat.set_langevin(kT=0.0, gamma=1.0) # slowly ramp un up the cap while (act_min_dist < 0.95): vtf.writevcf(system, outfile) print("min_dist: {} \t force cap: {}".format(act_min_dist, lj_cap)) system.integrator.run(warm_steps) system.part[:].v = [0, 0, 0] # Warmup criterion act_min_dist = system.analysis.min_dist() lj_cap = lj_cap * 1.01 system.force_cap = lj_cap #remove force cap lj_cap = 0 system.force_cap = lj_cap system.integrator.run(warm_steps * 10) # restore simulation temperature system.thermostat.set_langevin(kT=1.0, gamma=1.0)
'fluid_field.txt') path_fluid_compressed = os.path.join( os.path.join('/home/lv70806/', dir_path[14:]), 'fluid_compressed.txt.gz') path_fluid_sacrifice = os.path.join( os.path.join('/home/lv70806/', dir_path[14:]), 'you_cant_see_me.txt') core_inst = core() sim_inst = Simulation(core_inst) sim_inst.initialise_filament() sim_inst.set_filament() sim_inst.bond_rasp() sim_inst.init_magnetic_inter() sim_inst.set_steric() vtf.writevsf(sys, measurments_trj) vtf.writevcf(sys, measurments_trj) sim_inst.set_rot_intertia_from_units() print(sys.cuda_init_handle.device_list) sys.cuda_init_handle.device = 0 lbb = sim_inst.init_lb_GPU(timestep=core.time_step) sim_inst.create_flow_channel() # ////////////////////////////////////////////////////////////////////////////////////////////// sys.part.clear() lokacija = '/home/lv70806/deniz/upload/pypresso_testing/raspberry_filaments/shear_polymers/playground_magnetic_sphere' path_fluid_save = os.path.join(lokacija, 'fluid_field.txt') path_fluid_compressed = os.path.join(lokacija, 'fluid_compressed.txt.gz') path_fluid_sacrifice = os.path.join(lokacija, 'you_cant_see_me.txt')
sigma=lj_sig, cutoff=lj_cut, shift='auto') system.non_bonded_inter[0, 1].lennard_jones.set_params(epsilon=lj_eps, sigma=lj_sig, cutoff=lj_cut_mixed, shift='auto') system.force_cap = lj_cap checkpoint.register("system.non_bonded_inter") # write structure block as header vtf.writevsf(system, fp, types='all') # write initial positions as coordinate block vtf.writevcf(system, fp, types='all') # STEP 4 Warmup warm_steps = 100 warm_n_time = 2000 min_dist = 0.87 i = 0 act_min_dist = system.analysis.min_dist() while i < warm_n_time and act_min_dist < min_dist: system.integrator.run(warm_steps) act_min_dist = system.analysis.min_dist() i += 1 lj_cap += 1.0 system.force_cap = lj_cap
system.time_step = time_step for p in system.part[novi_kolacici:]: p.vs_auto_relate_to(0) # make sure that the mean values bellow correspond to values you expect!!! # also by tuning the nuber of partciles in the raspberry try to minimise the st_dev! you will see once you cant get better, doesnt take much time slice_master = [x.id for x in system.part[:] if x.type == 1] lister = [ np.linalg.norm(system.part[i].pos - system.part[j].pos) for i, j in product(slice_master, slice_master) if i != j ] lister.sort(reverse=False) print('mean of shell: ', np.mean(lister[:n_col_part - 10])) print('std dev of shell:', np.std(lister[:n_col_part - 10])) slice_master = [x.id for x in system.part[:] if x.type == 2] lister = [ np.linalg.norm(system.part[i].pos - system.part[j].pos) for i, j in product(slice_master, slice_master) if i != j ] lister.sort(reverse=False) print('mean of core: ', np.mean(lister[:n_col_part - 10])) print('std dev of core:', np.std(lister[:n_col_part - 10])) system.part[0].pos = (0, 0, 0) system.integrator.run(1) custom_data = open('raspberry_visual.vtf', mode='w+t') vtf.writevsf(system, custom_data) vtf.writevcf(system, custom_data)