{"action":"created","comment":{"url":"https://api.github.com/repos/pele-python/pele/pulls/comments/30462201","id":30462201,"diff_hunk":"@@ -0,0 +1,57 @@\n+#include \"pele/pressure_tensor.h\"\n+#include \"pele/simple_pairwise_potential.h\"\n+\n+namespace pele {\n+\n+/*\n+ * computes the static pressure tensor, ignoring the momenta of the atoms\n+ * the momentum component can be added\n+ * */\n+double pressure_tensor(std::shared_ptr<pele::BasePotential> pot_,\n+                       pele::Array<double> x,\n+                       pele::Array<double> ptensor,\n+                       const double volume)\n+{\n+    pele::SimplePairwisePotentialInterface* pot = dynamic_cast<pele::SimplePairwisePotentialInterface*>(pot_.get());\n+    if (pot == NULL) {\n+        throw std::runtime_error(\"pressure_tensor: illegal potential\");\n+    }\n+    const size_t ndim = pot->get_ndim();\n+    const size_t natoms = x.size() / ndim;\n+    if (ndim * natoms != x.size()) {\n+        throw std::runtime_error(\"x is not divisible by the number of dimensions\");\n+    }\n+    if (ptensor.size() != ndim * ndim) {\n+        throw std::runtime_error(\"ptensor must have size ndim * ndim\");\n+    }\n+    double gij;\n+    double dr[ndim];\n+    ptensor.assign(0.);\n+    for (size_t atomi = 0; atomi < natoms; ++atomi) {\n+        size_t const i1 = ndim * atomi;\n+        for (size_t atomj = 0; atomj < atomi; ++atomj) {\n+            size_t const j1 = ndim * atomj;\n+            pot->get_rij(dr, &x[i1], &x[j1]);\n+            double r2 = 0;\n+            for (size_t k = 0; k < ndim; ++k) {\n+                r2 += dr[k] * dr[k];\n+            }\n+            pot->get_interaction_energy_gradient(r2, &gij, atomi, atomj);\n+            for (size_t k = 0; k < ndim; ++k) {\n+                for (size_t l = k; l < ndim; ++l) {\n+                    ptensor[k * ndim + l] -= dr[l] * gij * dr[k];\n+                    ptensor[l * ndim + k] -= dr[k] * gij * dr[l]; //pressure tensor is symmetric\n+                }\n+            }\n+        }\n+    }\n+    ptensor /= volume;\n+    //pressure is the average of the trace of the pressure tensor\n+    double traceP = 0.;\n+    for (size_t i = 0; i < ndim; ++i) {\n+        traceP += ptensor[i + ndim + i];","path":"source/pressure_tensor.cpp","position":52,"original_position":52,"commit_id":"4a8eb9a7359a5de2f79beea801eae453136aff67","original_commit_id":"4a8eb9a7359a5de2f79beea801eae453136aff67","user":{"login":"smcantab","id":3187259,"avatar_url":"https://avatars.githubusercontent.com/u/3187259?v=3","gravatar_id":"","url":"https://api.github.com/users/smcantab","html_url":"https://github.com/smcantab","followers_url":"https://api.github.com/users/smcantab/followers","following_url":"https://api.github.com/users/smcantab/following{/other_user}","gists_url":"https://api.github.com/users/smcantab/gists{/gist_id}","starred_url":"https://api.github.com/users/smcantab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smcantab/subscriptions","organizations_url":"https://api.github.com/users/smcantab/orgs","repos_url":"https://api.github.com/users/smcantab/repos","events_url":"https://api.github.com/users/smcantab/events{/privacy}","received_events_url":"https://api.github.com/users/smcantab/received_events","type":"User","site_admin":false},"body":"yes that should be a product\n\nOn Fri, May 15, 2015 at 5:49 PM, Julian Schrenk <notifications@github.com>\nwrote:\n\n> In source/pressure_tensor.cpp\n> <https://github.com/pele-python/pele/pull/130#discussion_r30425101>:\n>\n> > +                r2 += dr[k] * dr[k];\n> > +            }\n> > +            pot->get_interaction_energy_gradient(r2, &gij, atomi, atomj);\n> > +            for (size_t k = 0; k < ndim; ++k) {\n> > +                for (size_t l = k; l < ndim; ++l) {\n> > +                    ptensor[k * ndim + l] -= dr[l] * gij * dr[k];\n> > +                    ptensor[l * ndim + k] -= dr[k] * gij * dr[l]; //pressure tensor is symmetric\n> > +                }\n> > +            }\n> > +        }\n> > +    }\n> > +    ptensor /= volume;\n> > +    //pressure is the average of the trace of the pressure tensor\n> > +    double traceP = 0.;\n> > +    for (size_t i = 0; i < ndim; ++i) {\n> > +        traceP += ptensor[i + ndim + i];\n>\n> @smcantab <https://github.com/smcantab>: should this be\n>\n> [i * ndim + i]\n>\n> ?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/pele-python/pele/pull/130/files#r30425101>.\n>\n","created_at":"2015-05-16T16:02:59Z","updated_at":"2015-05-16T16:02:59Z","html_url":"https://github.com/pele-python/pele/pull/130#discussion_r30462201","pull_request_url":"https://api.github.com/repos/pele-python/pele/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/pele-python/pele/pulls/comments/30462201"},"html":{"href":"https://github.com/pele-python/pele/pull/130#discussion_r30462201"},"pull_request":{"href":"https://api.github.com/repos/pele-python/pele/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/pele-python/pele/pulls/130","id":35378216,"html_url":"https://github.com/pele-python/pele/pull/130","diff_url":"https://github.com/pele-python/pele/pull/130.diff","patch_url":"https://github.com/pele-python/pele/pull/130.patch","issue_url":"https://api.github.com/repos/pele-python/pele/issues/130","number":130,"state":"open","locked":false,"title":"Pressure tensor","user":{"login":"kjs73","id":7257339,"avatar_url":"https://avatars.githubusercontent.com/u/7257339?v=3","gravatar_id":"","url":"https://api.github.com/users/kjs73","html_url":"https://github.com/kjs73","followers_url":"https://api.github.com/users/kjs73/followers","following_url":"https://api.github.com/users/kjs73/following{/other_user}","gists_url":"https://api.github.com/users/kjs73/gists{/gist_id}","starred_url":"https://api.github.com/users/kjs73/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjs73/subscriptions","organizations_url":"https://api.github.com/users/kjs73/orgs","repos_url":"https://api.github.com/users/kjs73/repos","events_url":"https://api.github.com/users/kjs73/events{/privacy}","received_events_url":"https://api.github.com/users/kjs73/received_events","type":"User","site_admin":false},"body":"Moves pressure measurement to standalone function, rather than being a member of base-potential. See PR #129. What do you guys think? @js850?","created_at":"2015-05-13T22:38:01Z","updated_at":"2015-05-16T16:02:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba0224c5cf5233e745051d9d2704cdfde5728c3d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pele-python/pele/pulls/130/commits","review_comments_url":"https://api.github.com/repos/pele-python/pele/pulls/130/comments","review_comment_url":"https://api.github.com/repos/pele-python/pele/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pele-python/pele/issues/130/comments","statuses_url":"https://api.github.com/repos/pele-python/pele/statuses/4a8eb9a7359a5de2f79beea801eae453136aff67","head":{"label":"kjs73:pressure_tensor","ref":"pressure_tensor","sha":"4a8eb9a7359a5de2f79beea801eae453136aff67","user":{"login":"kjs73","id":7257339,"avatar_url":"https://avatars.githubusercontent.com/u/7257339?v=3","gravatar_id":"","url":"https://api.github.com/users/kjs73","html_url":"https://github.com/kjs73","followers_url":"https://api.github.com/users/kjs73/followers","following_url":"https://api.github.com/users/kjs73/following{/other_user}","gists_url":"https://api.github.com/users/kjs73/gists{/gist_id}","starred_url":"https://api.github.com/users/kjs73/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjs73/subscriptions","organizations_url":"https://api.github.com/users/kjs73/orgs","repos_url":"https://api.github.com/users/kjs73/repos","events_url":"https://api.github.com/users/kjs73/events{/privacy}","received_events_url":"https://api.github.com/users/kjs73/received_events","type":"User","site_admin":false},"repo":{"id":18808460,"name":"pele","full_name":"kjs73/pele","owner":{"login":"kjs73","id":7257339,"avatar_url":"https://avatars.githubusercontent.com/u/7257339?v=3","gravatar_id":"","url":"https://api.github.com/users/kjs73","html_url":"https://github.com/kjs73","followers_url":"https://api.github.com/users/kjs73/followers","following_url":"https://api.github.com/users/kjs73/following{/other_user}","gists_url":"https://api.github.com/users/kjs73/gists{/gist_id}","starred_url":"https://api.github.com/users/kjs73/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjs73/subscriptions","organizations_url":"https://api.github.com/users/kjs73/orgs","repos_url":"https://api.github.com/users/kjs73/repos","events_url":"https://api.github.com/users/kjs73/events{/privacy}","received_events_url":"https://api.github.com/users/kjs73/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kjs73/pele","description":"Python energy landscape explorer","fork":true,"url":"https://api.github.com/repos/kjs73/pele","forks_url":"https://api.github.com/repos/kjs73/pele/forks","keys_url":"https://api.github.com/repos/kjs73/pele/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kjs73/pele/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kjs73/pele/teams","hooks_url":"https://api.github.com/repos/kjs73/pele/hooks","issue_events_url":"https://api.github.com/repos/kjs73/pele/issues/events{/number}","events_url":"https://api.github.com/repos/kjs73/pele/events","assignees_url":"https://api.github.com/repos/kjs73/pele/assignees{/user}","branches_url":"https://api.github.com/repos/kjs73/pele/branches{/branch}","tags_url":"https://api.github.com/repos/kjs73/pele/tags","blobs_url":"https://api.github.com/repos/kjs73/pele/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kjs73/pele/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kjs73/pele/git/refs{/sha}","trees_url":"https://api.github.com/repos/kjs73/pele/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kjs73/pele/statuses/{sha}","languages_url":"https://api.github.com/repos/kjs73/pele/languages","stargazers_url":"https://api.github.com/repos/kjs73/pele/stargazers","contributors_url":"https://api.github.com/repos/kjs73/pele/contributors","subscribers_url":"https://api.github.com/repos/kjs73/pele/subscribers","subscription_url":"https://api.github.com/repos/kjs73/pele/subscription","commits_url":"https://api.github.com/repos/kjs73/pele/commits{/sha}","git_commits_url":"https://api.github.com/repos/kjs73/pele/git/commits{/sha}","comments_url":"https://api.github.com/repos/kjs73/pele/comments{/number}","issue_comment_url":"https://api.github.com/repos/kjs73/pele/issues/comments{/number}","contents_url":"https://api.github.com/repos/kjs73/pele/contents/{+path}","compare_url":"https://api.github.com/repos/kjs73/pele/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kjs73/pele/merges","archive_url":"https://api.github.com/repos/kjs73/pele/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kjs73/pele/downloads","issues_url":"https://api.github.com/repos/kjs73/pele/issues{/number}","pulls_url":"https://api.github.com/repos/kjs73/pele/pulls{/number}","milestones_url":"https://api.github.com/repos/kjs73/pele/milestones{/number}","notifications_url":"https://api.github.com/repos/kjs73/pele/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kjs73/pele/labels{/name}","releases_url":"https://api.github.com/repos/kjs73/pele/releases{/id}","created_at":"2014-04-15T17:09:47Z","updated_at":"2014-12-03T10:57:57Z","pushed_at":"2015-05-15T16:44:30Z","git_url":"git://github.com/kjs73/pele.git","ssh_url":"git@github.com:kjs73/pele.git","clone_url":"https://github.com/kjs73/pele.git","svn_url":"https://github.com/kjs73/pele","homepage":null,"size":16585,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pele-python:master","ref":"master","sha":"8b3ceb568900bf33ce565f3a436b4bff1e433a45","user":{"login":"pele-python","id":4612288,"avatar_url":"https://avatars.githubusercontent.com/u/4612288?v=3","gravatar_id":"","url":"https://api.github.com/users/pele-python","html_url":"https://github.com/pele-python","followers_url":"https://api.github.com/users/pele-python/followers","following_url":"https://api.github.com/users/pele-python/following{/other_user}","gists_url":"https://api.github.com/users/pele-python/gists{/gist_id}","starred_url":"https://api.github.com/users/pele-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pele-python/subscriptions","organizations_url":"https://api.github.com/users/pele-python/orgs","repos_url":"https://api.github.com/users/pele-python/repos","events_url":"https://api.github.com/users/pele-python/events{/privacy}","received_events_url":"https://api.github.com/users/pele-python/received_events","type":"Organization","site_admin":false},"repo":{"id":10481958,"name":"pele","full_name":"pele-python/pele","owner":{"login":"pele-python","id":4612288,"avatar_url":"https://avatars.githubusercontent.com/u/4612288?v=3","gravatar_id":"","url":"https://api.github.com/users/pele-python","html_url":"https://github.com/pele-python","followers_url":"https://api.github.com/users/pele-python/followers","following_url":"https://api.github.com/users/pele-python/following{/other_user}","gists_url":"https://api.github.com/users/pele-python/gists{/gist_id}","starred_url":"https://api.github.com/users/pele-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pele-python/subscriptions","organizations_url":"https://api.github.com/users/pele-python/orgs","repos_url":"https://api.github.com/users/pele-python/repos","events_url":"https://api.github.com/users/pele-python/events{/privacy}","received_events_url":"https://api.github.com/users/pele-python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pele-python/pele","description":"Python energy landscape explorer","fork":false,"url":"https://api.github.com/repos/pele-python/pele","forks_url":"https://api.github.com/repos/pele-python/pele/forks","keys_url":"https://api.github.com/repos/pele-python/pele/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pele-python/pele/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pele-python/pele/teams","hooks_url":"https://api.github.com/repos/pele-python/pele/hooks","issue_events_url":"https://api.github.com/repos/pele-python/pele/issues/events{/number}","events_url":"https://api.github.com/repos/pele-python/pele/events","assignees_url":"https://api.github.com/repos/pele-python/pele/assignees{/user}","branches_url":"https://api.github.com/repos/pele-python/pele/branches{/branch}","tags_url":"https://api.github.com/repos/pele-python/pele/tags","blobs_url":"https://api.github.com/repos/pele-python/pele/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pele-python/pele/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pele-python/pele/git/refs{/sha}","trees_url":"https://api.github.com/repos/pele-python/pele/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pele-python/pele/statuses/{sha}","languages_url":"https://api.github.com/repos/pele-python/pele/languages","stargazers_url":"https://api.github.com/repos/pele-python/pele/stargazers","contributors_url":"https://api.github.com/repos/pele-python/pele/contributors","subscribers_url":"https://api.github.com/repos/pele-python/pele/subscribers","subscription_url":"https://api.github.com/repos/pele-python/pele/subscription","commits_url":"https://api.github.com/repos/pele-python/pele/commits{/sha}","git_commits_url":"https://api.github.com/repos/pele-python/pele/git/commits{/sha}","comments_url":"https://api.github.com/repos/pele-python/pele/comments{/number}","issue_comment_url":"https://api.github.com/repos/pele-python/pele/issues/comments{/number}","contents_url":"https://api.github.com/repos/pele-python/pele/contents/{+path}","compare_url":"https://api.github.com/repos/pele-python/pele/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pele-python/pele/merges","archive_url":"https://api.github.com/repos/pele-python/pele/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pele-python/pele/downloads","issues_url":"https://api.github.com/repos/pele-python/pele/issues{/number}","pulls_url":"https://api.github.com/repos/pele-python/pele/pulls{/number}","milestones_url":"https://api.github.com/repos/pele-python/pele/milestones{/number}","notifications_url":"https://api.github.com/repos/pele-python/pele/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pele-python/pele/labels{/name}","releases_url":"https://api.github.com/repos/pele-python/pele/releases{/id}","created_at":"2013-06-04T15:32:36Z","updated_at":"2015-04-01T10:01:59Z","pushed_at":"2015-05-15T16:44:31Z","git_url":"git://github.com/pele-python/pele.git","ssh_url":"git@github.com:pele-python/pele.git","clone_url":"https://github.com/pele-python/pele.git","svn_url":"https://github.com/pele-python/pele","homepage":null,"size":21006,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":11,"forks":14,"open_issues":11,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pele-python/pele/pulls/130"},"html":{"href":"https://github.com/pele-python/pele/pull/130"},"issue":{"href":"https://api.github.com/repos/pele-python/pele/issues/130"},"comments":{"href":"https://api.github.com/repos/pele-python/pele/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/pele-python/pele/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/pele-python/pele/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pele-python/pele/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/pele-python/pele/statuses/4a8eb9a7359a5de2f79beea801eae453136aff67"}}}}