def test_run(self):
        """
        Test initialization and few iterations
        """
        #%%
        m = 'CH'  #or 'CSH'
        ll = 1  #liquid lauer in front of portlandite
        l_ch = 25  #length of portlandite
        lx = (l_ch + ll) * 1.0e-6
        ly = 2.0e-6
        dx = 1.0e-6

        domain = yantra.Domain2D(corner=(0, 0),
                                 lengths=(lx, ly),
                                 dx=dx,
                                 grid_type='nodal')
        domain.nodetype[:, ll + 1:ll + l_ch] = ct.Type.MULTILEVEL
        domain.nodetype[0, :] = ct.Type.SOLID
        domain.nodetype[-1, :] = ct.Type.SOLID
        domain.nodetype[:, -1] = ct.Type.SOLID

        #%%
        nn = '09_unit_test'
        phrqc_input = {
            'c_bc': {
                'type': 'conc',
                'value': 0.01
            },  # another option 'c_bc':{'type':'pco2', 'value': 3.4}
            'c_mlvl': {
                'type': 'conc',
                'value': '0'
            },  # another option c_mlvl':{'type':'conc', 'value': '0'}
            'c_liq': {
                'type': 'conc',
                'value': '0'
            },  # another option c_liq':{'type':'conc', 'value': '0'}
            'ca_mlvl': {
                'type': 'eq',
                'value': 'portlandite'
            },
            'ca_liq': {
                'type': 'eq',
                'value': 'portlandite'
            }
        }  # another option ca_liq':{'type':'conc', 'value': '0'} or ca_liq':{'type':'eq', 'value': 'portlandite'}

        phrqc = fn.set_phrqc_input(phrqc_input)
        fn.save_phrqc_input(phrqc, root_dir, nn)

        scale = 50  # scale of molar volume
        init_porosCH = 0.05  #initial porosity of portlandite nodes
        mvol_ratio = 3.69 / 3.31
        mvolCH = 0.0331 * scale
        mvol = [mvolCH, mvolCH * mvol_ratio]
        mvol = fn.set_mvols(mvol, ptype=m)  #m3/mol
        #max_pqty = fn.get_max_pqty(mvol) #mol/m3
        init_conc = fn.set_init_pqty(mvol, init_porosCH)
        pqty = fn.get_pqty(init_conc, domain)

        slabels = fn.set_labels(domain, m)
        D = 1.0e-09  # default diffusion coefficient in pure liquid
        porosity = fn.get_porosity(domain, pqty, mvol, m)
        app_tort_degree = 1. / 3.
        app_tort = 1. * porosity**app_tort_degree

        settings = {
            'precipitation': 'interface',  # 'interface'/'all'/'mineral' nodes
            'dissolution': 'multilevel',  #'multilevel'/'subgrid'
            'active_nodes': 'all',  # 'all'/'smart'/'interface'
            'diffusivity': {
                'type': 'fixed',  #'archie'/'fixed'/'mixed'
                'D_border': D,  #diffusivity at border
                'D_CC': 1e-11,  # fixed diffusivity in calcite node
                'D_CH': 1e-13,  # fixed diffusivity in portlandite node
            },
            'pcs_mode': {
                'pcs': True,  #Pore-Size Controlled Solubility concept
                'pores': 'block',  #'block'/'cylinder'
                'int_energy': 0.5,  # internal energy
                'pore_size': 0.01 * dx,  # threshold radius or distance/2
                'crystal_size': 0.5 * dx,  # crystal or pore length
                'pore_density':
                2000,  #pore density per um3 - only for cylinder type
            },
            'subgrid': {
                'fraction': None
            },  # fraction of interface cell number or None = porosity
            'app_tort': {
                'degree': app_tort_degree
            },
            'velocity': False,
            'bc': phrqc_input['c_bc'],
            'dx': dx,
            'Dref': D
        }

        domain_params = fn.set_domain_params(D, mvol, pqty, porosity, app_tort, slabels,
                                     input_file = root_dir + \
                                     '\\phreeqc_input\\' + nn + '.phrq')#'CH_CC-nat.phrq'
        bc_params = fn.set_bc_params(bc_slabels={'left': 100001})
        solver_params = fn.set_solver_params(
            tfact=None, smart_thres=1e-8
        )  # optional values, for time step (if tfact => tfactbased tau)

        #%%
        carb_rt = rt.CarbonationRT('MultilevelAdvectionDiffusion', domain,
                                   domain_params, bc_params, solver_params,
                                   settings)

        itr = 0
        nitr = 10
        while itr < nitr:
            carb_rt.advance()
            itr += 1
        #%%
        self.assertEqual(carb_rt.iters, nitr)
示例#2
0
m = 'CH'
f = 0.01  # fraction
#ll = 1 #liquid lauer in front of portlandite
#l_ch = 10 #length of portlandite
#lx = (l_ch+ll)*1.0e-2
#ly = 2.0e-2
#dx = 1.0e-2

ll = 1  #liquid lauer in front of portlandite
l_ch = 40  #40 #length of portlandite
lx = (l_ch + ll) * 1.0e-6
ly = 2.0e-6
dx = 1.0e-6

domain = yantra.Domain2D(corner=(0, 0),
                         lengths=(lx, ly),
                         dx=dx,
                         grid_type='nodal')
domain.nodetype[:, (ll + 1):ll + l_ch] = ct.Type.MULTILEVEL
domain.nodetype[0, :] = ct.Type.SOLID
domain.nodetype[-1, :] = ct.Type.SOLID
domain.nodetype[:, -1] = ct.Type.SOLID

plt.figure(figsize=(5, 5))
plt.imshow(domain.nodetype)
plt.show()

#%%  PHREEQC
nn = os.path.basename(__file__)[:-3]
nn += str(f)
fn.make_output_dir(root_dir + '\\results\\output\\10_subgrid_leaching')
path = root_dir + '\\results\\output\\10_subgrid_leaching\\' + nn + '\\'
#=======================================================================================
from __future__ import division, print_function
__doc__ = """
Benchmark 5: Comparison of different collision models for domain with varying diffusion \
coefficient using Yantra's 2D implementation. The benchmark example refers to example of \
Perko and Patel (2014) PRE paper Fig 5 and results in Fig 6.
"""
#%% import necessray
import sys, os
PARENT = '..'
sys.path.append(os.path.join(os.path.dirname(__file__), PARENT))
import yantra
import matplotlib.pylab as plt

#%% generate domain instance
domain = yantra.Domain2D((0, 0), (0.1, 0.05), 0.001, grid_type='midway')
x, _ = domain.meshgrid()
Dlow = 1e-11
Dhigh = 2000 * Dlow
D = Dlow * (x <= 0.02) + Dhigh * (x > 0.02) * (x < 0.08) + Dlow * (x >= 0.08)
#%% define physics
#domain params
domain_params = {}
domain_params['D'] = D
domain_params['c'] = 0.1
domain_params['poros'] = 1

Dref = Dlow  #Dhigh/20
bc_params = {}
bc_params['left'] = ['c', 0.]
bc_params['right'] = ['flux', 0]
root_dir = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
src_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root_dir)
sys.path.append(src_dir)
import yantra
import numpy as np
import matplotlib.pylab as plt
import copy
#%% geometry
ll = 3
l = 5 + ll
lx = l * 1.0e-6
ly = 1.0e-6
dx = 1.0e-6
domain = yantra.Domain2D((0, 0), (lx, ly), dx, grid_type='midway')
domain.nodetype[:, ll + 1:l + ll + 1] = -5
pqty = 1. * (domain.nodetype > 0)
#%% params
slabels = np.zeros(domain.nodetype.shape)
slabels = 100001 * (domain.nodetype == -1) + 100002 * (domain.nodetype != -1)
pqty = 1. * (domain.nodetype == -5)
porosity = np.ones(pqty.shape)
D = 1e-9  #*(domain.nodetype== -1)+1e-09*(domain.nodetype!= -1) #1e-15
#domain params

domain_params = {}
domain_params['D0'] = D
domain_params['database'] = 'cemdata07.dat'
#domain_params['phrqc_input_file']='02_mlvl_portlandite.phrq'
domain_params['phrqc_input_file'] = 'portlandite_mlvl.phrq'
示例#5
0
of this benchmark are published in Patel et al (2014), Phy & Chem. of Earth.
"""

#%% import modules
import sys, os
root_dir = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
src_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root_dir)
sys.path.append(src_dir)
import yantra
import numpy as np
import matplotlib.pylab as plt
#%%
#generate mesh
domain = yantra.Domain2D((0, 0), (150e-6, 150e-6), 3e-6, grid_type='midway')
#make plus geometry
domain.draw_rect((75e-6, 75e-6), (30e-6, 7.5e-6), idx=1)
domain.draw_rect((75e-6, 75e-6), (7.5e-6, 30e-6), idx=1)
pqty = 1. * (domain.nodetype > 0)
#%%
#domain params
domain_params = {}
domain_params['D'] = 1e-9
domain_params['database'] = 'cemdata07.dat'
domain_params['phrqc_input_file'] = '01_plus_portlandite.phrq'
domain_params['solution_labels'] = 100001
domain_params['eq_names'] = ['portlandite']
domain_params['solid_phases'] = {
    'portlandite': {
        'type': 'non_diffusive',
#%% import modules
import sys,os
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
src_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root_dir)
sys.path.append(src_dir)
import yantra
import numpy as np
import matplotlib.pylab as plt
#%%
l = 10
lx = l*1.0e-6
ly = l*1.0e-6
dx = 1.0e-6
domain = yantra.Domain2D((0,0),(lx,ly),dx, grid_type = 'nodal')
domain.nodetype[5,5] = 1
pqty = 1.*(domain.nodetype>0)
#%%
#domain params
domain_params={}
domain_params['D']=1e-9
domain_params['database']='cemdata07.dat'
domain_params['phrqc_input_file']='01_plus_portlandite.phrq'
domain_params['solution_labels']=100001
domain_params['eq_names']=['portlandite']
domain_params['solid_phases']={'portlandite':{'type':'diffusive','mvol':1,'c':pqty}}
domain_params['voxel_vol']=1
#solver parameters
solver_params={}
solver_params['collision_model']='srt'
示例#7
0
import sys, os
root_dir = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
src_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root_dir)
sys.path.append(src_dir)
import yantra
import numpy as np
from numpy import exp
from scipy.special import erfc
import matplotlib.pylab as plt

#%% domain generation
l = 1e-5
domain = yantra.Domain2D((0, 0), (l, l), l / 6, grid_type='midway')
domain.nodetype[3, 3] = -2

#%%set Multilevel advection diffusion model
Dm= 1e-11*(domain.nodetype==-2)+\
    1e-9*(domain.nodetype==-1)
poros =1.0*(domain.nodetype==-2)+\
       1.0*(domain.nodetype==-1)
c = 1.*(domain.nodetype==-2)+\
    0.*(domain.nodetype==-1)
#domain parameters
domain_params = {}
domain_params['D0'] = Dm
domain_params['app_tort'] = 1.
domain_params['poros'] = poros
domain_params['c'] = c