示例#1
0
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
示例#2
0
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