#!/usr/bin/env python3 ############################################################################### # This file is part of SWIFT. # Copyright (c) 2022 Mladen Ivkovic (mladen.ivkovic@hotmail.com) # 2022 Tsang Keung Chan (chantsangkeung@gmail.com) # # 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 . # ############################################################################## # ---------------------------------------------------------------------- # plots # - radiation energies of particles as function of radius # - magnitude of radiation fluxes of particles as function of radius # - total energy in radial bins # - total vectorial sum of fluxes in radial bins # and compare with expected propagation speed solution. # Usage: # give snapshot number as cmdline arg to plot # single snapshot, otherwise this script plots # all snapshots available in the workdir. # Make sure to select the photon group to plot that # doesn't interact with gas to check the *propagation* # correctly. # ---------------------------------------------------------------------- import gc import os import sys import matplotlib as mpl import numpy as np import swiftsimio import unyt from matplotlib import pyplot as plt from scipy import stats from scipy.optimize import curve_fit import stromgren_plotting_tools as spt # Parameters users should/may tweak # snapshot basename snapshot_base = "propagation_test" # additional anisotropy estimate plot? plot_anisotropy_estimate = False # which photon group to use. # NOTE: array index, not group number (which starts at 1 for GEAR) group_index = 0 scatterplot_kwargs = { "alpha": 0.1, "s": 1, "marker": ".", "linewidth": 0.0, "facecolor": "blue", } lineplot_kwargs = {"linewidth": 2} # ----------------------------------------------------------------------- # Read in cmdline arg: Are we plotting only one snapshot, or all? plot_all = False try: snapnr = int(sys.argv[1]) except IndexError: plot_all = True mpl.rcParams["text.usetex"] = True def analytical_integrated_energy_solution(L, time, r, rmax): """ Compute analytical solution for the sum of the energy in bins for given injection rate at time