Beispiel #1
0
def main(conc_mats):
    data= []
    mesh = create_mesh()
    survey = create_survey(mesh)
    for tim,conc_mat in zip(times_select,conc_mats):
        try:
            survey.unpair()
        except:
            pass
        sigma_bulk = rock_physics(varlist,it,conc_mat)
        rho_grid,actv = create_model(sigma_bulk, mesh)
        simulation = create_simulation(it,tim,rho_grid,actv,mesh,survey)
        data.append(run_collect_data(simulation, rho_grid))
        try:
            survey.unpair()
        except:
            pass
    local_utils.save_obj(datadir,data,'aem_data_it{}'.format(it))
    print('saved to file aem_data_it{}'.format(it))
    return
Beispiel #2
0
#Load conc_mat
fname_conc = Path(ucn_dict[it])
times_select = np.arange(360*5,7201,360*5,dtype=np.float)
times = times_select
ucnobj = flopy.utils.binaryfile.UcnFile(Path(fname_conc).as_posix())
conc_mats = [ucnobj.get_data(totim=tim) for tim in times_select]

#Load and update varlist 
print('Loading varlist...')
try:
    varlist = local_utils.load_obj(datadir,'varlist_final')
except:
    varlist = local_utils.load_obj(datadir,'varlist')
    success_mat,_ = local_utils.unpack_success_files(datadir.joinpath('success'))
    varlist['success'][success_mat[:,0]]=success_mat[:,1]
    local_utils.save_obj(datadir,varlist,'varlist_final')



#RP transforms 
def WS_sigma(sigma_f, por = 0.4, CEC=1,B0=4.5e-8, m=1.3):
    rho_grain = 2650*1000 #g/m^3
#     CEC = 1 #meq/g    1:smect,  .2:Ill,  .02-.09:Kaol
#     B0 = 4.78e-8  #m^2/(sV)
    F = por**(-m)
    Qv = rho_grain*((1-por)/por)*CEC
    B = B0*(1-.6*np.exp(-sigma_f/.013))
    sigma_b = 1/F*(sigma_f + B*Qv)
    return sigma_b,B,Qv

np.random.seed(1)
dmisfit = DataMisfit.l2_DataMisfit(survey)
dmisfit.W = 1. / uncert

opt = Optimization.ProjectedGNCG(maxIter=10, maxIterCG=20)
# opt.upper = m_upper
# opt.lower = m_lower
invProb = InvProblem.BaseInvProblem(dmisfit, reg, opt)
beta = Directives.BetaSchedule(coolingFactor=2, coolingRate=1)
betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1.)
target = Directives.TargetMisfit(chifact=1.)
save_model = Directives.SaveOutputDictEveryIteration(
    directory=output_dir.as_posix())
inv = Inversion.BaseInversion(
    invProb, directiveList=[beta, betaest, target, save_model])
prob.counter = opt.counter = Utils.Counter()
opt.LSshorten = 0.5
opt.remember('xc')
try:
    save_model.outDict = {}
except:
    pass

print('Target misfit:', target.target)

## Run it!
mopt = inv.run(m0)
import local_utils
local_utils.save_obj(output_dir, save_model.outDict, 'outDict')