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
cutoff=2**(1. / 6), shift="auto") fene = interactions.FeneBond(k=10, d_r_max=2) system.bonded_inter.add(fene) positions = polymer.positions(n_polymers=1, beads_per_chain=50, bond_length=1.0, seed=3210) for i, pos in enumerate(positions[0]): id = len(system.part) system.part.add(id=id, pos=pos) if i > 0: system.part[id].add_bond((fene, id - 1)) vtf.writevsf(system, outfile) ############################################################# # 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
shift='auto') system.non_bonded_inter[1, 1].lennard_jones.set_params(epsilon=lj_eps, 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
path_fluid_save = os.path.join(os.path.join('/home/lv70806/', dir_path[14:]), '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')
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)