def print_log(pre, time, gravity, E0=0.0 | nbody_system.energy, cpu0=0.0, wall0=0.0): cpu = cputime() wall = wallclocktime() N = len(gravity.particles) M = gravity.total_mass U = gravity.potential_energy T = gravity.kinetic_energy Etop = T + U E = Etop if E0 == 0 | nbody_system.energy: E0 = E Rvir = -0.5 * M * M / U Q = -T / U com = pa.center_of_mass(gravity.particles) comv = pa.center_of_mass_velocity(gravity.particles) if N > 15: dcen,rcore,rhocore \ = pa.densitycentre_coreradius_coredens(gravity.particles) else: dcen = com rcore = zero rhocore = zero cmx, cmy, cmz = dcen lagr, mf = pa.LagrangianRadii(gravity.particles, cm=dcen) # no units! print '' print pre + "time=", time.number print pre + "cpu=", cpu - cpu0 print pre + "wall=", wall - wall0 print pre + "Ntot=", N print pre + "mass=", M.number print pre + "Etot=", E.number print pre + "dE/E=", E / E0 - 1 print pre + "Rvir=", Rvir.number print pre + "Qvir=", Q cmx, cmy, cmz = com print pre + "cmpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx, cmy, cmz = comv print pre + "cmvel[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx, cmy, cmz = dcen print pre + "dcpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) print pre + "Rcore=", rcore.number print pre + "Mlagr[9]=", for m in mf: print "%.4f" % (m), print '' print pre + "Rlagr[9]=", for r in lagr.number: print "%.8f" % (r), print '' sys.stdout.flush() return E, cpu, wall
def print_log(pre, time, gravity, E0 = 0.0 | nbody_system.energy, cpu0 = 0.0, wall0 = 0.0): # Standard log output. cpu = cputime() wall = wallclocktime() N = len(gravity.particles) M = gravity.total_mass U = gravity.potential_energy T = gravity.kinetic_energy Etop = T + U E = Etop if E0 == 0 | nbody_system.energy: E0 = E Rvir = -0.5*M*M/U Q = -T/U com = pa.center_of_mass(gravity.particles) comv = pa.center_of_mass_velocity(gravity.particles) if N >= 100: dcen,rcore,rhocore \ = pa.densitycentre_coreradius_coredens(gravity.particles) cmx,cmy,cmz = dcen lagr,mf = pa.LagrangianRadii(gravity.particles, cm=dcen) # no units! print '' print pre+"time=", time.number print pre+"cpu=", cpu-cpu0 print pre+"wall=", wall-wall0 print pre+"Ntot=", N print pre+"mass=", M.number print pre+"Etot=", E.number print pre+"dE/E=", E/E0 - 1 print pre+"Rvir=", Rvir.number print pre+"Qvir=", Q cmx,cmy,cmz = com print pre+"cmpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = comv print pre+"cmvel[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) if N >= 100: cmx,cmy,cmz = dcen print pre+"dcpos[3]= %.8f %.8f %.8f" \ % (cmx.number, cmy.number, cmz.number) print pre+"Rcore=", rcore.number print pre+"Mlagr[9]=", for m in mf: print "%.4f" % (m), print '' print pre+"Rlagr[9]=", for r in lagr.number: print "%.8f" % (r), print '' sys.stdout.flush() return E,cpu,wall
def print_log(pre, time, gravity, E0 = 0.0 | nbody_system.energy, cpu0 = 0.0): cpu = clock() N = len(gravity.particles) M = gravity.total_mass U = gravity.potential_energy T = gravity.kinetic_energy Etop = T + U Nmul, Nbin, Emul = gravity.get_total_multiple_energy() tmp1,tmp2,Emul2 = gravity.get_total_multiple_energy2() Etot = Etop + Emul Eext = gravity.multiples_external_tidal_correction Eint = gravity.multiples_internal_tidal_correction Eerr = gravity.multiples_integration_energy_error Edel = gravity.multiples_external_tidal_correction \ + gravity.multiples_internal_tidal_correction \ + gravity.multiples_integration_energy_error Ecor = Etot - Edel if E0 == 0 | nbody_system.energy: E0 = Ecor Rvir = -0.5*M*M/U Q = -T/U com = pa.center_of_mass(gravity.particles) comv = pa.center_of_mass_velocity(gravity.particles) dcen,rcore,rhocore = pa.densitycentre_coreradius_coredens(gravity.particles) cmx,cmy,cmz = dcen lagr,mf = pa.LagrangianRadii(gravity.particles, cm=dcen) # no units! print '' print pre+"time=", time.number print pre+"CPU=", cpu - cpu0 print pre+"Ntot=", N print pre+"mass=", M.number print pre+"Etot=", Etot.number print pre+"Etop=", Etop.number print pre+"Eext=", Eext.number print pre+"Eint=", Eint.number print pre+"Eerr=", Eerr.number print pre+"Edel=", Edel.number print pre+"Ecor=", Ecor.number print pre+"dE/E=", Ecor/E0 - 1 print pre+"Rvir=", Rvir.number print pre+"Qvir=", Q cmx,cmy,cmz = com print pre+"cmpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = comv print pre+"cmvel[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = dcen print pre+"dcpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) print pre+"Rcore=", rcore.number print pre+"Mcore=", (rhocore*rcore**3).number # fake... print pre+"Mlagr[9]=", for m in mf: print "%.4f" % (m), print '' print pre+"Rlagr[9]=", for r in lagr.number: print "%.8f" % (r), print '' kT = T/N Nmul,Nbin,Emul = gravity.print_multiples2(pre, kT, dcen) print pre+"Nmul=", Nmul print pre+"Nbin=", Nbin print pre+"Emul= %.5f" % (Emul.number) print pre+"Emul2= %.5f" % (Emul2.number) print pre+"Emul/kT= %.5f" % (Emul/kT) print pre+"Emul/E= %.5f" % (Emul/Etot) print '' sys.stdout.flush() return Ecor,cpu
def print_log(pre, time, gravity, E0 = 0.0 | nbody_system.energy, cpu0 = 0.0): cpu = clock() N = len(gravity.particles) M = gravity.total_mass U = gravity.potential_energy T = gravity.kinetic_energy Etop = T + U Nmul, Nbin, Emul = gravity.get_total_multiple_energy() tmp1,tmp2,Emul2 = gravity.get_total_multiple_energy2() Etot = Etop + Emul Eext = gravity.multiples_external_tidal_correction Eint = gravity.multiples_internal_tidal_correction Eerr = gravity.multiples_integration_energy_error Edel = gravity.multiples_external_tidal_correction \ + gravity.multiples_internal_tidal_correction \ + gravity.multiples_integration_energy_error Ecor = Etot - Edel if E0 == 0 | nbody_system.energy: E0 = Ecor Rvir = -0.5*M*M/U Q = -T/U com = pa.center_of_mass(gravity.particles) comv = pa.center_of_mass_velocity(gravity.particles) dcen,rcore,rhocore = pa.densitycentre_coreradius_coredens(gravity.particles) cmx,cmy,cmz = dcen lagr,mf = pa.LagrangianRadii(gravity.particles, cm=dcen) # no units! print '' print pre+"time=", time.number print pre+"CPU=", cpu - cpu0 print pre+"Ntot=", N print pre+"mass=", M.number print pre+"Etot=", Etot.number print pre+"Etop=", Etop.number print pre+"Eext=", Eext.number print pre+"Eint=", Eint.number print pre+"Eerr=", Eerr.number print pre+"Edel=", Edel.number print pre+"Ecor=", Ecor.number print pre+"dE/E=", Ecor/E0 - 1 print pre+"Rvir=", Rvir.number print pre+"Qvir=", Q cmx,cmy,cmz = com print pre+"cmpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = comv print pre+"cmvel[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = dcen print pre+"dcpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) print pre+"Rcore=", rcore.number print pre+"Mcore=", (rhocore*rcore**3).number # fake... print pre+"Mlagr[9]=", for m in mf: print "%.4f" % (m), print '' print pre+"Rlagr[9]=", for r in lagr.number: print "%.8f" % (r), print '' kT = T/N Nmul,Nbin,Emul = gravity.print_multiples2(pre, kT, dcen) print pre+"Nmul=", Nmul print pre+"Nbin=", Nbin print pre+"Emul= %.5f" % (Emul.number) print pre+"Emul2= %.5f" % (Emul2.number) print pre+"Emul/kT= %.5f" % (Emul.number/kT.number) print pre+"Emul/E= %.5f" % (Emul.number/Etot.number) print '' sys.stdout.flush() return Ecor,cpu
def print_log(pre, time, gravity, E0 = 0.0 | nbody_system.energy, cpu0 = 0.0): cpu = clock() N = len(gravity.particles) M = gravity.total_mass U = gravity.potential_energy T = gravity.kinetic_energy Etop = T + U Nmul, Nbin, Emul = gravity.get_total_multiple_energy() tmp1,tmp2,Emul2 = gravity.get_total_multiple_energy2() Etot = Etop + Emul Eext = gravity.multiples_external_tidal_correction Eint = gravity.multiples_internal_tidal_correction Eerr = gravity.multiples_integration_energy_error Edel = Eext + Eint + Eerr Ecor = Etot - Edel if E0 == 0 | nbody_system.energy: E0 = Ecor Rvir = -0.5*M*M/U Q = -T/U com = pa.center_of_mass(gravity.particles) comv = pa.center_of_mass_velocity(gravity.particles) # Hop complains if we have too few particles. dcen = com if N >= 100: dcen,rcore,rhocore \ = pa.densitycentre_coreradius_coredens(gravity.particles) cmx,cmy,cmz = dcen lagr,mf = pa.LagrangianRadii(gravity.particles, cm=dcen) # no units! print '' print pre+"time=", time.number print pre+"CPU=", cpu - cpu0 print pre+"Ntot=", N print pre+"mass=", M.number print pre+"Etot=", Etot.number print pre+"Etop=", Etop.number print pre+"Eext=", Eext.number print pre+"Eint=", Eint.number print pre+"Eerr=", Eerr.number print pre+"Edel=", Edel.number print pre+"Ecor=", Ecor.number print pre+"dE=", Ecor.number - E0.number print pre+"dE/E=", Ecor/E0 - 1 print pre+"Rvir=", Rvir.number print pre+"Qvir=", Q cmx,cmy,cmz = com print pre+"cmpos[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) cmx,cmy,cmz = comv print pre+"cmvel[3]= %.8f %.8f %.8f" % (cmx.number, cmy.number, cmz.number) if N >= 100: cmx,cmy,cmz = dcen print pre+"dcpos[3]= %.8f %.8f %.8f" \ % (cmx.number, cmy.number, cmz.number) print pre+"Rcore=", rcore.number print pre+"Mcore=", (rhocore*rcore**3).number # fake... print pre+"Mlagr[9]=", for m in mf: print "%.4f" % (m), print '' print pre+"Rlagr[9]=", for r in lagr.number: print "%.8f" % (r), print '' kT = 2*T/(3.*N) # 3/2 N kT = total KE, by definition kT0 = -2*E0/(3.*N) print pre+"kT= %.8f" % (kT.number) Nmul,Nbin,Emul = gravity.print_multiples2(pre, kT, dcen) print pre+"Nmul=", Nmul print pre+"Nbin=", Nbin print pre+"Emul= %.5f" % (Emul.number) print pre+"Emul2= %.5f" % (Emul2.number) print pre+"Emul/kT= %.5f" % (Emul/kT) print pre+"Emul/kT0= %.5f" % (Emul/kT0) print pre+"Emul/E= %.5f" % (Emul/Etot) print '' stars = gravity.particles.copy() schannel = gravity.particles.new_channel_to(stars) schannel.copy_attribute("index_in_code", "id") print_binaries(pre, stars, kT, 0.1) sys.stdout.flush() return Ecor,cpu