<jupyter_start><jupyter_text>Generate a Layered NetworkIn order to see a network with a noticable difference in permeability values in each principle direction, we'll make a network consisting of two distinct layers then stitch them together.  The process of stitching is explained in more detail [here](/examples/notebooks/networks/manipulation/stitching_and_merging_networks_together.ipynb).<jupyter_code>pn = op.network.Cubic(shape=[8, 8, 8], spacing=30e-6)
pn2 = op.network.Cubic(shape=[24, 24, 8], spacing=10e-6)<jupyter_output><empty_output><jupyter_text>Apply Labels to Each NetworkIn order to make it easier to find pore indices after stitching, it's helpful to apply unique and descriptive labels to the networks first. Labels are discussed detail [here](/examples/notebooks/tutorials/using_and_creating_labels.ipynb).<jupyter_code>pn['pore.coarse'] = True
pn['throat.coarse'] = True
pn2['pore.fine'] = True
pn2['throat.fine'] = True<jupyter_output><empty_output><jupyter_text>Now we can stitch the two network together, but first we must translate the fine network along the z-axis so the networks are not overlapping.  Stiching is described in more detail [here](.../tutorials/manipulation/stitching_and_merging_networks_together.ipynb).<jupyter_code>pn2['pore.coords'] += [0, 0, 8*30e-6]
op.topotools.stitch(network=pn, donor=pn2, 
                    P_network=pn.pores('top'), 
                    P_donor=pn2.pores('bottom'))<jupyter_output><empty_output><jupyter_text>Let's visualize the network to see if it stitched as expected. Quick plotting is described in more detail [here](/examples/notebooks/io/quick_plotting_networks.ipynb).<jupyter_code># NBVAL_IGNORE_OUTPUT
fig = op.topotools.plot_connections(pn)<jupyter_output><empty_output><jupyter_text>Create other objects needed for simulation Generate one Geometry for each layer<jupyter_code>np.random.seed(0)
Ps = pn.pores('fine')
Ts = pn.throats('fine')
geo2 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)
Ps = pn.pores('coarse')
Ts = pn.throats(['coarse', 'stitched'])
geo1 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)<jupyter_output><empty_output><jupyter_text>Let's visualize the pore sizes using histograms:<jupyter_code># NBVAL_IGNORE_OUTPUT
fig = plt.hist(geo1['pore.diameter'], bins=25, 
               density=True, edgecolor='k', alpha=0.5)
fig = plt.hist(geo2['pore.diameter'], bins=25, 
               density=True, edgecolor='k', alpha=0.5)<jupyter_output><empty_output><jupyter_text>Create a Phase and 2 Physics objects<jupyter_code>air = op.phases.Air(network=pn)
phys1 = op.physics.Standard(network=pn, phase=air, geometry=geo1)
phys2 = op.physics.Standard(network=pn, phase=air, geometry=geo2)<jupyter_output><empty_output><jupyter_text>Let's visualize the hydraulic conductances using histograms.  Note that the values are logged, to better visualize the distributions:<jupyter_code># NBVAL_IGNORE_OUTPUT
fig = plt.hist(np.log10(phys1['throat.hydraulic_conductance']), 
               bins=25, density=True, edgecolor='k', alpha=0.5)
fig = plt.hist(np.log10(phys2['throat.hydraulic_conductance']), 
               bins=25, density=True, edgecolor='k', alpha=0.5)<jupyter_output><empty_output><jupyter_text>Run a StokesFlow simulation in perpendicular directions<jupyter_code>sf_x = op.algorithms.StokesFlow(network=pn, phase=air)
Pin = 1.0
Pout = 0.0
sf_x.set_value_BC(pores=pn.pores('left'), values=1.0)
sf_x.set_value_BC(pores=pn.pores('right'), values=0.0)
sf_x.run()<jupyter_output><empty_output><jupyter_text>Let's make sure the pressure field is applied in the correct direction:<jupyter_code># NBVAL_IGNORE_OUTPUT
fig = op.topotools.plot_coordinates(pn, color=sf_x['pore.pressure'], 
                                    size_by=pn['pore.diameter'], 
                                    markersize=50)
sf_z = op.algorithms.StokesFlow(network=pn, phase=air)
Pin = 1.0
Pout = 0.0
sf_z.set_value_BC(pores=pn.pores(['top', 'coarse'], mode='and'), values=Pin)
sf_z.set_value_BC(pores=pn.pores(['top', 'fine'], mode='and'), values=Pout)
sf_z.run()<jupyter_output><empty_output><jupyter_text>Again, let's visualize the pressure field:<jupyter_code># NBVAL_IGNORE_OUTPUT
fig = op.topotools.plot_coordinates(pn, color=sf_z['pore.pressure'], 
                                    size_by=pn['pore.diameter'], 
                                    markersize=50)<jupyter_output><empty_output><jupyter_text>The presure in the coarse network is essentially constant since it's much more permeable than the fine layer.  Determine the Permeability Coefficient for each direction<jupyter_code>L = 8 * 30e-6
A = (8 * 30e-6)**2 + (8 * 24)*(10e-6)**2
mu = air['pore.viscosity'][0]
Q = sf_x.rate(pores=pn.pores('left'), mode='group')
Kx = Q*L*mu/(A*(Pin - Pout))
print('The permeability coefficient is:', Kx)
A = (8 * 30e-6)**2
L = (8 * 30e-6) + (8 * 10e-6)
mu = air['pore.viscosity'][0]
Q = sf_z.rate(pores=pn.pores(['top', 'coarse'], mode='and'), mode='group')
Kz = Q*L*mu/(A*(Pin - Pout))
print('The permeability coefficient is:', Kz)
Kx/Kz<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13452826472326176, 'fraction_numerical': 0.020681504825684458, 'mean_word_length': 5.3080745341614906, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '147474', 'license': 'MIT', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1783, 'n_words': 371, 'path': 'examples/notebooks/algorithms/single_phase/stokes_flow_and_permeability_tensor.ipynb', 'repo_name': 'Eravalord/OpenPNM', 'size': '5077'}