dtype=np.float64) else: send_array = -5 * np.array(np.random.rand(4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) if NPx % 2 != 0 and my_coords[0] == 0: send_array = np.zeros((4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) cpllib.recv(recv_array, cnstFRegion) cpllib.send(send_array, velBCRegion) nsteps = cpllib.get("nsteps_coupled") for i in xrange(nsteps): cpllib.recv(recv_array, cnstFRegion) cpllib.send(send_array, velBCRegion) cpllib.dump_region(velBCRegion, send_array, "md_vels.dat", realm_comm, components={ 0: None, 1: None, 2: None }, coords="other") cpllib.finalize()
velBCRegion = np.copy(olap_limits) velBCRegion[3] = velBCRegion[2] velBCPortion = cpllib.my_proc_portion(velBCRegion) [velBCncx, velBCncy, velBCncz] = cpllib.get_no_cells(velBCPortion) # Send dummy random stress distribution (constant value of stress = 0) to MD np.random.seed(1000) send_array = 5 * np.array(np.random.rand(9, cnstncx, cnstncy, cnstncz), order='F', dtype=np.float64) # Receive averaged velocities from LAMMPS socket recv_array = np.zeros((4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) cpllib.send(send_array, cnstFRegion) cpllib.recv(recv_array, velBCRegion) for step in xrange(nsteps): print("CFD step: ", step) cpllib.send(send_array, cnstFRegion) cpllib.recv(recv_array, velBCRegion) dx, dy, dz = (Lx / NCx, Ly / NCy, Lz / NCz) dA = dx * dz # Dump 1, 4 an 7 components of the stress tensor multiplied by the area of the cell func = lambda x: x*dA cpllib.dump_region(cnstFRegion, send_array, "cfd_forces.dat", realm_comm, components={1:func, 4:func, 7:func}, coords="other") cpllib.finalize()
dtype=np.float64) else: send_array = -5 * np.array(np.random.rand(4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) if NPx % 2 != 0 and my_coords[0] == 0: send_array = np.zeros((4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) cpllib.recv(recv_array, cnstFRegion) cpllib.send(send_array, velBCRegion) nsteps = cpllib.get("nsteps_coupled") for i in xrange(nsteps): cpllib.recv(recv_array, cnstFRegion) cpllib.send(send_array, velBCRegion) cpllib.dump_region(cnstFRegion, recv_array, "md_forces.dat", realm_comm, components={ 1: None, 4: None, 7: None }, coords="other") cpllib.finalize()