{"id":918,"date":"2024-10-09T13:42:02","date_gmt":"2024-10-09T13:42:02","guid":{"rendered":"https:\/\/doublelayer.eu\/vilab\/?p=918"},"modified":"2024-10-09T13:42:02","modified_gmt":"2024-10-09T13:42:02","slug":"working-with-cubes","status":"publish","type":"post","link":"https:\/\/doublelayer.eu\/vilab\/2024\/10\/09\/working-with-cubes\/","title":{"rendered":"Working with cubes"},"content":{"rendered":"\n<p>Working with cubes can be tedious. I need to show a change in electronic density of a MOF. For that I made two cubes for neutral and charged MOF. Then took their difference using cube_tools, like this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nfrom cube_tools import cube\n\n# Load the cube files using the cube class\ncube1 = cube('mof_opt_0.0.cube')\ncube2 = cube('mof_opt_2.0.cube')\n\n# Subtract the data from cube1 from cube2\ncube_diff = cube('mof_opt_2.0.cube')\ncube_diff.data = cube2.data - cube1.data\n\n# Get z-axis data and find indices where z > 13.3 (jellium density)\nz_indices_above_threshold = np.where(cube_diff.Z > 13.3)&#91;0]\n\n# Remove densities above z = 13.3 by setting them to zero\nfor idx in z_indices_above_threshold:\n    cube_diff.data&#91;:, :, idx] = 0\n\n# Save the modified cube data to a new file\ncube_diff.write_cube('cdd.cube')<\/code><\/pre>\n\n\n\n<p>Once I have got the charge density difference and opened it in VMD, I realised that one part of my MOF is right at the border of a periodic cell, so that part of density was split. So, I used a terminal command to shift the cube like this &#8220;cube_tools -t -24 -36 0 cdd.cube&#8221;. I had to shift manually positions of the atoms by taking into account the voxels size. Next challenge was hiding half of my MOF to clear the view. So I used this tcl syntax in VMD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vmd > mol clipplane normal 0 0 0 {1 0 0}\nvmd > mol clipplane center 0 0 0 {3 0 0}\nvmd > mol clipplane status 0 0 0 1\nvmd > mol clipplane normal 0 1 0 {1 0 0}\nvmd > mol clipplane center 0 1 0 {3 0 0} \nvmd > mol clipplane status 0 1 0 1\nvmd > mol clipplane normal 0 2 0 {1 0 0}\nvmd > mol clipplane center 0 2 0 {3 0 0}\nvmd > mol clipplane status 0 2 0 1<\/code><\/pre>\n\n\n\n<p>Here is the result \u2013 density is almost homogeneously spread over my MOF upon charging.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"508\" src=\"https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene-1024x508.png\" alt=\"\" class=\"wp-image-919\" srcset=\"https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene-1024x508.png 1024w, https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene-300x149.png 300w, https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene-768x381.png 768w, https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene-220x109.png 220w, https:\/\/doublelayer.eu\/vilab\/wp-content\/uploads\/2024\/10\/vmdscene.png 1195w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Working with cubes can be tedious. I need to show a change in electronic density of a MOF. For that I made two cubes for neutral and charged MOF. Then took their difference using cube_tools, like this. Once I have got the charge density difference and opened it in VMD, I realised that one part&hellip; <a class=\"read-more\" href=\"https:\/\/doublelayer.eu\/vilab\/2024\/10\/09\/working-with-cubes\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[61,34],"class_list":["post-918","post","type-post","status-publish","format-standard","hentry","category-know-how","tag-graphics","tag-software"],"_links":{"self":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/comments?post=918"}],"version-history":[{"count":1,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/918\/revisions"}],"predecessor-version":[{"id":920,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/918\/revisions\/920"}],"wp:attachment":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/media?parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/categories?post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/tags?post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}