def _output_ics_file(self): npart = [ self.p.N_GAS, self.p.N_HALO, self.p.N_DISK, self.p.N_BULGE, 0, 0 ] mdisk, mbulge = 0.0, 0.0 if self.p.M_STAR > 0.0: mdisk = self.p.M_STAR / self.p.N_DISK if self.p.M_BULGE > 0.0: mbulge = self.p.M_BULGE / self.p.N_BULGE masses = [0, self.p.M_HALO / self.p.N_HALO, mdisk, mbulge, 0, 0] out_file = self.p.OutputDir + '/' + self.p.OutputFile if out_file[5:] != '.hdf5' and out_file[3:] != '.h5': out_file += '.hdf5' ics = arepo.ICs(out_file, npart, masses=masses) id0 = 1 for part in self.data.keys(): for key in self.data[part].keys(): getattr(getattr(ics, part), key)[:] = self.data[part][key] N = len(self.data[part]['pos']) getattr(getattr(ics, part), 'id')[:] = np.arange(id0, id0 + N) id0 += N ics.write()
L_x = 0.5 L_y = 2. N_x = 256 N_y = 4 * N_x P = 2.5 g = -0.1 rho1 = 1. rho2 = 2. GAMMA = 1.4 dx = L_x / N_x dy = L_y / N_y sn = arepo.ICs("ics.hdf5", [N_x * N_y, 0, 0, 0, 0, 0], precision=np.float64) mesh = np.meshgrid(np.arange(N_x), np.arange(N_y)) posx = (mesh[0] * dx).reshape(N_x * N_y) + 0.5 * dx posy = (mesh[1] * dy).reshape(N_x * N_y) + 0.5 * dy sn.part0.pos[:, 0] = posx sn.part0.pos[:, 1] = posy rho = np.zeros((N_x * N_y)) rho[:N_y / 2 * N_x] = rho1 rho[N_y / 2 * N_x:] = rho2 sn.part0.mass[:] = rho * dx * dy
L_x = 1. L_y = 1. L_z = 1. N_x = 64 N_y = 64 N_z = 64 P = 1e-4 GAMMA = 5. / 3. dx = L_x / N_x dy = L_y / N_y dz = L_z / N_z sn = arepo.ICs("ics_3d.hdf5", [N_x * N_y * N_z, 0, 0, 0, 0, 0], precision=np.float64) mesh = np.mgrid[0:N_x, 0:N_y, 0:N_z] posx = (mesh[0] * dx).reshape(N_x * N_y * N_z) + 0.5 * dx posy = (mesh[1] * dy).reshape(N_x * N_y * N_z) + 0.5 * dy posz = (mesh[2] * dz).reshape(N_x * N_y * N_z) + 0.5 * dz sn.part0.pos[:, 0] = posx sn.part0.pos[:, 1] = posy sn.part0.pos[:, 2] = posz sn.part0.mass[:] = 1. * dx * dy * dz sn.part0.u[:] = P / ((GAMMA - 1) * 1.) E0 = 1. / sn.part0.mass[0] / 8.