Skip to content
Snippets Groups Projects
Select Git revision
  • cbcd454b57128d24bbca6b761adc8b1c7645842a
  • master default protected
  • darwin/gear_chemistry_fluxes
  • reyz/gear_preSN_feedback
  • fstasys/VEP_Fm2
  • MHD_canvas protected
  • sidm_merge protected
  • beyond-mesh-pair-removal
  • darwin/gear_preSN_fbk_merge
  • fewer_gpart_comms
  • zoom_merge protected
  • MAGMA2_matthieu
  • forcing_boundary_particles
  • melion/BalsaraKim
  • darwin/sink_mpi_physics
  • darwin/gear_mechanical_feedback
  • FS_VP_m2_allGrad
  • improve-snap-to-ic
  • karapiperis/Bcomoving_as_a2_Bphysical
  • split-space-split
  • reyz/debug
  • v2025.10 protected
  • v2025.04 protected
  • v2025.01 protected
  • v1.0.0 protected
  • v0.9.0 protected
  • v0.8.5 protected
  • v0.8.4 protected
  • v0.8.3 protected
  • v0.8.2 protected
  • v0.8.1 protected
  • v0.8.0 protected
  • v0.7.0 protected
  • v0.6.0 protected
  • v0.5.0 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0-pre protected
  • v0.1 protected
  • v0.0 protected
41 results

plotprog.py

Blame
  • Zorry Belcheva's avatar
    Zorry Belcheva authored and Matthieu Schaller committed
    af35dbd9
    History
    plotprog.py 2.10 KiB
    #!/usr/bin/env python
    ###############################################################################
    # This file is part of SWIFT.
    # Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl)
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU Lesser General Public License as published
    # by the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU Lesser General Public License
    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    ################################################################################
    import numpy as np
    import h5py
    import matplotlib.pyplot as plt
    from scipy.integrate import odeint
    
    t = np.linspace(0, 40, 100000)
    y0 = [0, 10]
    a = 30.0
    G = 4.300927e-06
    M = 1e15
    GM = G * M
    
    
    lengthrun = 2001
    numbpar = 3
    
    radius = np.zeros((numbpar, lengthrun))
    xx = np.zeros((numbpar, lengthrun))
    yy = np.zeros((numbpar, lengthrun))
    zz = np.zeros((numbpar, lengthrun))
    time = np.zeros(lengthrun)
    for i in range(0, lengthrun):
        Data = h5py.File("output_%04d.hdf5" % i, "r")
        header = Data["Header"]
        time[i] = header.attrs["Time"]
        particles = Data["PartType1"]
        positions = particles["Coordinates"]
        xx[:, i] = positions[:, 0] - 500.0
        yy[:, i] = positions[:, 1] - 500.0
        zz[:, i] = positions[:, 2] - 500.0
    
    col = ["b", "r", "c", "y", "k"]
    
    for i in range(0, numbpar):
        plt.plot(xx[i, :], yy[i, :], col[i])
    
    plt.ylabel("y (kpc)")
    plt.xlabel("x (kpc)")
    plt.savefig("xyplot.png")
    plt.close()
    
    
    for i in range(0, numbpar):
        plt.plot(xx[i, :], zz[i, :], col[i])
    
    plt.ylabel("z (kpc)")
    plt.xlabel("x (kpc)")
    plt.savefig("xzplot.png")
    plt.close()
    
    for i in range(0, numbpar):
        plt.plot(yy[i, :], zz[i, :], col[i])
    
    plt.ylabel("z (kpc)")
    plt.xlabel("y (kpc)")
    plt.savefig("yzplot.png")
    plt.close()