Пример #1
0
def make_map(sph, L=200):

    N = L

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.parsec(x)
    y = units.parsec(y)
    z = units.parsec(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    return rho
def make_map(sph, L=200):
    '''Makes 2D-projected density map of the gas particles in the sph code'''

    N = L

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.parsec(x)
    y = units.parsec(y)
    z = units.parsec(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    return rho
def make_map(sph, N=100, L=1, offset_x=None, offset_y=None):
    "Create a density map from an SPH code"
    x, y = numpy.indices((N + 1, N + 1))
    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.parsec(x)
    if offset_x is not None:
        x += offset_x
    y = units.parsec(y)
    if offset_y is not None:
        y += offset_y
    z = units.parsec(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))
    return rho
def plot_map(sph, Sun_and_Jupiter, title, N=100, L=1, show=True):

    print('Plotting', title)

    L = 200

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.AU(x)
    y = units.AU(y)
    z = units.AU(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    Sx = Sun_and_Jupiter[0].x.value_in(units.AU)
    Sy = Sun_and_Jupiter[0].y.value_in(units.AU)
    Sz = Sun_and_Jupiter[0].z.value_in(units.AU)
    Sr = 1
    sun = Circle((Sx, Sy), Sr, color='y')

    Jx = Sun_and_Jupiter[1].x.value_in(units.AU)
    Jy = Sun_and_Jupiter[1].y.value_in(units.AU)
    Jz = Sun_and_Jupiter[1].z.value_in(units.AU)
    Jr = 0.5
    jup = Circle((Jx, Jy), Jr, color='orange')

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    fig, ax = plt.subplots(1, figsize=(8, 8))
    ax.imshow(np.log10(1.e-5 +
                       rho.value_in(units.amu / units.cm**3)).transpose(),
              extent=[-L / 2, L / 2, -L / 2, L / 2],
              vmin=10,
              vmax=15,
              origin='lower')
    ax.add_patch(sun)
    ax.add_patch(jup)
    plt.title(title + ' yr', fontsize=15, weight='bold', pad=10)
    plt.xlabel('AU')
    plt.savefig('q3_distribution_plot_4K/' + title + '.png', dpi=150)

    if show:
        plt.show()

    plt.close()
Пример #5
0
def setup_grid(N, L):
    x,y=np.indices( ( N+1,N+1 ))
    x=L*(x.flatten()-N/2.)/N
    y=L*(y.flatten()-N/2.)/N
    z=0.*x 
    vx=0.*x
    vy=0.*x
    vz=0.*x
    x=units.kpc(x)
    y=units.kpc(y)
    z=units.kpc(z)
    vx=units.kms(vx)
    vy=units.kms(vy)
    vz=units.kms(vz)
    return x, y, z, vx, vy, vz
Пример #6
0
def make_map(sph, L, N=100):

    x, y = numpy.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.

    vx = units.kms(numpy.zeros_like(x.number))
    vy = units.kms(numpy.zeros_like(x.number))
    vz = units.kms(numpy.zeros_like(x.number))

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    return numpy.transpose(rho)
Пример #7
0
def make_map(sph, N=100, L=1):

    x, y = numpy.indices((N + 1, N + 1))
    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.AU(x)
    y = units.AU(y)
    z = units.AU(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    return numpy.transpose(rho)
def plot_map(sph, title, N=100, L=1, show=True):

    print('Plotting', title)

    L = 200

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.AU(x)
    y = units.AU(y)
    z = units.AU(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    plt.figure(figsize=(8, 8))
    plt.imshow(np.log10(1.e-5 + rho.value_in(units.amu / units.cm**3)),
               extent=[-L / 2, L / 2, -L / 2, L / 2],
               vmin=10,
               vmax=15)
    plt.title(title)
    plt.xlabel('AU')
    plt.savefig(title)

    if show:
        plt.show()

    plt.close()
def make_map(sph,N=100,L=1):

    x,y=numpy.indices( ( N+1,N+1 ))

    x=L*(x.flatten()-N/2.)/N
    y=L*(y.flatten()-N/2.)/N
    z=x*0.
    vx=0.*x
    vy=0.*x
    vz=0.*x

    x=units.parsec(x)
    y=units.parsec(y)
    z=units.parsec(z)
    vx=units.kms(vx)
    vy=units.kms(vy)
    vz=units.kms(vz)

    rho,rhovx,rhovy,rhovz,rhoe=sph.get_hydro_state_at_point(x,y,z,vx,vy,vz)
    rho=rho.reshape((N+1,N+1))

    return rho
Пример #10
0
def make_phi_map(sph,N=100,Rrange=(0.3,2),phioffset=0.):

    phi,r=numpy.mgrid[0:2*numpy.pi:N*1j,Rrange[0]:Rrange[1]:N*1j] 
    phi=phi.flatten()
    r=r.flatten()

    x,y=r*numpy.cos(phi+phioffset),r*numpy.sin(phi+phioffset)
    z=x*0.

    vx=0.*x
    vy=0.*x
    vz=0.*x

    x=units.AU(x)
    y=units.AU(y)
    z=units.AU(z)
    vx=units.kms(vx)
    vy=units.kms(vy)
    vz=units.kms(vz)

    rho,rhovx,rhovy,rhovz,rhoe=sph.get_hydro_state_at_point(x,y,z,vx,vy,vz)
    rho=rho.reshape((N,N))

    return numpy.transpose(rho)
def plot_map(sph, particles, title, N=100, L=200, show=True):

    print('Plotting', title)

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.AU(x)
    y = units.AU(y)
    z = units.AU(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    Sun = particles[0]
    Sx = Sun.x.value_in(units.AU)
    Sy = Sun.y.value_in(units.AU)
    Sz = Sun.z.value_in(units.AU)
    #Sr = Sun.radius.value_in(units.AU)
    Sr = 1
    sun = Circle((Sx, Sy), Sr, color='y')

    Jupiter = particles[1]
    Jx = Jupiter.x.value_in(units.AU)
    Jy = Jupiter.y.value_in(units.AU)
    Jz = Jupiter.z.value_in(units.AU)
    #Jr = Jupiter.radius.value_in(units.AU)
    Jr = 0.5
    jup = Circle((Jx, Jy), Jr, color='orange')

    PassStar = particles[2]
    PSx = PassStar.x.value_in(units.AU)
    PSy = PassStar.y.value_in(units.AU)
    PSz = PassStar.z.value_in(units.AU)
    PSr = 2.0
    ps = Circle((PSx, PSy), PSr, color='r')

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    fig, ax = plt.subplots(1, figsize=(8, 8))
    ax.imshow(np.log10(1.e-5 + rho.value_in(units.amu / units.cm**3)),
              extent=[-L / 2, L / 2, -L / 2, L / 2],
              vmin=10,
              vmax=15)
    ax.add_patch(sun)
    ax.add_patch(jup)
    ax.add_patch(ps)
    plt.title(title)
    plt.xlabel('AU')
    plt.savefig(title)

    if show:
        plt.show()

    plt.close()
def plot_map(sph, Sun_and_Jupiter, Pstar, title, N=100, L=1, show=True):

    print('Plotting', title)

    L = 400

    x, y = np.indices((N + 1, N + 1))

    x = L * (x.flatten() - N / 2.) / N
    y = L * (y.flatten() - N / 2.) / N
    z = x * 0.
    vx = 0. * x
    vy = 0. * x
    vz = 0. * x

    x = units.AU(x)
    y = units.AU(y)
    z = units.AU(z)
    vx = units.kms(vx)
    vy = units.kms(vy)
    vz = units.kms(vz)

    Sx = Sun_and_Jupiter[0].x.value_in(units.AU)
    Sy = Sun_and_Jupiter[0].y.value_in(units.AU)
    Sz = Sun_and_Jupiter[0].z.value_in(units.AU)
    #Sr = Sun_and_Jupiter[0].radius.value_in(units.AU)
    Sr = 1
    sun = Circle((Sx, Sy), Sr, color='y')

    Jx = Sun_and_Jupiter[1].x.value_in(units.AU)
    Jy = Sun_and_Jupiter[1].y.value_in(units.AU)
    Jz = Sun_and_Jupiter[1].z.value_in(units.AU)
    #Jr = Sun_and_Jupiter[1].radius.value_in(units.AU)
    Jr = 0.5
    jup = Circle((Jx, Jy), Jr, color='orange')

    Starx = Pstar.x.value_in(units.AU)
    Stary = Pstar.y.value_in(units.AU)
    Starz = Pstar.z.value_in(units.AU)
    Starr = 1.0
    star = Circle((Starx, Stary), Starr, color='r')

    rho, rhovx, rhovy, rhovz, rhoe = sph.get_hydro_state_at_point(
        x, y, z, vx, vy, vz)
    rho = rho.reshape((N + 1, N + 1))

    fig, ax = plt.subplots(1, figsize=(8, 8))
    ax.imshow(np.log10(1.e-5 + rho.value_in(units.amu / units.cm**3)),
              extent=[-L / 2, L / 2, -L / 2, L / 2],
              vmin=10,
              vmax=15)
    ax.add_patch(sun)
    ax.add_patch(jup)
    ax.add_patch(star)
    #plt.title(title)
    plt.xlabel('AU')
    plt.savefig(title)

    if show:
        plt.show()

    plt.close()