Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
phys_water.regenerate_models()
inlet = pn.pores('back') # pore inlet
outlet = pn.pores('front') # pore outlet
inlet2 = pn.pores('left') # pore inlet2
outlet2 = pn.pores('right') # pore outlet2
# ALGORITHMS
alg1 = op.algorithms.StokesFlow(network=pn, phase=water)
alg1.set_dirichlet_BC(pores=inlet, values=5)
alg1.set_dirichlet_BC(pores=outlet, values=0)
alg1.run()
alg1b = op.algorithms.TransientStokesFlow(network=pn, phase=water)
alg1b.set_IC(0)
alg1b.set_dirichlet_BC(pores=inlet, values=5)
alg1b.set_dirichlet_BC(pores=outlet, values=0)
alg1b.run()
phys_water.regenerate_models()
inlet = pn.pores('back') # pore inlet
outlet = pn.pores('front') # pore outlet
inlet2 = pn.pores('left') # pore inlet2
outlet2 = pn.pores('right') # pore outlet2
# ALGORITHMS
alg1 = op.algorithms.FickianDiffusion(network=pn, phase=water)
alg1.set_dirichlet_BC(pores=inlet, values=10)
alg1.set_dirichlet_BC(pores=outlet, values=0)
alg1.run()
alg1b = op.algorithms.TransientFickianDiffusion(network=pn, phase=water)
alg1b.set_IC(0)
alg1b.set_dirichlet_BC(pores=inlet, values=10)
alg1b.set_dirichlet_BC(pores=outlet, values=0)
alg1b.run()
# Define MultiPhase object
mphase = op.phases.MultiPhase(network=net, phases=[air, water])
mphase._set_automatic_throat_occupancy()
mphase.set_occupancy(phase=air, pores=[0, 1, 2, 3, 4])
mphase.set_occupancy(phase=water, pores=[5, 6, 7, 8, 9])
const = op.models.misc.constant
mphase.set_binary_partition_coef(propname="throat.partition_coef",
phases=[water, air], model=const, value=0.5)
# Define physics object
phys = op.physics.Standard(network=net, phase=mphase, geometry=geom)
mdiff = op.models.physics.diffusive_conductance.multiphase_diffusion
phys.add_model(propname="throat.diffusive_conductance", model=mdiff)
# Define algorithm: Fickian diffusion
fd = op.algorithms.FickianDiffusion(network=net, phase=mphase)
fd.set_value_BC(pores=0, values=1.0)
fd.set_value_BC(pores=9, values=0.1)
fd.run()
# Post-processing
c = fd["pore.concentration"]
plt.figure()
plt.plot(c, "ko:")
plt.xlabel("x (m)")
plt.ylabel("c (mol/m3)")
mphase.set_occupancy(air, pores=ps_air, throats=ts_air)
mphase.set_occupancy(water, pores=ps_water, throats=ts_water)
# Define physics
phys = op.physics.Standard(network=net, phase=mphase, geometry=geom)
# Assign a partition coefficient (concentration ratio)
K_water_air = 0.5 # c @ water / c @ air
const = op.models.misc.constant
mphase.set_binary_partition_coef(propname="throat.partition_coef",
phases=[water, air], model=const, value=K_water_air)
# Replace the "default" ordinary_diffusion w/ multiphase_diffusion conductance model
mdiff = op.models.physics.diffusive_conductance.multiphase_diffusion
phys.add_model(propname="throat.diffusive_conductance", model=mdiff)
# Fickian diffusion
fd = op.algorithms.FickianDiffusion(network=net, phase=mphase)
# Set source term
phys["pore.A1"] = -1e-8 * geom["pore.area"]
phys["pore.A2"] = 0.0
linear = op.models.physics.generic_source_term.linear
phys.add_model(propname="pore.rxn", model=linear, X="pore.concentration",
A1="pore.A1", A2="pore.A2", regen_mode="deferred")
rxn_pores = net.pores(["left", "right"])
net.set_label("rxn", pores=rxn_pores)
fd.set_source(propname="pore.rxn", pores=rxn_pores)
# Set BCs and run simulation
net.set_label("air", pores=ps_air)
front_air = net.pores(["front", "air"], mode="and")
back_air = net.pores(["back", "air"], mode="and")
fd.set_value_BC(pores=front_air, values=1.0)
fd.set_value_BC(pores=back_air, values=0.1)
geom['pore.area'] = sp.pi*(geom['pore.diameter']**2)/4.0
mod2 = op.models.physics.diffusive_conductance.bulk_diffusion
phys_water.add_model(propname='throat.diffusive_conductance',
model=mod2, diffusivity='pore.diffusivity')
phys_water.regenerate_models()
inlet = pn.pores('back') # pore inlet
outlet = pn.pores('front') # pore outlet
inlet2 = pn.pores('left') # pore inlet2
outlet2 = pn.pores('right') # pore outlet2
# ALGORITHMS
alg1 = op.algorithms.FickianDiffusion(network=pn, phase=water)
alg1.set_dirichlet_BC(pores=inlet, values=10)
alg1.set_dirichlet_BC(pores=outlet, values=0)
alg1.run()
alg1b = op.algorithms.TransientFickianDiffusion(network=pn, phase=water)
alg1b.set_IC(0)
alg1b.set_dirichlet_BC(pores=inlet, values=10)
alg1b.set_dirichlet_BC(pores=outlet, values=0)
alg1b.run()
eB_dif = op.models.physics.diffusive_conductance.ordinary_diffusion
phys.add_model(propname='throat.diffusive_conductance.' + Cl.name,
pore_diffusivity='pore.diffusivity.' + Cl.name,
throat_diffusivity='throat.diffusivity.' + Cl.name,
model=eB_dif, regen_mode='normal')
# algorithms
sf = op.algorithms.StokesFlow(network=net, phase=sw)
sf.set_value_BC(pores=net.pores('back'), values=0.01)
sf.set_value_BC(pores=net.pores('front'), values=0.00)
sf.settings['rxn_tolerance'] = 1e-12
sf.run()
sw.update(sf.results())
p = op.algorithms.ChargeConservation(network=net, phase=sw)
p.set_value_BC(pores=net.pores('left'), values=0.01)
p.set_value_BC(pores=net.pores('right'), values=0.00)
p.settings['rxn_tolerance'] = 1e-12
p.settings['charge_conservation'] = 'electroneutrality'
eA = op.algorithms.NernstPlanck(network=net, phase=sw, ion=Na.name)
eA.set_value_BC(pores=net.pores('back'), values=100)
eA.set_value_BC(pores=net.pores('front'), values=90)
eA.settings['rxn_tolerance'] = 1e-12
eB = op.algorithms.NernstPlanck(network=net, phase=sw, ion=Cl.name)
eB.set_value_BC(pores=net.pores('back'), values=100)
eB.set_value_BC(pores=net.pores('front'), values=90)
eB.settings['rxn_tolerance'] = 1e-12
ad_dif_mig_Na = op.models.physics.ad_dif_mig_conductance.ad_dif_mig