Commit 2357fe12 authored by NUNEZ Arturo's avatar NUNEZ Arturo

Automatic commit mardi 17 juillet 2018, 16:30:03 (UTC+0200)

parent 5fb4cff2
......@@ -3970,7 +3970,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": null,
"metadata": {
"collapsed": true
},
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"metadata": {
"collapsed": false,
"hide_input": false
......@@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"collapsed": false,
"hide_input": false
......@@ -112,7 +112,7 @@
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": true
"scrolled": false
},
"outputs": [
{
......@@ -217,6 +217,95 @@
"#########################################################################################3######"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Ellipticity T and S"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"get_mat = np.vectorize(nbe.m_matrix_for_r)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-13-c6922de9b3dd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlinspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmyhydro\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhsml\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mmyhydro\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr200\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m300\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mM_dm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mnbe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mm_matrix_for_r\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmyhydro\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'halo'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mM_st\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mnbe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mm_matrix_for_r\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmyhydro\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'stars'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0ma_dm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb_dm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc_dm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_dm\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_dm\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_dm\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0ma_st\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb_st\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc_st\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_st\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_st\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mM_st\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/arturo/Documents/git/WKBL/wkbl/astro/nbody_essentials.py\u001b[0m in \u001b[0;36mm_matrix_for_r\u001b[0;34m(halo, comp, r)\u001b[0m\n\u001b[1;32m 234\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Not a valid component'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 235\u001b[0m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 236\u001b[0;31m \u001b[0mpos_selection\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 237\u001b[0m \u001b[0mmass_selection\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmass\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 238\u001b[0m \u001b[0mD\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmass_distribution_tensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmass_selection\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mpos_selection\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"r = np.linspace(myhydro.gs.hsml.min(),2*myhydro.r200,300)\n",
"M_dm = np.array([nbe.m_matrix_for_r(myhydro,'halo',i) for i in r])\n",
"M_st = np.array([nbe.m_matrix_for_r(myhydro,'stars',i) for i in r])\n",
"a_dm, b_dm, c_dm = np.sqrt(M_dm[:,0,0]), np.sqrt(M_dm[:,1,1]), np.sqrt(M_dm[:,2,2])\n",
"a_st, b_st, c_st = np.sqrt(M_st[:,0,0]), np.sqrt(M_st[:,1,1]), np.sqrt(M_st[:,2,2])\n",
"S_dm = c_dm/a_dm\n",
"T_dm = ((a_dm**2) - (b_dm**2))/((a_dm**2) -(c_dm**2)) \n",
"S_st = c_st/a_st\n",
"T_st = ((a_st**2) - (b_st**2))/((a_st**2) -(c_st**2)) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"##############################################################################################33\n",
"#########################################################################################3######"
]
},
{
"cell_type": "code",
"execution_count": 10,
This diff is collapsed.
......@@ -288,27 +288,207 @@
"myDMO.p.kpctokm"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# Hydro\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"loading Dark matter..\n",
"loading Stars..\n",
"loading Gas..\n",
"36844.594\n",
"[20418.88714131 17567.72033332 17124.40448217]\n",
"| r_200 = 212.70\n",
"| Diagonal matrix computed \n",
"| | 20, 0, 0|\n",
"| D =| 0, 14, 0|\n",
"| | 0, 0, 4|\n"
]
}
],
"source": [
"#halo = HALOBHydro(where=\"home\") \n",
"\n",
"pathsim = \"/data/OWN/SF1test/SF0/mstar1_T3600/output_00041\"\n",
"myhydro = wkbl.Galaxy_Hound(pathsim)\n",
"print myhydro.dm.pos3d[:,0].max()\n",
"zoom_reg = np.where(myhydro.dm.mass==myhydro.dm.mass.min())\n",
"nucenter = nbe.real_center(myhydro.dm.pos3d[zoom_reg], myhydro.dm.mass[zoom_reg])\n",
"print nucenter\n",
"myhydro.center_shift(nucenter)\n",
"myhydro.r_virial(600,n=25)\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Phy' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-368dc7a307b5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mprint\u001b[0m \u001b[0mPhy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'Phy' is not defined"
"name": "stdout",
"output_type": "stream",
"text": [
"done r200 = 212.6953125\n"
]
}
],
"source": [
"print Phy"
"myGkm = 6.673e-11*(1e-3**3)*myhydro.p.msuntokg#km^ 3 Msun^-1 s^-2\n",
"\n",
"#\"\"\"\n",
"\n",
"print \"done r200 = {0}\".format(myhydro.r200)\n",
"pos_dm = np.array(myhydro.dm.pos3d.reshape(len(myhydro.dm.pos3d)*3),dtype=np.float32)\n",
"pos_gs = np.array(myhydro.gs.pos3d.reshape(len(myhydro.gs.pos3d)*3),dtype=np.float32)\n",
"pos_st = np.array(myhydro.st.pos3d.reshape(len(myhydro.st.pos3d)*3),dtype=np.float32)\n",
"pos = np.concatenate((pos_dm, pos_st))#, pos_gs))\n",
"mass = np.concatenate((myhydro.dm.mass,myhydro.st.mass))#,myhydro.gs.mass))\n",
"v = np.concatenate((myhydro.dm.v,myhydro.st.v))#,myhydro.gs.v))\n",
"\n",
"pos3d = pos.reshape(len(pos)/3,3)\n",
"r = np.sqrt(pos3d[:,0]**2 + pos3d[:,1]**2 +pos3d[:,2]**2)\n",
"r_sorted = np.argsort(r)\n",
"M_i = np.cumsum(mass[r_sorted]) - mass[r_sorted]\n",
"m_i = mass[r_sorted]\n",
"r_i = r[r_sorted]*(1e-2*myhydro.p.pctocm)# in km\n",
"U = np.sum(-myGkm*M_i*m_i/r_i)\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"inside_halo = np.where(r<(myhydro.r200))\n",
"kmtokpc = 1 / 3.08567758128e+16\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.124800100066088e+16"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.sum(mass[inside_halo]*(v[inside_halo])**2) /2."
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6.099869749582234e+16\n"
]
},
{
"data": {
"text/plain": [
"6.908632733532155e-60"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"kgofHtomol = 992.122\n",
"msunohHtomol = kgofHtomol*myhydro.p.msuntokg\n",
"n = myhydro.gs.mass\n",
"print np.sum(myhydro.gs.mass[myhydro.gs.r<myhydro.r200]*myhydro.gs.temp[myhydro.gs.r<myhydro.r200])*(3./2.)\n",
"myhydro.p.k_boltz"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-0.7708812981406286"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"K = (np.sum(mass[inside_halo]*(v[inside_halo])**2) /2. ) + (np.sum(n[myhydro.gs.r<myhydro.r200]*myhydro.gs.temp[myhydro.gs.r<myhydro.r200])*(3./2.))\n",
"2*K/U"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1.5040020737518434e-74"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(3./2.)*myhydro.p.kB*np.sum(myhydro.gs.temp[myhydro.gs.r<myhydro.r200])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"K_thermal_gas = np.sum(myhalo.gs.mass[myhalo.gs.r<myhalo.r200]*myhalo.gs.temp[myhalo.gs.r<myhalo.r200])*(3./2.)"
]
},
{
......@@ -318,7 +498,9 @@
"collapsed": true
},
"outputs": [],
"source": []
"source": [
"q = (np.sum(mass[inside_halo]*(v[inside_halo])**2) / U ) + 1"
]
}
],
"metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment