-
Hello, I just wanted to understand the flux conservation for the single phase transport. For 1D model (When I set the BCs such as 1 and 0 for right and left side, respectively), it is conserved using FickianDiffusion algorithm. However, When I set the BCs such as 1, 1, 1 and 0 for right, top, bottom, and left, respectively, the total flux is not conserved. To check conservation, I call the following code "fd.rate(pores=right)". I applied it to find flow rates at the left, top, and bottom BCs as well. Probably, I did something wrong. But I couldn't find my fault. I have attached my simple code as follows: import scipy as sp
import numpy as np
import openpnm as op
import scipy.stats as spst
import matplotlib.pyplot as plt
import openpnm.models.geometry as gm
np.set_printoptions(precision=4)
np.random.seed(10)
ws = op.Workspace()
ws.settings["loglevel"] = 40
#np.set_printoptions(precision=5)
shape = [30, 30, 1]
spacing = 3e-5
net = op.network.Cubic(shape=shape, spacing=spacing)
geom = op.geometry.GenericGeometry(network=net, pores=net.Ps, throats=net.Ts)
f = spst.weibull_min
geom['pore.diameter'] = 4e-7
geom['throat.diameter']=1e-7
geom.add_model(propname='pore.area',
model=gm.pore_cross_sectional_area.sphere)
geom.add_model(propname='throat.area',
model=gm.throat_cross_sectional_area.cylinder)
geom.add_model(propname='throat.endpoints',
model=gm.throat_endpoints.circular_pores)
geom.add_model(propname='throat.length',
model=gm.throat_length.piecewise)
geom.add_model(propname='throat.conduit_lengths',
model=gm.throat_length.conduit_lengths)
geom.add_model(propname='pore.volume',
model=gm.pore_volume.sphere)
air = op.phases.Air(network=net)
phys_air = op.physics.Standard(network=net, phase=air, geometry=geom)
fd = op.algorithms.FickianDiffusion(network=net, phase=air)
C_in = 1.0
C_out = 0.0
C_upper=1
C_bottom=1
fd.set_value_BC(pores=net.pores('right'), values=C_in)
fd.set_value_BC(pores=net.pores('left'), values=C_upper)
fd.set_value_BC(pores=net.pores('front'), values=C_bottom)
fd.set_value_BC(pores=net.pores('back'), values=C_out)
fd.run()
rate_inlet=fd.rate(pores=net.pores('right'))
rate_outlet=fd.rate(pores=net.pores('left'))
rate_bottom=fd.rate(pores=net.pores('front'))
rate_upper=fd.rate(pores=net.pores('back')) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @alper-can import numpy as np
import openpnm as op
np.set_printoptions(precision=4)
np.random.seed(10)
ws = op.Workspace()
ws.settings["loglevel"] = 30
net = op.network.Cubic(shape=[30, 30, 1], spacing=3e-5)
geom = op.geometry.StickAndBall(network=net, pores=net.Ps, throats=net.Ts)
del geom.models['pore.diameter']
del geom.models['throat.diameter']
geom['pore.diameter'] = 4e-7
geom['throat.diameter'] = 1e-7
geom.regenerate_models()
air = op.phases.Air(network=net)
phys_air = op.physics.Standard(network=net, phase=air, geometry=geom)
fd = op.algorithms.FickianDiffusion(network=net, phase=air)
Ps1 = net.pores('left', asmask=True)
fd.set_value_BC(pores=Ps1, values=1)
Ps2 = net.pores('right', asmask=True)
fd.set_value_BC(pores=Ps2, values=0)
Ps3 = net.pores('front', asmask=True) * (~Ps1) * (~Ps2)
fd.set_value_BC(pores=Ps3, values=0)
Ps4 = net.pores('back', asmask=True) * (~Ps1) * (~Ps2)
fd.set_value_BC(pores=Ps4, values=0)
fd.run()
rate_inlet = fd.rate(pores=Ps1)
rate_outlet = fd.rate(pores=Ps2)
rate_bottom = fd.rate(pores=Ps3)
rate_upper = fd.rate(pores=Ps4)
np.testing.assert_allclose(rate_inlet, -(rate_outlet + rate_bottom + rate_upper)) |
Beta Was this translation helpful? Give feedback.
Hi @alper-can
Thanks for opening this as a Q&A rather than a bug. It's not a bug :-) The problem is that your pores overlap at the corners ('front' and 'left' share a pore). So when you computed the rate into each face you were asking for the rate of all 'front' pores, but this included the rate from the 'left' BCs as well. Hopefully my code snippet below helps.