Last active
August 29, 2015 14:05
-
-
Save yymao/dfc79d12df9ccbfb8a1a to your computer and use it in GitHub Desktop.
A python script to generate a "simulation cheat sheet" which shows the relation between number of particles, box sizes and mass resolutions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulation Cheatsheet by Yao-Yuan Mao | |
import math | |
import numpy as np | |
import matplotlib.pyplot as plt | |
rho_crit = 2.7745945707e+11 | |
log10_rhom_30 = math.log10(rho_crit*0.30) | |
log10_rhom_25 = math.log10(rho_crit*0.25) | |
log2_10 = math.log(10, 2) | |
fig, ax = plt.subplots(figsize=(8,8)) | |
xlim = (-1, 4.5) | |
ylim = (8, 16) | |
xnticks = int((xlim[1]-xlim[0])*2+1) | |
ynticks = int(ylim[1]-ylim[0]+1) | |
#m_log10 = log10(rho_m) + 3/log2(10)*[log2(L/100) - log2(NP)] + 6 | |
#log2(NP) = log2(L/100) - [m_log10 - log10(rho_m) - 6]/3*log2(10) | |
d = lambda lm, lrho: (lm - lrho - 6.)*log2_10/3. | |
x = np.linspace(-1, 5, 2) | |
for i in range(3, 14): | |
d_25 = d(i, log10_rhom_25) | |
d_30 = d(i, log10_rhom_30) | |
ax.plot(x, x-d_25, 'k-', alpha=0.15); | |
ax.plot(x, x-d_30, 'k-', alpha=0.85); | |
if xlim[1]-d_30 < ylim[1]-0.2: | |
ax.text(xlim[1]-0.02, xlim[1]-d_30+0.02, '1E%d'%i, rotation=32, \ | |
ha='right'); | |
else: | |
ax.text(ylim[1]+d_30-0.25, ylim[1]-0.2, '1E%d'%i, rotation=32, \ | |
ha='right'); | |
def puttext(l, p, t, m='s'): | |
x = math.log(l, 2)-log2_10*2 | |
y = math.log(p, 2) | |
ms = 3 if m=='s' else 5 | |
plt.plot(x, y, 'k'+m, ms=ms) | |
plt.text(x+0.05, y+0.02, t, size='small') | |
puttext(250, 2048, 'Bolshoi') | |
#puttext(2400, 1280, 'Oriana') | |
puttext(1000, 1120, 'Carmen') | |
puttext(640, 1250, 'Esmeralda') | |
puttext(500, 2160, 'MS') | |
puttext(100, 2160, 'MS-II') | |
puttext(420, 1400, 'Consuelo') | |
puttext(125, 1024, 'c125-1024') | |
puttext(125, 2048, 'c125-2048') | |
puttext(1000, 10240, 'ds14_b') | |
puttext(1000, 2560, 'ds14_b_sub') | |
puttext(400, 4096, 'ds14_i') | |
puttext(256, 2560, 'ds14_j') | |
puttext(62.5, 270, 'Sussing') | |
puttext(1000, 8192, 'Rhapsody', '*') | |
puttext(125, 8192, 'MW-resims', '*') | |
puttext(50, 4096, 'ELVIS', '*') | |
puttext(50, 8192, 'iELVIS', '*') | |
puttext(100, 900*41, 'Aq-A-1', '*') | |
puttext(100, 900*20.5, 'Aq-A-2', '*') | |
puttext(100, 900*6.7, 'Aq-A-4', '*') | |
ax.grid(); | |
ax.set_xlim(*xlim); | |
ax.set_ylim(*ylim); | |
ax.set_xticks(np.linspace(xlim[0], xlim[1], xnticks)); | |
ax.set_xticklabels((np.logspace(xlim[0], xlim[1], xnticks, base=2)*10.).astype(int)*10); | |
ax.set_yticks(np.linspace(ylim[0], ylim[1], ynticks)); | |
ax.set_yticklabels(np.logspace(ylim[0], ylim[1], ynticks, base=2).astype(int)); | |
ax.set_xlabel(r'Box size on each side [${\rm Mpc}/h$]'); | |
ax.set_ylabel('Number of particles on each side'); | |
ax.set_title(r'Particle mass [$M_\odot/h$] for $\Omega_{M0} = 0.3$ ($0.25$ in grey) and $h=0.7$''\n') | |
fig.tight_layout(); | |
plt.savefig('simulation_cheatsheet.pdf') | |
plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment