def model(pars, hostname='dum', processor=1): # ATS ############################################################################## # Modify base ats xml input file and run ats branchName = "hillslope-fieldParams_18Dec18" fname = branchName + "-" + str(pars['bac']) + "bac_" + str( pars['bct']) + "bct" m = atsxml.get_root('../test7_' + branchName + '_template' + '_18Dec18_UncrashedRuns' + '_input.xml') atsxml.replace_by_path( m, ['mesh', 'domain', 'read mesh file parameters', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain acrotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain catotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain mineral', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain bedrock', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'surface', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'bottom face', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'acrotelm', 'function', 'function-constant', 'value' ], pars['Kac']) atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'catotelm', 'function', 'function-constant', 'value' ], pars['Kct']) atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'rest domain', 'function', 'function-constant', 'value' ], pars['Kmn']) atsxml.replace_by_path( m, ['cycle driver', 'restart from checkpoint file'], '../checkpoint_files/' + runName + checkpointSuffix + '/' + runName + checkpointSuffix + '.' + str(pars['RunNum']) + 'checkpoint_last.h5') atsxml.run(m, nproc=1, mpiexec='mpirun', stdout='stdout.out', stderr='stdout.err', cpuset=processor) return True
def model(pars, hostname='dum', processor=1): # ATS ############################################################################## # Modify base ats xml input file and run ats branchName = "Paper2_ParamSweep_300m" fname = branchName + "-" + str(pars['bac']) + "bac_" + str( pars['bct']) + "bct" m = atsxml.get_root('../test7_' + 'Paper2_NoCheckpoint_NoVerbosity_Default.xml') atsxml.replace_by_path( m, ['mesh', 'domain', 'read mesh file parameters', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain acrotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain catotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain mineral', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain bedrock', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'surface', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'bottom face', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'acrotelm', 'function', 'function-constant', 'value' ], pars['Kac']) atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'catotelm', 'function', 'function-constant', 'value' ], pars['Kct']) atsxml.replace_by_path(m, [ 'state', 'permeability', 'function', 'rest domain', 'function', 'function-constant', 'value' ], pars['Kmn']) atsxml.run(m, nproc=1, mpiexec='mpirun', stdout='stdout.out', stderr='stdout.err', cpuset=processor) return True
def model(pars, hostname='dum', processor=1): # ATS ############################################################################## # Modify base ats xml input file and run ats branchName = "hillslope-30mSuite" fname = branchName + "-" + str(pars['slope']) + "m_" + str( pars['bac']) + "bac_" + str(pars['bct']) + "bct" m = atsxml.get_root('../test7_' + branchName + '_template_' + runName + suffix + '.xml') atsxml.replace_by_path( m, ['mesh', 'domain', 'read mesh file parameters', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain acrotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain catotelm', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain mineral', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path(m, [ 'regions', 'computational domain bedrock', 'region: labeled set', 'file' ], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'surface', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['regions', 'bottom face', 'region: labeled set', 'file'], '../../mesh/' + branchName + '/' + fname + '.exo') atsxml.replace_by_path( m, ['cycle driver', 'restart from checkpoint file'], '../checkpoint_files/' + runName + checkpointRunName + '_checkpoint_files/checkpoint_' + fname + '.h5') atsxml.run(m, nproc=1, mpiexec='mpirun', stdout='stdout.out', stderr='stdout.err', cpuset=processor) return True
def model(pars,hostname,processor): # Modify base ats xml input file with pars dictionary and run ats m = atsxml.get_root('../test7-v_fwd.xml') atsxml.replace_by_path(m,['base_porosity','rest domain','value'],pars['poro_m']) atsxml.replace_by_path(m,['base_porosity','peat','value'],pars['poro_p']) atsxml.replace_by_path(m,['permeability','rest domain','value'],10**pars['perm_m']) atsxml.replace_by_path(m,['permeability','peat','value'],10**pars['perm_p']) atsxml.run(m,nproc=4,stdout='stdout.out',stderr='stdout.err',cpuset=processor) # Read results from ats visualization files #keys,times,file handle k,t,f = parse_ats.readATS() # Collect point at middle of polygon 1 m deep # x,z = 7.17946807, 4.65764252 # index for this location is 1733, see below how to find this # Create output dictionary that matches MATK observations out = {} out['Sl'] = f[u'saturation_liquid.cell.0/'+k[-1]][1733] out['T'] = f[u'temperature.cell.0/'+k[-1]][1733] # Return simulated values of interest return out