Articles on ruhi's Bloghttps://blogs.python-gsoc.orgUpdates on different articles published on ruhi's BlogenMon, 28 Aug 2023 17:52:50 +0000Post 14: Final Report and Recollectionshttps://blogs.python-gsoc.org/en/ruhis-blog/post-14-final-report-and-recollections/<p>I have finalized my report here:</p> <p>https://gist.github.com/RuhiRG/9a33441072660bd62b987f77b9d88367</p> <p>I also submitted my final google form.</p> <p>Since the semester has begun in earnest I haven't had much free time for FOSS work. I do have plans for the winter and other vacations. I thought I'd wrap up with some scattered thoughts on what the project was (from my running notes throughout the coding period which never made it into a full blog before).</p> <ul> <li>By offering Python bindings through pyseams, d-SEAMS is now accessible to a wider audience, including researchers who are more familiar with Python than C++ or Lua. This will potentially speed up the analysis of complex ice nucleation and solvated chemistry simulation and analysis.</li> <li>I found working with C++ to be quite challenging initially. Getting my head around its syntax and idiosyncrasies took some time, but it gave me a new appreciation for type safety and memory management.</li> <li> <p>The project is closely aligned with my academic focus on computational biology, and I would love to work on the scientific uses more.</p> </li> </ul> <p>It would be an honor to work on a GSoC project under the PSF next year as well. It has been a pleasure.</p>ms20110@iisermohali.ac.in (ruhi)Mon, 28 Aug 2023 17:52:50 +0000https://blogs.python-gsoc.org/en/ruhis-blog/post-14-final-report-and-recollections/Week 13: Addenum and Capstonehttps://blogs.python-gsoc.org/en/ruhis-blog/week-13-addenum-and-capstone/<h1>Overview</h1> <p><br> This is my last week working on d-SEAMS and my freshly minted `pyseams` project as a GSoC student for 2023. I have been working on polishing up my PRs so they can be merged and finalizing my work product. It has been a pleasure to share my progress with the community each week. Moreover, I've been discussing the design of `d-SEAMS`, which my mentor tells me is a good sign of taking responsibility. This has been my first project in the public eye, and it has truly been a pleasure..</p> <p>For my final report, I opted for a Github Gist:</p> <p><strong><a href="https://gist.github.com/RuhiRG/9a33441072660bd62b987f77b9d88367">gsoc23_pyseams_fin_report.md</a></strong></p> <p>I plan to keep revising this for a while now, with inputs from my mentor as well.</p> <h2>Issues Opened</h2> <p>- <a href="https://github.com/d-SEAMS/seams-core/issues/41">RFC: Removing <code>lua</code> bindings</a></p> <h2>PRs Merged</h2> <p>- <a href="https://github.com/d-SEAMS/seams-core/pull/40">BLD: Work on MacOS, use as a subproject</a></p>ms20110@iisermohali.ac.in (ruhi)Wed, 23 Aug 2023 18:38:24 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-13-addenum-and-capstone/week 12: wrapping uphttps://blogs.python-gsoc.org/en/ruhis-blog/week-12-wrapping-up/<p>Initially, the plan was to write the python binding along side of lua so that we could use both. while, doing the python bindings, we (me and my mentors) realized that the lua pointer to objects function design led to very awkward (not pythonic) bindings. To this end I worked on refactoring the functions inside seams-core itself, though this in-turn broke the lua interface which did not support constructing C++ objects from lua (and by extension could not use the new value return-type functions). So, this week as discussed with my mentors, we removed the lua interface from the C++ command line interface.</p> <p>At one point in an earlier week I had floated the idea of eventually embedding the python interpreter into the C++ CLI instead of the lua interpreter and using the new bindings, however, the development team felt that this is a cleaner approach. The C++ CLI remains capable of reproducing the older D-SEAMS results, and a major release will clarify the role of the C++ core as a backend engine with Python bindings.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li>Wrote the last of example function binding <a href="https://github.com/d-SEAMS/pyseams/commit/5ad8ade360b874590167ceba481552518e2ce16e">chillPlus</a>.    </li> <li>Wrote <a href="https://github.com/RuhiRG/seams-core/commit/72fc40a19adf47381c5579a0bdbc08aa744a233a">code</a> to call it directly from C++ and python without any involvement of lua.</li> <li>The problem with installation of dSEAMS in <a href="https://github.com/d-SEAMS/seams-core/pull/40">Macos</a> is fixed.</li> </ol> <h3>What is coming up next?</h3> <ol> <li>Clear documentation for the whole work.</li> <li>Final report which will also detail my next steps for collaboration.</li> </ol> <h3>Did you get stuck anywhere?</h3> <p>No, I wasn't stuck anywhere.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 16 Aug 2023 17:55:11 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-12-wrapping-up/week 11: Bulk systems and 2-D ice analysishttps://blogs.python-gsoc.org/en/ruhis-blog/week-11-bulk-systems-and-2-d-ice-analysis/<p>This week, I was testing more in-built examples from seams-core by calling it from python. Unfortunately, I ran into a bug while writing the <code>pybind</code> for <code>bulkTopologicalCriterion</code> example. I raised an issue about it.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li>Wrote working pybinds for <a href="https://github.com/d-SEAMS/pyseams/commit/5bfe3f04f3dda74a3635849c691b622c2ec9f445">topo2d</a> , <a href="https://github.com/d-SEAMS/pyseams/commit/c8df7fe47a63d4b097e43b3397d4d413dd3d9dbc">BPring</a> and <a href="https://github.com/d-SEAMS/pyseams/commit/817b2cadf86668dc7a36ebe40337fcb2f5fe70f0">bulkTopologicalCriterion</a> in-built examples.</li> <li>Raised an <a href="https://github.com/d-SEAMS/pyseams/issues/4">issue</a> for a bug in <code>bulkTopologicalCriterion</code> example.</li> </ol> <h3>What is coming up next?</h3> <ol> <li>Better documentation of <code>pyseams</code></li> <li>Visualising workflows.</li> <li>Look into replacing the <code>lua</code> interpreter in the C++ CLI with <code>pybind11</code>.</li> </ol> <h3>Did you get stuck anywhere?</h3> <p>No, I wasn't stuck anywhere.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 09 Aug 2023 23:18:50 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-11-bulk-systems-and-2-d-ice-analysis/week 10: Testing examples with pybindhttps://blogs.python-gsoc.org/en/ruhis-blog/week-10-testing-examples-with-pybind/<p>This week, I was testing in-built examples from seams-core by calling it from python. I was also working on updating the new installation methods for seams-core with <code>meson</code> and building the executable with <code>lua</code> and <code>meson.</code></p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li>Ran an in-built example from seams-core from python and compared to the <code>lua</code> implementation.</li> <li>Made changes in the <a href="https://github.com/d-SEAMS/seams-core/commit/838f74bc090d3d53b7b09adbec8125683f982dd8">README.md</a> file for installing updates.</li> <li>Updated the <a href="https://github.com/d-SEAMS/seams-core/commit/8ddb7ee21b21b3484d770a52951fc023bfb17c6d">environment.yml and meson.build</a> file for version updates.</li> <li>Started working on atomic visualizations.</li> </ol> <h3>What is coming up next?</h3> <ol> <li>Adding plots.</li> <li>Better documentation of <code>pyseams</code></li> <li>Visualizing workflows.</li> <li>Adding pytests.</li> <li>Continuing the CI test to see if the results are same.</li> <li>Doing the rest of the two workflows.</li> </ol> <h3>Did you get stuck anywhere?</h3> <p>No, I wasn't stuck anywhere.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 02 Aug 2023 21:48:48 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-10-testing-examples-with-pybind/week 9: Basic testinghttps://blogs.python-gsoc.org/en/ruhis-blog/week-9-basic-testing/<p>This week, as my mentor <a href="https://github.com/d-SEAMS/pyseams/issues/2">suggested</a>, I was working on testing pyseams on linux in the cloud with the help of github actions. While doing that it came to my attention that the function named "keepAxialRingsOnly" is unused and not defined in any file but it is declared in "topo_one_dim.hpp". I created an issue about it <a href="https://github.com/d-SEAMS/seams-core/issues/39">here</a></p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li>Ran a basic test in github for pyseams.</li> <li>Created an <a href="https://github.com/d-SEAMS/seams-core/issues/39">issue</a> for an unsued function.</li> <li>Started working on atomic visualizations</li> <li>Was reading the d-SEAMS paper to write the <code>lua</code> workflow</li> </ol> <h3>What is coming up next?</h3> <ol> <li>Running the dSEAMS workflow in <code>python</code></li> <li>Visualizing it.</li> <li>Adding pytests.</li> </ol> <h3>Did you get stuck anywhere?</h3> <p>No, I wasn't stuck anywhere. My meetings with my mentors are regular and frequent which helps me to clear my doubt ASAP.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 26 Jul 2023 19:57:15 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-9-basic-testing/week 8: More python binding for functionshttps://blogs.python-gsoc.org/en/ruhis-blog/week-8-more-python-binding-for-functions/<p>This week I wrote function bindings for functions in the namespaces <code>sinp</code>, <code>nneigh</code>, <code>bond</code>, <code>primitive</code>, <code>ring</code>, <code>tum3</code> and <code>gen</code>. I made some commits as well over in <code>pyseams</code>. I worked a little bit on string representation for users while using the dSEAMS in python, it looks like this but this would be confusing for the users  as the representation was <span style="font-family: Courier New,Courier,monospace;">&lt;build.cyoda.pointdouble 0x7fbab9a75a30="" at="" object=""&gt; &lt;/build.cyoda.pointdouble&gt;</span>which is terrible in lists.</p> <p>So, we changed it to <span style="font-family: Courier New,Courier,monospace;">&lt;pointdouble mem_loc:1eb6b20=""&gt;&lt;/pointdouble&gt;</span> by using this:</p> <pre style="background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><code class="lang-c++">.def(<span class="hljs-string">"__repr__"</span>, [](<span class="hljs-keyword">const</span> molSys::Point&lt;<span class="hljs-keyword">double</span>&gt; &amp;a) { <span class="hljs-built_in">std</span>::<span class="hljs-keyword">uintptr_t</span> ptr_val = <span class="hljs-built_in">std</span>::<span class="hljs-keyword">uintptr_t</span>(&amp;a); <span class="hljs-keyword">return</span> fmt::format(<span class="hljs-string">"&lt;pointdouble mem_loc:=""&gt;"&lt;/pointdouble&gt;</span>, <span class="hljs-keyword">static_cast</span>&lt;uint&gt;(ptr_val)); .def(<span class="hljs-string">"__str__"</span>, [](<span class="hljs-keyword">const</span> molSys::Point&lt;<span class="hljs-keyword">double</span>&gt; &amp;a) { <span class="hljs-keyword">return</span> fmt::format( <span class="hljs-string">"x: {} y: {} z: {} type: {} molID: {} atomID: {} inSlice: {}"</span>, a.x, a.y, a.z, a.type, a.molID, a.atomID, a.inSlice); });&lt;/uint&gt;</code></span></pre> <p>this looks more clear and specific. It also allows for users to get the memory location fairly easily if needed with <code>aa.pts[0].split(':')[:-1]</code>.</p> <p>Since we implemented <code>__str__</code> as well, by using the following command, they can get more information by calling <span style="font-family: Courier New,Courier,monospace;">str()</span> on a <span style="font-family: Courier New,Courier,monospace;">PointDouble</span>.</p> <p>However we might change this to expose a <code>print()</code> or <code>info</code> function instead.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li> <p>python bindings for functions. The following are the commits made in response to that.</p> <ol> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/0cf9e62b44193290f7c1de35882338d2d9cb37fc">1</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/14206da96b4f76f9a56032759844ae3e151d6991">2</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/b3dfa1244ca8b69837d1239b65ce2eed621c1bcf">3</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/4db0a8323577f6f54b850eba8dff30814d4d8fc5">4</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/f3c41161e33093e561f9465404ef8a766c0e9058">5</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/f3c41161e33093e561f9465404ef8a766c0e9058">6</a>.</li> <li>commit <a href="https://github.com/d-SEAMS/pyseams/commit/aa099de13701b45c328d7a3dc085b62825617875">7</a>.</li> </ol> <h3>What is coming up next?</h3> <ol> <li> <p>Writing python scripts</p> </li> <li>Writing pytests</li> <li>More repr and str work</li> </ol> <h3>Did you get stuck anywhere?</h3> <p>No, I didn't get stuck anywhere.</p> </li> </ol>ms20110@iisermohali.ac.in (ruhi)Mon, 17 Jul 2023 23:44:54 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-8-more-python-binding-for-functions/Week 7: Admin, Python distribution, testinghttps://blogs.python-gsoc.org/en/ruhis-blog/week-7-admin-python-distribution-testing/<h2>Overview</h2> <p>This week I was rather unwell. However, I spent my time going over python packaging rules for eventual distribution via PIP, and I looked into alternate ways to fill in the core `yodaStruct` object because of segfaults in d-SEAMS. I am splitting my time now between the C++ core (with my mentor mostly) and the Python (pure and Pybind11) bindings.</p> <p> </p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <p>- Moved `pyseams` into the d-SEAMS organization</p> <p>- Looked into `ase` atoms and how to read an `xyz` in Python to populate a`yodaStruct`</p> <p>- Discussed the (re-)design of the readers in D-SEAMS for the bindings</p> <p>- Started writing some basic `pytest` fixtures, since the data needed will have to be shared across tests</p> <h3>What is coming up next?</h3> <p>- More re-writing of the C++ core</p> <p>- Adding more tests and continuous integration (I was asked to look into this)</p> <p>- Understanding more of `ase` and how the Atoms class maps to the d-SEAMS yodaStruct</p> <h3>Did you get stuck anywhere?</h3> <p>No, I was not well, and couldn't raise any PRs this week, but I'm on track, and have discussed the next steps with my mentors.</p>ms20110@iisermohali.ac.in (ruhi)Thu, 13 Jul 2023 22:56:11 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-7-admin-python-distribution-testing/Week 6: Pointers and Pybind11https://blogs.python-gsoc.org/en/ruhis-blog/week-6-pointers-and-pybind11/<p> </p> <h2>Overview</h2> <p>This week I spent a lot of time on debugging issues with pointers in d-SEAMS. As noted on the issue I opened and discussions with the core-team, some refactoring is required which I began working on in tandem.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li> <p>Worked on binding the functions for input in d-SEAMS</p> </li> <li> <p>Opened an issue to discuss issues with the code: <a href="https://github.com/d-SEAMS/seams-core/issues/35">https://github.com/d-SEAMS/seams-core/issues/35</a></p> </li> <li> <p>Added bindings and cleaned up <a href="https://github.com/RuhiRG/pyseams/">https://github.com/RuhiRG/pyseams</a> for migration.</p> </li> <li> <p>Opened a pull request to seames-core : <a href="https://github.com/d-SEAMS/seams-core/pull/36">https://github.com/d-SEAMS/seams-core/pull/36</a></p> </li> </ol> <h3>What is coming up next?</h3> <ol> <li> <p>More fixing of the d-SEAMS core</p> </li> <li> <p>Add bindings and fix build</p> </li> <li> <p>Setting up an issue with the order in which I will implement the bindings</p> </li> </ol> <h3>Did you get stuck anywhere?</h3> <p>I was able to meet my mentor and the project organisers.  Pointers and their usage are a bit confusing to me so far.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 05 Jul 2023 23:56:17 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-6-pointers-and-pybind11/week 5: Core compound type bindingshttps://blogs.python-gsoc.org/en/ruhis-blog/week-5-core-compound-type-bindings/<h1>Overview</h1> <p>This week I started by making a github repository named <a href="https://github.com/RuhiRG/pyseams">pyseams</a>. Me and my mentor worked together on writing a meson build file. After this, I realised that dSEAMS had some enums which had to be converted to enum class to prevent the implicit conversion to other types i.e., to another enum or int and made a <a href="https://github.com/d-SEAMS/seams-core/pull/34">pull request</a> for the same thing. Then I proceeded with writing bindings using pybind11, tested it locally, and committed to the git repo pyseams.</p> <pre style="background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;">// The following bindings <span style="font-family: Courier New,Courier,monospace;"><code>are still in progress: <code class="lang-c++"><span class="hljs-comment">#include &lt;pybind11/pybind11.h&gt;</span> <span class="hljs-comment">#include "../subprojects/seams-core/src/include/internal/mol_sys.hpp"</span></code> namespace py = pybind11; PYBIND11_MODULE(cyoda, m) { <span class="hljs-symbol">py:</span><span class="hljs-symbol">:class_&lt;molSys</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:Point&lt;double&gt;&gt;</span>(m, <span class="hljs-string">"PointDouble"</span>) .def(<span class="hljs-symbol">py:</span><span class="hljs-symbol">:init&lt;&gt;</span>()) .def_readwrite(<span class="hljs-string">"c_type"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:type</span>) .def_readwrite(<span class="hljs-string">"molID"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:molID</span>) .def_readwrite(<span class="hljs-string">"atomID"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:atomID</span>) .def_readwrite(<span class="hljs-string">"x"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:x</span>) .def_readwrite(<span class="hljs-string">"y"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:y</span>) .def_readwrite(<span class="hljs-string">"z"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Point&lt;double&gt;</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:z</span>); <span class="hljs-symbol">py:</span><span class="hljs-symbol">:enum_&lt;molSys</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:bond_type&gt;</span>(m, <span class="hljs-string">"BondType"</span>) .value(<span class="hljs-string">"staggered"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:bond_type</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:staggered</span>) .value(<span class="hljs-string">"eclipsed"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:bond_type</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:eclipsed</span>) .value(<span class="hljs-string">"out_of_range"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:bond_type</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:out_of_range</span>); <span class="hljs-symbol">py:</span><span class="hljs-symbol">:enum_&lt;molSys</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:atom_state_type</span> &gt;(m, <span class="hljs-string">"AtomStateType"</span>) .value(<span class="hljs-string">"cubic"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:cubic</span>) .value(<span class="hljs-string">"hexagonal"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:hexagonal</span>) .value(<span class="hljs-string">"water"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:water</span>) .value(<span class="hljs-string">"interfacial"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:interfacial</span>) .value(<span class="hljs-string">"clathrate"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:clathrate</span>) .value(<span class="hljs-string">"interClathrate"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:interClathrate</span>) .value(<span class="hljs-string">"unclassified"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:unclassified</span>) .value(<span class="hljs-string">"reCubic"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:reCubic</span>) .value(<span class="hljs-string">"reHex"</span>, <span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:atom_state_type</span> <span class="hljs-symbol">:</span><span class="hljs-symbol">:reHex</span>); <span class="hljs-symbol">py:</span><span class="hljs-symbol">:class_&lt;molSys</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:Result&gt;</span>(m, <span class="hljs-string">"Result"</span>) .def(<span class="hljs-symbol">py:</span><span class="hljs-symbol">:init&lt;&gt;</span>()) .def_readwrite(<span class="hljs-string">"classifier"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Result</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:classifier</span>) .def_readwrite(<span class="hljs-string">"c_value"</span>, &amp;<span class="hljs-symbol">molSys:</span><span class="hljs-symbol">:Result</span><span class="hljs-symbol">:</span><span class="hljs-symbol">:c_value</span>); }</code></span></pre> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li> <p>Made a Github repository named <a href="https://github.com/RuhiRG/pyseams">pyseams</a>.</p> </li> <li> <p><a href="https://github.com/d-SEAMS/seams-core/pull/34">Pull request</a> for enum to enum class change.</p> </li> <li> <p>Made a meson build file.</p> </li> <li> <p>Started compiling the extensions and running the <code>python</code> <a href="https://github.com/RuhiRG/pyseams/blob/main/pyb11_srcs/py_one.cc">bindings</a>.</p> </li> </ol> <h3>What is coming up next?</h3> <ol> <li> <p>Finishing the <code>python</code> bindings for the first workflow in the <code>lua</code> design as discussed earlier.</p> </li> <li> <p>Writing documentation and tests</p> </li> <li> <p>Moving the pyseams repository to the dseams-core.</p> </li> </ol> <h3>Did you get stuck anywhere?</h3> <p>I was a bit stuck at the meson build file process, but my mentor helped me with it. I think I am on track.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 28 Jun 2023 23:32:31 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-5-core-compound-type-bindings/Week 4: Local builds and Python API designhttps://blogs.python-gsoc.org/en/ruhis-blog/week-4-local-builds-and-python-api-design/<h1>Overview</h1> <p>This week I was setting up d-seams in my Mac, but that did not seem like a great idea as some requirements for d-seams were not supported on the M1 Mac (I opened an issue and PR regarding this). I had to figure out a way to run it on a remote linux machine.</p> <p>I was also working with how the code design would look like.</p> <pre style="background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><code class="lang-python"><span class="hljs-built_in">import</span> pyseams</code></span> <span style="font-family: Courier New,Courier,monospace;"><span class="hljs-comment"># Configuration Variables</span> <span class="hljs-attr">cutoffRadius</span> = <span class="hljs-number">3.5</span> <span class="hljs-attr">oxygenAtomType</span> = <span class="hljs-number">2</span> <span class="hljs-attr">hydrogenAtomType</span> = <span class="hljs-number">1</span> <span class="hljs-attr">targetFrame</span> = <span class="hljs-number">1</span> <span class="hljs-attr">finalFrame</span> = <span class="hljs-number">1</span> <span class="hljs-attr">frameGap</span> = <span class="hljs-number">1</span> <span class="hljs-attr">maxDepth</span> = <span class="hljs-number">6</span> <span class="hljs-attr">isSlice</span> = False <span class="hljs-attr">sliceLowerLimits</span> = [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>] <span class="hljs-attr">sliceUpperLimits</span> = [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>] <span class="hljs-attr">outDir</span> = <span class="hljs-string">"runOne/"</span> <span class="hljs-attr">trajectory</span> = <span class="hljs-string">"input/traj/exampleTraj.lammpstrj"</span> <span class="hljs-attr">lowestAtomID</span> = <span class="hljs-number">0</span></span> <span style="font-family: Courier New,Courier,monospace;">print(<span class="hljs-string">"\nWelcome to the Ice Type Determination Module\n"</span>)</span> <span style="font-family: Courier New,Courier,monospace;"><span class="hljs-attr">resCloud</span> = None <span class="hljs-comment"># Initialize resCloud variable</span></span> <span style="font-family: Courier New,Courier,monospace;">for frame <span class="hljs-keyword">in</span> range(targetFrame, finalFrame + <span class="hljs-number">1</span>, frameGap): <span class="hljs-attr">resCloud</span> = pyseams.readFrameOnlyOne(trajectory, frame, resCloud, oxygenAtomType, isSlice, sliceLowerLimits, sliceUpperLimits) <span class="hljs-attr">nList</span> = pyseams.neighborList(cutoffRadius, resCloud, oxygenAtomType) <span class="hljs-attr">hbnList</span> = pyseams.getHbondNetwork(trajectory, resCloud, nList, frame, hydrogenAtomType) <span class="hljs-attr">hbnList</span> = pyseams.bondNetworkByIndex(resCloud, hbnList) <span class="hljs-attr">rings</span> = pyseams.getPrimitiveRings(hbnList, maxDepth) pyseams.prismAnalysis(outDir, rings, hbnList, resCloud, maxDepth, lowestAtomID, targetFrame, frame, False)</span> <span style="font-family: Courier New,Courier,monospace;">print(<span class="hljs-string">"Ice Type Determination completed."</span>)</span></pre> <p>This is just a rough draft. I will be working on it to make it more perfectly.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ol> <li> <p>build issues in <a href="https://github.com/d-SEAMS/seams-core/issues/25">GitHub</a>.</p> </li> <li> <p>did a pull request on <a href="https://github.com/d-SEAMS/seams-core/issues/26">GitHub</a>.</p> </li> <li> <p>worked a little bit on pybind design.</p> </li> </ol> <h3>What is coming up next?</h3> <ol> <li> <p>I will make a repository with python bindings which will be linked with d-seams as a shared library.</p> </li> <li> <p>d-seams and python binding uses cmake. I am not that comfortable with cmake so I was planning to use meson for the python bindings. Meson supports pybind11 as mentioned <a href="https://mesonbuild.com/Dependencies.html#pybind11">here</a></p> </li> <li> <p>I will also work on the python design a bit more.</p> </li> </ol> <h3>Did you get stuck anywhere?</h3> <p>I was stuck as my M1-macos machine didn't support certain requirements of d-seams which set me back a little bit. I had to work on a linux machine. My mentor helped me out with the process.</p>ms20110@iisermohali.ac.in (ruhi)Thu, 22 Jun 2023 03:44:01 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-4-local-builds-and-python-api-design/Week 3: Embedding and automated bindingshttps://blogs.python-gsoc.org/en/ruhis-blog/week-3-embedding-and-automated-bindings/<h1>Overview</h1> <p>Since last week, I was going over the Pybind11 documentation and also looking into automated binding generators. I have been mulling over what it means to provide bindings and how the interface is going to change. I tested out <a href="https://cppyy.readthedocs.io/en/latest/">cppyy</a> and its examples, but my mentor suggested that it may not be the right fit for the project as it is unlikely to be able to handle templates without more involved bindings.</p> <p>However, as I began setting up a new repository for the bindings, it occurred to me that for backwards compatibility, though providing a compiled extension will be useful for more users, switching over from Lua really needs an <strong>embedding</strong> of the Python interpreter! I am fairly sure of this, as the binary (from last week's <code>main.cpp</code>) essentially copies into C++ data from Lua. Embedding is part of<a href="https://pybind11.readthedocs.io/en/stable/advanced/embedding.html"> Pybind11's feature-set</a>:</p> <pre style="background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><code class="lang-cpp"><span class="hljs-comment">// Starts the interpreter and keeps it alive</span> py::scoped_interpreter guard{};</code></span></pre> <p>However, there's a catch, we need both the bindings (to run <code>seams-core</code>) from <code>python</code> so we can transfer data into the C++ in a robust manner! This means my timeline is a little altered, I will need to write the compiled extension, and then interface that to the <code>main.cpp</code>. So:</p> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><code class="lang-python">from pyseams <span class="hljs-keyword">import</span> <span class="hljs-built_in">PointCloud</span></code></span></div> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;">pinp = <span class="hljs-built_in">PointCloud</span>(...)</span></div> <p>Which will then be read in on the C++ side by the embedded interpreter. Sort of like <a href="https://github.com/d-SEAMS/seams-core/blob/0d242463acac0fc5e53048b556cb4a366a70dbb5/example_lua/chillPlus/iceType/vars.lua">the existing examples</a>:</p> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><code class="lang-lua"><span class="hljs-built_in">print</span>(<span class="hljs-string">"\n Welcome to the manual lua function evaluation environment.\n"</span>);</code></span></div> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;"><span class="hljs-keyword">for</span> frame=targetFrame,finalFrame,frameGap <span class="hljs-keyword">do</span><br>    resCloud=readFrame(trajectory,frame,resCloud,oxygenAtomType,isSlice,sliceLowerLimits,sliceUpperLimits) <span class="hljs-comment">--- Get the frame</span><br>    nList=neighborList(cutoffRadius, resCloud, oxygenAtomType); <span class="hljs-comment">--- Calculate the neighborlist by ID</span><br>    <span class="hljs-comment">---</span><br>    resCloud=chillPlus_cij(resCloud,nList,isSlice); <span class="hljs-comment">--- Calculate Cij (cloud,slice)</span><br>    resCloud=chillPlus_iceType(resCloud,nList,outDir,targetFrame,isSlice,chillPlus_noMod); <span class="hljs-comment">--- Write out data (cloud,slice,name)</span><br>    writeDump(resCloud,outDir,dumpChillP); <span class="hljs-comment">--- Dump the rescloud which currently has CHILL Plus classifications</span><br>    <span class="hljs-comment">--- Modified CHILL+</span><br>    avgQ6=averageQ6(resCloud,nList,isSlice); <span class="hljs-comment">--- Average Q6 (cloud,slice)</span><br>    resCloud=modifyChill(resCloud,avgQ6); <span class="hljs-comment">--- Modification (cloud,q6)</span><br>    percentage_Ice(resCloud,outDir,targetFrame,isSlice,chillPlus_mod); <span class="hljs-comment">--- Post reclassification writeOut</span><br>    writeDump(resCloud,outDir,dumpSupaaP); <span class="hljs-comment">--- Dump the rescloud which now has the supaa CHILL Plus Trajectory</span><br>    <span class="hljs-comment">--- Get the largest ice cluster. Here, iceNeighbourList is the neighbour list by index.</span><br>    clusterAnalysis(outDir, clusterCloud, resCloud, nList, iceNeighbourList, cutoffRadius, targetFrame, <span class="hljs-string">"q6"</span>);<br>    <span class="hljs-comment">--- Recenter the cluster such that the centroid is at the center of the simulation box </span><br>    recenterCluster(clusterCloud, iceNeighbourList);<br>    writeDump(resCloud,outDir,largestClusterDump); <span class="hljs-comment">--- Dump the recentered largest ice cluster</span><br> <span class="hljs-keyword">end</span></span></div> <p>This is a tentative design which I will discuss with my mentor this week.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ul> <li>Looked into automated bindings (<code>cppyy</code>)</li> <li>Realized I need to embed an interpreter for backwards compatibility</li> <li>Started designing the classes based on <code>pypotlib</code> <h3>What is coming up next?</h3> </li> <li>I'm still planning on that personal site</li> <li>I will publicly post my repo for the <code>python-bindings</code> <ul> <li>My mentor will move it into the <code>dseams</code> workspace</li> <li>This will be my first time working in an organization on Github</li> </ul> </li> <li>I will start a design document</li> <li>I will go over the C-Python documentation to understand the automated / manual bindings system in a bit more detail <ul> <li>My mentor pointed me to <a href="https://rgoswami.me/posts/cython-derivedtype-f2py/">his post on interoperability between Python C and Fortran</a> for some background information</li> </ul> </li> </ul> <p>The goal is to have working code examples by my midway evaluation as per the original plan.</p> <h3>Did you get stuck anywhere?</h3> <ul> <li>The embedding of the interpreter was something which I hadn't considered, not even in my proposal</li> <li>I was interested (and a bit caught up on) how automatic bindings work</li> <li>I am having some trouble (the "tyranny of a blank page") getting started with runnable code <ul> <li>Especially when I realized I cannot run the exact code (<code>main.cpp</code>) until after the bindings are complete!</li> </ul> </li> <li>I was having trouble formatting my posts on the PSF GSoC blogroll <ul> <li>Figured out I can use <a href="https://markdowntohtml.com/">this site</a> (or <code>pandoc</code>)</li> </ul> </li> </ul>ms20110@iisermohali.ac.in (ruhi)Thu, 15 Jun 2023 18:18:45 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-3-embedding-and-automated-bindings/Week 2: Into the Lua Bindingshttps://blogs.python-gsoc.org/en/ruhis-blog/week-2-into-the-lua-bindings/<h1>Overview</h1> <p>I have been going over the source code of d-SEAMS and puzzling out the minimal required objects and functions. It seems that for the `lua` bindings, the objects were mostly constructed in `C++` and then populated in `lua`, however, for the `python` bindings each class will need to have separate bindings. I have narrowed my focus to a single workflow, not the entire driver (which is controlled by the `yaml` file), that is as discussed in the <a href="https://pubs.acs.org/doi/10.1021/acs.jcim.0c00031">paper</a> (from <a href="https://github.com/d-SEAMS/seams-core/blob/0d242463acac0fc5e53048b556cb4a366a70dbb5/src/main.cpp#L73-L133">here</a>):</p> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;">```cpp<br> <span style="font-family: Courier New,Courier,monospace;">if (config["topoTwoDim"]["use"].as&lt;bool&gt;()) {<br>     // Use the variables script<br>     lua.script_file(vars);<br>     // -----------------<br>     // Variables which must be declared in C++<br>     //<br>     // Newer pointCloud (rescloud -&gt; ice structure, solcloud -&gt; largest cluster)<br>     molSys::PointCloud&lt;molSys::Point&lt;double&gt;, double&gt; resCloud;<br>     // Some neighbor lists<br>     std::vector&lt;std::vector&lt;int&gt;&gt; nList, hbnList;<br>     // For the list of all rings (of all sizes)<br>     std::vector&lt;std::vector&lt;int&gt;&gt; ringsAllSizes;<br>     std::vector&lt;std::vector&lt;int&gt;&gt; rings;<br>     // RDF stuff<br>     std::vector&lt;double&gt; rdfValues; // RDF vector<br>     // -----------------<br>     // This section basically only registers functions and handles the rest in<br>     // lua Use the functions defined here<br>     auto lscript = lua.get&lt;std::string&gt;("functionScript");<br>     // Transfer variables to lua<br>     lua["doBOP"] = config["bulk"]["use"].as&lt;bool&gt;();<br>     lua["topoOneDim"] = config["topoOneDim"]["use"].as&lt;bool&gt;();<br>     lua["topoTwoDim"] = config["topoTwoDim"]["use"].as&lt;bool&gt;();<br>     lua["topoBulk"] = config["bulk"]["use"].as&lt;bool&gt;();<br>     //<br>     lua["nList"] = &amp;nList;<br>     lua["hbnList"] = &amp;hbnList;<br>     lua["resCloud"] = &amp;resCloud;<br>     lua["trajectory"] = tFile;<br>     // Confined ice stuff<br>     lua["ringsAllSizes"] = &amp;rings;<br>     // RDF stuff<br>     lua["rdf"] = &amp;rdfValues;<br>     // -----------------<br>     // Register functions<br>     //<br>     // Writing stuff<br>     // Generic requirements<br>     lua.set_function("readFrameOnlyOne", sinp::readLammpsTrjreduced);<br>     lua.set_function("readFrameOnlyOneAllAtoms", sinp::readLammpsTrj); // reads in all atoms regardless of type  <br>     lua.set_function("neighborList", nneigh::neighListO);<br>     // -----------------<br>     // Topological Network Method Specific Functions<br>     // Generic requirements (read in only inside the slice)<br>     lua.set_function("getHbondNetwork", bond::populateHbonds);<br>     lua.set_function("bondNetworkByIndex", nneigh::neighbourListByIndex);<br>     // -----------------<br>     // Primitive rings<br>     lua.set_function("getPrimitiveRings", primitive::ringNetwork);<br>     // -----------------<br>     // Quasi-two-dimensional ice<br>     lua.set_function("ringAnalysis", ring::polygonRingAnalysis);<br>     // --------------------------<br>     // RDF functions<br>     lua.set_function("calcRDF", rdf2::rdf2Danalysis_AA);<br>     // --------------------------<br>     // Use the script<br>     lua.script_file(lscript);<br>     // --------------------------</span></div> <div style="background: #eeeeee; border: 1px solid #cccccc; padding: 5px 10px;"><span style="font-family: Courier New,Courier,monospace;">  } // end of two-dimensional ice block</span><br> ```</div> <p>It is clear that the bindings might be a mite more complicated in `python`, especially as I realized many of the core structures are templated.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <ul> <li>Went over the `d-seams` documentation and examples locally <ul> <li>Settled on a workflow to bind</li> <li>Looked into the classes and functions needed</li> </ul> </li> <li>Went over the `sol3` documentation on the `lua` bindings</li> </ul> <h3>What is coming up next?</h3> <p>1.  I intend to have a personal site with more details of the internals<br> 2. I shall start designing the code and determine a style guide with my mentor<br> 3. I will finish enumerating the functions and objects needed to be bound for this workflow</p> <h3>Did you get stuck anywhere?</h3> <p>I was a bit confused about the manner in which memory was managed between `lua` and `cpp` and how it would change with the `python` bindings. I hope to clarify this further, and have a minimal toy setup on my machine to work with when I meet my mentor later this week.</p>ms20110@iisermohali.ac.in (ruhi)Wed, 07 Jun 2023 21:58:38 +0000https://blogs.python-gsoc.org/en/ruhis-blog/week-2-into-the-lua-bindings/Community Bonding and Week 1https://blogs.python-gsoc.org/en/ruhis-blog/community-bonding-and-week-1/<h1>Overview</h1> <p>As this post is at the start of the first week of the coding period, there haven't been any concrete pull requests, though over the course of the community bonding period I pointed towards a project called <span style="font-family: Courier New,Courier,monospace;">pypotlib</span> (<a href="https://github.com/TheochemUI/pypotlib">GH source</a>) as an example of the split binding / core library design I will be implementing.</p> <h2>Check-in Questions</h2> <h3>What did you do this week?</h3> <p>1. Went over the <span style="font-family: Courier New,Courier,monospace;">pybind11 </span>documentation and examples locally</p> <p>2. Looked into style and design guides for PyPI a bit</p> <h3>What is coming up next?</h3> <p>1. Local setup</p> <p>2. Setting up an issue with the order in which I will implement the bindings</p> <h3>Did you get stuck anywhere?</h3> <p>I was able to meet my mentor and the project organisers. I think I am on track and do not feel stuck so far.</p>ms20110@iisermohali.ac.in (ruhi)Thu, 01 Jun 2023 12:09:33 +0000https://blogs.python-gsoc.org/en/ruhis-blog/community-bonding-and-week-1/