def event_by_event(fname_partons, fout): if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 201 cfg.NY = 201 cfg.NZ = 81 cfg.DT = 0.005 cfg.DX = 0.16 cfg.DY = 0.16 cfg.IEOS = 2 cfg.ntskip = 60 cfg.TAU0 = 0.4 cfg.ETAOS = 0.16 cfg.fPathOut = fout t0 = time() visc = CLVisc(cfg) visc.create_ini_from_partons(fname_partons, SIGR=0.6, SIGZ=0.6, KFACTOR=1.2) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=False) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0))
def main(): '''set default platform and device in opencl''' #os.environ[ 'PYOPENCL_CTX' ] = '0:0' print('start ...') t0 = time() from config import cfg cfg.NX = 201 cfg.NY = 201 cfg.NZ = 61 cfg.DT = 0.005 cfg.DX = 0.16 cfg.DY = 0.16 cfg.IEOS = 2 cfg.ntskip = 40 cfg.TAU0 = 0.2 cfg.ETAOS = 0.08 from visc import CLVisc visc = CLVisc(cfg) fname_partons = '/u/lpang/P10.txt' #fname_partons = '/data01/hyihp/pang/GammaJet/AuAu200_0_80/P1.txt' Smearing(cfg, visc.ctx, visc.queue, visc.compile_options, visc.ideal.d_ev[1], fname_partons, visc.eos_table) visc.evolve(max_loops=2400, save_hypersf=True) t1 = time() print('finished. Total time: {dtime}'.format(dtime = t1-t0))
def event_by_event(fname_partons, fout, etaos=0.0): if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 301 cfg.NY = 301 cfg.NZ = 101 cfg.DT = 0.005 cfg.DX = 0.1 cfg.DY = 0.1 cfg.DZ = 0.15 cfg.IEOS = 4 cfg.TFRZ = 0.136 cfg.ntskip = 60 cfg.nzskip = 2 cfg.TAU0 = 0.4 cfg.ETAOS = etaos cfg.fPathOut = fout write_config(cfg) t0 = time() visc = CLVisc(cfg, gpu_id=3) visc.create_ini_from_partons(fname_partons, SIGR=0.6, SIGZ=0.6, KFACTOR=1.3) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=True) t1 = time() print('finished. Total time: {dtime}'.format(dtime = t1-t0))
def event_by_event(fout, cent='30_35', idx=0, etaos=0.0, fname_ini='/lustre/nyx/hyihp/lpang/hdf5_data/auau39.h5', gpu_id=3): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 301 cfg.NY = 301 cfg.NZ = 5 cfg.DT = 0.005 cfg.DX = 0.1 cfg.DY = 0.1 cfg.DZ = 0.15 cfg.IEOS = 1 cfg.TFRZ = 0.136 cfg.ntskip = 60 cfg.nzskip = 1 cfg.TAU0 = 0.4 cfg.ETAOS = etaos cfg.fPathOut = fout t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) parton_list, eid, imp_b, nwound, npartons = read_p4x4(cent, idx, fname_ini) comments = 'cent=%s, eventid=%s, impact parameter=%s, nw=%s, npartons=%s' % ( cent, eid, imp_b, nwound, npartons) write_config(cfg, comments) visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.3, force_bjorken=True) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=False) # test whether queue.finish() fix the opencl memory leak problem visc.queue.finish() t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0))
def setUp(self): cfg.NX = 8 cfg.NY = 8 cfg.NZ = 1 cfg.IEOS = 0 cfg.ETAOS_YMIN = 0.08 cfg.ETAOS_XMIN = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.ETAOS_RIGHT_SLOP = 0.0 self.visc = CLVisc(cfg) self.ctx = self.visc.ideal.ctx self.queue = self.visc.ideal.queue
def one_shot(fout, impact_parameter=7.8): if not os.path.exists(fout): os.makedirs(fout) cfg.NX = 301 cfg.NY = 301 cfg.NZ = 121 cfg.DT = 0.005 cfg.DX = 0.08 cfg.DY = 0.08 cfg.DZ = 0.15 cfg.IEOS = 1 cfg.ntskip = 60 cfg.nxskip = 4 cfg.nyskip = 4 cfg.nzskip = 2 cfg.ImpactParameter = impact_parameter cfg.Hwn = 0.95 cfg.TAU0 = 0.4 cfg.Edmax = 55.0 cfg.ETAOS = 0.20 cfg.fPathOut = fout write_config(cfg) t0 = time() visc = CLVisc(cfg, gpu_id=2) ini = Glauber(cfg, visc.ctx, visc.queue, visc.compile_options, visc.ideal.d_ev[1], save_nbc=True) #visc.create_ini_from_partons(fname_partons, SIGR=0.6, SIGZ=0.6, KFACTOR=1.2) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0)) cwd = os.getcwd() os.chdir('../CLSmoothSpec/build') os.system('cmake -D VISCOUS_ON=ON ..') os.system('make') call(['./spec', fout]) os.chdir(cwd) after_reso = '0' call(['python', '../spec/main.py', fout, after_reso]) os.chdir(cwd)
def get_orbital_angular_momentum(fname_partons): '''calculate the initial orbital angular momentum for minimum bias Au+Au 200 GeV collisions return: jy = -tau0 * \int dx dy deta x * sinh(eta) * ed(x,y,eta) in units of hbar; where GeV*fm = 5 hbar''' cfg.NX = 301 cfg.NY = 301 cfg.NZ = 61 cfg.DT = 0.005 cfg.DX = 0.1 cfg.DY = 0.1 cfg.IEOS = 0 cfg.ntskip = 60 cfg.TAU0 = 0.4 cfg.ETAOS = 0.0 write_config(cfg) t0 = time() visc = CLVisc(cfg, gpu_id=1) visc.create_ini_from_partons(fname_partons, SIGR=0.6, SIGZ=0.6, KFACTOR=1.3) visc.ideal.ev_to_host() ed = visc.ideal.h_ev1[:,0].reshape(cfg.NX, cfg.NY, cfg.NZ) x = np.linspace(-15, 15, cfg.NX, endpoint=True) y = np.ones(cfg.NY) eta_s = np.linspace(-9, 9, cfg.NZ, endpoint=True) xx, yy, hh = np.meshgrid(x, y, eta_s, indexing='ij') jy = - xx * np.sinh(hh) * ed * cfg.TAU0 * cfg.DX * cfg.DY * cfg.DZ #plt.imshow(xx[:,cfg.NY/2,:], origin='lower') #plt.colorbar() #plt.show() return jy.sum()*5.0
def ebehydro(fpath, cent='0_5', etaos=0.12, gpu_id=0, system='pbpb2760', oneshot=False): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' fout = fpath if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 200 cfg.NY = 200 cfg.NZ = 121 cfg.DT = 0.02 cfg.DX = 0.16 cfg.DY = 0.16 cfg.DZ = 0.20 cfg.ntskip = 20 cfg.nxskip = 2 cfg.nyskip = 2 cfg.nzskip = 2 cfg.IEOS = 1 cfg.TAU0 = 0.6 cfg.fPathOut = fout cfg.TFRZ = 0.120 #cfg.TFRZ = 0.100 cfg.ETAOS_XMIN = 0.154 cfg.ETAOS_YMIN = 0.15 cfg.ETAOS_RIGHT_SLOP = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.save_to_hdf5 = True # for auau if system == 'auau200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'au+au IP-Glasma' collision = AuAu200() scale_factor = 57.0 # for pbpb elif system == 'pbpb2760': cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 comments = 'pb+pb IP-Glasma' collision = PbPb2760() scale_factor = 128.0 elif system == 'pbpb5020': cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 comments = 'pb+pb IP-Glasma' collision = PbPb5020() scale_factor = 151.0 elif system == 'xexe5440': cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 comments = 'xe+xe IP-Glasma' collision = XeXe5440() scale_factor = 145.0 grid_max = cfg.NX/2 * cfg.DX fini = os.path.join(fout, 'trento_ini/') if os.path.exists(fini): call(['rm', '-r', fini]) # use more events for 0-80% than 0-5% to get one-shot initial condition cent_min, cent_max = cent.split('_') events_in_cent = 200 * (int(cent_max) - int(cent_min)) collision.create_ini(cent, fini, num_of_events=events_in_cent, grid_max=grid_max, grid_step=cfg.DX, one_shot_ini=oneshot, align_for_oneshot=True) s = np.loadtxt(os.path.join(fini, 'one_shot_ini.dat')) smax = s.max() s_scale = s * scale_factor t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) ed = from_sd_to_ed(s_scale, visc.ideal.eos) ev = np.zeros((cfg.NX*cfg.NY*cfg.NZ, 4), cfg.real) # repeat the ed(x,y) NZ times ev[:, 0] = np.repeat((ed.T).flatten(), cfg.NZ) eta_max = cfg.NZ//2 * cfg.DZ eta = np.linspace(-eta_max, eta_max, cfg.NZ) heta = np.ones(cfg.NZ) fall_off = np.abs(eta) > cfg.Eta_flat eta_fall = np.abs(eta[fall_off]) heta[fall_off] = np.exp(-(eta_fall - cfg.Eta_flat)**2/(2.0*cfg.Eta_gw**2)) # apply the heta longitudinal distribution ev[:, 0] *= np.tile(heta, cfg.NX * cfg.NY) visc.ideal.load_ini(ev) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=False) write_config(cfg, comments) t1 = time() print('finished. Total time: {dtime}'.format(dtime = t1-t0)) viscous_on = "true" if etaos < 0.0001: viscous_on = "false" # get particle spectra from MC sampling and force decay call(['python', '../pyvisc/spec.py', '--event_dir', cfg.fPathOut, '--viscous_on', viscous_on, "--reso_decay", "true", "--nsampling", "2000", '--mode', 'mc']) # calc the smooth particle spectra call(['python', '../pyvisc/spec.py', '--event_dir', cfg.fPathOut, '--viscous_on', viscous_on, "--reso_decay", "false", '--mode', 'smooth'])
def test_riemann(self): ''' initialize with step energy density in (t, x, y, z) coordinates to test the riemann solution, ''' z = np.linspace(-10, 10, cfg.NZ) edv = np.zeros((cfg.NX * cfg.NY * cfg.NZ, 4), dtype=np.float32) from gubser import Riemann analytical_solution = Riemann(z, pressure_left=1.0) #cfg.TAU0 = 1.0 self.visc = CLVisc(cfg) self.ctx = self.visc.ctx self.queue = self.visc.queue ed_ini = analytical_solution.energy_density(cfg.TAU0) vz_ini = analytical_solution.fluid_velocity(cfg.TAU0) for i in range(cfg.NX): for j in range(cfg.NY): for k in range(cfg.NZ): index = i * cfg.NY * cfg.NZ + j * cfg.NZ + k edv[index, 0] = ed_ini[k] edv[index, 3] = vz_ini[k] self.visc.ideal.load_ini(edv) self.visc.evolve(max_loops=1001, plot_bulk=True, save_hypersf=False, force_run_to_maxloop=True) bulk = self.visc.ideal.bulkinfo import matplotlib.pyplot as plt import h5py h5 = h5py.File('riemann_ideal.h5', 'w') h5.create_dataset('z', data=z) nstep = 10 tau_list = np.empty(nstep) cs2 = 1.0 / 3.0 for i in range(nstep): h5.create_dataset('clvisc/ed/%s' % i, data=bulk.ez[i]) h5.create_dataset('clvisc/pr/%s' % i, data=bulk.ez[i] * cs2) h5.create_dataset('clvisc/vz/%s' % i, data=bulk.vz[i]) h5.create_dataset('riemann/ed/%s' % i, data=analytical_solution.energy_density(i)) h5.create_dataset('riemann/pr/%s' % i, data=analytical_solution.pressure(i)) h5.create_dataset('riemann/vz/%s' % i, data=analytical_solution.fluid_velocity(i)) tau = cfg.TAU0 + i * cfg.ntskip * cfg.DT tau_list[i] = tau h5.create_dataset('tau', data=tau_list) h5.close() for i in [0, 2, 4, 8]: plt.plot(z, bulk.ez[i] / 3.0, '--') ez = analytical_solution.pressure(i) plt.plot(z, ez) plt.text(-i, 0.9, r'$\tau=%s\ [fm]$' % i) plt.ylim(-0.5, 1.5) plt.xlabel(r'$z\ [fm]$') plt.ylabel(r'$\varepsilon$') smash_style.set(line_styles=False) plt.savefig('riemann_ed.pdf') plt.close() for i in [0, 2, 4, 8]: plt.plot(z, bulk.vz[i], '--') vz = analytical_solution.fluid_velocity(i) plt.plot(z, vz) plt.text(i, 0.9, r'$\tau=%s\ [fm]$' % i) plt.ylim(-0.5, 1.5) plt.xlabel(r'$z\ [fm]$') plt.ylabel(r'$v_z$') smash_style.set(line_styles=False) plt.savefig('riemann_vz.pdf') plt.close()
def pbpb_collisions(fout, cent_min=0, cent_max=5, edmax=85, idx=0, etaos=0.0, gpu_id=3): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 361 cfg.NY = 361 cfg.NZ = 121 cfg.SQRT = 2760 cfg.DT = 0.01 cfg.DX = 0.08 cfg.DY = 0.08 cfg.DZ = 0.15 cfg.IEOS = 1 cfg.TFRZ = 0.137 cfg.A = 208 cfg.Ra = 6.62 cfg.Edmax = edmax cfg.Eta = 0.546 cfg.Si0 = 6.4 cfg.ImpactParameter = 2.65 cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 cfg.ntskip = 30 cfg.nxskip = 4 cfg.nyskip = 4 cfg.nzskip = 2 cfg.Hwn = 0.95 cfg.TAU0 = 0.6 cfg.ETAOS = etaos cfg.fPathOut = fout cfg.save_to_hdf5 = True comments = 'pb+pb test, cent_min=%s, cent_max=%s, etaos=%s' % ( cent_min, cent_max, etaos) t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) visc.optical_glauber_ini(system='Pb+Pb', cent_min=cent_min, cent_max=cent_max, save_binary_collisions=True) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=False) write_config(cfg, comments) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0))
def ebehydro(fpath, cent='0_5', etaos=0.12, gpu_id=0, system='pbpb2760', boost_invariance=True, oneshot=True): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' fout = fpath if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 66 cfg.NY = 66 cfg.NZ = 67 cfg.DT = 0.02 cfg.DX = 0.3 cfg.DY = 0.3 cfg.DZ = 0.3 cfg.ntskip = 10 cfg.nxskip = 4 cfg.nyskip = 4 cfg.nzskip = 2 #cfg.eos_type = 'hotqcd2014' cfg.eos_type = 'lattice_pce165' cfg.TAU0 = 0.6 cfg.fPathOut = fout cfg.TFRZ = 0.137 cfg.ETAOS_XMIN = 0.16 cfg.ETAOS_YMIN = 0.16 cfg.ETAOS_RIGHT_SLOP = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.save_to_hdf5 = True # for auau if system == 'auau200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'au+au IP-Glasma' collision = AuAu200() scale_factor = 57.0 elif system == 'RuRu200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Ru+Ru IP-Glasma' collision = RuRu200() scale_factor = 57.0 elif system == 'Ru2Ru2200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Ru2+Ru2 IP-Glasma' collision = Ru2Ru2200() scale_factor = 57.0 elif system == 'Ru3Ru3200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Ru3+Ru3 IP-Glasma' collision = Ru3Ru3200() scale_factor = 57.0 elif system == 'ZrZr200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Zr+Zr IP-Glasma' collision = RuRu200() scale_factor = 57.0 elif system == 'Zr2Zr2200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Zr2+Zr2 IP-Glasma' collision = Ru2Ru2200() scale_factor = 57.0 elif system == 'Zr3Zr3200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'Zr3+Zr3 IP-Glasma' collision = Ru3Ru3200() scale_factor = 57.0 elif system == 'Xe2Xe25440': comments = 'Xe2+Xe2' cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.23 collision = Xe2Xe25440() scale_factor = 155.0 #one_shot elif system == 'OO6500': comments = 'O+O' cfg.Eta_gw = 2.0 cfg.Eta_flat = 1.7 collision = OO6500() scale_factor = 180.0 #180.0 one_shot elif system == 'ArAr5850': comments = 'Ar+Ar' cfg.Eta_gw = 2.0 cfg.Eta_flat = 1.7 collision = ArAr5850() scale_factor = 160.0 #160 one_shot # for pbpb else: cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 comments = 'pb+pb IP-Glasma' if system == 'pbpb2760': collision = PbPb2760() scale_factor = 130 #118.0 #130.0 one_shot elif system == 'pbpb5020': cfg.Eta_gw = 2.0 cfg.Eta_flat = 1.7 collision = PbPb5020() scale_factor = 155.0 #one_shot grid_max = np.floor(cfg.NX / 2) * cfg.DX eta_max = np.floor(cfg.NZ / 2) * cfg.DZ fini = os.path.join(fout, 'trento_ini/') if os.path.exists(fini): call(['rm', '-r', fini]) ev = np.zeros((cfg.NX * cfg.NY * cfg.NZ, 4), cfg.real) if boost_invariance: print("################# run Trento 2D ###################") cwd = os.getcwd() os.chdir("../3rdparty/trento_with_participant_plane/build/src/") if oneshot: print("################# oneshot ###################") collision.create_ini(cent, fini, num_of_events=100, grid_max=grid_max, grid_step=cfg.DX, one_shot_ini=oneshot) s = np.loadtxt(os.path.join(fini, 'one_shot_ini.dat')) else: collision.create_ini(cent, fini, num_of_events=1, grid_max=grid_max, grid_step=cfg.DX, one_shot_ini=oneshot) s = np.loadtxt(os.path.join(fini, '0.dat')) os.chdir(cwd) smax = s.max() s_scale = s * scale_factor t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) ed = from_sd_to_ed(s_scale, visc.ideal.eos) # repeat the ed(x,y) NZ times ev[:, 0] = np.repeat((ed.T).flatten(), cfg.NZ) eta_max = cfg.NZ // 2 * cfg.DZ eta = np.linspace(-eta_max, eta_max, cfg.NZ) heta = np.ones(cfg.NZ) fall_off = np.abs(eta) > cfg.Eta_flat eta_fall = np.abs(eta[fall_off]) heta[fall_off] = np.exp(-(eta_fall - cfg.Eta_flat)**2 / (2.0 * cfg.Eta_gw**2)) # apply the heta longitudinal distribution ev[:, 0] *= np.tile(heta, cfg.NX * cfg.NY) else: print("################# run Trento 3D ###################", system) cwd = os.getcwd() os.chdir("../3rdparty/trento3d-master/build/src/") if oneshot: print("################# oneshot ###################") collision.create_ini3D(cent, fini, num_of_events=100, grid_max=grid_max, grid_step=cfg.DX, eta_max=eta_max, eta_step=cfg.DZ, one_shot_ini=oneshot) s = np.loadtxt(os.path.join(fini, 'one_shot_ini.dat')) else: collision.create_ini3D(cent, fini, num_of_events=1, grid_max=grid_max, grid_step=cfg.DX, eta_max=eta_max, eta_step=cfg.DZ, one_shot_ini=oneshot) s = np.loadtxt(os.path.join(fini, '0.dat')) os.chdir(cwd) smax = s.max() s_scale = s * scale_factor t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) ed = from_sd_to_ed(s_scale, visc.ideal.eos) ed = ed.reshape((cfg.NY, cfg.NX, cfg.NZ)) ev[:, 0] = ed.transpose((1, 0, 2)).flatten() visc.ideal.load_ini(ev) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=False) write_config(cfg, comments) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0)) # get particle spectra from MC sampling and force decay call([ 'python', 'spec.py', '--event_dir', cfg.fPathOut, '--viscous_on', "true", "--reso_decay", "true", "--nsampling", "2000", '--mode', 'mc' ])
def event_by_event(fout, cent='30_35', idx=0, etaos=0.0, system='auau200', fname_ini='/lustre/nyx/hyihp/lpang/hdf5_data/auau39.h5', gpu_id=3, switch_off_longitudinal_fluctuations=False, force_bjorken=False, eos_type="lattice_pce150"): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 201 cfg.NY = 201 cfg.NZ = 121 cfg.DT = 0.01 cfg.DX = 0.16 cfg.DY = 0.16 cfg.DZ = 0.16 cfg.ntskip = 32 cfg.nzskip = 2 cfg.nxskip = 2 cfg.nyskip = 2 #cfg.NX = 301 #cfg.NY = 301 #cfg.NZ = 51 #cfg.DT = 0.005 #cfg.DX = 0.1 #cfg.DY = 0.1 #cfg.DZ = 0.2 cfg.eos_type = eos_type #cfg.TFRZ = 0.110 #cfg.TFRZ = 0.105 #cfg.TFRZ = 0.137 cfg.TFRZ = 0.100 cfg.TAU0 = 0.4 if system == 'pbpb2p76': cfg.TAU0 = 0.2 cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 elif system == 'auau200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 #cfg.ETAOS = etaos cfg.ETAOS_XMIN = 0.154 cfg.ETAOS_YMIN = etaos cfg.ETAOS_RIGHT_SLOP = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.fPathOut = fout t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) parton_list, eid, imp_b, nwound, npartons = read_p4x4(cent, idx, fname_ini) comments = 'cent=%s, eventid=%s, impact parameter=%s, nw=%s, npartons=%s' % ( cent, eid, imp_b, nwound, npartons) write_config(cfg, comments) if force_bjorken: if cfg.eos_type == "lattice_pce150": # KFACTOR=1.4 for etaos = 0.08; KFACTOR = 1.2 for etaos=0.16 visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.2, force_bjorken=True) elif cfg.eos_type == "first_order": visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=0.8, force_bjorken=True) elif switch_off_longitudinal_fluctuations: heta = create_longitudinal_profile(cfg) visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.4, longitudinal_profile=heta) else: if etaos >= 0.16: visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.2) elif etaos >= 0.08: visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.4) else: visc.smear_from_p4x4(parton_list, SIGR=0.6, SIGZ=0.6, KFACTOR=1.5) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=True) # test whether queue.finish() fix the opencl memory leak problem visc.queue.finish() t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0))
def ebehydro(fpath, cent='0_5', etaos=0.12, gpu_id=0, system='pbpb2760', oneshot=False): ''' Run event_by_event hydro, with initial condition from smearing on the particle list''' fout = fpath if not os.path.exists(fout): os.mkdir(fout) cfg.NX = 200 cfg.NY = 200 cfg.NZ = 121 cfg.DT = 0.02 cfg.DX = 0.16 cfg.DY = 0.16 cfg.DZ = 0.20 cfg.ntskip = 20 cfg.nxskip = 2 cfg.nyskip = 2 cfg.nzskip = 2 cfg.eos_type = 'lattice_pce150' cfg.TAU0 = 0.6 cfg.fPathOut = fout #cfg.TFRZ = 0.137 cfg.TFRZ = 0.100 cfg.ETAOS_XMIN = 0.154 cfg.ETAOS_YMIN = 0.15 cfg.ETAOS_RIGHT_SLOP = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.save_to_hdf5 = True # for auau if system == 'auau200': cfg.Eta_gw = 1.3 cfg.Eta_flat = 1.5 comments = 'au+au IP-Glasma' collision = AuAu200() scale_factor = 57.0 # for pbpb else: cfg.Eta_gw = 1.8 cfg.Eta_flat = 2.0 comments = 'pb+pb IP-Glasma' if system == 'pbpb2760': collision = PbPb2760() scale_factor = 128.0 elif system == 'pbpb5020': collision = PbPb5020() scale_factor = 151.0 grid_max = cfg.NX / 2 * cfg.DX fini = os.path.join(fout, 'trento_ini/') if os.path.exists(fini): call(['rm', '-r', fini]) collision.create_ini(cent, fini, num_of_events=1, grid_max=grid_max, grid_step=cfg.DX, one_shot_ini=oneshot) if oneshot: s = np.loadtxt(os.path.join(fini, 'one_shot_ini.dat')) else: s = np.loadtxt(os.path.join(fini, '0.dat')) smax = s.max() s_scale = s * scale_factor t0 = time() visc = CLVisc(cfg, gpu_id=gpu_id) ed = from_sd_to_ed(s_scale, visc.ideal.eos) ev = np.zeros((cfg.NX * cfg.NY * cfg.NZ, 4), cfg.real) # repeat the ed(x,y) NZ times ev[:, 0] = np.repeat((ed.T).flatten(), cfg.NZ) eta_max = cfg.NZ // 2 * cfg.DZ eta = np.linspace(-eta_max, eta_max, cfg.NZ) heta = np.ones(cfg.NZ) fall_off = np.abs(eta) > cfg.Eta_flat eta_fall = np.abs(eta[fall_off]) heta[fall_off] = np.exp(-(eta_fall - cfg.Eta_flat)**2 / (2.0 * cfg.Eta_gw**2)) # apply the heta longitudinal distribution ev[:, 0] *= np.tile(heta, cfg.NX * cfg.NY) visc.ideal.load_ini(ev) visc.evolve(max_loops=4000, save_hypersf=True, save_bulk=True, save_vorticity=False) write_config(cfg, comments) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0)) cwd = os.getcwd() os.chdir('../sampler/mcspec/') viscous_on = 'true' after_reso = 'true' nsampling = '2000' call(['python', 'sampler.py', fout, viscous_on, after_reso, nsampling]) os.chdir(cwd) #from create_table import create_table_for_jet #create_table_for_jet(fout, visc.ideal.eos) os.chdir('../CLSmoothSpec/build') #os.system('cmake -D VISCOUS_ON=ON ..') #os.system('make') call(['./spec', fpath]) os.chdir(cwd) after_reso = '0' call(['python', '../spec/main.py', fpath, after_reso])
def one_shot(fout, impact_parameter=7.8, etaos=0.0, with_eloss=False, gpuid=2, eventid=0): if not os.path.exists(fout): os.makedirs(fout) cfg.NX = 301 cfg.NY = 301 cfg.NZ = 121 cfg.DT = 0.005 cfg.DX = 0.08 cfg.DY = 0.08 cfg.DZ = 0.15 cfg.IEOS = 1 cfg.ntskip = 60 cfg.nxskip = 4 cfg.nyskip = 4 cfg.nzskip = 2 cfg.ImpactParameter = impact_parameter cfg.Hwn = 0.95 cfg.TAU0 = 0.4 cfg.Edmax = 55.0 cfg.ETAOS_YMIN = etaos cfg.fPathOut = fout write_config(cfg) t0 = time() visc = CLVisc(cfg, gpu_id=gpuid) ini = Glauber(cfg, visc.ctx, visc.queue, visc.compile_options, visc.ideal.d_ev[1], save_nbc=True) if with_eloss: jet_eloss_src = { 'switch_on': True, 'start_pos_index': random_pos_index[eventid], 'direction': random_angles[eventid] } else: jet_eloss_src = { 'switch_on': False, 'start_pos_index': random_pos_index[eventid], 'direction': random_angles[eventid] } visc.evolve(max_loops=2500, save_hypersf=True, save_bulk=True, jet_eloss_src=jet_eloss_src, force_run_to_maxloop=True) t1 = time() print('finished. Total time: {dtime}'.format(dtime=t1 - t0)) cwd = os.getcwd() os.chdir('../CLSmoothSpec/build') os.system('cmake -D VISCOUS_ON=ON ..') os.system('make') call(['./spec', fout]) os.chdir(cwd) after_reso = '0' call(['python', '../spec/main.py', fout, after_reso]) os.chdir(cwd)
cfg.real = np.float32 cfg.real4 = array.vec.float4 cfg.real8 = array.vec.float8 cfg.sz_real = np.dtype('float32').itemsize #==sizeof(float) in c cfg.sz_real4 = array.vec.float4.itemsize cfg.sz_real8 = array.vec.float8.itemsize else : cfg.real = np.float64 cfg.real4 = array.vec.double4 cfg.real8 = array.vec.double8 cfg.sz_real = np.dtype('float64').itemsize #==sizeof(double) in c cfg.sz_real4= array.vec.double4.itemsize cfg.sz_real8= array.vec.double8.itemsize visc = CLVisc(cfg, gpu_id=cfg.GPU_ID) if cfg.initial_condition == 'Glauber': visc.optical_glauber_ini() visc.evolve(max_loops=2000, save_hypersf=True, save_bulk=False, force_run_to_maxloop=False, save_vorticity=False) t1 = time() print('finished. Total time: {dtime}'.format(dtime = t1-t0), file=sys.stdout) from subprocess import call # get particle spectra from MC sampling and force decay call(['python', 'spec.py', '--event_dir', cfg.fPathOut, '--viscous_on', "false", "--reso_decay", "true", "--nsampling", "2000",
cfg.DX = 0.04 cfg.DY = 0.04 # etaos(T) = 0.2 cfg.ETAOS_YMIN = 0.2 cfg.ETAOS_XMIN = 0.0 cfg.ETAOS_LEFT_SLOP = 0.0 cfg.ETAOS_RIGHT_SLOP = 0.0 cfg.LAM1 = Lam cfg.ntskip = 100 cfg.gubser_visc_test = True cfg.save_to_hdf5 = False cfg.THETA = 1.8 visc = CLVisc(cfg, gpu_id=3) ctx = visc.ctx queue = visc.queue CreateIni(ctx, queue, visc.ideal.d_ev[1], visc.d_pi[1], tau=cfg.TAU0, L=L, lam1=Lam, NX=cfg.NX, NY=cfg.NY, NZ=cfg.NZ, DX=cfg.DX, DY=cfg.DY, DZ=cfg.DZ) CreateIni(ctx, queue, visc.ideal.d_ev[2], visc.d_pi[2], tau=cfg.TAU0 + cfg.DT, L=L, lam1=Lam, NX=cfg.NX, NY=cfg.NY, NZ=cfg.NZ, DX=cfg.DX, DY=cfg.DY, DZ=cfg.DZ) visc.update_udiff(visc.ideal.d_ev[1], visc.ideal.d_ev[2]) visc.evolve(max_loops=2000, force_run_to_maxloop=True, save_bulk=False, plot_bulk=True, save_hypersf=False, save_pi=True) bulk = visc.ideal.bulkinfo