Created
June 30, 2017 20:40
-
-
Save anonymous/b80284a5c8fa09d94cf428163f97902d to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"yt : [INFO ] 2017-06-30 15:35:07,580 Parameters: current_time = 0.0060000200028298\n", | |
"yt : [INFO ] 2017-06-30 15:35:07,581 Parameters: domain_dimensions = [32 32 32]\n", | |
"yt : [INFO ] 2017-06-30 15:35:07,582 Parameters: domain_left_edge = [ 0. 0. 0.]\n", | |
"yt : [INFO ] 2017-06-30 15:35:07,583 Parameters: domain_right_edge = [ 1. 1. 1.]\n", | |
"yt : [INFO ] 2017-06-30 15:35:07,585 Parameters: cosmological_simulation = 0.0\n" | |
] | |
} | |
], | |
"source": [ | |
"import yt\n", | |
"import numpy as np\n", | |
"\n", | |
"from yt.units import Mpc\n", | |
"from yt.utilities.amr_kdtree.amr_kdtree import AMRKDTree\n", | |
"from yt.visualization.streamlines import Streamlines\n", | |
"\n", | |
"ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Parsing Hierarchy : 100%|██████████| 173/173 [00:00<00:00, 19168.77it/s]\n", | |
"yt : [INFO ] 2017-06-30 15:35:07,623 Gathering a field list (this may take a moment.)\n" | |
] | |
} | |
], | |
"source": [ | |
"# create AMRKDTRee that uses extrapolation to generate vertex centered data\n", | |
"volume = AMRKDTree(ds)\n", | |
"volume.set_fields(fields=['velocity_x', 'velocity_y', 'velocity_z'], log_fields=[False, False, False], no_ghost=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"scale = ds.domain_width[0]\n", | |
"pos_dx = np.random.random((100,3))*scale-scale/2.\n", | |
"pos = ds.domain_center+pos_dx\n", | |
"\n", | |
"streamlines = Streamlines(ds, pos, 'velocity_x', 'velocity_y', 'velocity_z',\n", | |
" length=0.5*Mpc, get_magnitude=True, volume=volume)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Streamlining: 100%|██████████| 100/100 [00:18<00:00, 5.41it/s]\n" | |
] | |
} | |
], | |
"source": [ | |
"streamlines.integrate_through_volume()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[ 0.3825317 0.90573005 0.38431177]\n", | |
" [ 0.38256523 0.90561744 0.38434483]\n", | |
" [ 0.38259877 0.90550483 0.38437789]\n", | |
" ..., \n", | |
" [ 0.50379712 0.49873317 0.50014693]\n", | |
" [ 0.50385362 0.49884102 0.5001553 ]\n", | |
" [ 0.50390518 0.49895133 0.50016361]] code_length\n" | |
] | |
} | |
], | |
"source": [ | |
"print(streamlines.streamlines[0])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# try again, this time with an AMRKDTree that samples a subset of the simulation volume\n", | |
"# using a data object\n", | |
"volume = AMRKDTree(ds, data_source=ds.sphere(ds.domain_center, 1*Mpc))\n", | |
"volume.set_fields(fields=['velocity_x', 'velocity_y', 'velocity_z'], log_fields=[False, False, False], no_ghost=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"scale = ds.domain_width[0]\n", | |
"pos_dx = np.random.random((100,3))*scale-scale/2.\n", | |
"pos = ds.domain_center+pos_dx\n", | |
"\n", | |
"streamlines = Streamlines(ds, pos, 'velocity_x', 'velocity_y', 'velocity_z',\n", | |
" length=0.5*Mpc, get_magnitude=True, volume=volume)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Streamlining: 100%|██████████| 100/100 [00:18<00:00, 5.33it/s]\n" | |
] | |
} | |
], | |
"source": [ | |
"streamlines.integrate_through_volume()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[ 0.5102313 0.96801447 0.35891466]\n", | |
" [ 0.51023265 0.96789774 0.3589503 ]\n", | |
" [ 0.510234 0.96778102 0.35898595]\n", | |
" ..., \n", | |
" [ 0.46327867 0.52574021 0.48639458]\n", | |
" [ 0.46335171 0.52565211 0.48643703]\n", | |
" [ 0.46342487 0.52556414 0.48647953]] code_length\n" | |
] | |
} | |
], | |
"source": [ | |
"print(streamlines.streamlines[0])" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment