<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>PMEAL</title>
<link>https://www.pmeal.com/blog.html</link>
<atom:link href="https://www.pmeal.com/blog.xml" rel="self" type="application/rss+xml"/>
<description></description>
<generator>quarto-1.11.9</generator>
<lastBuildDate>Sat, 22 Nov 2025 00:00:00 GMT</lastBuildDate>
<item>
  <title>Fun with Github actions and bumping version numbers</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2025-11-22/</link>
  <description><![CDATA[ 






<p>Someone recently asked me if OpenPNM was still being maintained, and I was pretty shocked to see it had been months since we/I had dealt with any of the basic maintenance issues which were lingering. For instance, several of our dependencies had major version changes which had broken some things in OpenPNM. This email message has spurred me into action, and I have been busy updating all the backend stuff. My starting point has been the “bump-version” process. We have automated “actions” setup on Github which increment the package version number on each merged PR. This was a life saver when we first figured out how to do it. Before this we regularly forgot to update the version number on a release, or used the wrong version number (i.e.&nbsp;sometimes with a ‘V’ and sometimes not). Anyway, I just spent a few hours learning the <code>bump-my-version</code> package, and I did it by creating a sandbox repo and messing with settings until it worked. The repo can be <a href="https://github.com/jgostick/bump-my-version-sandbox">found here</a>, so you can grab the work flow files and settings if you’re interested. I also included a lengthy README file which outlines all the details of the process. I’m sure I’ll find this a useful reference in a few years when things are broken again and I have to figure out what I did and why. But until then it’s working great for the OpenPNM repo. I’ll be adding it to PoreSpy next!</p>



 ]]></description>
  <category>news</category>
  <category>tips</category>
  <guid>https://www.pmeal.com/posts/2025-11-22/</guid>
  <pubDate>Sat, 22 Nov 2025 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2025-11-22/cover.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Tips and Tricks: Converting STL files to voxel images</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2025-01-13/</link>
  <description><![CDATA[ 






<section id="tips-and-tricks-converting-stl-files-to-voxel-images" class="level1">
<h1>Tips and Tricks: Converting STL files to voxel images</h1>
<p><a href="https://en.wikipedia.org/wiki/STL_(file_format)">STL</a> files are a common way to represent 3D volumes. They are used by 3D printers and CFD models, among others. I was recently handed a batch of STL files by someone that had generated packings of randomly packed particles. They used physics-based simulations to determine where the particles would settle under the influence of gravity, providing realistic geometries for doing flow simulations. I spent a bit of time trying to find a simple way to convert these files to the basic voxelized representation that we require for most of our analysis, like <a href="https://doi.org/10.1103/PhysRevE.96.023307">extracting networks</a> for use in <a href="https://openpnm.org">OpenPNM</a>, or <a href="https://doi.org/10.1016/j.advwatres.2024.104799">simulating non-wetting fluid invasion</a>.</p>
<p>The solution I found was pretty simple, but I had to piece together several bits of information from different tutorials, so I thought I’d collect it here.</p>
<p>At first I discovered the <a href="https://pypi.org/project/numpy-stl/">numpy-stl</a> which allowed me to read the files successfully and plot <em>something</em>, but it didn’t seem to offer the tools I needed to <em>convert</em> the data to a voxel image. After some internet searching I (re)discovered <a href="https://pypi.org/project/pyvista/">pyvista</a>, which I don’t regularly use, but this is not the first time it has come to rescue so perhaps I should dig into this package deeper in the near future.</p>
<p>Anyway, PyVista offers <em>a lot</em> of tools for converting spatial data between formats. In fact, the challenge was to determine which of the many tools was best suited to do the job. It was also a bit of a trick to understand the relationship between “point” and “cell” data, which I’ll explain below.</p>
<section id="using-pyvista-to-read-stl-files." class="level2">
<h2 class="anchored" data-anchor-id="using-pyvista-to-read-stl-files.">Using PyVista to <code>read</code> STL files.</h2>
<p>The first step was easy. PyVista has a top-level function for reading <code>STL</code> files, not surprizingly called <code>read()</code>. This function reads the file and creates a <code>mesh</code> object. Conveniently, the <code>mesh</code> object has a <code>plot</code> method for quick confirmation that things worked:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pyvista <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pv</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-3"></span>
<span id="cb1-4">mesh <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pv.read(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'file.stl)</span></span>
<span id="cb1-5"><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">mesh.plot</span>()</span></code></pre></div></div>
<p><img src="https://www.pmeal.com/posts/2025-01-13/plotted_mesh.png" class="img-fluid"></p>
</section>
<section id="voxelizing-the-mesh" class="level2">
<h2 class="anchored" data-anchor-id="voxelizing-the-mesh">Voxelizing the Mesh</h2>
<p>Now comes the hard part. We are trying to create a voxel image, in the form of a 3D Numpy <code>ndarray</code>, where each voxel contains a <code>boolean</code> value indicating whether it lies in the void phase or not. This means that we need to decide if a given point in space lies within the mesh or not, then assign the corresponding <code>boolean</code> value to the corresponding voxel in the <code>ndarray</code>. In terms of the above image, this means determining whether a point lies inside one of the ellipses or not. To do this we first need to define the “points” that will become the voxels in the final image. Then we want to ask PyVista to compute whether each point lies inside the mesh or not. There are two ways to do this.</p>
<section id="using-voxelize_volume" class="level3">
<h3 class="anchored" data-anchor-id="using-voxelize_volume">Using <code>voxelize_volume</code></h3>
<p>The <em>simplest</em> way is to use the appropriately named <code>voxelize_volume</code> function. This requires that we pass in the <code>mesh</code> and also specify the <code>density</code> of the voxelization. The density controls to the number of points that we wish to have in the final image. A lower <code>density</code> means more points, which seems a bit counterintuitive actually. Consider that image resolution is usually given as as a voxel size expressed as <img src="https://latex.codecogs.com/png.latex?m/voxel">, but could just as easily be given as <img src="https://latex.codecogs.com/png.latex?m%5E3/voxel">, which would mean that a smaller number corresponds to higher resolution or more points for a given image. The units of “density” in my experience are usually as “some value per unit volume”, so if we wanted to express image resolution as a density it should be <img src="https://latex.codecogs.com/png.latex?voxels/m%5E3">, in which case a <em>higher</em> value would result in more points. In fact, the reason a lower density gives more points is because this value is actually used as a step-size in Numpy’s <code>arange</code> function, like <code>np.arange(start, step, density)</code>; hence a smaller value of density means more points are generated. Nonetheless, the function is super helpful so I’ll let this issue slide and thank the author(s) for their work. Anyway, this function is used as follows:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1">vox <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pv.voxelize_volume(mesh, density<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>)</span></code></pre></div></div>
<p><code>vox</code> is not actually a voxel image (yet). It’s a new <em>mesh</em> object where the triangulated surfaces visible in the original rendering have been replaced with cubic elements. Note that this process is quite slow. It took over an hour on my (admittedly antiquated) workstation to generate a voxel image of size ~400-cubed. Luckily, this process only needs to be done once for each mesh, so waiting overnight for a batch to run is not really too painful.</p>
<p>The voxelized mesh can be visualized easily as well:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">slices <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> vox.slice_orthogonal()</span>
<span id="cb3-2">slices.plot(scalars<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'InsideMesh'</span>)</span></code></pre></div></div>
<p>Which yields the following, where the voxelized nature of the surfaces can seen:</p>
<p><img src="https://www.pmeal.com/posts/2025-01-13/voxelized.png" class="img-fluid"></p>
<p>The final step is converting this <code>vox</code> mesh object into a Numpy array. The voxelization process not only generates a cubic mesh, but it also determine which voxel represents solid or not. This information is stored on the <code>vox</code> dictionary object under the key <code>'InsideMesh'</code>, as a vector containing <code>1</code> for voxels inside the ellipsoids, and <code>0</code> outside. Converting this vector into a cubic image was the last hurdle. I needed to <code>reshape</code> it from a linear vector into 3D array, but first I needed to determine what shape to use.</p>
<p>Although the the <code>'InsideMesh'</code> array contains one value for each voxel, the <code>vox</code> mesh itself has coordinates for the <em>corners</em> of each voxel. One can thus determine the number of cells by looking at the number of number of corners defined in the mesh (i.e.&nbsp;looking at the shape of <code>vox.x</code>, <code>vox.y</code> or <code>vox.z</code>), <em>then</em> subtracting 1 from each axis, to not count the extra layer of points at the <em>end</em> of each axis. Also, I learned that it is necessary to specify the Fortran ordering of the data using the <code>order='F'</code> option when reshaping:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.reshape(</span>
<span id="cb4-2">    vox[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'InsideMesh'</span>], </span>
<span id="cb4-3">    np.array(vox.meshgrid[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>].shape)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, </span>
<span id="cb4-4">    order<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'F'</span>,</span>
<span id="cb4-5">)</span></code></pre></div></div>
<p>The result is a standard voxel image in the form of a Numpy <code>ndarray</code>, perfectly suited for simulations.</p>
<p><img src="https://www.pmeal.com/posts/2025-01-13/ndarray.png" class="img-fluid"></p>
<p>Given how long the <code>voxelize_volume()</code> function requires, it is probably a good idea to save the array for future use:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">np.save(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'stl_as_ndarray'</span>, im)</span></code></pre></div></div>
</section>
<section id="using-select_enclosed_points" class="level3">
<h3 class="anchored" data-anchor-id="using-select_enclosed_points">Using <code>select_enclosed_points</code></h3>
<p>Although the above method worked great for me, the slowness inspired me to investigate whether an alternative approach might be faster. A bit more searching led to the <a href="https://github.com/pyvista/pyvista/discussions/5652">following solution</a>, suggested by Github user <a href="https://github.com/dveni"><span class="citation" data-cites="dveni">@dveni</span></a>:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="annotated-cell-6" style="background: #f1f3f5;"><pre class="sourceCode python code-annotation-code code-with-copy code-annotated"><code class="sourceCode python"><span id="annotated-cell-6-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> stl_to_array(mesh: pv.PolyData, density: <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">float</span>):</span>
<span id="annotated-cell-6-2">    x_min, x_max, y_min, y_max, z_min, z_max <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mesh.bounds</span>
<span id="annotated-cell-6-3">    x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.arange(x_min, x_max, density)</span>
<span id="annotated-cell-6-4">    y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.arange(y_min, y_max, density)</span>
<span id="annotated-cell-6-5">    z <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.arange(z_min, z_max, density)</span>
<span id="annotated-cell-6-6">    x, y, z <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.meshgrid(x, y, z)</span>
<span id="annotated-cell-6-7"></span>
<span id="annotated-cell-6-8">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create unstructured grid from the structured grid</span></span>
<span id="annotated-cell-6-9">    grid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pv.StructuredGrid(x, y, z)</span>
<span id="annotated-cell-6-10">    ugrid <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pv.UnstructuredGrid(grid)</span>
<span id="annotated-cell-6-11"></span>
<span id="annotated-cell-6-12">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get part of the mesh within the mesh's bounding surface.</span></span>
<span id="annotated-cell-6-13">    selection <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ugrid.select_enclosed_points(</span>
<span id="annotated-cell-6-14">        mesh.extract_surface(),</span>
<span id="annotated-cell-6-15">        tolerance<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0</span>,</span>
<span id="annotated-cell-6-16">        check_surface<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>,</span>
<span id="annotated-cell-6-17">    )</span>
<span id="annotated-cell-6-18">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> selection[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'SelectedPoints'</span>].view(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">bool</span>)</span>
<a class="code-annotation-anchor" data-target-cell="annotated-cell-6" data-target-annotation="1" onclick="event.preventDefault();">1</a><span id="annotated-cell-6-19" class="code-annotation-target">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mask.reshape(x.shape, order<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'F'</span>)</span>
<span id="annotated-cell-6-20">    mask <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.array(mask)</span>
<span id="annotated-cell-6-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> mask</span><div class="code-annotation-gutter-bg"></div><div class="code-annotation-gutter"></div></code></pre></div></div>
<dl class="code-annotation-container-grid">
<dt data-target-cell="annotated-cell-6" data-target-annotation="1">1</dt>
<dd>
<span data-code-cell="annotated-cell-6" data-code-lines="19" data-code-annotation="1">Note that the here <code>x</code> is coming from <code>meshgrid</code>, but it was used to compute the <em>cell centers</em> so there is no need to subtract 1, unlike the <code>meshgrid</code> attribute of the <code>vox</code> mesh returned by <code>voxelize_volume</code> which defines the <em>cell corners</em>.</span>
</dd>
</dl>
<p>This function is clearly less convenient than just using <code>voxelize_volume</code>, but I thought it might be faster because it uses a different method for finding whether a point is inside the mesh or not. Specifically it uses the <code>select_enclosed_points()</code> method of the <code>UnstructuredGrid</code> class. I was hoping that this might be faster since it searches for points without also creating a voxelized mesh object. I did an informal comparison of both methods and found them to require about equal times, so I will probably use the <code>voxelize_volume()</code> function in future since it’s easier to remember, and it is probably helpful to have the mesh object handy for future use.</p>
</section>
</section>
<section id="comparing-the-outputs-of-the-two-methods" class="level2">
<h2 class="anchored" data-anchor-id="comparing-the-outputs-of-the-two-methods">Comparing the Outputs of the Two Methods</h2>
<p>I did notice however, that the two methods produce a different result. The <code>voxelize_volume()</code> function seems to produce an image with more solid voxels, resulting in a structure that is a over packed:</p>
<p><img src="https://www.pmeal.com/posts/2025-01-13/method_comparison.png" class="img-fluid"></p>
<p>I am guessing that each of these methods uses a different behavior for identifying voxels laying on the boundary, perhaps it’s the difference between using <code>&lt;</code> instead of a <code>&lt;=</code>.</p>
<p>In any event, the <code>select_enclosed_points</code> method seems preferable since the particles are much better defined. It is possible to dilate the particles to get something similar to the <code>voxelize_volume</code> result, while eroding the particles from <code>voxelize_volume</code> will not give the clear separation of the <code>select_enclosed_points</code> method.</p>
</section>
<section id="conclusions" class="level2">
<h2 class="anchored" data-anchor-id="conclusions">Conclusions</h2>
<p>Despite the much cleaner implementation of the <code>voxel_volume</code> method, I think I will be using the <code>select_enclosed_points</code> method since it gives better results. The speed (or lack thereof) of the two methods is about equal, so there is nothing to chose there. The only downside of the <code>select_enclosed_points</code> method is that it does not create a rectilinear mesh object, which may or may not be useful for some uses. Perhaps the <code>stl_to_array</code> function should be added to the <code>io</code> module of <a href="https://porespy.org">PoreSpy</a>, then the ugliness of the implementation will be hidden from sight.</p>


</section>
</section>

 ]]></description>
  <category>news</category>
  <category>tips</category>
  <guid>https://www.pmeal.com/posts/2025-01-13/</guid>
  <pubDate>Mon, 13 Jan 2025 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2025-01-13/plotted_mesh.png" medium="image" type="image/png" height="108" width="144"/>
</item>
<item>
  <title>Introducing QBIP: a new image-based fluid invasion algorithm including gravity and built for speed</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2024-06-06/</link>
  <description><![CDATA[ 






<p>Today we pushed our preprint to the <a href="https://arxiv.org/abs/2406.02895">Ar<img src="https://latex.codecogs.com/png.latex?%5Cchi">iv</a>, so we can show off our great new “Queue-Based Invasion Percolation” algorithm (QBIP) while we wait for the peer review process to run its course.</p>
<p>To appreciate this new algorithm requires some backstory: In 2022 we published a paper in <a href="https://doi.org/10.1029/2021WR031509">Water Resources Research</a> describing a modified version of the classic <a href="https://doi.org/10.1007/BF00616924">Morphological Image Opening</a> approach that included the effect of gravity on the fluid. Around the same time we published a paper in <a href="https://doi.org/10.1016/j.cageo.2021.104978">Computers and the Geosciences</a> where we used image-based tools to simulate the volume controlled invasion of a non-wetting fluid. This algorithm differed from the the traditional Image Morphology approaches because it followed a volume-controlled rather than a pressure controlled invasion. The allowed it to simulate entire invasion path rather than just providing the stable fluid configuration at discrete pressures. The animation below illustrates the output of the volume-controlled approach:</p>
<p><img src="https://www.pmeal.com/posts/2024-06-06/image_based_ip.gif" class="img-fluid"></p>
<p>Now getting to the exciting part of this announcement: we have now combined the above to algorithms to provide an volume-controlled invasion <em>with the effect of gravity</em>. The result is something like this:</p>
<p><img src="https://www.pmeal.com/posts/2024-06-06/image_based_ip_w_gravity.gif" class="img-fluid"></p>
<p>In the above animation you can see that the invading fluid is being impacted by gravity, resulting in a flatter invasion front. Instead of invading a large throat at a high elevation in the image, the fluid prefers to invade a smaller opening near the bottom because it does not have to overcome the effect of gravity.</p>
<p>Another <em>very</em> nice feature of the QBIP algorithm is that it is at leat 10X faster than the original IBIP. We were able to achieve this by using a priorty queue to keep track of which voxel to invade next rather than searching for it on each step. So not only does the new QBIP algorithm yield fluid invasion paths under the influence of gravity (or not), but it can also do this in a <em>much</em> more reasonable time.</p>
<p><img src="https://www.pmeal.com/posts/2024-06-06/timing.png" class="img-fluid"></p>
<p>This work was a collaboration between the <a href="https://www.pmeal.com">PMEAL</a> group at the University of Waterloo, and the group of Robin Zhao at McMaster University. Robin and his team provided the experimental micromodel data which was used to validate the model. It was great to work with them and given how close they are, I’m sure we’ll be doing more collaboration soon.</p>
<p>Anyway, we hope you find this new algorithm useful.</p>



 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2024-06-06/</guid>
  <pubDate>Wed, 05 Jun 2024 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2024-06-06/cover.png" medium="image" type="image/png" height="119" width="144"/>
</item>
<item>
  <title>4-Phase Pore Network Model of a Fuel Cell Catalyst Layer</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2023-10-11/</link>
  <description><![CDATA[ 






<section id="creating-a-detailed-pore-scale-model-of-the-pemfc-catalyst-layer-using-openpnm-and-porespy" class="level1">
<h1>Creating a Detailed Pore-Scale Model of the PEMFC Catalyst layer using OpenPNM and PoreSpy</h1>
<p>A few days ago our lastest paper went “live” in <a href="https://doi.org/10.1016/j.apenergy.2023.122004">Applied Energy</a>. I don’t normally post announcements about this sort of thing, but this case is noteworthy. Firstly, it’s a really great paper, with contributions from more collaborators than usual. Shawn Litster’s group at CMU provided volumetric images. Researchers from the fuel cell research team at GM provided the experimental performance and degradation data. Dave Muller’s group from Cornell measured the Pt distribution in the catalyst layer. So lots of brain power was behind this work…but that is not the part I want to brag about. This paper represents the culmination of all the work conducted in the PMEAL lab over the last 5 years, and I wanted to take a moment to summarize just how many developments were required to get here.</p>
<section id="multiphase-network-extraction" class="level2">
<h2 class="anchored" data-anchor-id="multiphase-network-extraction">Multiphase Network Extraction</h2>
<p>The ability to reliably extract pore networks from images has always been a challenge. Martin Blunt has been generous with sharing of his group’s MaximalBall code since he published it in 2010, but this code was not exactly user friendly. In 2017 I moved from McGill to UWaterloo and had a few semesters in a row with no teaching. This turned out to be the perfect opportunity to work on our own network extraction code, which we called SNOW (since catchy acronyms are always a good idea!). Having our own extraction code, written in python, and frankly quite simple, was a huge boost for us since we could customize and optimize it at will. We leveraged this ability to make several important extensions to the code.</p>
<p><img src="https://www.pmeal.com/_static/images/figure_1f.png" class="img-fluid"></p>
<p>At some point we realized that not only could the network extraction be applied to <a href="https://dx.doi.org/10.1149/1945-7111/ab7bd8">both the solid and void phases</a>, but also that we could connect these two networks to allow exchange of material between the phases. This was the subject of a paper in <a href="https://doi.org/10.1016/j.compchemeng.2018.12.025">Computers in Chemical Engineering</a>, and utilized for <a href="https://doi.org/10.1149/1945-7111/ac120c">modeling Li-ion battery discharge</a>. Interconnected, multiphase network extraction is essential for ‘multiphysics’ modeling in PNMs.</p>
<p><img src="https://www.pmeal.com/_static/images/2_phase_extraction_4.png" class="img-fluid"></p>
</section>
<section id="parallelized-network-extraction" class="level2">
<h2 class="anchored" data-anchor-id="parallelized-network-extraction">Parallelized Network Extraction</h2>
<p>The watershed filter is the main step in the SNOW algorithm, but it can be annoyingly slow on large images. <a href="https://doi.org/10.1016/j.advwatres.2020.103734">In 2020</a> we found that this filter could be applied to an image in chunks and then pieced back together to nearly perfect results, if a sufficent amount of overlap was used between the chunks. The ability to process many chunks in parallel is obviously quite handy when dealing with massive images, assuming you have a PC with lots of cores and enough RAM.</p>
<p><img src="https://www.pmeal.com/_static/images/parallel_snow.png" class="img-fluid"></p>
</section>
<section id="phase-network-extraction-of-a-2nmvoxel-pfib-sem-image" class="level2">
<h2 class="anchored" data-anchor-id="phase-network-extraction-of-a-2nmvoxel-pfib-sem-image">4-Phase Network Extraction of a 2nm/voxel pFIB-SEM Image</h2>
<p>The above progress in network extraction allowed us to build “the ultimate” pore network model of a fuel cell catalyst layer. These layers consist of FOUR phases: void, ionomer, carbon and platinum. Gas diffusion in the void space and dissolves into the ionomer phase. Ions travel through the ionomer phase and meet dissolved gas at the catalyst sites. Electrons travel through the carbon backbone to the reaction sites as well. The transport of all these species is directly coupled to the microscopic structure of each phase so this problem is a great candidate for PNMs.</p>
<p>We started applying our multiphase network extraction tool to artificially generated images, and gave a talk about this at an ECS meeting. Shawn Litster was in the audience and mentioned that he had REAL images of catalyst layers obtained with FIB-SEM at 2nm voxel resolution (in all three directions!). So we switched to working on these images. This required some experimenting with ways to insert carbon spheres and Pt sites into the image, but eventually we had a viable image. The problem was that even with such excellent resolution, the network extraction tool had trouble with the smaller features…so we had to magnify the image by 4x.</p>
<p>So we had 4 phase image that was already quite large (1600 voxels cubed) that was zoomed up by another factor of 4, and we needed to perform multiphase network extraction on it. This felt like all the hard work over the past 5+ years was leading to this moment. The results speak form themselves:</p>
<p><img src="https://www.pmeal.com/_static/images/tomography-4phase-all-net2.png" class="img-fluid"></p>
</section>
<section id="multiphysics-simulation-of-pemfc-polarization-curves" class="level2">
<h2 class="anchored" data-anchor-id="multiphysics-simulation-of-pemfc-polarization-curves">Multiphysics Simulation of PEMFC Polarization Curves</h2>
<p>The pictures look great, but the model worked great too. We were able to predict the polarization behavior of the cell at “beginnng of life” (i.e.&nbsp;new) and after accelerated stress tests caused catalyst degradation. The interesting thing about this result is that we were able to capture most of the degradation just by deleting Pt sites from the network, in proportion to the loss of Pt surface area. There must be a few other mechanisms occuring too, but considering only this single, simple thing was enough to largely describe the trends.</p>
<p><img src="https://www.pmeal.com/_static/images/degradation_skewedPtLoss.png" class="img-fluid"></p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>So big congratulations to Amin Sadeghi, who was my PhD student then postdoctoral associate during the years the above work was being done. Also thanks to all the collaborators and contributors to this project.</p>


</section>
</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2023-10-11/</guid>
  <pubDate>Wed, 11 Oct 2023 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/_static/images/tomography-4phase-all-net2.png" medium="image" type="image/png" height="81" width="144"/>
</item>
<item>
  <title>Congratulations to Niloo for successfully defending her PhD!</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2022-12-24/</link>
  <description><![CDATA[ 






<section id="congratulations-to-niloo-for-successfully-defending-her-phd" class="level1">
<h1>Congratulations to Niloo for successfully defending her PhD!</h1>
<p>Niloofar Misaghian joined the PMEAL group in the fall of 2018, and after 4 years of intense learning and research she successfully defended her thesis on December 9th. It was a slam-dunk, with 3 first-author papers, plus authorship on another. Not to mention many contributions to the OpenPNM and PoreSpy code bases. Thanks for all your hard work Niloo!</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2022-12-24/</guid>
  <pubDate>Sat, 24 Dec 2022 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2022-12-24/cover.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>What’s New in OpenPNM V3</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2022-10-10/</link>
  <description><![CDATA[ 






<section id="whats-new-in-openpnm-v3" class="level1">
<h1>What’s New in OpenPNM V3</h1>
<p>It’s been a long process, much longer than we would’ve liked, but OpenPNM Version 3.0 is finally here. Version 2.0 was released in August 2018, and version 2.8.2, the last of the V2 series, was released in September 2021. This 3 year stretch saw a lot growth in the OpenPNM userbase, which if we use the Github star count as a proxy, showed a 300% increase over the period!</p>
<p><img src="https://www.pmeal.com/_static/images/openpnm-star-history-20221010.png" class="img-fluid"></p>
<p>A lot has happened over these four years, and it’s been quite a blur so it’s hard to remember which milestones to highlight. One major event or theme was the PMEAL group receiving funding from CANARIE to support the growth of OpenPNM (and PoreSpy). This funding allowed for the hiring of many highly talented students who really took OpenPNM to the next level.</p>
<section id="overview-of-the-biggest-change" class="level2">
<h2 class="anchored" data-anchor-id="overview-of-the-biggest-change">Overview of the Biggest Change</h2>
<p>There have been a LOT of useful and powerful additions to V3, but perhaps the biggest change is what’s missing:</p>
<blockquote class="blockquote">
<p>V3 has removed the concept of <code>Geometry</code> and <code>Physics</code> objects. This “workflow” was invented on the whiteboard during our initial planning sessions for V1 in 2011, and looked sensible at the time, but over the past 10+ years it became clear that this created a lot of confusion for users and a friction for the developers.</p>
</blockquote>
<p>For comparison let’s look at how this changes the scripts. In version 2 you’d initialize 4 objects:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb1-1"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{python}</span></span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> openpnm <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> op</span>
<span id="cb1-3">pn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.network.Cubic(shape<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>], spacing<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-5</span>)</span>
<span id="cb1-4">geo <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.network.SphersAndCylinders(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.Ps, throats<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.Ts)</span>
<span id="cb1-5">air <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.phases.Air(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn)</span>
<span id="cb1-6">phys <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.physics.Standard(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, geometry<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>geo, phase<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>air)</span>
<span id="cb1-7"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span></code></pre></div></div>
<p>While in version 3 the same result is obtained as follows:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb2-1"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{python}</span></span>
<span id="cb2-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> openpnm <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> op</span>
<span id="cb2-3">pn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.network.Cubic(shape<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>], spacing<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-5</span>)</span>
<span id="cb2-4">pn.add_model_collection(op.models.collections.geometry.spheres_and_cylinders)</span>
<span id="cb2-5">air <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.phase.Air(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn)</span>
<span id="cb2-6">air.add_model_collection(op.models.collections.physics.standard)</span>
<span id="cb2-7"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span></code></pre></div></div>
<p>This difference results in several important changes:</p>
<hr>
<p><strong>Back End Simplicity:</strong> The ‘back-end’ code complexity was <em>massively</em> reduced, which will make it far easier to maintain OpenPNM moving forward. There was quite a lot of <em>machinery</em> dedicated to tracking which pores and throats were assigned to <code>geo</code>, and that <code>phys</code> was associated with <code>geo</code>. For instance, in cases where multiple domains were used, such as <code>geo1</code> and <code>geo2</code> a lot of checks were done behind the scenes to ensure they did not conflict with each other and that all pores and throats were accounted for. There was also functionality required for ‘redefining’ which pores and throats they were applied to, and so on. Easily thousands of lines of code were deleted by this change.</p>
<hr>
<p><strong>Fewer Objects to Think About:</strong> Speaking of multiple domains, most users probably did not use this capability, but for those who did, this change will result in a much simpler experience. In most cases the effects of multiple domains are only relevant to geometries, so one might specify <code>geo1</code> and <code>geo2</code> each with different pore size distributions, but probably the same physics applied to each domain. In the old approach, you had to create a unique <code>Physics</code> object associated with each subdomain, but now you can just add a single set of physics models to a phase and they can apply everywhere.</p>
<hr>
<p><strong>Emphasizes Pore-Scale Models:</strong> Although we’ve attempted to make this new approach as smooth as possible, there is no such thing as a free lunch, and the user must still invest some effort in defining which models to assign (and where). We have created <em>collections</em> to facilitate this process, which are demonstrated above. In V2 when you initialized a <code>StickAndBall</code> object it added all the models as part of the initialization. In V3 you create a network, <em>then</em> add all the models yourself, which is where the <code>collections</code> come in handy. A positive take of this new approach is that users are now forced interact with pore-scale models, which are the foundation of OpenPNM’s calculations, so hopefully this encourage them to write and use their own models.</p>
<hr>
<p><strong>Easy Multidomain Control:</strong> We have created a new way defining multiple domains, or more to the point, we created a way to assign different pore-scale models to specific pores. In the <code>pn.models</code> dictionary you will find all the models defined on the network, but now each model name also includes the domain where it applies, so instead of <code>'pore.diameter'</code>, it’s <code>'pore.diameter@&lt;xyz&gt;'</code>, where <code>@</code> is a delimiter and <code>&lt;xyz&gt;</code> is the name of a label on the network. The default is <code>'@all'</code>, meaning the model applies everywhere. To create two domains with different pore sizes you now define different models such as <code>pn.models['pore.diameter@domain1']</code> and <code>pn.models['pore.diameter@domain2']</code>. Conveniently, you don’t need to specify different models for <em>other</em> properties like <code>'pore.volume'</code> (unless you want to).</p>
<p>The best way to illustrate this change is by example. The code snippets below will create a domain with 2 different pore sizes, but all other models the same. It will then <em>change</em> the domains so that different pores are assigned to each domain.</p>
<div class="cell" data-execution_count="1">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> openpnm <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> op</span>
<span id="cb3-2">pn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.network.Cubic(shape<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], spacing<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span>)</span>
<span id="cb3-3">Ps1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> pn.coords[:, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb3-4">pn.set_label(label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain1'</span>, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>Ps1)</span>
<span id="cb3-5">pn.set_label(label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain2'</span>, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=~</span>Ps1)</span>
<span id="cb3-6">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.visualization.plot_coordinates(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.pores(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain1'</span>), c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'r'</span>, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb3-7">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.visualization.plot_coordinates(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.pores(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain2'</span>), c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'b'</span>, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, ax<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ax)</span>
<span id="cb3-8">op.visualization.plot_connections(pn, c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, ax<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ax)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-10-10/index_files/figure-html/cell-2-output-1.png" width="661" height="468" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Now let’s retrieve the <code>stick_and_ball</code> geometry model collection, create a copy, alter the pore sizes on them, then assign each to different pores:</p>
<div class="cell" data-execution_count="2">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">mods1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.models.collections.geometry.spheres_and_cylinders</span>
<span id="cb4-2">mods2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mods1.copy()</span>
<span id="cb4-3">pn.add_model_collection(mods1, domain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain1'</span>)</span>
<span id="cb4-4">pn.add_model_collection(mods2, domain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain2'</span>)</span></code></pre></div></div>
</div>
<p>Let’s replace the model used for computing the pore diameter with a random number between some limits, which we’ll use to create a layer of small and large pores.</p>
<div class="cell" data-execution_count="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">pn.add_model(propname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pore.diameter'</span>, </span>
<span id="cb5-2">             model<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>op.models.geometry.pore_size.random,</span>
<span id="cb5-3">             num_range<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>],</span>
<span id="cb5-4">             domain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain1'</span>)</span>
<span id="cb5-5">pn.add_model(propname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pore.diameter'</span>, </span>
<span id="cb5-6">             model<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>op.models.geometry.pore_size.random,</span>
<span id="cb5-7">             num_range<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>],</span>
<span id="cb5-8">             domain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain2'</span>)</span>
<span id="cb5-9">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.visualization.plot_coordinates(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, size_by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pore.diameter'</span>], edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>)</span>
<span id="cb5-10">op.visualization.plot_connections(pn, c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, ax<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ax)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-10-10/index_files/figure-html/cell-4-output-1.png" width="661" height="468" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>This new approach may take some getting used to, but hopefully it has enough upsides to make it worth it. We don’t dive into all of these here, but let’s just look at one feature which will hopefully make it clear why this new approach simplifies the back-end. Lets change which pores belong to <code>domain1</code> and <code>domain2</code> just by adjusting the labels. In the previous version this required calls to the <code>set_locations</code> methods of all the geometry objects. In V3 we just need to change some pore labels and regenerate the models:</p>
<div class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">pn.set_label(label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain1'</span>, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.coords[:, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'overwrite'</span>)</span>
<span id="cb6-2">pn.set_label(label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'domain2'</span>, pores<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn.coords[:, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'overwrite'</span>)</span>
<span id="cb6-3">pn.regenerate_models()</span>
<span id="cb6-4">ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> op.visualization.plot_coordinates(network<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn, s<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, size_by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pn[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pore.diameter'</span>], edgecolor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>)</span>
<span id="cb6-5">op.visualization.plot_connections(pn, c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'k'</span>, ax<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ax)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">[14:25:08] </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.max_size was not run since the following property is missing:             <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.domain1'</span>                                                                 <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.diameter was not run since the following property is missing:             <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.max_size'</span>                                                                <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.cross_sectional_area was not run since the following property is missing: <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.diameter'</span>                                                                <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.hydraulic_size_factors was not run since the following property is        <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         missing: <span style="color: #008000; text-decoration-color: #008000">'throat.domain1'</span>                                                        <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.diffusive_size_factors was not run since the following property is        <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         missing: <span style="color: #008000; text-decoration-color: #008000">'throat.domain1'</span>                                                        <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.lens_volume was not run since the following property is missing:          <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.diameter'</span>                                                                <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.length was not run since the following property is missing:               <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.domain1'</span>                                                                 <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.total_volume was not run since the following property is missing:         <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.length'</span>                                                                  <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span><span style="color: #800000; text-decoration-color: #800000">WARNING </span> throat.volume was not run since the following property is missing:               <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">_models.py:480</span>
<span style="color: #7fbfbf; text-decoration-color: #7fbfbf">           </span>         <span style="color: #008000; text-decoration-color: #008000">'throat.total_volume'</span>                                                            <span style="color: #7f7f7f; text-decoration-color: #7f7f7f">              </span>
</pre>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-10-10/index_files/figure-html/cell-5-output-10.png" width="661" height="468" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The key here, from a back-end perspective is that OpenPNM did literally nothing behind the scenes. Only the labels were changed by the user, and OpenPNM just adapted.</p>
</section>
<section id="other-important-changes" class="level2">
<h2 class="anchored" data-anchor-id="other-important-changes">Other Important Changes</h2>
<p>There have been a handful of other <em>breaking</em> changes including:</p>
<ul>
<li>Renamed of the <code>phases</code> module to <code>phase</code>. This was purely cosmetic so that all modules have consistant pluralization.</li>
<li>Removed the term “Generic” from the numerous class names to avoid overly complicating things. Instead of instantiating a <code>GenericPhase</code> it is now just <code>Phase</code>.</li>
<li>Moved of the plotting tools to a new <code>visualization</code> module. Previously they were in <code>topotools</code> which was not really obvious.</li>
<li>Overhaul of the <code>io</code> module to be a collection of clearly named functions like <code>network_from_statoil</code> rather than categorized functions like <code>statoil.load</code>. This is more consistant with other packages like <code>pandas</code> which offer functions like <code>from_csv</code>.</li>
<li>The Bravais network generator has been removed in favor of specificly named classes like <code>FaceCenteredCubic</code> and <code>BodyCenteredCubic</code>.</li>
<li>A lot of minor functions and features were removed. This was done in the spirit of keeping the code base small and manageble, which we’d grown to realize was a very important design consideration.</li>
<li>Subdictionaries now work as expected, so that <code>pn['pore.conduit_length']['pore1']</code> works the same as <code>pn['pore.conduit_length.pore1']</code>. We also updated many of the models to return Nt-by-3 arrays of conduit properties rather than a dictionary.</li>
<li>Migrated to a new documentation engine and website generator, which creates very beautiful example pages from jupyter notebooks, making it super easy to write a high quality and detailed tutorial for the website. This paved the way for the next few items…</li>
<li>Removed the <code>metrics</code> module, in favor of creating detailed examples on the website. We created these metrics as a way to make OpenPNM <em>even easier</em> to use, but they only obscurred from the user what were relatively simple calculations.</li>
<li>Removed the <code>materials</code> module, which will also be replaced by detailed examples on the website.</li>
</ul>
</section>
<section id="exciting-additions" class="level2">
<h2 class="anchored" data-anchor-id="exciting-additions">Exciting Additions</h2>
<ul>
<li>Transient solvers have been extended substantially. In V2 we’d implemented the basic Implicit and Crank-Nicolson methods, while in V3 we leverage the <code>scipy.integrate.ivp_solve</code> library to access their high-order explicit solvers. In V3.0 we have created wrappers for RK45, but more are planned. These wrappers are in the new <code>integrators</code> module.</li>
<li>Redesigned the numerical solver framework. We added a new module called <code>solvers</code> containing classes which define how to wrap any arbitrary numerical solver library. At present we have wrappers for <code>pypardiso</code> and <code>scipy.linalg.spsolve</code>, but more are planned.</li>
<li>A framework for estimating physical properties of mixtures. The property calculations are based on the <code>chemicals</code> package and provides a first approximation for computing properties that are functions on composition which may change during a simulation.</li>
<li>Complete rewrite of the ordinary percolation algorithm, now called <code>Drainage</code>.</li>
<li>Definition of <em>pore size factors</em> which contain all the information about the shape of pores and throats. This means that computing of diffusive flow through an element is done as <img src="https://latex.codecogs.com/png.latex?N_A%20=%20D_%7BAB%7D%20%5Ccdot%20f_%7Bsize%7D%20%5CDelta%20C_A"> where the length and area of the element are embedded in <img src="https://latex.codecogs.com/png.latex?f_%7Bsize%7D"> which includes a rigorous analyztical description of the changing cross-sectional shape.</li>
</ul>
</section>
<section id="full-changelog-on-github" class="level2">
<h2 class="anchored" data-anchor-id="full-changelog-on-github">Full Changelog on Github</h2>
<p>During this past 3 years we’ve also migrated all of our continuous integration testing and release process to Github Actions. One of the great side effects of this that we can now generate very detailed changelogs from the commit messages for each merge onto the <code>dev</code> branch. The full change can be <a href="https://github.com/PMEAL/OpenPNM/releases">viewed here</a>.</p>


</section>
</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2022-10-10/</guid>
  <pubDate>Mon, 10 Oct 2022 00:00:00 GMT</pubDate>
</item>
<item>
  <title>PMEAL Members Represent Strong at CRSC 2022</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2022-06-03/</link>
  <description><![CDATA[ 






<section id="pmeal-members-represent-strong-at-crsc-2022" class="level1">
<h1>PMEAL Members Represent Strong at CRSC 2022</h1>
<p>The 4th annual <a href="https://www.canarie.ca/event/crsc-2022/">Canadian Research Software Conference</a> was held earlier this week. Several members of the PMEAL group were present, and for the 4th straight year we won a top poster award! Congratulations to Niloo for her hard work and enthralling the audience with her work on the use of AI to predict diffusive conductance for use in extracted pore networks. This poster was based on her recently published paper <a href="https://doi.org/10.1016/j.cageo.2022.105086">Computers and Geosciences</a>. Also, a nod to Amin who presented a 20 minute short talk on the use of Julia to speed up numerical computations. This talk led to many follow-up conversations during the coffee breaks, and was really very convincing. Maybe OpenPNM V4 will be in Julia?</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2022-06-03/</guid>
  <pubDate>Fri, 03 Jun 2022 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2022-06-03/cover_image.png" medium="image" type="image/png" height="68" width="144"/>
</item>
<item>
  <title>Adding Gravity to Image Based Drainage Simulations</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2022-02-09/</link>
  <description><![CDATA[ 






<section id="adding-gravity-to-image-based-drainage-simulations" class="level1">
<h1>Adding Gravity to Image Based Drainage Simulations</h1>
<p>The PMEAL team recently developed a way to add gravitational effects to the standard drainage simulation algorithm based on sphere insertion, also sometimes called <em>morphological image opening</em> or <em>full morphology</em>. The paper is available in Water Resources Research. This post will give a brief overview of how to use this new algorithm, which is being included in a new function called <code>drainage</code> located in the also newly added <code>porespy.simulations</code> module. The new <code>drainage</code> function can produce results with or without gravity effects, creating a more powerful yet flexible function for performing such simulations.</p>
<div class="cell" data-execution_count="1">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> porespy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> ps</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> edt <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> edt</span></code></pre></div></div>
</div>
<p>Start by generating a 2D image of blobs:</p>
<div class="cell" data-execution_count="2">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1">im <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ps.generators.blobs([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>], porosity<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, blobiness<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>)</span>
<span id="cb2-2">ps.imshow(im)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-3-output-1.png" width="424" height="411" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>First we’ll compute a reference capillary pressure curve with no gravity effects using the new <code>drainage</code> function. This function requires us to supply an image of capillary pressure values associated with each voxel. Typicall one would use the Washburn equation:</p>
<p><img src="https://latex.codecogs.com/png.latex?%20P_C%20=%20-2%5Csigma%20%5Ccos%20(%5Ctheta)%20%5Cbigg(%5Cfrac%7B1%7D%7Br%7D%5Cbigg)%20"></p>
<p>where <code>r</code> is conveniently provided by the distance transfer. This can be computed as follows:</p>
<div class="cell" data-execution_count="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1">voxel_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-4</span></span>
<span id="cb3-2">dt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> edt(im)</span>
<span id="cb3-3">pc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.072</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>np.cos(np.deg2rad(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">180</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>(dt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>voxel_size)</span></code></pre></div></div>
</div>
<p>The reason for requiring <code>pc</code> instead of just the boolean <code>im</code> is to allow users to compute the capillary pressure using any method they wish. For instance a 2D image of a glass micromodel has a spacing between the plates which can be accounted for as:</p>
<p><img src="https://latex.codecogs.com/png.latex?%20P_C%20=%20-%5Csigma%20%5Ccos%20(%5Ctheta)%20%5Cbigg(%5Cfrac%7B1%7D%7Br%7D%20+%20%5Cfrac%7B1%7D%7Bs%7D%5Cbigg)%20"></p>
<p>Note that <code>s</code> could be set to <code>np.inf</code> for a 2D simulation. Computing <code>pc</code> externally also reduces the number of arguments that must be sent to the function, by eliminating the surface tension and contact angles.</p>
<p>In any event, the function is called as follows:</p>
<div class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1">inlets <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.zeros_like(im)</span>
<span id="cb4-2">inlets[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, ...] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb4-3">drn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ps.simulations.drainage(pc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pc, im<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>im, inlets<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>inlets, voxel_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>voxel_size, g<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb4-4">ps.imshow(np.log10(drn.im_pc))</span>
<span id="cb4-5">cbar <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.colorbar()</span>
<span id="cb4-6">cbar.set_label(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'log10(Pc)'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"82274c12210d4076bca3ebdbea6d79c0","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"9afdf39a0c2b4175b643e8e3aff34136","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-5-output-3.png" width="517" height="411" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The above image is colored according to the capillary pressure at which a given voxel was invaded. Note that we have applied a base-10 logarithm to the values to improve visibility. This format is handy since it contains the entire invasion sequence in a single image. Next let’s plot the capillary pressure curve. There are some functions available in <code>porespy.metrics</code> for this, but the <code>drainage</code> function actually does it for us and attaches the result to the returned object:</p>
<div class="cell" data-execution_count="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">plt.semilogx(drn.pc, drn.snwp, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'b-o'</span>)</span>
<span id="cb5-2">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Capillary Pressure [Pa]'</span>)</span>
<span id="cb5-3">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Non-wetting Phase Saturation'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-6-output-1.png" width="589" height="431" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Now let’s perform the same experiment but including the gravity effects:</p>
<div class="cell" data-execution_count="6">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1">drn2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ps.simulations.drainage(pc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pc, im<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>im, inlets<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>inlets, voxel_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>voxel_size, g<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.81</span>)</span>
<span id="cb6-2">ps.imshow(np.log10(drn2.im_pc))</span>
<span id="cb6-3">cbar <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.colorbar()</span>
<span id="cb6-4">cbar.set_label(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'log10(Pc)'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"88071540125d49bab9665e111451c850","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<script type="application/vnd.jupyter.widget-view+json">
{"model_id":"34293c70aa51473f8bbd263e30a22fac","version_major":2,"version_minor":0,"quarto_mimetype":"application/vnd.jupyter.widget-view+json"}
</script>
</div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-7-output-3.png" width="517" height="411" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>We can see from the colormap that the invasion pattern is different. Plotting the capillary pressure curve will make the differences more obvious:</p>
<div class="cell" data-execution_count="7">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1">plt.semilogx(drn2.pc, drn2.snwp, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'r-o'</span>)</span>
<span id="cb7-2">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Capillary Pressure [Pa]'</span>)</span>
<span id="cb7-3">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Non-wetting Phase Saturation'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-8-output-1.png" width="589" height="431" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Combining both plots together for a better comparison:</p>
<div class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1">plt.semilogx(drn.pc, drn.snwp, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'b-o'</span>)</span>
<span id="cb8-2">plt.semilogx(drn2.pc, drn2.snwp, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'r-o'</span>)</span>
<span id="cb8-3">plt.xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Capillary Pressure [Pa]'</span>)</span>
<span id="cb8-4">plt.ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Non-wetting Phase Saturation'</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.pmeal.com/posts/2022-02-09/index_files/figure-html/cell-9-output-1.png" width="589" height="431" class="figure-img"></p>
</figure>
</div>
</div>
</div>
<p>The red curve above is shifted to the right with a lower slope. This is the expected result since the impact of gravity makes it more difficult for the heavy non-wetting fluid to rise up the domain and penetrate into pores. The decresed slope is also expected since pores are invaded more gradually rather than in a larger percolation event.</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2022-02-09/</guid>
  <pubDate>Wed, 09 Feb 2022 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2022-02-09/cover_image.png" medium="image" type="image/png" height="114" width="144"/>
</item>
<item>
  <title>Prof Gostick presents new image-based invasion algorithm at AGU21</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2021-12-14/</link>
  <description><![CDATA[ 






<section id="prof-gostick-presents-new-image-based-invasion-algorithm-at-agu21" class="level1">
<h1>Prof Gostick presents new image-based invasion algorithm at AGU21</h1>
<p>The annual fall meeting of the Americal Geophysical Union (aka AGU) is underway this week. The PMEAL group gave a talk about our new image-based invasion algorithm that incorporates gravity. This work was motivated by the ever increasing size of tomograms, which introduces the possibility that gravity may impact the phase distributions. Standard sphere insertion algorithms only include capillary effects, so this work extended them to also include gravity. This work is currently under review, so a more detailed announcement and demonstration will be made when it’s accepted, but for now you can watch a pre-recorded video of the talk <a href="https://tinyurl.com/AGU21-Gostick">here</a>.</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2021-12-14/</guid>
  <pubDate>Tue, 14 Dec 2021 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2021-12-14/cover_image.png" medium="image" type="image/png" height="105" width="144"/>
</item>
<item>
  <title>Prof Gostick Named Inaugural Azzam-Dullien Endowed Professor</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2021-12-07/</link>
  <description><![CDATA[ 






<section id="prof-gostick-named-inaugural-azzam-dullien-endowed-professor" class="level1">
<h1>Prof Gostick Named Inaugural Azzam-Dullien Endowed Professor</h1>
<p>The Department of Chemical Engineering recently received a generous donation from a former PhD student, Dr.&nbsp;Mohamed Azzam. Dr.&nbsp;Azzam undertook his PhD studies under Prof.&nbsp;Francis Dullien in the early 1970’s. His work focused on hydraulic flow through complex conduits (see [<a href="https://doi.org/10.1016/0009-2509(77)80241-8">1</a>], [<a href="https://doi.org/10.1002/aic.690190204">2</a>], [<a href="https://doi.org/10.1021/i160060a010">3</a>], [<a href="https://doi.org/10.1021/i160058a013">4</a>], [<a href="https://doi.org/10.1002/aic.690190522">5</a>]), and contributed to the development of the pore network modeling approach pioneered by Prof.&nbsp;Dullien and his team later that decade. After graduation Dr.&nbsp;Azzam founded a successful company and had recently decided to honor Prof.&nbsp;Dullien and his former department with a generous gift. The Azzam-Dullien Endowed Professorship was created, and Prof.&nbsp;Jeff Gostick was named as the inaugural recipient for a term of 4 years. This endowment is earmarked to fund graduate students in the area of transport in porous media, which will ensure the continued legacy of porous media research at the University of Waterloo.</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2021-12-07/</guid>
  <pubDate>Tue, 07 Dec 2021 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2021-12-07/cover.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>PMEAL Blog and Website now hosted on Github Pages</title>
  <dc:creator>Jeff Gostick</dc:creator>
  <link>https://www.pmeal.com/posts/2021-07-04/</link>
  <description><![CDATA[ 






<section id="pmeal-blog-and-website-now-hosted-on-github-pages" class="level1">
<h1>PMEAL Blog and Website now hosted on Github Pages</h1>
<p>We used to host all our websites, openpnm.org, porespy.org and pmeal.com, on an Amazon cloud server using Wordpress. A few months we updated the PoreSpy website/landing page to be the same as the documentation site and moved it to Github instead of “Read The Docs”. Having all the code and docs in the same place was very handy, so we did the same thing to the OpenPNM website. Now that we are only hosting one website on the Wordpress instance, it makes sense to move PMEAL over to Github as well. The new site is not quite as fancy looking due limitations of the static build of Github Pages, but seems to looking pretty good so far. Over the next few weeks we’ll be improving things.</p>


</section>

 ]]></description>
  <category>news</category>
  <guid>https://www.pmeal.com/posts/2021-07-04/</guid>
  <pubDate>Sun, 04 Jul 2021 00:00:00 GMT</pubDate>
  <media:content url="https://www.pmeal.com/posts/2021-07-04/cover.svg" medium="image" type="image/svg+xml"/>
</item>
</channel>
</rss>
