def test(self): import object_in_fluid as oif system = espressomd.System(box_l=(10, 10, 10)) self.assertEqual(system.max_oif_objects, 0) system.time_step = 0.4 system.cell_system.skin = 0.5 system.thermostat.set_langevin(kT=0, gamma=0.7, seed=42) # creating the template for OIF object cell_type = oif.OifCellType( nodes_file=abspath("data/sphere393nodes.dat"), triangles_file=abspath("data/sphere393triangles.dat"), system=system, ks=1.0, kb=1.0, kal=1.0, kag=0.1, kv=0.1, check_orientation=False, resize=(3.0, 3.0, 3.0)) # creating the OIF object cell0 = oif.OifCell(cell_type=cell_type, particle_type=0, origin=[5.0, 5.0, 5.0]) self.assertEqual(system.max_oif_objects, 1) # cell0.output_vtk_pos_folded(file_name="cell0_0.vtk") # fluid diameter_init = cell0.diameter() print("initial diameter = " + str(diameter_init)) # OIF object is being stretched by factor 1.5 maxCycle = 500 system.part[:].pos = (system.part[:].pos - 5) * 1.5 + 5 diameter_stretched = cell0.diameter() print("stretched diameter = " + str(diameter_stretched)) # main integration loop # OIF object is let to relax into relaxed shape of the sphere for i in range(3): system.integrator.run(steps=90) diameter_final = cell0.diameter() print("final diameter = " + str(diameter_final)) self.assertAlmostEqual(diameter_final / diameter_init - 1, 0, delta=0.005)
# for i in range(0,k,1): # dist = DistanceBetween(ox, oy, oz, cell_positions[i][0], cell_positions[i][1], cell_positions[i][2]) # if dist < (1.0 - allowed_overlap)*2*radius_rbc + 1.0: # origin_ok = 0 # # # if everything was ok, remember origin # if origin_ok == 1: # print ("seeding of cell: "+str(k)+" with origin: "+str(ox)+", "+str(oy)+", "+str(oz)) # sim_info.write("seeding of cell: "+str(k)+" with origin: "+str(ox)+", "+str(oy)+", "+str(oz) + " time: " + str(datetime.datetime.now()) + " " + "\n") # sim_info.write("\n") # cell_positions.append([ox,oy,oz]) # sim_info.close() ########## END - RANDOM SEEDING OF CELLS # CREATING TEMPLATES FOR CELLS rbc_type_1 = oif.OifCellType(nodes_file=rbc_nodes, triangles_file=rbc_triangles, system = system, ks=ks_rbc_1, kb=kb_rbc_1, kal=kal_rbc_1, kag=kag_rbc_1, kv=kv_rbc_1, kvisc=kvisc_rbc\ , resize =[resize_rbc, resize_rbc, resize_rbc], check_orientation=False, normal= True) rbc_type_2 = oif.OifCellType(nodes_file=rbc_nodes, triangles_file=rbc_triangles, system = system, ks=ks_rbc_2, kb=kb_rbc_2, kal=kal_rbc_2, kag=kag_rbc_2, kv=kv_rbc_2, kvisc=kvisc_rbc\ , resize =[resize_rbc, resize_rbc, resize_rbc], check_orientation=False, normal= True) # CREATING CELLS rbcs = list() # #Pre nahodny seeding # for id, pos in enumerate(cell_positions): # if id < diffCells: # print("id cell = " + str(id) + " -> type_1") # sim_info = open(directory + "/sim_info.dat", "a") # sim_info.write("cell " + str(id) + " -> type_1 | ") # sim_info.close() # cell_rbc = oif.OifCell(cell_type=rbc_type_1, particle_type=id, origin=pos, rotate=[random.random()*2*np.pi, random.random()*2*np.pi, random.random()*2*np.pi], particle_mass=mass_rbc/nnode_rbc)
foutParam.write("") ##################################### #initialization ###################################### system = espressomd.System(box_l=[boxX, boxY, boxZ]) system.time_step = timeStep system.cell_system.skin = 0.2 # creating the template for cells cellType = oif.OifCellType(nodes_file=fileNodes, triangles_file=fileTriangles, system=system, ks=ks, kb=kb, kal=kal, kag=kag, kv=kv, kvisc=kvisc, resize=[stretch, stretch, stretch]) # creating the RBC cell = oif.OifCell(cell_type=cellType, particle_type=0, origin=[originX, originY, originZ], rotate=[np.pi / 2.0, 0.0, 0.0], particle_mass=partMass) # fluid lbf = lb.LBFluid(agrid=grid, dens=dens, visc=visc, tau=timeStep) system.actors.add(lbf)
else: warnings.warn("Folder {} already exists, files will be overwritten" .format(output_path)) boxX = 22.0 boxY = 14.0 boxZ = 15.0 time_step = 0.1 system = espressomd.System(box_l=(boxX, boxY, boxZ)) system.time_step = time_step system.cell_system.skin = 0.2 # creating the template for RBCs cell_type = oif.OifCellType( nodes_file="input/rbc374nodes.dat", triangles_file="input/rbc374triangles.dat", system=system, ks=0.04, kb=0.016, kal=0.02, kag=0.9, kv=1.0, check_orientation=False, resize=(2.0, 2.0, 2.0)) # creating the RBCs cell0 = oif.OifCell(cell_type=cell_type, particle_type=0, origin=[5.0, 5.0, 3.0]) cell1 = oif.OifCell(cell_type=cell_type, particle_type=1, origin=[5.0, 5.0, 7.0]) # cell-wall interactions system.non_bonded_inter[0, 10].soft_sphere.set_params( a=0.0001, n=1.2, cutoff=0.1, offset=0.0) system.non_bonded_inter[1, 10].soft_sphere.set_params( a=0.0001, n=1.2, cutoff=0.1, offset=0.0) # fluid
def test(self): import object_in_fluid as oif system = espressomd.System(box_l=(10, 10, 10)) self.assertEqual(system.max_oif_objects, 0) system.time_step = 0.4 system.cell_system.skin = 0.5 # creating the template for OIF object cell_type = oif.OifCellType( nodes_file=abspath("data/sphere393nodes.dat"), triangles_file=abspath("data/sphere393triangles.dat"), system=system, ks=1.0, kb=1.0, kal=1.0, kag=0.1, kv=0.1, check_orientation=False, resize=(3.0, 3.0, 3.0)) # creating the OIF object cell0 = oif.OifCell(cell_type=cell_type, particle_type=0, origin=[5.0, 5.0, 5.0]) self.assertEqual(system.max_oif_objects, 1) # cell0.output_vtk_pos_folded(file_name="cell0_0.vtk") # fluid diameter_init = cell0.diameter() print("initial diameter = " + str(diameter_init)) # OIF object is being stretched by factor 1.5 system.part[:].pos = (system.part[:].pos - 5) * 1.5 + 5 diameter_stretched = cell0.diameter() print("stretched diameter = " + str(diameter_stretched)) # Apply non-isotropic deformation system.part[:].pos = system.part[:].pos * np.array((0.96, 1.05, 1.02)) # Test that restoring forces net to zero and don't produce a torque system.integrator.run(1) np.testing.assert_allclose(np.sum(system.part[:].f, axis=0), [0., 0., 0.], atol=1E-12) total_torque = np.zeros(3) for p in system.part: total_torque += np.cross(p.pos, p.f) np.testing.assert_allclose(total_torque, [0., 0., 0.], atol=2E-12) # main integration loop system.thermostat.set_langevin(kT=0, gamma=0.7, seed=42) # OIF object is let to relax into relaxed shape of the sphere for _ in range(2): system.integrator.run(steps=240) diameter_final = cell0.diameter() print("final diameter = " + str(diameter_final)) self.assertAlmostEqual(diameter_final / diameter_init - 1, 0, delta=0.005)
cell_positions.append([cluster_centerX, cluster_centerY - (cell_radius + gap_size/2.0), cluster_centerZ]) cell_positions.append([cluster_centerX + taznica_length, cluster_centerY, cluster_centerZ]) cell_positions.append([cluster_centerX + tazisko_distance_from_base, cluster_centerY, cluster_centerZ + taznica_length_from_center] ) typeCell_soft = oif.OifCellType(nodes_file="input/sphere642nodes.dat", triangles_file="input/sphere642triangles.dat", check_orientation=False, system=system, ks=0.02, kb=0.1, kal=0.05, kag=0.7, kv=0.9, normal=True, resize=[cell_radius, cell_radius, cell_radius]) # create cells cells = [] for i in range(4): cells.append(oif.OifCell(cell_type=typeCell_soft, particle_type=i, origin=cell_positions[i], particle_mass=0.5)) # cell-wall interactions