{"action":"created","comment":{"url":"https://api.github.com/repos/pyne/pyne/pulls/comments/35251677","id":35251677,"diff_hunk":"@@ -517,3 +519,149 @@ def irradiation_blocks(material_lib, element_lib, data_library, cooling,\n     s += \"dump_file {0}\\n\".format(dump_file)\n \n     return s\n+\n+\"\"\" Chebyshev Rational Approximation Method functions\n+\"\"\"\n+\n+def _build_matrix(N):\n+    \"\"\" This function  builds burnup matrix, A. Decay only.\n+    \"\"\"\n+    \n+    A = np.zeros((len(N), len(N)))\n+    \n+    # convert N to id form\n+    N_id = []\n+    for i in xrange(len(N)):\n+        ID = id(N[i])\n+        N_id.append(ID)\n+        \n+    sds = SimpleDataSource()\n+\n+    # Decay\n+    for i in xrange(len(N)):\n+        A[i, i] -= decay_const(N_id[i])\n+        \n+        # Find decay parents\n+        for k in xrange(len(N)):\n+            if N_id[i] in decay_children(N_id[k]):\n+                A[k, i] += decay_const(N_id[k])\n+            \n+    return A\n+\n+def _rat_apprx_14(A, t, n_0):\n+    \"\"\" CRAM of order 14\n+\n+    Parameters\n+    ---------\n+\n+    A : numpy array\n+\tBurnup matrix\n+    t : float\n+\tTime step\n+    n_0: numpy array\n+\tInital composition vector\n+    \"\"\"\n+\t\n+    theta = np.array([ complex(-8.8977731864688888199, 16.630982619902085304), \n+                   complex(-3.7032750494234480603, 13.656371871483268171), ","path":"pyne/alara.py","position":61,"original_position":61,"commit_id":"b06e708041182ea61d438050f775defb83b79053","original_commit_id":"b06e708041182ea61d438050f775defb83b79053","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"body":"It is probably better to use complex literals, eg\r\n\r\n```python\r\n-3.7032750494234480603 + 13.656371871483268171j\r\n```\r\nNotice the `j` at the end.  Silly electrical engineers. ","created_at":"2015-07-22T19:15:17Z","updated_at":"2015-07-22T19:15:17Z","html_url":"https://github.com/pyne/pyne/pull/746#discussion_r35251677","pull_request_url":"https://api.github.com/repos/pyne/pyne/pulls/746","_links":{"self":{"href":"https://api.github.com/repos/pyne/pyne/pulls/comments/35251677"},"html":{"href":"https://github.com/pyne/pyne/pull/746#discussion_r35251677"},"pull_request":{"href":"https://api.github.com/repos/pyne/pyne/pulls/746"}}},"pull_request":{"url":"https://api.github.com/repos/pyne/pyne/pulls/746","id":40511994,"html_url":"https://github.com/pyne/pyne/pull/746","diff_url":"https://github.com/pyne/pyne/pull/746.diff","patch_url":"https://github.com/pyne/pyne/pull/746.patch","issue_url":"https://api.github.com/repos/pyne/pyne/issues/746","number":746,"state":"open","locked":false,"title":"Added CRAM to alara.py","user":{"login":"mzweig","id":9748194,"avatar_url":"https://avatars.githubusercontent.com/u/9748194?v=3","gravatar_id":"","url":"https://api.github.com/users/mzweig","html_url":"https://github.com/mzweig","followers_url":"https://api.github.com/users/mzweig/followers","following_url":"https://api.github.com/users/mzweig/following{/other_user}","gists_url":"https://api.github.com/users/mzweig/gists{/gist_id}","starred_url":"https://api.github.com/users/mzweig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzweig/subscriptions","organizations_url":"https://api.github.com/users/mzweig/orgs","repos_url":"https://api.github.com/users/mzweig/repos","events_url":"https://api.github.com/users/mzweig/events{/privacy}","received_events_url":"https://api.github.com/users/mzweig/received_events","type":"User","site_admin":false},"body":"I added CRAM to alara. I have done some testing myself (results are below). The exponential method seems to be good, but there are a few issues with the last test. \r\n\r\nTesting:\r\n\r\n\"\"\" Testing the exponentiation part of CRAM. The rat_apprx functions give n(t) = (e^At)*n_0, setting t to 1.0 and \r\nn_0 to the identity gives e^A \"\"\"\r\n\r\n# Test 1, I = the identity matrix, e^I\r\nIN: \r\nA = np.eye(3)\r\nprint \"CRAM: \"\r\nprint rat_apprx_16(A, 1.0, np.eye(3))\r\nprint \"e^I: \"\r\nprint np.e * np.eye(3)\r\n\r\nOUT: \r\nCRAM: \r\n[[ 2.71828183  0.          0.        ]\r\n [ 0.          2.71828183  0.        ]\r\n [ 0.          0.          2.71828183]]\r\ne^I: \r\n[[ 2.71828183  0.          0.        ]\r\n [ 0.          2.71828183  0.        ]\r\n [ 0.          0.          2.71828183]]\r\n\r\n# Test 2, random 3x3 matrix compared to Pade approximation and Taylor\r\nIN:\r\nA = np.random.rand(3, 3)\r\nCRAM_test2 = rat_apprx_16(A, 1.0, np.eye(3))\r\nPade_test2 = scipy.linalg.expm(A)\r\nTaylor_test2 = scipy.linalg.expm3(A)\r\nprint \"CRAM: \"\r\nprint CRAM_test2\r\nprint \"Pade: \"\r\nprint Pade_test2\r\nprint \"Taylor: \"\r\nprint Taylor_test2\r\nprint \"Errors: \"\r\nprint np.linalg.norm(CRAM_test2 - Pade_test2)\r\nprint np.linalg.norm(CRAM_test2 - Taylor_test2)\r\n\r\nOUT:\r\nCRAM: \r\n[[ 1.47736655  0.65559436  0.22226281]\r\n [ 1.85166701  3.1315016   0.7647304 ]\r\n [ 1.35744556  1.71593956  1.57244038]]\r\nPade: \r\n[[ 1.47736655  0.65559437  0.22226282]\r\n [ 1.85166704  3.13150163  0.76473041]\r\n [ 1.35744558  1.71593958  1.57244038]]\r\nTaylor: \r\n[[ 1.47736655  0.65559437  0.22226282]\r\n [ 1.85166704  3.13150163  0.76473041]\r\n [ 1.35744558  1.71593958  1.57244038]]\r\nErrors: \r\n4.85973599949e-08\r\n4.85973601684e-08\r\n\r\n# Test 3 Carbon14 decay\r\n\r\n# PyNE decay\r\nIN:\r\nfrom pyne.material import Material\r\nc14_0 = Material({'C14': 1.0})\r\nc14_hl = data.half_life('C14')\r\nc14_1 = c14_0.decay(8*c14_hl)\r\nprint(c14_1)\r\n\r\nOUT:\r\nMaterial:\r\nmass = 0.99998805078\r\ndensity = -1.0\r\natoms per molecule = 1.0\r\n------------------------\r\nC14    0.00390629531964\r\nN14    0.99609370468\r\n\r\n# CRAM\r\nIN: CRAM(['C14', 'N14'], c14_hl * 8.0, [1.0, 0], 16)\r\n\r\nOUT: array([ 0.00390625,  0.99609375])\r\n\r\n# Test 4 Thorium 232 Decay\r\n\r\n# PyNE decay\r\nIN:\r\nth232_0 = Material({'Th232' : 1.0})\r\nth232_hl = data.half_life('Th232')\r\nth232_1 = th232_0.decay(th232_hl)\r\nprint th232_1\r\n\r\nOUT:\r\nMaterial:\r\nmass = 0.948152030025\r\ndensity = -1.0\r\natoms per molecule = 1.00000000029\r\n----------------------------------\r\nHg206  4.01984011444e-34\r\nTl206  1.4307557741e-32\r\nTl208  7.04340618772e-17\r\nPb206  1.87243515228e-11\r\nPb208  0.472658433937\r\nPb210  3.02694341042e-20\r\nPb212  4.17699719613e-14\r\nBi210  1.87099228895e-23\r\nBi212  3.96172387083e-15\r\nPo210  5.16558236955e-22\r\nPo212  2.08868049467e-25\r\nPo216  1.61111466519e-19\r\nRn220  6.2924652605e-17\r\nRa224  3.64403721206e-13\r\nRa228  2.12846560755e-10\r\nAc228  2.59700242554e-14\r\nTh228  7.07605987179e-11\r\nTh232  0.52734156576\r\n\r\n# CRAM (note values for Pb208 and Pb206, among others, are off)\r\n\r\nIN:\r\nnuclides = ['Th232', 'Th228', 'Ac228', 'Ra228', 'Ra224', 'Rn220', \r\n            'Po216', 'Po212', 'Po210', 'Bi212', 'Bi210', 'Pb212',\r\n            'Pb210', 'Pb208', 'Pb206', 'Tl208', 'Tl206', 'Hg206']\r\nn_0 = np.zeros((18))\r\nn_0[0] = 1.0\r\nCRAM(nuclides, th232_hl, n_0, 16)\r\n\r\nOUT:\r\narray([  5.00000000e-01,   6.82714286e-11,   2.50562237e-14,\r\n         2.05357143e-10,   3.57876210e-13,   6.29234887e-17,\r\n         1.64099026e-19,   3.38383509e-25,   1.35304586e-11,\r\n         4.11152940e-15,   4.90075292e-13,   4.33493042e-14,\r\n         7.92857145e-10,   9.99999999e-01,   1.50000000e+00,\r\n         2.07307997e-16,   5.70657194e-16,   5.64953338e-16])","created_at":"2015-07-21T22:25:52Z","updated_at":"2015-07-22T19:15:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23ed5059dc5191b3b6de192c9a64e2b33b7e417c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pyne/pyne/pulls/746/commits","review_comments_url":"https://api.github.com/repos/pyne/pyne/pulls/746/comments","review_comment_url":"https://api.github.com/repos/pyne/pyne/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyne/pyne/issues/746/comments","statuses_url":"https://api.github.com/repos/pyne/pyne/statuses/b06e708041182ea61d438050f775defb83b79053","head":{"label":"mzweig:develop","ref":"develop","sha":"b06e708041182ea61d438050f775defb83b79053","user":{"login":"mzweig","id":9748194,"avatar_url":"https://avatars.githubusercontent.com/u/9748194?v=3","gravatar_id":"","url":"https://api.github.com/users/mzweig","html_url":"https://github.com/mzweig","followers_url":"https://api.github.com/users/mzweig/followers","following_url":"https://api.github.com/users/mzweig/following{/other_user}","gists_url":"https://api.github.com/users/mzweig/gists{/gist_id}","starred_url":"https://api.github.com/users/mzweig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzweig/subscriptions","organizations_url":"https://api.github.com/users/mzweig/orgs","repos_url":"https://api.github.com/users/mzweig/repos","events_url":"https://api.github.com/users/mzweig/events{/privacy}","received_events_url":"https://api.github.com/users/mzweig/received_events","type":"User","site_admin":false},"repo":{"id":26647624,"name":"pyne","full_name":"mzweig/pyne","owner":{"login":"mzweig","id":9748194,"avatar_url":"https://avatars.githubusercontent.com/u/9748194?v=3","gravatar_id":"","url":"https://api.github.com/users/mzweig","html_url":"https://github.com/mzweig","followers_url":"https://api.github.com/users/mzweig/followers","following_url":"https://api.github.com/users/mzweig/following{/other_user}","gists_url":"https://api.github.com/users/mzweig/gists{/gist_id}","starred_url":"https://api.github.com/users/mzweig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzweig/subscriptions","organizations_url":"https://api.github.com/users/mzweig/orgs","repos_url":"https://api.github.com/users/mzweig/repos","events_url":"https://api.github.com/users/mzweig/events{/privacy}","received_events_url":"https://api.github.com/users/mzweig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mzweig/pyne","description":"PyNE: The Nuclear Engineering Toolkit","fork":true,"url":"https://api.github.com/repos/mzweig/pyne","forks_url":"https://api.github.com/repos/mzweig/pyne/forks","keys_url":"https://api.github.com/repos/mzweig/pyne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mzweig/pyne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mzweig/pyne/teams","hooks_url":"https://api.github.com/repos/mzweig/pyne/hooks","issue_events_url":"https://api.github.com/repos/mzweig/pyne/issues/events{/number}","events_url":"https://api.github.com/repos/mzweig/pyne/events","assignees_url":"https://api.github.com/repos/mzweig/pyne/assignees{/user}","branches_url":"https://api.github.com/repos/mzweig/pyne/branches{/branch}","tags_url":"https://api.github.com/repos/mzweig/pyne/tags","blobs_url":"https://api.github.com/repos/mzweig/pyne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mzweig/pyne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mzweig/pyne/git/refs{/sha}","trees_url":"https://api.github.com/repos/mzweig/pyne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mzweig/pyne/statuses/{sha}","languages_url":"https://api.github.com/repos/mzweig/pyne/languages","stargazers_url":"https://api.github.com/repos/mzweig/pyne/stargazers","contributors_url":"https://api.github.com/repos/mzweig/pyne/contributors","subscribers_url":"https://api.github.com/repos/mzweig/pyne/subscribers","subscription_url":"https://api.github.com/repos/mzweig/pyne/subscription","commits_url":"https://api.github.com/repos/mzweig/pyne/commits{/sha}","git_commits_url":"https://api.github.com/repos/mzweig/pyne/git/commits{/sha}","comments_url":"https://api.github.com/repos/mzweig/pyne/comments{/number}","issue_comment_url":"https://api.github.com/repos/mzweig/pyne/issues/comments{/number}","contents_url":"https://api.github.com/repos/mzweig/pyne/contents/{+path}","compare_url":"https://api.github.com/repos/mzweig/pyne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mzweig/pyne/merges","archive_url":"https://api.github.com/repos/mzweig/pyne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mzweig/pyne/downloads","issues_url":"https://api.github.com/repos/mzweig/pyne/issues{/number}","pulls_url":"https://api.github.com/repos/mzweig/pyne/pulls{/number}","milestones_url":"https://api.github.com/repos/mzweig/pyne/milestones{/number}","notifications_url":"https://api.github.com/repos/mzweig/pyne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mzweig/pyne/labels{/name}","releases_url":"https://api.github.com/repos/mzweig/pyne/releases{/id}","created_at":"2014-11-14T16:40:23Z","updated_at":"2014-11-14T16:40:25Z","pushed_at":"2015-07-21T22:12:03Z","git_url":"git://github.com/mzweig/pyne.git","ssh_url":"git@github.com:mzweig/pyne.git","clone_url":"https://github.com/mzweig/pyne.git","svn_url":"https://github.com/mzweig/pyne","homepage":"http://pyne.io/","size":14766,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"pyne:develop","ref":"develop","sha":"8a6b60aaafb547b4e89521273f696146cfd14849","user":{"login":"pyne","id":760696,"avatar_url":"https://avatars.githubusercontent.com/u/760696?v=3","gravatar_id":"","url":"https://api.github.com/users/pyne","html_url":"https://github.com/pyne","followers_url":"https://api.github.com/users/pyne/followers","following_url":"https://api.github.com/users/pyne/following{/other_user}","gists_url":"https://api.github.com/users/pyne/gists{/gist_id}","starred_url":"https://api.github.com/users/pyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyne/subscriptions","organizations_url":"https://api.github.com/users/pyne/orgs","repos_url":"https://api.github.com/users/pyne/repos","events_url":"https://api.github.com/users/pyne/events{/privacy}","received_events_url":"https://api.github.com/users/pyne/received_events","type":"Organization","site_admin":false},"repo":{"id":1684953,"name":"pyne","full_name":"pyne/pyne","owner":{"login":"pyne","id":760696,"avatar_url":"https://avatars.githubusercontent.com/u/760696?v=3","gravatar_id":"","url":"https://api.github.com/users/pyne","html_url":"https://github.com/pyne","followers_url":"https://api.github.com/users/pyne/followers","following_url":"https://api.github.com/users/pyne/following{/other_user}","gists_url":"https://api.github.com/users/pyne/gists{/gist_id}","starred_url":"https://api.github.com/users/pyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyne/subscriptions","organizations_url":"https://api.github.com/users/pyne/orgs","repos_url":"https://api.github.com/users/pyne/repos","events_url":"https://api.github.com/users/pyne/events{/privacy}","received_events_url":"https://api.github.com/users/pyne/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyne/pyne","description":"PyNE: The Nuclear Engineering Toolkit","fork":false,"url":"https://api.github.com/repos/pyne/pyne","forks_url":"https://api.github.com/repos/pyne/pyne/forks","keys_url":"https://api.github.com/repos/pyne/pyne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyne/pyne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyne/pyne/teams","hooks_url":"https://api.github.com/repos/pyne/pyne/hooks","issue_events_url":"https://api.github.com/repos/pyne/pyne/issues/events{/number}","events_url":"https://api.github.com/repos/pyne/pyne/events","assignees_url":"https://api.github.com/repos/pyne/pyne/assignees{/user}","branches_url":"https://api.github.com/repos/pyne/pyne/branches{/branch}","tags_url":"https://api.github.com/repos/pyne/pyne/tags","blobs_url":"https://api.github.com/repos/pyne/pyne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyne/pyne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyne/pyne/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyne/pyne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyne/pyne/statuses/{sha}","languages_url":"https://api.github.com/repos/pyne/pyne/languages","stargazers_url":"https://api.github.com/repos/pyne/pyne/stargazers","contributors_url":"https://api.github.com/repos/pyne/pyne/contributors","subscribers_url":"https://api.github.com/repos/pyne/pyne/subscribers","subscription_url":"https://api.github.com/repos/pyne/pyne/subscription","commits_url":"https://api.github.com/repos/pyne/pyne/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyne/pyne/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyne/pyne/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyne/pyne/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyne/pyne/contents/{+path}","compare_url":"https://api.github.com/repos/pyne/pyne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyne/pyne/merges","archive_url":"https://api.github.com/repos/pyne/pyne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyne/pyne/downloads","issues_url":"https://api.github.com/repos/pyne/pyne/issues{/number}","pulls_url":"https://api.github.com/repos/pyne/pyne/pulls{/number}","milestones_url":"https://api.github.com/repos/pyne/pyne/milestones{/number}","notifications_url":"https://api.github.com/repos/pyne/pyne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyne/pyne/labels{/name}","releases_url":"https://api.github.com/repos/pyne/pyne/releases{/id}","created_at":"2011-04-30T15:04:07Z","updated_at":"2015-06-03T02:07:22Z","pushed_at":"2015-07-22T18:58:14Z","git_url":"git://github.com/pyne/pyne.git","ssh_url":"git@github.com:pyne/pyne.git","clone_url":"https://github.com/pyne/pyne.git","svn_url":"https://github.com/pyne/pyne","homepage":"http://pyne.io/","size":88704,"stargazers_count":50,"watchers_count":50,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":73,"mirror_url":null,"open_issues_count":62,"forks":73,"open_issues":62,"watchers":50,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/pyne/pyne/pulls/746"},"html":{"href":"https://github.com/pyne/pyne/pull/746"},"issue":{"href":"https://api.github.com/repos/pyne/pyne/issues/746"},"comments":{"href":"https://api.github.com/repos/pyne/pyne/issues/746/comments"},"review_comments":{"href":"https://api.github.com/repos/pyne/pyne/pulls/746/comments"},"review_comment":{"href":"https://api.github.com/repos/pyne/pyne/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyne/pyne/pulls/746/commits"},"statuses":{"href":"https://api.github.com/repos/pyne/pyne/statuses/b06e708041182ea61d438050f775defb83b79053"}}}}