{"action":"created","comment":{"url":"https://api.github.com/repos/tardis-sn/tardis/pulls/comments/76789898","id":76789898,"diff_hunk":"@@ -0,0 +1,161 @@\n+#include <string.h>\n+#include <assert.h>\n+#include <stdio.h>\n+#include <math.h>\n+\n+#include \"integrator.h\"\n+\n+#ifdef WITHOPENMP\n+#include <omp.h>\n+#endif\n+\n+#define NULEN   0\n+#define LINELEN 1\n+#define PLEN    2\n+#define SHELLEN 3\n+\n+\n+#define C_INV 3.33564e-11\n+\n+indexpair_t find_nu_limits_for_crossing_and_p(double nu, double p,int cr_idx, int no_of_shell_cr, double* Rs,double inv_t)\n+{\n+    double blu_R, red_R, z_blu, z_red, z_cr, nu_blu, nu_red;\n+    indexpair_t pair;\n+\n+    if (no_of_shell_cr > 1)\n+    {\n+        assert(Rs[0] > Rs[1]); // Decreasing order\n+        \n+        blu_R = get_r(cr_idx-1,no_of_shell_cr,Rs);\n+        red_R = get_r(cr_idx,no_of_shell_cr,Rs);\n+        z_blu = sqrt( blu_R*blu_R - p*p );\n+        z_red = sqrt( red_R*red_R - p*p );\n+        nu_blu = nu * (1 + get_cr_sign(cr_idx,no_of_shell_cr)*z_blu*C_INV*inv_t);\n+        nu_red = nu * (1 + get_cr_sign(cr_idx,no_of_shell_cr)*z_red*C_INV*inv_t);\n+    }\n+    else \n+    {\n+        z_cr = sqrt( Rs[cr_idx]*Rs[cr_idx] - p*p );\n+        nu_blu = nu * (1 - z_cr*C_INV*inv_t);\n+        nu_red = nu * (1 + z_cr*C_INV*inv_t);\n+    }\n+\n+    pair.start = nu_blu;\n+    pair.end   = nu_red;\n+    \n+    return pair;\n+}\n+\n+double get_r(int cr_idx, int no_of_shell_cr, double* Rs)\n+{\n+    if (cr_idx < no_of_shell_cr){\n+        return Rs[cr_idx];}\n+    else if (cr_idx < 2*no_of_shell_cr){\n+        return Rs[(2*no_of_shell_cr - 1) - cr_idx];}\n+}\n+\n+int get_cr_sign(int cr_idx, int no_of_shell_cr)\n+{\n+    if (cr_idx < no_of_shell_cr){\n+        return -1;}\n+    else if (cr_idx < 2*no_of_shell_cr){\n+        return 1;}\n+}\n+\n+int get_cr_start(int no_of_shell_cr, double p, double R_ph)\n+{\n+    if (p >= R_ph) {\n+        return 0;}\n+    else if (p < R_ph) {\n+        return no_of_shell_cr+1;\n+    }\n+}\n+\n+int get_sh_idx(int cr_idx, int no_of_shell_cr)\n+{\n+    if (cr_idx < no_of_shell_cr){\n+       return cr_idx;}\n+    else if (cr_idx < 2*no_of_shell_cr){\n+        return ((2*no_of_shell_cr - 1) - cr_idx);}\n+\n+}\n+int get_num_shell_cr(double p, double* Rs, int len)\n+{\n+    assert(Rs[0] > Rs[1]);\n+\n+    int num;\n+    for(int num = 0; num < len; ++num)\n+    {\n+        if( p > Rs[num]) {\n+            break;}\n+    }\n+    return num;\n+}\n+\n+\n+double integrate_intensity(double* I_nu,double* ps, int len)\n+{\n+    double result = 0.0;\n+    double h = (ps[0]-ps[len-1])/len;\n+    result =  I_nu[0]*h/2.0;\n+\n+    for (int idx = 1; idx < len-1; ++idx)\n+    {\n+        result += I_nu[idx]*h;\n+    }\n+    result += I_nu[len-1]*h/2.0;\n+    return result;\n+}\n+\n+void debug_print_arg(double* arg,int len)\n+{\n+    for (int64_t i = 0; i < len; i++)\n+    {\n+        printf(\"%e, \",arg[i]);\n+    }\n+}\n+void debug_print_2d_arg(double* arg,int len1, int len2)\n+{\n+    for (int64_t i = 0; i < len1; ++i)\n+    {\n+        for(int64_t j = 0; j < len2; ++j)\n+        {\n+        printf(\"[%d,%d,%d]: %.8f, \",i,j,i*len2+j,arg[i*len2+j]);\n+        }\n+        printf(\"\\n\\n\");\n+    }\n+}\n+\n+\n+void integrate_source_functions(double* L_nu, double* line_nu, double* taus, double* att_S_ul, double* I_BB, double* nus, \n+              double* ps, double* Rs, double R_ph, int64_t* lens)\n+{\n+    double I_nu[lens[SHELLEN]];","path":"tardis/montecarlo/src/integrator.c","position":133,"original_position":133,"commit_id":"c11aacda1acab1151b65fc13d7a92fa36611e3e1","original_commit_id":"c11aacda1acab1151b65fc13d7a92fa36611e3e1","user":{"login":"yeganer","id":6164110,"avatar_url":"https://avatars.githubusercontent.com/u/6164110?v=3","gravatar_id":"","url":"https://api.github.com/users/yeganer","html_url":"https://github.com/yeganer","followers_url":"https://api.github.com/users/yeganer/followers","following_url":"https://api.github.com/users/yeganer/following{/other_user}","gists_url":"https://api.github.com/users/yeganer/gists{/gist_id}","starred_url":"https://api.github.com/users/yeganer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yeganer/subscriptions","organizations_url":"https://api.github.com/users/yeganer/orgs","repos_url":"https://api.github.com/users/yeganer/repos","events_url":"https://api.github.com/users/yeganer/events{/privacy}","received_events_url":"https://api.github.com/users/yeganer/received_events","type":"User","site_admin":false},"body":"I'd declare as\r\n`double  *I_nu = calloc(lens[PLEN], sizeof(double))`","created_at":"2016-08-30T13:05:19Z","updated_at":"2016-08-30T13:05:19Z","html_url":"https://github.com/tardis-sn/tardis/pull/615#discussion_r76789898","pull_request_url":"https://api.github.com/repos/tardis-sn/tardis/pulls/615","_links":{"self":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/comments/76789898"},"html":{"href":"https://github.com/tardis-sn/tardis/pull/615#discussion_r76789898"},"pull_request":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/615"}}},"pull_request":{"url":"https://api.github.com/repos/tardis-sn/tardis/pulls/615","id":75636655,"html_url":"https://github.com/tardis-sn/tardis/pull/615","diff_url":"https://github.com/tardis-sn/tardis/pull/615.diff","patch_url":"https://github.com/tardis-sn/tardis/pull/615.patch","issue_url":"https://api.github.com/repos/tardis-sn/tardis/issues/615","number":615,"state":"open","locked":false,"title":"Formal source function integral","user":{"login":"Tobychev","id":3251727,"avatar_url":"https://avatars.githubusercontent.com/u/3251727?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobychev","html_url":"https://github.com/Tobychev","followers_url":"https://api.github.com/users/Tobychev/followers","following_url":"https://api.github.com/users/Tobychev/following{/other_user}","gists_url":"https://api.github.com/users/Tobychev/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobychev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobychev/subscriptions","organizations_url":"https://api.github.com/users/Tobychev/orgs","repos_url":"https://api.github.com/users/Tobychev/repos","events_url":"https://api.github.com/users/Tobychev/events{/privacy}","received_events_url":"https://api.github.com/users/Tobychev/received_events","type":"User","site_admin":false},"body":"Implementing the source integral method of Lucy 99b.\r\n\r\nTo do\r\n====\r\n- [x] Add way to calculate source function\r\n- [x] Add way to integrate source function\r\n- [ ] Add continuum source of opacity\r\n- [ ] Make sure integrator gives sensible results\r\n- [ ] Consider  if 448 could be done without making lots of NaN's\r\n- [ ] Consider adding a p at exactly R_min ","created_at":"2016-06-29T12:11:04Z","updated_at":"2016-08-30T13:05:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83e2d93ec715185cbb97055440ba57c8c571d6fb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tardis-sn/tardis/pulls/615/commits","review_comments_url":"https://api.github.com/repos/tardis-sn/tardis/pulls/615/comments","review_comment_url":"https://api.github.com/repos/tardis-sn/tardis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tardis-sn/tardis/issues/615/comments","statuses_url":"https://api.github.com/repos/tardis-sn/tardis/statuses/c11aacda1acab1151b65fc13d7a92fa36611e3e1","head":{"label":"Tobychev:source","ref":"source","sha":"c11aacda1acab1151b65fc13d7a92fa36611e3e1","user":{"login":"Tobychev","id":3251727,"avatar_url":"https://avatars.githubusercontent.com/u/3251727?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobychev","html_url":"https://github.com/Tobychev","followers_url":"https://api.github.com/users/Tobychev/followers","following_url":"https://api.github.com/users/Tobychev/following{/other_user}","gists_url":"https://api.github.com/users/Tobychev/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobychev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobychev/subscriptions","organizations_url":"https://api.github.com/users/Tobychev/orgs","repos_url":"https://api.github.com/users/Tobychev/repos","events_url":"https://api.github.com/users/Tobychev/events{/privacy}","received_events_url":"https://api.github.com/users/Tobychev/received_events","type":"User","site_admin":false},"repo":{"id":58677058,"name":"tardis","full_name":"Tobychev/tardis","owner":{"login":"Tobychev","id":3251727,"avatar_url":"https://avatars.githubusercontent.com/u/3251727?v=3","gravatar_id":"","url":"https://api.github.com/users/Tobychev","html_url":"https://github.com/Tobychev","followers_url":"https://api.github.com/users/Tobychev/followers","following_url":"https://api.github.com/users/Tobychev/following{/other_user}","gists_url":"https://api.github.com/users/Tobychev/gists{/gist_id}","starred_url":"https://api.github.com/users/Tobychev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tobychev/subscriptions","organizations_url":"https://api.github.com/users/Tobychev/orgs","repos_url":"https://api.github.com/users/Tobychev/repos","events_url":"https://api.github.com/users/Tobychev/events{/privacy}","received_events_url":"https://api.github.com/users/Tobychev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Tobychev/tardis","description":"TARDIS - Temperature And Radiative Diffusion In Supernovae","fork":true,"url":"https://api.github.com/repos/Tobychev/tardis","forks_url":"https://api.github.com/repos/Tobychev/tardis/forks","keys_url":"https://api.github.com/repos/Tobychev/tardis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tobychev/tardis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tobychev/tardis/teams","hooks_url":"https://api.github.com/repos/Tobychev/tardis/hooks","issue_events_url":"https://api.github.com/repos/Tobychev/tardis/issues/events{/number}","events_url":"https://api.github.com/repos/Tobychev/tardis/events","assignees_url":"https://api.github.com/repos/Tobychev/tardis/assignees{/user}","branches_url":"https://api.github.com/repos/Tobychev/tardis/branches{/branch}","tags_url":"https://api.github.com/repos/Tobychev/tardis/tags","blobs_url":"https://api.github.com/repos/Tobychev/tardis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tobychev/tardis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tobychev/tardis/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tobychev/tardis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tobychev/tardis/statuses/{sha}","languages_url":"https://api.github.com/repos/Tobychev/tardis/languages","stargazers_url":"https://api.github.com/repos/Tobychev/tardis/stargazers","contributors_url":"https://api.github.com/repos/Tobychev/tardis/contributors","subscribers_url":"https://api.github.com/repos/Tobychev/tardis/subscribers","subscription_url":"https://api.github.com/repos/Tobychev/tardis/subscription","commits_url":"https://api.github.com/repos/Tobychev/tardis/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tobychev/tardis/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tobychev/tardis/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tobychev/tardis/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tobychev/tardis/contents/{+path}","compare_url":"https://api.github.com/repos/Tobychev/tardis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tobychev/tardis/merges","archive_url":"https://api.github.com/repos/Tobychev/tardis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tobychev/tardis/downloads","issues_url":"https://api.github.com/repos/Tobychev/tardis/issues{/number}","pulls_url":"https://api.github.com/repos/Tobychev/tardis/pulls{/number}","milestones_url":"https://api.github.com/repos/Tobychev/tardis/milestones{/number}","notifications_url":"https://api.github.com/repos/Tobychev/tardis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tobychev/tardis/labels{/name}","releases_url":"https://api.github.com/repos/Tobychev/tardis/releases{/id}","deployments_url":"https://api.github.com/repos/Tobychev/tardis/deployments","created_at":"2016-05-12T21:10:32Z","updated_at":"2016-06-29T11:58:03Z","pushed_at":"2016-08-30T11:35:08Z","git_url":"git://github.com/Tobychev/tardis.git","ssh_url":"git@github.com:Tobychev/tardis.git","clone_url":"https://github.com/Tobychev/tardis.git","svn_url":"https://github.com/Tobychev/tardis","homepage":"","size":21767,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"tardis-upstream"}},"base":{"label":"tardis-sn:montecarlo/source_function_integration","ref":"montecarlo/source_function_integration","sha":"d219e797b50b1d530d67d65a90c84571247a46c1","user":{"login":"tardis-sn","id":6108234,"avatar_url":"https://avatars.githubusercontent.com/u/6108234?v=3","gravatar_id":"","url":"https://api.github.com/users/tardis-sn","html_url":"https://github.com/tardis-sn","followers_url":"https://api.github.com/users/tardis-sn/followers","following_url":"https://api.github.com/users/tardis-sn/following{/other_user}","gists_url":"https://api.github.com/users/tardis-sn/gists{/gist_id}","starred_url":"https://api.github.com/users/tardis-sn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardis-sn/subscriptions","organizations_url":"https://api.github.com/users/tardis-sn/orgs","repos_url":"https://api.github.com/users/tardis-sn/repos","events_url":"https://api.github.com/users/tardis-sn/events{/privacy}","received_events_url":"https://api.github.com/users/tardis-sn/received_events","type":"Organization","site_admin":false},"repo":{"id":2938270,"name":"tardis","full_name":"tardis-sn/tardis","owner":{"login":"tardis-sn","id":6108234,"avatar_url":"https://avatars.githubusercontent.com/u/6108234?v=3","gravatar_id":"","url":"https://api.github.com/users/tardis-sn","html_url":"https://github.com/tardis-sn","followers_url":"https://api.github.com/users/tardis-sn/followers","following_url":"https://api.github.com/users/tardis-sn/following{/other_user}","gists_url":"https://api.github.com/users/tardis-sn/gists{/gist_id}","starred_url":"https://api.github.com/users/tardis-sn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardis-sn/subscriptions","organizations_url":"https://api.github.com/users/tardis-sn/orgs","repos_url":"https://api.github.com/users/tardis-sn/repos","events_url":"https://api.github.com/users/tardis-sn/events{/privacy}","received_events_url":"https://api.github.com/users/tardis-sn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tardis-sn/tardis","description":"TARDIS - Temperature And Radiative Diffusion In Supernovae","fork":false,"url":"https://api.github.com/repos/tardis-sn/tardis","forks_url":"https://api.github.com/repos/tardis-sn/tardis/forks","keys_url":"https://api.github.com/repos/tardis-sn/tardis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tardis-sn/tardis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tardis-sn/tardis/teams","hooks_url":"https://api.github.com/repos/tardis-sn/tardis/hooks","issue_events_url":"https://api.github.com/repos/tardis-sn/tardis/issues/events{/number}","events_url":"https://api.github.com/repos/tardis-sn/tardis/events","assignees_url":"https://api.github.com/repos/tardis-sn/tardis/assignees{/user}","branches_url":"https://api.github.com/repos/tardis-sn/tardis/branches{/branch}","tags_url":"https://api.github.com/repos/tardis-sn/tardis/tags","blobs_url":"https://api.github.com/repos/tardis-sn/tardis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tardis-sn/tardis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tardis-sn/tardis/git/refs{/sha}","trees_url":"https://api.github.com/repos/tardis-sn/tardis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tardis-sn/tardis/statuses/{sha}","languages_url":"https://api.github.com/repos/tardis-sn/tardis/languages","stargazers_url":"https://api.github.com/repos/tardis-sn/tardis/stargazers","contributors_url":"https://api.github.com/repos/tardis-sn/tardis/contributors","subscribers_url":"https://api.github.com/repos/tardis-sn/tardis/subscribers","subscription_url":"https://api.github.com/repos/tardis-sn/tardis/subscription","commits_url":"https://api.github.com/repos/tardis-sn/tardis/commits{/sha}","git_commits_url":"https://api.github.com/repos/tardis-sn/tardis/git/commits{/sha}","comments_url":"https://api.github.com/repos/tardis-sn/tardis/comments{/number}","issue_comment_url":"https://api.github.com/repos/tardis-sn/tardis/issues/comments{/number}","contents_url":"https://api.github.com/repos/tardis-sn/tardis/contents/{+path}","compare_url":"https://api.github.com/repos/tardis-sn/tardis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tardis-sn/tardis/merges","archive_url":"https://api.github.com/repos/tardis-sn/tardis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tardis-sn/tardis/downloads","issues_url":"https://api.github.com/repos/tardis-sn/tardis/issues{/number}","pulls_url":"https://api.github.com/repos/tardis-sn/tardis/pulls{/number}","milestones_url":"https://api.github.com/repos/tardis-sn/tardis/milestones{/number}","notifications_url":"https://api.github.com/repos/tardis-sn/tardis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tardis-sn/tardis/labels{/name}","releases_url":"https://api.github.com/repos/tardis-sn/tardis/releases{/id}","deployments_url":"https://api.github.com/repos/tardis-sn/tardis/deployments","created_at":"2011-12-08T06:20:19Z","updated_at":"2016-08-27T18:56:57Z","pushed_at":"2016-08-30T11:35:09Z","git_url":"git://github.com/tardis-sn/tardis.git","ssh_url":"git@github.com:tardis-sn/tardis.git","clone_url":"https://github.com/tardis-sn/tardis.git","svn_url":"https://github.com/tardis-sn/tardis","homepage":"","size":199105,"stargazers_count":34,"watchers_count":34,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":91,"forks":110,"open_issues":91,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/615"},"html":{"href":"https://github.com/tardis-sn/tardis/pull/615"},"issue":{"href":"https://api.github.com/repos/tardis-sn/tardis/issues/615"},"comments":{"href":"https://api.github.com/repos/tardis-sn/tardis/issues/615/comments"},"review_comments":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/615/comments"},"review_comment":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tardis-sn/tardis/pulls/615/commits"},"statuses":{"href":"https://api.github.com/repos/tardis-sn/tardis/statuses/c11aacda1acab1151b65fc13d7a92fa36611e3e1"}}}}
{"actor":{"display_login":"yeganer"}}